From 17a0a1a406bb52bde8c1306cd7ff44c00acb84de Mon Sep 17 00:00:00 2001 From: andromeda Date: Wed, 18 Mar 2026 16:18:19 +0100 Subject: yeh only chr consts fn --- twasm/asm/main.asm | 46 +++++++++++----------------------------------- 1 file changed, 11 insertions(+), 35 deletions(-) (limited to 'twasm/asm/main.asm') 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 -- cgit v1.3.1