1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
global main
;================================================================================================
;CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE
;================================================================================================
[section .code use64]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
main:
call test_truth
; Exit program
mov rax, 1
mov rbx, 0
int 0x80
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;================================================================================================
;END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE
;================================================================================================
;========================================================================================================
;FONCTIONS FONCTIONS FONCTIONS FONCTIONS FONCTIONS FONCTIONS FONCTIONS
;========================================================================================================
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
assert_equal:
mov eax, [rsp + 8]
cmp eax, [rsp + 12]
jne not_found
found:
mov rax, 4
mov rbx, 1
mov rcx, msg_green
mov rdx, end_msg_green - msg_green
int 0x80
ret
not_found:
mov rax, 4
mov rbx, 1
mov rcx, msg_red
mov rdx, end_msg_red - msg_red
int 0x80
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
test_truth:
sub rsp, (4 + 4)
mov [rsp], dword 1
mov [rsp + 4], dword 1
call assert_equal
add rsp, (4 + 4)
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;====================================================================================================
;END_FONCTIONS END_FONCTIONS END_FONCTIONS END_FONCTIONS END_FONCTIONS
;====================================================================================================
;================================================================================================
;DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA
;================================================================================================
[section .data use64]
msg_green db "Passed", 10
end_msg_green:
msg_red db "Failed", 10
end_msg_red:
;================================================================================================
;END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA
;================================================================================================ |
Partager