From 46bdc91966d7bb5513a28e23a252c9ea82282bf7 Mon Sep 17 00:00:00 2001 From: andromeda Date: Sat, 7 Mar 2026 15:51:51 +0100 Subject: [PATCH] clear tables --- twasm/asm/main.asm | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/twasm/asm/main.asm b/twasm/asm/main.asm index 9805b56..d2a6431 100644 --- a/twasm/asm/main.asm +++ b/twasm/asm/main.asm @@ -22,6 +22,8 @@ start: call run_tests + call clear_token_table + jmp halt ; ------------------------------------------------------------------------------ @@ -178,6 +180,34 @@ elemb: .f db "found", 0x0D, 0x0A, 0x00 .nf db "not found", 0x0D, 0x0A, 0x00 +; ------------------------------------------------------------------------------ +; clear_token_table +; +; description: +; clears the token table as specified by TOKEN_TABLE_SIZE and TOKEN_TABLE_ADDR +; ------------------------------------------------------------------------------ + +clear_token_table: + xor rax, rax ; value to write + mov rcx, TOKEN_TABLE_SIZE / 4 ; number of double words + mov rdi, TOKEN_TABLE_ADDR ; address to start + rep stosd + ret + +; ------------------------------------------------------------------------------ +; clear_test_arena +; +; description: +; clears the test arena as specified by TEST_ARENA_SIZE and TEST_ARENA_ADDR +; ------------------------------------------------------------------------------ + +clear_test_arena: + xor rax, rax ; value to write + mov rcx, TOKEN_TABLE_SIZE / 4 ; number of double words + mov rdi, TOKEN_TABLE_ADDR ; address to start + rep stosd + ret + ; ------------------------------------------------------------------------------ ; tests ; ------------------------------------------------------------------------------ @@ -193,8 +223,13 @@ run_tests: mov rsi, .msg call print + call clear_test_arena call test_copy_byte + + call clear_test_arena call test_copy_token + + call clear_test_arena call test_elemb ret