summaryrefslogtreecommitdiff
path: root/twasm/asm/main.asm
diff options
context:
space:
mode:
authorandromeda <andromeda@lenovo>2026-03-18 16:18:19 +0100
committerandromeda <andromeda@lenovo>2026-03-18 16:18:19 +0100
commit17a0a1a406bb52bde8c1306cd7ff44c00acb84de (patch)
tree81e3976981f5f6504bb11e0acc4e44ac12d5df4f /twasm/asm/main.asm
parente79a30ba713054053e8995639a14b00e8ea1c16f (diff)
yeh only chr consts fn
Diffstat (limited to 'twasm/asm/main.asm')
-rw-r--r--twasm/asm/main.asm46
1 files changed, 11 insertions, 35 deletions
diff --git a/twasm/asm/main.asm b/twasm/asm/main.asm
index 2c28dbf..f4f13af 100644
--- a/twasm/asm/main.asm
+++ b/twasm/asm/main.asm
@@ -732,8 +732,7 @@ tokenise:
; | 0x00 | 0x | hexidecimal |
; | 0x01 | 0q | octal |
; | 0x02 | 0b | binary |
-; | 0x03 | '' | ascii char |
-; | 0x04 | "" | ascii string |
+; | 0x03 | " | char |
; | 0xFF | | unrecognised |
;
; where `p.` is the prefix or otherwise indicator
@@ -763,19 +762,12 @@ evaluate_constant:
cmp dl, '0'
je .numeric
- ; char case
+ ; chr case
mov rcx, 0x03
push rcx
- cmp dl, "'"
- je .chr
- pop rcx
-
- ; str case
- mov rcx, 0x04
- push rcx
xor ecx, ecx ; rcx = number of times right-rolled
cmp dl, '"'
- je .str
+ je .chr
pop rcx
jmp .unrecognised
@@ -874,26 +866,9 @@ evaluate_constant:
jmp .bin_loop
.chr:
- mov al, [rdi]
-
- ; bound check byte as printable char
- cmp al, 0x20
- jl .unrecognised
- cmp al, 0x7E
- jg .unrecognised
-
- dec rsi
- inc rdi
- mov dl, [rdi]
- cmp dl, "'"
- jne .unrecognised
-
- jmp .break
-
- .str:
- ; TODO range check rcx / return string longer as a register
+ ; TODO range check rcx
cmp rsi, 1 ; range check
- je .str_break
+ je .chr_break
ror rax, 8
inc rcx
@@ -911,16 +886,16 @@ evaluate_constant:
dec rsi
inc rdi
- jmp .str
+ jmp .chr
- .str_break:
+ .chr_break:
cmp rcx, 1 ; for each [1..rcx]
- jle .str_break_for_good
+ jle .chr_break_for_good
rol rax, 8 ; roll left to make up for the roll right earlier
dec rcx
- jmp .str_break
+ jmp .chr_break
- .str_break_for_good:
+ .chr_break_for_good:
mov dl, [rdi]
cmp dl, '"'
jne .unrecognised
@@ -932,6 +907,7 @@ evaluate_constant:
ret
.unrecognised:
+ pop rdx
mov rdx, 0xFF ; unrecognised type
ret