-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaunit.s
67 lines (54 loc) · 1.05 KB
/
aunit.s
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
.data
ok: .asciz "."
ko: .asciz "x"
.text
_assertEqual:
mov 8(%rsp), %rax
mov 16(%rsp), %rbx
cmp %rax, %rbx
jne _different
_equal:
mov $0, %rax
jmp _end_assertEqual
_different:
mov $42, %rax
_end_assertEqual:
ret
_displayChar:
mov $0x2000004, %rax
mov $1, %rdi
mov 8(%rsp), %rsi
mov $1, %rdx
syscall
ret
_runTestSuite:
push %rbp
mov %rsp, %rbp
sub $16, %rsp
movq $0, -8(%rbp)
movq $0, -16(%rbp)
_runNextTest:
mov 16(%rbp), %rax
mov -8(%rbp), %rdi
call *(%rax, %rdi, 8)
cmp $0, %rax
jne _failure
_success:
push ok@GOTPCREL(%rip)
call _displayChar
add $8, %rsp
jmp _continue
_failure:
push ko@GOTPCREL(%rip)
call _displayChar
add $8, %rsp
movq $42, -16(%rbp)
_continue:
addq $1, -8(%rbp)
mov 24(%rbp), %rbx
cmpq %rbx, -8(%rbp)
jne _runNextTest
mov -16(%rbp), %rax
mov %rbp, %rsp
pop %rbp
ret