summaryrefslogtreecommitdiff
path: root/sanctuary.s
diff options
context:
space:
mode:
Diffstat (limited to 'sanctuary.s')
-rw-r--r--sanctuary.s52
1 files changed, 52 insertions, 0 deletions
diff --git a/sanctuary.s b/sanctuary.s
index 4108078..83b924e 100644
--- a/sanctuary.s
+++ b/sanctuary.s
@@ -1108,6 +1108,58 @@ defcode "u>=", ugreatereq, 0
ret
; }}}
+; todo doc
+; ( a¹ u¹ a² u² -- n )
+defcode "compare", compare, 0
+ pspop r11 ; u2
+ pspop rdi ; a2
+ pspop r13 ; u1
+ pspop rsi ; a1
+
+ ; check a* = 0?
+
+.loop:
+ cmpsb
+
+ jl .below
+ jg .above
+
+ dec r11
+ dec r13
+
+ ; check both = 0
+ ; either of these = 0 then jmp accordingly also
+
+ cmp r11, 0
+ jne .11n0
+
+ cmp r13, 0 ; r11 = r13 & strings identical
+ je .same
+
+ ; u2 > u1
+ jmp .above
+
+.11n0:
+ cmp r13, 0 ; u1 < u2
+ je .below
+
+.cont:
+ jmp .loop
+
+.below:
+ mov r11, true
+ jmp .e
+
+.above:
+ mov r11, 1
+ jmp .e
+
+.same:
+ mov r11, false
+.e:
+ pspush r11
+ ret
+
defcode "branch", branch, 0
mov r12, [dp]
mov byte [r12], 0xe9