summaryrefslogtreecommitdiff
path: root/twasm/asm/tests.asm
diff options
context:
space:
mode:
authorandromeda <andromeda@lenovo>2026-03-18 20:26:30 +0100
committerandromeda <andromeda@lenovo>2026-03-18 20:26:30 +0100
commit2e222c304abd45dc33c252da757119e588652100 (patch)
tree5f406450e06fea7160670099e925be3a53591939 /twasm/asm/tests.asm
parentec88bd7381f78e834177d4326a010bfe5fb8c11e (diff)
add evaluate_operand, fix operator tokenising
Diffstat (limited to 'twasm/asm/tests.asm')
-rw-r--r--twasm/asm/tests.asm49
1 files changed, 49 insertions, 0 deletions
diff --git a/twasm/asm/tests.asm b/twasm/asm/tests.asm
index b7a9bec..e2dd79e 100644
--- a/twasm/asm/tests.asm
+++ b/twasm/asm/tests.asm
@@ -40,6 +40,9 @@ run_tests:
call clear_test_arena
call test_identify_operator
+ call clear_test_arena
+ call test_evaluate_operand
+
ret
.msg db "running test suite...", 0x0A, 0x00
@@ -499,6 +502,52 @@ test_identify_operator:
ret
.msg db "test_identify_operator...", 0x00
+; ------------------------------------------------------------------------------
+; test_evaluate_operand
+;
+; description:
+; tests evaluate_operand described funtionality
+; ------------------------------------------------------------------------------
+
+test_evaluate_operand:
+ mov rsi, .msg
+ call print.test
+
+ mov rdi, .case0
+ mov rsi, 3
+ call evaluate_operand
+ cmp dl, 0x00
+ jne .fail
+ cmp ax, 0x0000
+ jne .fail
+
+ mov rdi, .case1
+ mov rsi, 0
+ call evaluate_operand
+ cmp dl, 0xFF
+ jne .fail
+
+ mov rdi, .case2
+ mov rsi, 3
+ call evaluate_operand
+ cmp dl, 0x00
+ jne .fail
+ cmp ax, 0x0003
+ jne .fail
+
+ .pass:
+ mov rsi, msg_pass
+ call print
+ ret
+ .fail:
+ mov rsi, msg_fail
+ call print
+ ret
+ .case0 db "rax"
+ .case1: ; intentionally blank
+ .case2 db "rdx"
+ .msg db "test_evaluate_operand...", 0x00
+
msg_pass:
db 0x0A
times (TEST_LINE_LENGTH + .start - .end) db " ", ; right align