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
72 53/push-EBX
73
74 e8/call . . . . . . factorial/disp32
75
76 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
77
78 f7 4/subop/multiply 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 8/disp8 .
79
80 $factorial:exit:
81
82 5b/pop-to-EBX
83 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
84 5d/pop-to-EBP
85 c3/return
86
87 test_factorial:
88
89
90 68/push 5/imm32
91
92 e8/call factorial/disp32
93
94 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
95
96
97 68/push "F - test_factorial"/imm32
98 68/push 0x78/imm32/expected-120
99 50/push-EAX
100
101 e8/call check_ints_equal/disp32
102
103 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
104
105 c3/return
106
107