projects
/
rrq
/
jonasforth.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
6345a1a
)
Implement '!' and '@' commands and add 'STATE' variable
author
Jonas Hvid
<mail@johv.dk>
Tue, 3 Dec 2019 18:35:51 +0000
(19:35 +0100)
committer
Jonas Hvid
<mail@johv.dk>
Tue, 3 Dec 2019 18:35:51 +0000
(19:35 +0100)
main.asm
patch
|
blob
|
history
diff --git
a/main.asm
b/main.asm
index 8d9c51b77573f2da465b50914b6574acb1f29679..edcba0ae9421c712218041e64d4fc0872370f8d9 100644
(file)
--- a/
main.asm
+++ b/
main.asm
@@
-312,6
+312,26
@@
forth_asm DOTU, '.U'
pop rsi
next
pop rsi
next
+;; Takes a value and an address, and stores the value at the given address.
+forth_asm PUT, '!'
+ pop rbx ; Address
+ pop rax ; Value
+ mov [rbx], rax
+ next
+
+;; Takes an address and returns the value at the given address.
+forth_asm GET, '@'
+ pop rax
+ mov rax, [rax]
+ push rax
+ next
+
+;; Get the location of the STATE variable. It can be set with '!' and read with
+;; '@'.
+forth STATE, 'STATE'
+ dq LIT, var_STATE
+ dq EXIT
+
forth MAIN, 'MAIN'
dq HELLO
dq INTERPRET
forth MAIN, 'MAIN'
dq HELLO
dq INTERPRET
@@
-322,6
+342,10
@@
segment readable writable
latest_entry dq initial_latest_entry
latest_entry dq initial_latest_entry
+;; The STATE variable is 0 when the interpreter is executing, and non-zero when
+;; it is compiling.
+var_STATE dq 0
+
FIND.rsi dq ?
READ_WORD.rsi dq ?
FIND.rsi dq ?
READ_WORD.rsi dq ?