evaluate constants as long as they are hex in the form 0x
This commit is contained in:
@@ -31,6 +31,9 @@ run_tests:
|
||||
call clear_test_arena
|
||||
call test_get_reg_bits
|
||||
|
||||
call clear_test_arena
|
||||
call test_evaluate_constant
|
||||
|
||||
ret
|
||||
.msg db "running test suite...", 0x0A, 0x00
|
||||
|
||||
@@ -300,6 +303,71 @@ test_get_reg_bits:
|
||||
ret
|
||||
.msg db "test_get_reg_bits...", 0x00
|
||||
|
||||
; ------------------------------------------------------------------------------
|
||||
; test_evaluate_constant
|
||||
;
|
||||
; description:
|
||||
; tests evaluate_constant described funtionality
|
||||
; ------------------------------------------------------------------------------
|
||||
|
||||
test_evaluate_constant:
|
||||
mov rsi, .msg
|
||||
call print.test
|
||||
|
||||
; just numerals
|
||||
mov rdi, .case0 ; addr of constant
|
||||
mov rsi, 8 ; length of constant
|
||||
call evaluate_constant
|
||||
cmp rax, [.case0_solution]
|
||||
jne .fail
|
||||
cmp rdx, 0x00
|
||||
jne .fail
|
||||
|
||||
; just chars
|
||||
mov rdi, .case1 ; addr of constant
|
||||
mov rsi, 8 ; length of constant
|
||||
call evaluate_constant
|
||||
cmp rax, [.case1_solution]
|
||||
jne .fail
|
||||
cmp rdx, 0x00
|
||||
jne .fail
|
||||
|
||||
; just chars
|
||||
mov rdi, .case2 ; addr of constant
|
||||
mov rsi, 12 ; length of constant
|
||||
call evaluate_constant
|
||||
cmp rax, [.case2_solution]
|
||||
jne .fail
|
||||
cmp rdx, 0x00
|
||||
jne .fail
|
||||
|
||||
; PI
|
||||
mov rdi, .case3 ; addr of constant
|
||||
mov rsi, 18 ; length of constant
|
||||
call evaluate_constant
|
||||
cmp rax, [.case3_solution]
|
||||
jne .fail
|
||||
cmp rdx, 0x00
|
||||
jne .fail
|
||||
|
||||
.pass:
|
||||
mov rsi, msg_pass
|
||||
call print
|
||||
ret
|
||||
.fail:
|
||||
mov rsi, msg_fail
|
||||
call print
|
||||
ret
|
||||
.msg db "test_evaluate_constant...", 0x00
|
||||
.case0 db "0x012390"
|
||||
.case0_solution dq 0x012390
|
||||
.case1 db "0xABCDEF"
|
||||
.case1_solution dq 0xABCDEF
|
||||
.case2 db "0x1234567890"
|
||||
.case2_solution dq 0x1234567890
|
||||
.case3 db "0x243F6A8885A308D3"
|
||||
.case3_solution dq 0x243F6A8885A308D3
|
||||
|
||||
msg_pass:
|
||||
db 0x0A
|
||||
times (TEST_LINE_LENGTH + .start - .end) db " ", ; right align
|
||||
|
||||
Reference in New Issue
Block a user