https://github.com/akkartik/mu/blob/master/069allocate.subx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 == code
20
21
22
23
24
25
26 allocate:
27
28 55/push-ebp
29 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
30
31 51/push-ecx
32 52/push-edx
33
34 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 8/disp8 .
35
36 8b/copy 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
37
38
39 89/copy 3/mod/direct 2/rm32/edx . . . 0/r32/eax . .
40 03/add 1/mod/*+disp8 5/rm32/ebp . . . 2/r32/edx 0xc/disp8 .
41 3b/compare 1/mod/*+disp8 1/rm32/ecx . . . 2/r32/edx 4/disp8 .
42 73/jump-if-greater-or-equal-signed $allocate:abort/disp8
43 $allocate:commit:
44
45 89/copy 0/mod/indirect 1/rm32/ecx . . . 2/r32/edx . .
46 $allocate:end:
47
48 5a/pop-to-edx
49 59/pop-to-ecx
50
51 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
52 5d/pop-to-ebp
53 c3/return
54
55 $allocate:abort:
56
57
58 68/push "allocate: failed to allocate\n"/imm32
59 68/push 2/imm32/stderr
60
61 e8/call _write/disp32
62
63 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
64
65 bb/copy-to-ebx 1/imm32
66 b8/copy-to-eax 1/imm32/exit
67 cd/syscall 0x80/imm8
68
69
70 test-allocate-success:
71
72 55/push-ebp
73 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
74
75 68/push 0xf/imm32/limit
76 68/push 0xb/imm32/curr
77 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
78
79
80 68/push 3/imm32
81 51/push-ecx
82
83 e8/call allocate/disp32
84
85 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
86
87
88 68/push "F - test-allocate-success: returns current pointer of allocation descriptor"/imm32
89 68/push 0xb/imm32
90 50/push-eax
91
92 e8/call check-ints-equal/disp32
93
94 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
95
96
97 68/push "F - test-allocate-success: updates allocation descriptor"/imm32
98 68/push 0xe/imm32
99 ff 6/subop/push 0/mod/indirect 1/rm32/ecx . . . . . .
100
101 e8/call check-ints-equal/disp32
102
103 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
104
105 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
106 5d/pop-to-ebp
107 c3/return
108
109 _pending-test-allocate-failure:
110
111 55/push-ebp
112 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
113
114 68/push 0xf/imm32/limit
115 68/push 0xb/imm32/curr
116 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
117
118
119 68/push 6/imm32
120 51/push-ecx
121
122 e8/call allocate/disp32
123
124 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
125
126
127 68/push "F - test-allocate-failure: returns null"/imm32
128 68/push 0/imm32
129 50/push-eax
130
131 e8/call check-ints-equal/disp32
132
133 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
134
135
136
137 68/push "F - test-allocate-failure: updates allocation descriptor"/imm32
138 68/push 0xb/imm32
139 ff 6/subop/push 0/mod/indirect 1/rm32/ecx . . . . . .
140
141 e8/call check-ints-equal/disp32
142
143 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
144
145 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
146 5d/pop-to-ebp
147 c3/return
148
149
150 allocate-region:
151
152 55/push-ebp
153 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
154
155 51/push-ecx
156
157
158 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 .
159 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
160
161 e8/call allocate/disp32
162
163 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
164
165 3d/compare-eax-and 0/imm32
166 74/jump-if-equal $allocate-region:abort/disp8
167
168
169 89/copy 3/mod/direct 1/rm32/ecx . . . 0/r32/eax . .
170 81 0/subop/add 3/mod/direct 1/rm32/ecx . . . . . 8/imm32
171 89/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
172
173 89/copy 3/mod/direct 1/rm32/ecx . . . 0/r32/eax . .
174 03/add 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 0xc/disp8 .
175 89/copy 1/mod/*+disp8 0/rm32/eax . . . 1/r32/ecx 4/disp8 .
176
177 59/pop-to-ecx
178
179 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
180 5d/pop-to-ebp
181 c3/return
182
183
184
185
186
187
188
189 $allocate-region:abort:
190
191
192 68/push "allocate-region: failed to allocate\n"/imm32
193 68/push 2/imm32/stderr
194
195 e8/call _write/disp32
196
197 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
198
199 bb/copy-to-ebx 1/imm32
200 b8/copy-to-eax 1/imm32/exit
201 cd/syscall 0x80/imm8
202
203
204