projects
/
rrq
/
jonasforth.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
623eb65
)
Implement ','
author
Jonas Hvid
<mail@johv.dk>
Fri, 6 Dec 2019 12:37:07 +0000
(13:37 +0100)
committer
Jonas Hvid
<mail@johv.dk>
Fri, 6 Dec 2019 12:37:07 +0000
(13:37 +0100)
main.asm
patch
|
blob
|
history
diff --git
a/main.asm
b/main.asm
index cbf8a139d6e4df42f6cfc6ab17b432b39a0efbe3..8af0955347ffb2f088ff8b65cc8bb531f4065649 100644
(file)
--- a/
main.asm
+++ b/
main.asm
@@
-366,6
+366,23
@@
forth_asm GET, '@'
push rax
next
push rax
next
+;; Add two integers on the stack.
+forth_asm PLUS, '+'
+ pop rax
+ pop rbx
+ add rax, rbx
+ push rax
+ next
+
+;; Calculate difference between two integers on the stack. The second number is
+;; subtracted from the first.
+forth_asm MINUS, '-'
+ pop rax
+ pop rbx
+ sub rbx, rax
+ push rbx
+ next
+
;; Get the location of the STATE variable. It can be set with '!' and read with
;; '@'.
forth STATE, 'STATE'
;; Get the location of the STATE variable. It can be set with '!' and read with
;; '@'.
forth STATE, 'STATE'
@@
-385,6
+402,12
@@
forth HERE, 'HERE'
dq LIT, here
dq EXIT
dq LIT, here
dq EXIT
+forth COMMA, ','
+ dq HERE, GET, PUT ; Set the memory at the address pointed to by HERE
+ dq HERE, GET, LIT, 8, PLUS ; Calculate new address for HERE to point to
+ dq HERE, PUT ; Update HERE to point to the new address
+ dq EXIT
+
forth MAIN, 'MAIN'
dq HELLO
dq INTERPRET
forth MAIN, 'MAIN'
dq HELLO
dq INTERPRET