remove unused code
This commit is contained in:
@@ -695,71 +695,6 @@ identify_next_token:
|
|||||||
mov rdx, rsi ; length
|
mov rdx, rsi ; length
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; ------------------------------------------------------------------------------
|
|
||||||
; copy_token
|
|
||||||
;
|
|
||||||
; description:
|
|
||||||
; copies a token from one spot in memory to another
|
|
||||||
;
|
|
||||||
; parameters:
|
|
||||||
; rdi -> start of buffer to be read
|
|
||||||
; rsi -> start of buffer to be written
|
|
||||||
;
|
|
||||||
; returned:
|
|
||||||
; rax -> last byte read
|
|
||||||
; rdx -> last byte written
|
|
||||||
; ------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
copy_token:
|
|
||||||
.loop:
|
|
||||||
mov dl, [rdi] ; move bit to compare to current byte in read buffer
|
|
||||||
|
|
||||||
push rdi ; push incrementors to call elemb
|
|
||||||
push rsi ;
|
|
||||||
|
|
||||||
mov rdi, 8 ; length of terminator list
|
|
||||||
mov rsi, token_terminator_8 ; start of terminator list
|
|
||||||
; dl set before pushing rdi
|
|
||||||
call elemb
|
|
||||||
|
|
||||||
pop rsi ;
|
|
||||||
pop rdi ; pop incrementors after call
|
|
||||||
|
|
||||||
cmp rax, 1 ; check if the next character is a token terminator
|
|
||||||
je .break ; > if so, break the function
|
|
||||||
|
|
||||||
; rdi and rsi set from previous loop iteration
|
|
||||||
call copy_byte ; if not, copy the current byte in read buffer
|
|
||||||
|
|
||||||
inc rdi ; read pointer
|
|
||||||
inc rsi ; write pointer
|
|
||||||
jmp .loop
|
|
||||||
|
|
||||||
.break:
|
|
||||||
mov rax, rdi ; -> last byte read
|
|
||||||
mov rdx, rsi ; -> last byte written
|
|
||||||
ret
|
|
||||||
|
|
||||||
; ------------------------------------------------------------------------------
|
|
||||||
; copy_byte
|
|
||||||
;
|
|
||||||
; description:
|
|
||||||
; copies a byte from one spot in memory to another
|
|
||||||
;
|
|
||||||
; parameters:
|
|
||||||
; rdi -> word to be read
|
|
||||||
; rsi -> word to be written
|
|
||||||
;
|
|
||||||
; returned:
|
|
||||||
; al = byte that was read; the rest of rax is zeroed
|
|
||||||
; ------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
copy_byte:
|
|
||||||
xor eax, eax ; zero out so it returns fine
|
|
||||||
mov al, [rdi]
|
|
||||||
mov [rsi], al
|
|
||||||
ret
|
|
||||||
|
|
||||||
; ------------------------------------------------------------------------------
|
; ------------------------------------------------------------------------------
|
||||||
; utilities
|
; utilities
|
||||||
; ------------------------------------------------------------------------------
|
; ------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -13,12 +13,6 @@ run_tests:
|
|||||||
mov rsi, .msg
|
mov rsi, .msg
|
||||||
call print.test
|
call print.test
|
||||||
|
|
||||||
call clear_test_arena
|
|
||||||
call test_copy_byte
|
|
||||||
|
|
||||||
call clear_test_arena
|
|
||||||
call test_copy_token
|
|
||||||
|
|
||||||
call clear_test_arena
|
call clear_test_arena
|
||||||
call test_elemb
|
call test_elemb
|
||||||
|
|
||||||
@@ -46,94 +40,6 @@ run_tests:
|
|||||||
ret
|
ret
|
||||||
.msg db "running test suite...", 0x0A, 0x00
|
.msg db "running test suite...", 0x0A, 0x00
|
||||||
|
|
||||||
; ------------------------------------------------------------------------------
|
|
||||||
; test_copy_byte
|
|
||||||
;
|
|
||||||
; description:
|
|
||||||
; tests copy_byte described functionality
|
|
||||||
; ------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
test_copy_byte:
|
|
||||||
mov rsi, .msg
|
|
||||||
call print.test
|
|
||||||
|
|
||||||
mov rdi, test_byte ; byte to be copied
|
|
||||||
mov rsi, TEST_ARENA_ADDR ; location of test
|
|
||||||
call copy_byte
|
|
||||||
|
|
||||||
mov cx, [rsi]
|
|
||||||
and ax, 0xFF ; only compare bottom byte
|
|
||||||
and cx, 0xFF
|
|
||||||
cmp ax, cx ; compare returned byte to copied byte
|
|
||||||
jne .fail
|
|
||||||
cmp al, [test_byte] ; compare returned byte to expected byte
|
|
||||||
jne .fail
|
|
||||||
|
|
||||||
.pass:
|
|
||||||
mov rsi, msg_pass
|
|
||||||
call print
|
|
||||||
ret
|
|
||||||
.fail:
|
|
||||||
mov rsi, msg_fail
|
|
||||||
call print
|
|
||||||
ret
|
|
||||||
.msg db "test_copy_byte...", 0x00
|
|
||||||
|
|
||||||
; ------------------------------------------------------------------------------
|
|
||||||
; test_copy_token
|
|
||||||
;
|
|
||||||
; description:
|
|
||||||
; tests copy_token described functionality
|
|
||||||
; ------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
test_copy_token:
|
|
||||||
mov rsi, .msg
|
|
||||||
call print.test
|
|
||||||
|
|
||||||
; test case: space terminated
|
|
||||||
|
|
||||||
mov rdi, test_token_space ; read buffer
|
|
||||||
mov rsi, TEST_ARENA_ADDR ; write buffer
|
|
||||||
call copy_token
|
|
||||||
|
|
||||||
; check reported final indicies with the expected final indicies
|
|
||||||
cmp rax, test_token_space + 8 ; last byte read
|
|
||||||
jne .fail
|
|
||||||
cmp rdx, TEST_ARENA_ADDR + 8 ; last byte written
|
|
||||||
jne .fail
|
|
||||||
|
|
||||||
mov rsi, TEST_ARENA_ADDR
|
|
||||||
mov rcx, [rsi]
|
|
||||||
cmp rcx, [test_token_space] ; check if copied token matches expected token
|
|
||||||
jne .fail ; if not, fail
|
|
||||||
|
|
||||||
; test case: null terminated
|
|
||||||
|
|
||||||
mov rdi, test_token_null ; read buffer
|
|
||||||
mov rsi, TEST_ARENA_ADDR ; write buffer
|
|
||||||
call copy_token
|
|
||||||
|
|
||||||
; check reported final indicies with the expected final indicies
|
|
||||||
cmp rax, test_token_null + 8 ; last byte read
|
|
||||||
jne .fail
|
|
||||||
cmp rdx, TEST_ARENA_ADDR + 8 ; last byte written
|
|
||||||
jne .fail
|
|
||||||
|
|
||||||
mov rsi, TEST_ARENA_ADDR
|
|
||||||
mov rcx, [rsi]
|
|
||||||
cmp rcx, [test_token_null] ; check if copied token matches expected token
|
|
||||||
jne .fail ; if not, fail
|
|
||||||
|
|
||||||
.pass:
|
|
||||||
mov rsi, msg_pass
|
|
||||||
call print
|
|
||||||
ret
|
|
||||||
.fail:
|
|
||||||
mov rsi, msg_fail
|
|
||||||
call print
|
|
||||||
ret
|
|
||||||
.msg db "test_copy_token...", 0x00
|
|
||||||
|
|
||||||
; ------------------------------------------------------------------------------
|
; ------------------------------------------------------------------------------
|
||||||
; test_elemb
|
; test_elemb
|
||||||
;
|
;
|
||||||
|
|||||||
Reference in New Issue
Block a user