summaryrefslogtreecommitdiff
path: root/sanctuary.s
diff options
context:
space:
mode:
authorkitty <nepeta@canaglie.net>2026-03-19 18:52:59 +1100
committerkitty <nepeta@canaglie.net>2026-03-19 18:52:59 +1100
commitae2bb07e11ce6582cc9c7d45d1b8137c355e9db7 (patch)
tree7d97c829a1b6e50737119996a3545f2f9293a91c /sanctuary.s
parente8d44270cde4c9e3149cde0ab9ae6bf58cd05578 (diff)
math stuff
Diffstat (limited to 'sanctuary.s')
-rw-r--r--sanctuary.s64
1 files changed, 64 insertions, 0 deletions
diff --git a/sanctuary.s b/sanctuary.s
index f9fc5f0..44cd4af 100644
--- a/sanctuary.s
+++ b/sanctuary.s
@@ -449,6 +449,7 @@ defcode "(header)", brac_header, 0
pspush r12
ret
+; fix to follow ans: yielding colon-sys
defcode ":", colon, 0
call parse_name
; todo check zero
@@ -459,6 +460,8 @@ defcode ":", colon, 0
mov qword [state], COMPILING
ret
+; fix to follow ans: reading from colon-sys
+; this will not work with :noname or i think does>.
defcode ";", semicolon, immediate_mask
mov r12, [latest]
add r12, 8
@@ -659,6 +662,67 @@ defcode "rdrop", rdrop, 0
; }}}
; math + comparison {{{
+; i believe some of these could be improved by direct accesses to [r15]
+defcode "+", plus, 0
+ pspop r11
+ pspop r12
+ add r11, r12
+ pspush r11
+ ret
+
+defcode "-", minus, 0
+ pspop r11
+ pspop r12
+ sub r12, r11
+ pspush r12
+ ret
+
+defcode "*", _times, 0
+ pspop r11
+ pspop r12
+ imul r11, r12
+ pspush r11
+ ret
+
+defcode "/mod", divmod, 0
+ xor rdx, rdx
+ pspop r11
+ pspop rax
+ idiv r11
+ pspush rdx
+ pspush rax
+ ret
+
+defcode "and", _and, 0
+ pspop r11
+ and [r14], r11
+ ret
+
+defcode "or", _or, 0
+ pspop r11
+ or [r14], r11
+ ret
+
+defcode "xor", _xor, 0
+ pspop r11
+ xor [r14], r11
+ ret
+
+defcode "invert", invert, 0
+ not qword [r14]
+ ret
+
+defcode "*/mod", starslashmod, 0
+ pspop r15 ; n3
+ pspop r13 ; n2
+ pspop rax ; n1
+
+ imul r13
+ idiv r15
+
+ pspush rdx
+ pspush rax
+ ret
; }}}
; TEMPORARY WONKY DEBUGGING FUNCTIONS {{{