summaryrefslogtreecommitdiff
path: root/twasm/asm/tests.asm
diff options
context:
space:
mode:
authorandromeda <andromeda@lenovo>2026-03-10 16:32:06 +0100
committerandromeda <andromeda@lenovo>2026-03-10 16:32:06 +0100
commit08c39a2bd89e6ef9ebc4b249368ab1282ab4f5fc (patch)
treee753428df7824418273963825f6b7f4c66ea23b9 /twasm/asm/tests.asm
parenta972f38bb636fdcb41a2bb7c856f7f546076b397 (diff)
add get_opcode and its test, fix a couple bugs + semantics things
Diffstat (limited to 'twasm/asm/tests.asm')
-rw-r--r--twasm/asm/tests.asm44
1 files changed, 44 insertions, 0 deletions
diff --git a/twasm/asm/tests.asm b/twasm/asm/tests.asm
index 8480554..22d626a 100644
--- a/twasm/asm/tests.asm
+++ b/twasm/asm/tests.asm
@@ -37,6 +37,9 @@ run_tests:
call clear_test_arena
call test_get_direct_addressing_ModRM
+ call clear_test_arena
+ call test_get_opcode
+
ret
.msg db "running test suite...", 0x0A, 0x00
@@ -513,6 +516,47 @@ test_get_direct_addressing_ModRM:
ret
.msg db "test_get_direct_addressing_ModRM...", 0x00
+; ------------------------------------------------------------------------------
+; test_get_opcode
+;
+; description:
+; tests get_opcode described functionality
+; ------------------------------------------------------------------------------
+
+test_get_opcode:
+ mov rsi, .msg
+ call print
+
+ mov di, 0x0053 ; xor
+ call get_opcode
+ cmp al, 0x33
+ jne .fail
+
+ mov di, 0x0054 ; inc
+ call get_opcode
+ cmp al, 0xFF
+ jne .fail
+
+ mov di, 0x004F ; hlt
+ call get_opcode
+ cmp al, 0xF4
+ jne .fail
+
+ mov di, 0x0003 ; rdx (not an operator)
+ call get_opcode
+ cmp al, UNRECOGNISED_ID_OPCODE
+ jne .fail
+
+ .pass:
+ mov rsi, msg_pass
+ call print
+ ret
+ .fail:
+ mov rsi, msg_fail
+ call print
+ ret
+ .msg db "test_get_opcode...", 0x00
+
msg_pass:
db 0x0A
times (TEST_LINE_LENGTH + .start - .end) db " ", ; right align