summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandromeda <andromeda@lenovo>2026-03-18 20:45:12 +0100
committerandromeda <andromeda@lenovo>2026-03-18 20:45:12 +0100
commitac0a10fafd5745f5c50539a079340504f5e060ad (patch)
tree612ef5ac5893d92ea4fa4110bc1b7e4eb528272a
parent2e222c304abd45dc33c252da757119e588652100 (diff)
finally change .gitignore, correctly handle register operands
-rw-r--r--.gitignore1
-rw-r--r--twasm/.bootle/diskbin1474560 -> 0 bytes
-rw-r--r--twasm/asm/main.asm25
3 files changed, 25 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index fcfc4a1..bd6fbc7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
result*
+.bootle*
diff --git a/twasm/.bootle/disk b/twasm/.bootle/disk
deleted file mode 100644
index 995de23..0000000
--- a/twasm/.bootle/disk
+++ /dev/null
Binary files differ
diff --git a/twasm/asm/main.asm b/twasm/asm/main.asm
index 8b2d7ef..9c8d483 100644
--- a/twasm/asm/main.asm
+++ b/twasm/asm/main.asm
@@ -635,6 +635,10 @@ tokenise:
test byte [.expecting], E_OPERAND ; make sure an operand was expected
jz .unexpected_operand ; if not, error
+ push rax
+ push rdi
+ xor eax, eax ; rax = length of operand
+
.operand_loop:
mov dl, [rdi]
@@ -645,10 +649,29 @@ tokenise:
cmp dl, 0x00
je .operand_break
- inc rdi
+ inc rax ; inc length counter
+ inc rdi ; inc byte pointer
jmp .operand_loop
.operand_break:
+ pop rdi ; rdi = first byte of operand
+ push rdi
+ push rsi
+ mov rsi, rax ; rsi = length of operand in bytes
+
+ mov cx, ax ; cx = length counter for safe keeping
+ call evaluate_operand
+ ; ax = register's token ID
+
+ pop rsi
+ pop rdi ; rdi = first byte of operand
+ add di, cx ; rdi = last byte of operand
+ mov cx, ax ; cx = register's token ID for safe keeping
+ pop rax ; rax = number of tokens processed
+
+ mov [TOKEN_TABLE_ADDR + rax * TOKEN_TABLE_ENTRY_SIZE], cx
+ inc rax ; another token processed
+
mov byte [.expecting], E_COMMENT | E_NEWLINE | E_WHITESPACE | E_COMMA
jmp .loop