summaryrefslogtreecommitdiff
path: root/sanctuary.s
blob: 5859ac1ae931c1079ee30559d7a079b82a678ab5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
; sanctuary

; macros {{{
; in this forth pspush and pspop are only necessary if you need to
; go deeper into the stack.
; TODO: error handling (once i add that)
%macro pspush 1
	lea r14, [r14-8]
	mov qword [r14], r15
	mov r15, %1
%endmacro

%macro pspop 1
	mov %1, r15
	mov r15, qword [r14]
	lea r14, [r14+8]
%endmacro

%define s_latest 0

%macro defdict 3 ; name label flags
	%strlen slen %1
	global lfa_%2
	lfa_%2: dq s_latest
	%define s_latest lfa_%2
	ffa_%2: db %3
	nfa_%2: db slen
		db %1
%endmacro

%macro defcode 3
	defdict %1, %2, %3
	%2:
%endmacro

; this is just taken from jewelforth, and does not correspond
; to how user variables are planned to work in sanctuary
; so todo make better later? i don't know if it really matters
; because it will only apply to builtin variables.
%macro defvar 3
	%2: dq %4
	defdict %1, %2, %3
	; pspush qword %2 ; todo
	%2:
%endmacro
; }}}

section .bss
resq 4091
wstk: resq 1

section .text
global _start
_start:
	mov rdi, 0
	mov rax, 60
	syscall