commit 271b59a54e4b7c873b530d75da986e0efa6c60a7
parent c231a29b70c94c3b42035351ecde8be65dfdf9cb
Author: Henry Wilson <m3henry@googlemail.com>
Date: Sun, 11 Jun 2017 04:06:51 +0100
swap, over
Diffstat:
M | main.s | | | 30 | ++++++++++++++++-------------- |
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/main.s b/main.s
@@ -30,29 +30,19 @@ abort: forthword
.quad quit
quit: forthword
+ const 10
const 4
.quad flag
.quad halt
-linelp: const 10
- starlp2: .quad star
- .quad dec
- .quad dup
- .quad dowhile
- .quad . - starlp2
- .quad drop
- .quad cr
- .quad dec
- .quad dup
- .quad dowhile
- .quad . - linelp
- .quad halt
flag: forthword
- flaglp: const 10
+ flaglp: .quad over
.quad line
.quad dec
.quad dup
while flaglp
+ .quad drop
+ .quad drop
endword
line: forthword
@@ -110,6 +100,18 @@ _drop: mov (SP), TOS
sub $8, SP
jmp next
+swap: codeword
+ push TOS
+ mov (SP), TOS
+ pop (SP)
+ jmp next
+
+over: codeword
+ push (SP)
+ _dup
+ pop TOS
+ jmp next
+
emit: codeword
movq TOS, buff
mov $1, %rax # system call 1 is write