summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--readme.md36
-rw-r--r--sanctuary.s114
2 files changed, 150 insertions, 0 deletions
diff --git a/readme.md b/readme.md
index f799132..0bc797e 100644
--- a/readme.md
+++ b/readme.md
@@ -77,6 +77,24 @@ end compilation of the currently compiling word.
### `@ ( a -- u )`
fetch the 64 bit value at memory address a.
+### `= ( n1 n2 -- ? )`
+return true if n1 and n2 are equal.
+
+### `< ( n1 n2 -- ? )`
+return true if n1 is less than n2.
+
+### `<= ( n1 n2 -- ? )`
+return true if n1 is less than or equal to n2.
+
+### `<> ( n1 n2 -- ? )`
+return true if n1 and n2 are not equal.
+
+### `> ( n1 n2 -- ? )`
+return true if n1 is greater than n2.
+
+### `>= ( n1 n2 -- ? )`
+return true if n1 is greater than or equal to n2.
+
### `>body ( xt -- a )`
yield the code field of xt.
@@ -87,6 +105,24 @@ in the input buffer.
### `>r ( u -- ) ( R: -- u )`
move a value from the working stack to the return stack.
+### `0= ( n -- ? )`
+return true if n is equal to zero.
+
+### `0< ( n -- ? )`
+return true if n is less than zero.
+
+### `0<= ( n -- ? )`
+return true if n is less than or equal to zero.
+
+### `0<> ( n -- ? )`
+return true if n is not equal to zero.
+
+### `0> ( n -- ? )`
+return true if n is greater than zero.
+
+### `0>= ( n -- ? )`
+return true if n is greater than or equal to zero.
+
### `1+ ( u -- u')`
add one to u.
diff --git a/sanctuary.s b/sanctuary.s
index 6e5707a..ec6949b 100644
--- a/sanctuary.s
+++ b/sanctuary.s
@@ -824,6 +824,120 @@ defcode "*/mod", starslashmod, 0
pspush rdx
pspush rax
ret
+
+defcode "=", equals, 0
+ pspop r11
+ pspop r12
+ cmp r11, r12
+ sete r13b
+ movzx r11, r13b
+ neg r11
+ pspush r11
+ ret
+
+defcode "<>", less_greater, 0
+ pspop r11
+ pspop r12
+ cmp r11, r12
+ setne r13b
+ movzx r11, r13b
+ neg r11
+ pspush r11
+ ret
+
+defcode "<", less, 0
+ pspop r11
+ pspop r12
+ cmp r12, r11
+ setl r13b
+ movzx r11, r13b
+ neg r11
+ pspush r11
+ ret
+
+defcode ">", greater, 0
+ pspop r11
+ pspop r12
+ cmp r12, r11
+ setg r13b
+ movzx r11, r13b
+ neg r11
+ pspush r11
+ ret
+
+defcode "<=", lesseq, 0
+ pspop r11
+ pspop r12
+ cmp r12, r11
+ setle r13b
+ movzx r11, r13b
+ neg r11
+ pspush r11
+ ret
+
+defcode ">=", greatereq, 0
+ pspop r11
+ pspop r12
+ cmp r12, r11
+ setge r13b
+ movzx r11, r13b
+ neg r11
+ pspush r11
+ ret
+
+defcode "0=", zero_equals, 0
+ pspop r11
+ test r11, r11
+ sete r13b
+ movzx r11, r13b
+ neg r11
+ pspush r11
+ ret
+
+defcode "0<>", zero_less_greater, 0
+ pspop r11
+ test r11, r11
+ setne r13b
+ movzx r11, r13b
+ neg r11
+ pspush r11
+ ret
+
+defcode "0<", zero_less, 0
+ pspop r11
+ test r11, r11
+ setl r13b
+ movzx r11, r13b
+ neg r11
+ pspush r11
+ ret
+
+defcode "0>", zero_greater, 0
+ pspop r11
+ test r11, r11
+ setg r13b
+ movzx r11, r13b
+ neg r11
+ pspush r11
+ ret
+
+defcode "0<=", zero_lesseq, 0
+ pspop r11
+ test r11, r11
+ setle r13b
+ movzx r11, r13b
+ neg r11
+ pspush r11
+ ret
+
+defcode "0>=", zero_greatereq, 0
+ pspop r11
+ test r11, r11
+ setge r13b
+ movzx r11, r13b
+ neg r11
+ pspush r11
+ ret
; }}}
; TEMPORARY WONKY DEBUGGING FUNCTIONS {{{