1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 == data
18
19
20
21 Test-ostream:
22
23 00 00 00 00
24
25 08 00 00 00
26
27 00 00 00 00 00 00 00 00
28
29 == code
30
31
32
33
34
35
36
37 e8/call run-tests/disp32
38
39 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 1/r32/EBX Num-test-failures/disp32
40 b8/copy-to-EAX 1/imm32
41 cd/syscall 0x80/imm8
42
43 write:
44
45 55/push-EBP
46 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
47
48 50/push-EAX
49 51/push-ECX
50 52/push-EDX
51 53/push-EBX
52 56/push-ESI
53
54 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 0x08000000/imm32
55 7f/jump-if-greater $write:else/disp8
56
57 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 .
58 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 .
59
60 e8/call _write/disp32
61
62 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
63 eb/jump $write:end/disp8
64 $write:else:
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 0/r32/EAX 8/disp8 .
101
102 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 3/r32/EBX 0xc/disp8 .
103
104 8b/copy 1/mod/*+disp8 0/rm32/EAX . . . 1/r32/ECX 4/disp8 .
105
106 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/EAX 1/index/ECX . 1/r32/ECX 8/disp8 .
107
108 8b/copy 0/mod/indirect 0/rm32/EAX . . . 6/r32/ESI . .
109
110 8b/copy 0/mod/indirect 3/rm32/EBX . . . 2/r32/EDX . .
111
112 81 7/subop/compare 3/mod/direct 2/rm32/EDX . . . . . 0/imm32
113 74/jump-if-equal $write:end/disp8
114
115 01/add 0/mod/indirect 0/rm32/EAX . . . 2/r32/EDX . .
116
117 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/EAX 6/index/ESI . 0/r32/EAX 8/disp8 .
118
119 8d/copy-address 1/mod/*+disp8 4/rm32/sib 3/base/EBX 2/index/EDX . 6/r32/ESI 4/disp8 .
120
121 81 0/subop/add 3/mod/direct 3/rm32/EBX . . . . . 4/imm32
122
123 $write:loop:
124
125 39/compare 3/mod/direct 3/rm32/EBX . . . 6/r32/ESI . .
126 7d/jump-if-greater-or-equal $write:end/disp8
127
128 39/compare 3/mod/direct 0/rm32/EAX . . . 1/r32/ECX . .
129 7d/jump-if-greater-or-equal $write:end/disp8
130
131 8a/copy-byte 0/mod/indirect 3/rm32/EBX . . . 2/r32/DL . .
132 88/copy-byte 0/mod/indirect 0/rm32/EAX . . . 2/r32/DL . .
133
134 40/increment-EAX
135 43/increment-EBX
136 eb/jump $write:loop/disp8
137 $write:end:
138
139 5e/pop-to-ESI
140 5b/pop-to-EBX
141 5a/pop-to-EDX
142 59/pop-to-ECX
143 58/pop-to-EAX
144
145 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
146 5d/pop-to-EBP
147 c3/return
148
149 clear-ostream:
150
151 55/push-EBP
152 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
153
154 50/push-EAX
155 51/push-ECX
156
157 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 0/r32/EAX 8/disp8 .
158
159 8b/copy 1/mod/*+disp8 0/rm32/EAX . . . 1/r32/ECX 4/disp8 .
160
161 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/EAX 1/index/ECX . 1/r32/ECX 8/disp8 .
162
163 c7/copy 0/mod/direct 0/rm32/EAX . . . . . 0/imm32
164
165 81 0/subop/add 3/mod/direct 0/rm32/EAX . . . . . 8/imm32
166
167 $clear-ostream:loop:
168
169 39/compare 3/mod/direct 0/rm32/EAX . . . 1/r32/ECX . .
170 7d/jump-if-greater-or-equal $clear-ostream:end/disp8
171
172 c7/copy 0/mod/direct 0/rm32/EAX . . . . . 0/imm32
173
174 81 0/subop/add 3/mod/direct 0/rm32/EAX . . . . . 4/imm32
175 eb/jump $clear-ostream:loop/disp8
176 $clear-ostream:end:
177
178 59/pop-to-ECX
179 58/pop-to-EAX
180
181 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
182 5d/pop-to-EBP
183 c3/return
184
185 test-write-single:
186
187
188 68/push Test-ostream/imm32
189
190 e8/call clear-ostream/disp32
191
192 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
193
194
195 68/push "Ab"/imm32
196 68/push Test-ostream/imm32
197
198 e8/call write/disp32
199
200 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
201
202
203 68/push "F - test-write-single"/imm32
204 68/push 0x006241/imm32/Ab
205
206 b8/copy-to-EAX Test-ostream/imm32
207 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 8/disp8 .
208
209 e8/call check-ints-equal/disp32
210
211 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
212
213 c3/return
214
215 test-write-appends:
216
217
218 68/push Test-ostream/imm32
219
220 e8/call clear-ostream/disp32
221
222 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
223
224
225 68/push "C"/imm32
226 68/push Test-ostream/imm32
227
228 e8/call write/disp32
229
230 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
231
232
233 68/push "D"/imm32
234 68/push Test-ostream/imm32
235
236 e8/call write/disp32
237
238 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
239
240
241 68/push "F - test-write-appends"/imm32
242 68/push 0x00004443/imm32/C-D
243
244 b8/copy-to-EAX Test-ostream/imm32
245 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 8/disp8 .
246
247 e8/call check-ints-equal/disp32
248
249 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
250
251 c3/return