https://github.com/akkartik/mu/blob/master/subx/apps/handle.subx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 == code
16
17
18
19
20
21 e8/call run-tests/disp32
22
23 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/EBX Num-test-failures/disp32
24 b8/copy-to-EAX 1/imm32/exit
25 cd/syscall 0x80/imm8
26
27 new:
28
29 55/push-EBP
30 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
31
32 50/push-EAX
33 51/push-ECX
34 52/push-EDX
35
36 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 1/r32/ECX 0xc/disp8 .
37 81 0/subop/add 3/mod/direct 1/rm32/ECX . . . . . 4/imm32
38
39
40 51/push-ECX
41 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
42
43 e8/call allocate/disp32
44
45 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
46
47 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 2/r32/EDX 0x10/disp8 .
48
49 89/copy 1/mod/*+disp8 2/rm32/EDX . . . 0/r32/EAX 4/disp8 .
50
51 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0/imm32
52 75/jump-if-not-equal $new:continue/disp8
53 c7 0/subop/copy 0/mod/indirect 2/rm32/EDX . . . . . 0/imm32
54 eb/jump $new:end/disp8
55 $new:continue:
56
57
58 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 1/r32/ECX Next-alloc-id/disp32
59
60 89/copy 0/mod/indirect 0/rm32/EAX . . . 1/r32/ECX . .
61
62 89/copy 0/mod/indirect 2/rm32/EDX . . . 1/r32/ECX . .
63
64 ff 0/subop/increment 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32
65 $new:end:
66
67 5a/pop-to-EDX
68 59/pop-to-ECX
69 58/pop-to-EAX
70
71 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
72 5d/pop-to-EBP
73 c3/return
74
75 test-new:
76
77 55/push-EBP
78 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
79
80 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 0x34/imm32
81
82 68/push 0x0b00000a/imm32/limit
83 68/push 0x0b000000/imm32/curr
84 89/copy 3/mod/direct 0/rm32/EAX . . . 4/r32/ESP . .
85
86 68/push 0/imm32/address
87 68/push 0/imm32/alloc-id
88 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
89
90
91 51/push-ECX
92 68/push 2/imm32/size
93 50/push-EAX
94
95 e8/call new/disp32
96
97 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
98
99
100 68/push "F - test-new: alloc id of handle"/imm32
101 68/push 0x34/imm32
102 ff 6/subop/push 0/mod/indirect 1/rm32/ECX . . . . . .
103
104 e8/call check-ints-equal/disp32
105
106 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
107
108
109 68/push "F - test-new: address of handle"/imm32
110 68/push 0x0b000000/imm32
111 ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 .
112
113 e8/call check-ints-equal/disp32
114
115 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
116
117
118 68/push "F - test-new: alloc id of payload"/imm32
119 68/push 0x34/imm32
120 8b/copy 1/mod/*+disp8 1/rm32/ECX . . . 2/r32/EDX 4/disp8 .
121 ff 6/subop/push 0/mod/indirect 2/rm32/EDX . . . . . .
122
123 e8/call check-ints-equal/disp32
124
125 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
126
127
128 68/push "F - test-new: next alloc id"/imm32
129 68/push 0x35/imm32
130 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32
131
132 e8/call check-ints-equal/disp32
133
134 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
135
136
137 c7 0/subop/copy 0/mod/direct 0/rm32/EAX . . . . . 1/imm32
138
139 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
140 5d/pop-to-EBP
141 c3/return
142
143 test-new-failure:
144
145 55/push-EBP
146 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
147
148 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 0x34/imm32
149
150
151 68/push 0x10/imm32/limit
152 68/push 0x10/imm32/curr
153 89/copy 3/mod/direct 0/rm32/EAX . . . 4/r32/ESP . .
154
155 68/push 1234/imm32/address
156 68/push 5678/imm32/alloc-id
157 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
158
159
160
161 51/push-ECX
162 68/push 2/imm32/size
163 50/push-EAX
164
165 e8/call new/disp32
166
167 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
168
169
170
171 68/push "F - test-new-failure: alloc id of handle"/imm32
172 68/push 0/imm32
173 ff 6/subop/push 0/mod/indirect 1/rm32/ECX . . . . . .
174
175 e8/call check-ints-equal/disp32
176
177 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
178
179
180 68/push "F - test-new-failure: address of handle"/imm32
181 68/push 0/imm32
182 ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 .
183
184 e8/call check-ints-equal/disp32
185
186 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
187
188
189
190 68/push "F - test-new-failure: next alloc id"/imm32
191 68/push 0x34/imm32
192 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32
193
194 e8/call check-ints-equal/disp32
195
196 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
197
198
199 c7 0/subop/copy 0/mod/direct 0/rm32/EAX . . . . . 1/imm32
200
201 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
202 5d/pop-to-EBP
203 c3/return
204
205 == data
206
207
208 Next-alloc-id:
209 01 00 00 00
210
211