1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 == code
17
18
19
20
21
22
23 8b/copy 0/mod/indirect 4/rm32/sib 4/base/ESP 4/index/none . 0/r32/EAX . .
24 3d/compare . . . . . . . 1/imm32
25 7e/jump-if-lesser-or-equal $run_main/disp8
26
27 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none . 0/r32/EAX 8/disp8 .
28
29 68/push Test_argv/imm32
30 50/push-EAX
31
32 e8/call argv_equal/disp32
33
34 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
35
36 3d/compare . . . . . . . 1/imm32
37 75/jump-if-not-equal $run_main/disp8
38
39 e8/call run_tests/disp32
40 eb/jump $main_exit/disp8
41
42 $run_main:
43
44 68/push . . . . . . . 5/imm32
45
46 e8/call . . . . . . factorial/disp32
47
48 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
49 $main_exit:
50
51 89/copy 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . .
52 b8/copy . . . . . . . 1/imm32
53 cd/syscall 0x80/imm8
54
55
56 factorial:
57
58 b8/copy . . . . . . . 1/imm32
59
60 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none . . 4/disp8 1/imm32
61 7e/jump-if-<= . . . . . . $factorial:exit/disp8
62
63 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none 3/r32/EBX 4/disp8 .
64 81 5/subop/subtract 3/mod/direct 3/rm32/EBX . . . . . 1/imm32
65
66 55/push . . . . . . . .
67 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
68
69 53/push . . . . . . . .
70 e8/call . . . . . . factorial/disp32
71
72 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
73
74 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
75 5d/pop . . . . . . . .
76
77 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none 2/r32/EDX 4/disp8 .
78
79 f7 4/subop/multiply 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none 4/disp8 .
80
81 $factorial:exit:
82 c3/return
83
84 test_factorial:
85
86
87 68/push . . . . . . . 5/imm32
88
89 e8/call . . . . . . factorial/disp32
90
91 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
92
93 3d/compare . . . . . . . 0x78/imm32/120
94 75/jump-if-unequal . . . . . . $test_factorial:else/disp8
95
96
97 68/push . . . . . . . Test_passed/imm32
98
99 e8/call . . . . . . write_stderr/disp32
100
101 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
102
103 c3/return
104
105 $test_factorial:else:
106
107
108 68/push . . . . . . . Test_failed/imm32
109
110 e8/call . . . . . . write_stderr/disp32
111
112 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
113
114 c3/return
115
116
117
118
119
120 argv_equal:
121
122 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none . 1/r32/ECX 8/disp8 .
123 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none . 2/r32/EDX 4/disp8 .
124
125 $argv_loop:
126
127 b8/copy 0/imm32
128 8a/copy 0/mod/indirect 1/rm32/ECX . . . 0/r32/EAX . .
129 bb/copy 0/imm32
130 8a/copy 0/mod/indirect 2/rm32/EDX . . . 3/r32/EBX . .
131
132 3d/compare . . . . . . . 0/imm32
133 74/jump-if-equal $argv_break/disp8
134
135 39/compare 3/mod/direct 0/rm32/EAX . . . 3/r32/EBX . .
136 75/jump-if-not-equal $argv_fail/disp8
137
138 41/inc-ECX
139 42/inc-EDX
140
141 eb/jump $argv_loop/disp8
142 $argv_break:
143
144 81 7/subop/compare 3/mod/direct 3/rm32/EBX . . . . . 0/imm32
145 75/jump-if-not-equal $argv_fail/disp8
146 b8/copy . . . . . . . 1/imm32
147 c3/return
148
149 $argv_fail:
150 b8/copy . . . . . . . 0/imm32
151 c3/return
152
153 write_stderr:
154
155 50/push . . . . . . . .
156 51/push . . . . . . . .
157 52/push . . . . . . . .
158 53/push . . . . . . . .
159
160
161 bb/copy . . . . . . . 2/imm32
162
163 8b/copy 1/mod/*+disp8 4/rm32/SIB 4/base/ESP 4/index/none . 1/r32/ECX 0x14/disp8 .
164 81 0/subop/add 3/mod/direct 1/rm32/ECX . . . . . 4/imm32
165
166 8b/copy 1/mod/*+disp8 4/rm32/SIB 4/base/ESP 4/index/none . 2/r32/EDX 0x14/disp8 .
167 8b/copy 0/mod/indirect 2/rm32/EDX . . . 2/r32/EDX . .
168
169 b8/copy . . . . . . . 4/imm32/write
170 cd/syscall 0x80/imm8
171
172 5b/pop . . . . . . . .
173 5a/pop . . . . . . . .
174 59/pop . . . . . . . .
175 58/pop . . . . . . . .
176
177 c3/return
178
179 == data
180 Test_argv:
181
182 74/t 65/e 73/s 74/t 00/null
183
184 Test_passed:
185
186 01 00 00 00
187
188 2e/dot
189
190 Test_failed:
191
192 01 00 00 00
193
194 46/F
195
196