From 2e222c304abd45dc33c252da757119e588652100 Mon Sep 17 00:00:00 2001 From: andromeda Date: Wed, 18 Mar 2026 20:26:30 +0100 Subject: add evaluate_operand, fix operator tokenising --- twasm/asm/tests.asm | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'twasm/asm/tests.asm') 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 -- cgit v1.3.1