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:
28f8191
)
Terminate program correctly
author
Jonas Hvid
<mail@johv.dk>
Mon, 18 Nov 2019 17:23:37 +0000
(18:23 +0100)
committer
Jonas Hvid
<mail@johv.dk>
Mon, 18 Nov 2019 17:23:37 +0000
(18:23 +0100)
main.asm
patch
|
blob
|
history
diff --git
a/main.asm
b/main.asm
index 626de1610f6d360e0331ce54ea12338f194bc84e..c6ada7329cbd4b320947c8b925203ad448ac162d 100644
(file)
--- a/
main.asm
+++ b/
main.asm
@@
-32,8
+32,7
@@
main:
mov rsi, program
next
mov rsi, program
next
-program:
- dq HELLO
+program: dq MAIN
;; The codeword is the code that will be executed at the beginning of a forth
;; word. It needs to save the old RSI and update it to point to the next word to
;; The codeword is the code that will be executed at the beginning of a forth
;; word. It needs to save the old RSI and update it to point to the next word to
@@
-43,9
+42,11
@@
docol:
lea rsi, [rax + 8] ; RAX currently points to the address of the codeword, so we want to continue at RAX+8
next ; Execute word pointed to by RSI
lea rsi, [rax + 8] ; RAX currently points to the address of the codeword, so we want to continue at RAX+8
next ; Execute word pointed to by RSI
-;; This
code
word is called at the end of a Forth definition. It just needs to
+;; This word is called at the end of a Forth definition. It just needs to
;; restore the old value of RSI (saved by 'docol') and resume execution.
;; restore the old value of RSI (saved by 'docol') and resume execution.
-exit:
+EXIT:
+ dq .start
+.start:
popr rsi
next
popr rsi
next
@@
-84,7
+85,21
@@
HELLO:
dq EMIT
dq EMIT
dq EMIT
dq EMIT
dq EMIT
dq EMIT
- dq exit
+ dq EXIT
+
+TERMINATE:
+ dq .start
+.start:
+ mov rax, $3C
+ mov rdi, 0
+ syscall
+
+MAIN:
+ dq docol
+ dq HELLO
+ dq HELLO
+ dq HELLO
+ dq TERMINATE
segment readable writable
segment readable writable