commit 2bb5669ea3e5d66fab6c4c67b92d1dd9b2808add
parent 9cd8622ef9beaa5c12c0a0d62c2b5e806557fef0
Author: Henry Wilson <m3henry@googlemail.com>
Date: Tue, 20 Jun 2017 04:21:02 +0100
split macros in to own file
Diffstat:
M | main.s | | | 146 | ++----------------------------------------------------------------------------- |
1 file changed, 2 insertions(+), 144 deletions(-)
diff --git a/main.s b/main.s
@@ -1,112 +1,4 @@
-.macro do label
- .quad \label
-.endm
-
-.macro forthword name
- do enter
-.endm
-
-.macro endword
- do EXIT
-.endm
-
-.macro const val
- do docon
- .quad \val
-.endm
-
-.macro variable
- do dovar
- .quad 0
-.endm
-
-.macro get var
- do \var
- do fetch
-.endm
-
-.macro set var:req value
-.ifnb \value
- const \value
-.endif
- do \var
- do store
-.endm
-
-.macro strlit msg
- .quad 9f - 8f
-8: .ascii "\msg\()"
-9:
-.endm
-
-.macro string msg
- do dostr
- strlit "\msg\()"
-.endm
-
-.macro say msg
- string "\msg\()"
- do PRINT
-.endm
-
-.macro saycr msg
- say "\msg\()\n"
-.endm
-
-.macro scratch length
- const 8f
- goto 9f
-8: .skip \length
-9:
-.endm
-
-.macro goto label
- do dogoto
- .quad \label
-.endm
-
-.macro if label
- do dobranch
- .quad \label
-.endm
-
-.macro test compare:req value:req target:req
- do DUP
- const \value
- do \compare
- if \target
-.endm
-
-.macro unless label
- do NOT
- if \label
-.endm
-
-.macro debug
- do DUP
- do dot
- do CR
-.endm
-
-.macro offset var distance
- do \var
- const \distance
- do plus
-.endm
-
-.macro verb type:req name:req altname end
-.ifnb \end
- .quad 0
-.else
- .quad 7b - 8
-.endif
-.ifnb \altname
-7: strlit "\altname\()"
-.else
-7: strlit "\name\()"
-.endif
-\name\(): \type\()word
-.endm
+.include "macros.i"
.data
@@ -370,19 +262,7 @@ buff: .quad 0
stack: .skip 1024 #1048576
-# Codeword macros
-
-.macro codeword
- .quad . + 8
-.endm
-
-.macro advance register
- add $8, \register
-.endm
-
-.macro retreat register
- sub $8, \register
-.endm
+# Codewords
.global _start
@@ -407,10 +287,6 @@ stack: .skip 1024 #1048576
# Stack manipulation
-.macro _dup
- advance SP
- mov TOS, (SP)
-.endm
verb code DUP
_dup
jmp next
@@ -638,24 +514,6 @@ verb code divide "/%"
# Comparison
-.macro compare op name altname
-verb code \name "\altname\()"
- cmp TOS, (SP)
- \op truecmp
- movq $0, (SP)
- jmp _drop
-.endm
-
-.macro cmpaddr op name altname
-verb code \name "\altname\()"
- mov (SP), ACC
- mov (ACC), ACC
- cmp (TOS), ACC
- \op truecmp
- movq $0, (SP)
- jmp _drop
-.endm
-
truecmp:
movq $-1, (SP)
jmp _drop