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 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Num-test-failures/disp32
42 eb/jump $main:end/disp8
43
44 $run-main:
45
46 68/push 5/imm32
47
48 e8/call factorial/disp32
49
50 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
51 $main:end:
52
53 89/copy 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . .
54 b8/copy-to-EAX 1/imm32
55 cd/syscall 0x80/imm8
56
57
58 factorial:
59
60 55/push-EBP
61 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
62 53/push-EBX
63
64 b8/copy-to-EAX 1/imm32
65
66 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 1/imm32
67 7e/jump-if-<= $factorial:end/disp8
68
69 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 3/r32/EBX 8/disp8 .
70 81 5/subop/subtract 3/mod/direct 3/rm32/EBX . . . . . 1/imm32
71
72
73 53/push-EBX
74
75 e8/call factorial/disp32
76
77 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
78
79 f7 4/subop/multiply 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 8/disp8 .
80
81 $factorial:end:
82
83 5b/pop-to-EBX
84 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
85 5d/pop-to-EBP
86 c3/return
87
88 test-factorial:
89
90
91 68/push 5/imm32
92
93 e8/call factorial/disp32
94
95 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
96
97
98 68/push "F - test-factorial"/imm32
99 68/push 0x78/imm32/expected-120
100 50/push-EAX
101
102 e8/call check-ints-equal/disp32
103
104 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
105
106 c3/return
107
108