projects
/
rrq
/
jonasforth.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add syntax=fasm to FASM files
[rrq/jonasforth.git]
/
main.asm
diff --git
a/main.asm
b/main.asm
index 086d1dc243dcfa4d8641d2eba627eedd804c1138..183264c8a47d25ee0bce07677da5456da6385882 100644
(file)
--- a/
main.asm
+++ b/
main.asm
@@
-1,3
+1,5
@@
+;; vim: syntax=fasm
+
format ELF64 executable
;; The code in this macro is placed at the end of each Forth word. When we are
format ELF64 executable
;; The code in this macro is placed at the end of each Forth word. When we are
@@
-235,16
+237,6
@@
forth_asm TERMINATE, 'TERMINATE'
mov rdi, 0
syscall
mov rdi, 0
syscall
-forth HELLO, 'HELLO'
- dq LIT, 'H', EMIT
- dq LIT, 'e', EMIT
- dq LIT, 'l', EMIT
- dq LIT, 'l', EMIT
- dq LIT, 'o', EMIT
- dq LIT, '!', EMIT
- dq NEWLINE
- dq EXIT
-
;; Duplicate a pair of elements.
forth_asm PAIRDUP, '2DUP'
pop rbx
;; Duplicate a pair of elements.
forth_asm PAIRDUP, '2DUP'
pop rbx
@@
-563,8
+555,35
@@
forth_asm TICK, "'"
push rax
next
push rax
next
+forth_asm ROT, 'ROT'
+ pop rax
+ pop rbx
+ pop rdx
+ push rax
+ push rdx
+ push rbx
+ next
+
+forth_asm PICK, 'PICK'
+ pop rax
+ lea rax, [rsp + 8 * rax]
+ mov rax, [rax]
+ push rax
+ next
+
+forth_asm EQL, '='
+ pop rax
+ pop rbx
+ cmp rax, rbx
+ je .eq
+.noteq:
+ push 0
+ next
+.eq:
+ push 1
+ next
+
forth MAIN, 'MAIN'
forth MAIN, 'MAIN'
- dq HELLO
dq INTERPRET
dq BRANCH, -8 * 2
dq TERMINATE
dq INTERPRET
dq BRANCH, -8 * 2
dq TERMINATE