1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 == code
18
19
20
21
22
23
24 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
25
26 81 7/subop/compare 1/mod/*+disp8 4/rm32/SIB 5/base/EBP 4/index/none . . 0/disp8 1/imm32
27 7e/jump-if-lesser-or-equal $run_main/disp8
28
29
30 68/push "test"/imm32
31 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x8/disp8 .
32
33 e8/call kernel_string_equal/disp32
34
35 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
36
37 3d/compare-EAX 1/imm32
38 75/jump-if-not-equal $run_main/disp8
39
40 e8/call run_tests/disp32
41 eb/jump $main_exit/disp8
42
43 $run_main:
44
45 68/push 5/imm32
46
47 e8/call factorial/disp32
48
49 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
50 $main_exit:
51
52 89/copy 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . .
53 b8/copy . . . . . . . 1/imm32
54 cd/syscall 0x80/imm8
55
56
57 factorial:
58
59 55/push-EBP
60 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
61 53/push-EBX
62
63 b8/copy . . . . . . . 1/imm32
64
65 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 1/imm32
66 7e/jump-if-<= $factorial:exit/disp8
67
68 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 3/r32/EBX 8/disp8 .
69 81 5/subop/subtract 3/mod/direct 3/rm32/EBX . . . . . 1/imm32
70
71 53/push-EBX
72 e8/call . . . . . . factorial/disp32
73
74 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
75
76 f7 4/subop/multiply 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 8/disp8 .
77
78 $factorial:exit:
79
80 5b/pop-to-EBX
81 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
82 5d/pop-to-EBP
83 c3/return
84
85 test_factorial:
86
87
88 68/push 5/imm32
89
90 e8/call factorial/disp32
91
92 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
93
94
95 68/push "F - test_factorial"/imm32
96 68/push 0x78/imm32/expected-120
97 50/push-EAX
98
99 e8/call check_ints_equal/disp32
100
101 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
102
103 c3/return
104
105