From e6d7cb2f2104183e6d090ead5ad0f491f603e3ce Mon Sep 17 00:00:00 2001 From: andromeda Date: Tue, 10 Mar 2026 21:21:59 +0100 Subject: add get_reg_bits and test, streamline ModRM calculations, correct opcodes, fix typos... --- twasm/asm/tests.asm | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'twasm/asm/tests.asm') diff --git a/twasm/asm/tests.asm b/twasm/asm/tests.asm index 22d626a..4705829 100644 --- a/twasm/asm/tests.asm +++ b/twasm/asm/tests.asm @@ -40,6 +40,9 @@ run_tests: call clear_test_arena call test_get_opcode + call clear_test_arena + call test_get_reg_bits + ret .msg db "running test suite...", 0x0A, 0x00 @@ -529,7 +532,7 @@ test_get_opcode: mov di, 0x0053 ; xor call get_opcode - cmp al, 0x33 + cmp al, 0x31 jne .fail mov di, 0x0054 ; inc @@ -557,6 +560,42 @@ test_get_opcode: ret .msg db "test_get_opcode...", 0x00 +; ------------------------------------------------------------------------------ +; test_get_reg_bits +; +; description: +; tests get_reg_bits described functionality +; ------------------------------------------------------------------------------ + +test_get_reg_bits: + mov rsi, .msg + call print + + mov di, 0x0000 ; rax + call get_reg_bits + cmp al, 000b + jne .fail + + mov di, 0x0010 ; eax + call get_reg_bits + cmp al, 000b + jne .fail + + mov di, 0x0003 ; rdx + call get_reg_bits + cmp al, 010b + jne .fail + + .pass: + mov rsi, msg_pass + call print + ret + .fail: + mov rsi, msg_fail + call print + ret + .msg db "test_get_reg_bits...", 0x00 + msg_pass: db 0x0A times (TEST_LINE_LENGTH + .start - .end) db " ", ; right align -- cgit v1.3.1