Rev 2664 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2664 | Rev 2665 | ||
---|---|---|---|
1 | ; flat assembler core |
1 | ; flat assembler core |
2 | ; Copyright (c) 1999-2012, Tomasz Grysztar. |
2 | ; Copyright (c) 1999-2012, Tomasz Grysztar. |
3 | ; All rights reserved. |
3 | ; All rights reserved. |
4 | 4 | ||
5 | assembler: |
5 | assembler: |
6 | xor eax,eax |
6 | xor eax,eax |
7 | mov [stub_size],eax |
7 | mov [stub_size],eax |
8 | mov [current_pass],ax |
8 | mov [current_pass],ax |
9 | mov [resolver_flags],eax |
9 | mov [resolver_flags],eax |
10 | mov [number_of_sections],eax |
10 | mov [number_of_sections],eax |
11 | mov [actual_fixups_size],eax |
11 | mov [actual_fixups_size],eax |
12 | assembler_loop: |
12 | assembler_loop: |
13 | mov eax,[labels_list] |
13 | mov eax,[labels_list] |
14 | mov [display_buffer],eax |
14 | mov [display_buffer],eax |
15 | mov eax,[additional_memory] |
15 | mov eax,[additional_memory] |
16 | mov [free_additional_memory],eax |
16 | mov [free_additional_memory],eax |
17 | mov eax,[additional_memory_end] |
17 | mov eax,[additional_memory_end] |
18 | mov [structures_buffer],eax |
18 | mov [structures_buffer],eax |
19 | mov esi,[source_start] |
19 | mov esi,[source_start] |
20 | mov edi,[code_start] |
20 | mov edi,[code_start] |
21 | xor eax,eax |
21 | xor eax,eax |
22 | mov dword [adjustment],eax |
22 | mov dword [adjustment],eax |
23 | mov dword [adjustment+4],eax |
23 | mov dword [adjustment+4],eax |
24 | mov dword [org_origin],edi |
24 | mov dword [org_origin],edi |
25 | mov dword [org_origin+4],eax |
25 | mov dword [org_origin+4],eax |
26 | mov [org_start],edi |
26 | mov [org_start],edi |
27 | mov [org_registers],eax |
27 | mov [org_registers],eax |
28 | mov [org_symbol],eax |
28 | mov [org_symbol],eax |
29 | mov [error_line],eax |
29 | mov [error_line],eax |
30 | mov [counter],eax |
30 | mov [counter],eax |
31 | mov [format_flags],eax |
31 | mov [format_flags],eax |
32 | mov [number_of_relocations],eax |
32 | mov [number_of_relocations],eax |
33 | mov [undefined_data_end],eax |
33 | mov [undefined_data_end],eax |
34 | mov [file_extension],eax |
34 | mov [file_extension],eax |
35 | mov [next_pass_needed],al |
35 | mov [next_pass_needed],al |
36 | mov [output_format],al |
36 | mov [output_format],al |
37 | mov [labels_type],al |
37 | mov [org_origin_sign],al |
- | 38 | mov [adjustment_sign],al |
|
- | 39 | mov [labels_type],al |
|
38 | mov [virtual_data],al |
40 | mov [virtual_data],al |
39 | mov [code_type],16 |
41 | mov [code_type],16 |
40 | pass_loop: |
42 | pass_loop: |
41 | call assemble_line |
43 | call assemble_line |
42 | jnc pass_loop |
44 | jnc pass_loop |
43 | mov eax,[additional_memory_end] |
45 | mov eax,[additional_memory_end] |
44 | cmp eax,[structures_buffer] |
46 | cmp eax,[structures_buffer] |
45 | je pass_done |
47 | je pass_done |
46 | sub eax,20h |
48 | sub eax,20h |
47 | mov eax,[eax+4] |
49 | mov eax,[eax+4] |
48 | mov [current_line],eax |
50 | mov [current_line],eax |
49 | jmp missing_end_directive |
51 | jmp missing_end_directive |
50 | pass_done: |
52 | pass_done: |
51 | call close_pass |
53 | call close_pass |
52 | mov eax,[labels_list] |
54 | mov eax,[labels_list] |
53 | check_symbols: |
55 | check_symbols: |
54 | cmp eax,[memory_end] |
56 | cmp eax,[memory_end] |
55 | jae symbols_checked |
57 | jae symbols_checked |
56 | test byte [eax+8],8 |
58 | test byte [eax+8],8 |
57 | jz symbol_defined_ok |
59 | jz symbol_defined_ok |
58 | mov cx,[current_pass] |
60 | mov cx,[current_pass] |
59 | cmp cx,[eax+18] |
61 | cmp cx,[eax+18] |
60 | jne symbol_defined_ok |
62 | jne symbol_defined_ok |
61 | test byte [eax+8],1 |
63 | test byte [eax+8],1 |
62 | jz symbol_defined_ok |
64 | jz symbol_defined_ok |
63 | sub cx,[eax+16] |
65 | sub cx,[eax+16] |
64 | cmp cx,1 |
66 | cmp cx,1 |
65 | jne symbol_defined_ok |
67 | jne symbol_defined_ok |
66 | and byte [eax+8],not 1 |
68 | and byte [eax+8],not 1 |
67 | or [next_pass_needed],-1 |
69 | or [next_pass_needed],-1 |
68 | symbol_defined_ok: |
70 | symbol_defined_ok: |
69 | test byte [eax+8],10h |
71 | test byte [eax+8],10h |
70 | jz use_prediction_ok |
72 | jz use_prediction_ok |
71 | mov cx,[current_pass] |
73 | mov cx,[current_pass] |
72 | and byte [eax+8],not 10h |
74 | and byte [eax+8],not 10h |
73 | test byte [eax+8],20h |
75 | test byte [eax+8],20h |
74 | jnz check_use_prediction |
76 | jnz check_use_prediction |
75 | cmp cx,[eax+18] |
77 | cmp cx,[eax+18] |
76 | jne use_prediction_ok |
78 | jne use_prediction_ok |
77 | test byte [eax+8],8 |
79 | test byte [eax+8],8 |
78 | jz use_prediction_ok |
80 | jz use_prediction_ok |
79 | jmp use_misprediction |
81 | jmp use_misprediction |
80 | check_use_prediction: |
82 | check_use_prediction: |
81 | test byte [eax+8],8 |
83 | test byte [eax+8],8 |
82 | jz use_misprediction |
84 | jz use_misprediction |
83 | cmp cx,[eax+18] |
85 | cmp cx,[eax+18] |
84 | je use_prediction_ok |
86 | je use_prediction_ok |
85 | use_misprediction: |
87 | use_misprediction: |
86 | or [next_pass_needed],-1 |
88 | or [next_pass_needed],-1 |
87 | use_prediction_ok: |
89 | use_prediction_ok: |
88 | test byte [eax+8],40h |
90 | test byte [eax+8],40h |
89 | jz check_next_symbol |
91 | jz check_next_symbol |
90 | and byte [eax+8],not 40h |
92 | and byte [eax+8],not 40h |
91 | test byte [eax+8],4 |
93 | test byte [eax+8],4 |
92 | jnz define_misprediction |
94 | jnz define_misprediction |
93 | mov cx,[current_pass] |
95 | mov cx,[current_pass] |
94 | test byte [eax+8],80h |
96 | test byte [eax+8],80h |
95 | jnz check_define_prediction |
97 | jnz check_define_prediction |
96 | cmp cx,[eax+16] |
98 | cmp cx,[eax+16] |
97 | jne check_next_symbol |
99 | jne check_next_symbol |
98 | test byte [eax+8],1 |
100 | test byte [eax+8],1 |
99 | jz check_next_symbol |
101 | jz check_next_symbol |
100 | jmp define_misprediction |
102 | jmp define_misprediction |
101 | check_define_prediction: |
103 | check_define_prediction: |
102 | test byte [eax+8],1 |
104 | test byte [eax+8],1 |
103 | jz define_misprediction |
105 | jz define_misprediction |
104 | cmp cx,[eax+16] |
106 | cmp cx,[eax+16] |
105 | je check_next_symbol |
107 | je check_next_symbol |
106 | define_misprediction: |
108 | define_misprediction: |
107 | or [next_pass_needed],-1 |
109 | or [next_pass_needed],-1 |
108 | check_next_symbol: |
110 | check_next_symbol: |
109 | add eax,LABEL_STRUCTURE_SIZE |
111 | add eax,LABEL_STRUCTURE_SIZE |
110 | jmp check_symbols |
112 | jmp check_symbols |
111 | symbols_checked: |
113 | symbols_checked: |
112 | cmp [next_pass_needed],0 |
114 | cmp [next_pass_needed],0 |
113 | jne next_pass |
115 | jne next_pass |
114 | mov eax,[error_line] |
116 | mov eax,[error_line] |
115 | or eax,eax |
117 | or eax,eax |
116 | jz assemble_ok |
118 | jz assemble_ok |
117 | mov [current_line],eax |
119 | mov [current_line],eax |
118 | cmp [error],undefined_symbol |
120 | cmp [error],undefined_symbol |
119 | jne error_confirmed |
121 | jne error_confirmed |
120 | mov eax,[error_info] |
122 | mov eax,[error_info] |
121 | or eax,eax |
123 | or eax,eax |
122 | jz error_confirmed |
124 | jz error_confirmed |
123 | test byte [eax+8],1 |
125 | test byte [eax+8],1 |
124 | jnz next_pass |
126 | jnz next_pass |
125 | error_confirmed: |
127 | error_confirmed: |
126 | call error_handler |
128 | call error_handler |
127 | error_handler: |
129 | error_handler: |
128 | mov eax,[error] |
130 | mov eax,[error] |
129 | sub eax,error_handler |
131 | sub eax,error_handler |
130 | add [esp],eax |
132 | add [esp],eax |
131 | ret |
133 | ret |
132 | next_pass: |
134 | next_pass: |
133 | inc [current_pass] |
135 | inc [current_pass] |
134 | mov ax,[current_pass] |
136 | mov ax,[current_pass] |
135 | cmp ax,[passes_limit] |
137 | cmp ax,[passes_limit] |
136 | je code_cannot_be_generated |
138 | je code_cannot_be_generated |
137 | jmp assembler_loop |
139 | jmp assembler_loop |
138 | assemble_ok: |
140 | assemble_ok: |
139 | ret |
141 | ret |
140 | 142 | ||
141 | assemble_line: |
143 | assemble_line: |
142 | mov eax,[display_buffer] |
144 | mov eax,[display_buffer] |
143 | sub eax,100h |
145 | sub eax,100h |
144 | cmp edi,eax |
146 | cmp edi,eax |
145 | ja out_of_memory |
147 | ja out_of_memory |
146 | lods byte [esi] |
148 | lods byte [esi] |
147 | cmp al,1 |
149 | cmp al,1 |
148 | je assemble_instruction |
150 | je assemble_instruction |
149 | jb source_end |
151 | jb source_end |
150 | cmp al,3 |
152 | cmp al,3 |
151 | jb define_label |
153 | jb define_label |
152 | je define_constant |
154 | je define_constant |
153 | cmp al,0Fh |
155 | cmp al,0Fh |
154 | je new_line |
156 | je new_line |
155 | cmp al,13h |
157 | cmp al,13h |
156 | je code_type_setting |
158 | je code_type_setting |
157 | cmp al,10h |
159 | cmp al,10h |
158 | jne illegal_instruction |
160 | jne illegal_instruction |
159 | lods byte [esi] |
161 | lods byte [esi] |
160 | jmp segment_prefix |
162 | jmp segment_prefix |
161 | code_type_setting: |
163 | code_type_setting: |
162 | lods byte [esi] |
164 | lods byte [esi] |
163 | mov [code_type],al |
165 | mov [code_type],al |
164 | jmp line_assembled |
166 | jmp line_assembled |
165 | new_line: |
167 | new_line: |
166 | lods dword [esi] |
168 | lods dword [esi] |
167 | mov [current_line],eax |
169 | mov [current_line],eax |
168 | mov [prefixed_instruction],0 |
170 | mov [prefixed_instruction],0 |
169 | cmp [symbols_file],0 |
171 | cmp [symbols_file],0 |
170 | je continue_line |
172 | je continue_line |
171 | mov ebx,[display_buffer] |
173 | cmp [next_pass_needed],0 |
- | 174 | jne continue_line |
|
- | 175 | mov ebx,[display_buffer] |
|
172 | mov dword [ebx-4],1 |
176 | mov dword [ebx-4],1 |
173 | mov dword [ebx-8],1Ch |
177 | mov dword [ebx-8],1Ch |
174 | sub ebx,8+1Ch |
178 | sub ebx,8+1Ch |
175 | cmp ebx,edi |
179 | cmp ebx,edi |
176 | jbe out_of_memory |
180 | jbe out_of_memory |
177 | mov [display_buffer],ebx |
181 | mov [display_buffer],ebx |
178 | mov [ebx],eax |
182 | mov [ebx],eax |
179 | mov [ebx+4],edi |
183 | mov [ebx+4],edi |
180 | mov eax,dword [org_origin] |
184 | mov eax,dword [org_origin] |
181 | mov edx,dword [org_origin+4] |
185 | mov edx,dword [org_origin+4] |
182 | mov ecx,[org_registers] |
186 | mov ecx,[org_registers] |
183 | mov [ebx+8],eax |
187 | mov [ebx+8],eax |
184 | mov [ebx+8+4],edx |
188 | mov [ebx+8+4],edx |
185 | mov [ebx+10h],ecx |
189 | mov [ebx+10h],ecx |
186 | mov edx,[org_symbol] |
190 | mov edx,[org_symbol] |
187 | mov eax,dword [labels_type] |
191 | ; mov al,[virtual_data] |
- | 192 | ; mov ah,[org_origin_sign] |
|
- | 193 | ; shl eax,16 |
|
- | 194 | ; mov al,[labels_type] |
|
- | 195 | ; mov ah,[code_type] |
|
- | 196 | mov eax,dword [labels_type] |
|
188 | mov [ebx+14h],edx |
197 | mov [ebx+14h],edx |
189 | mov [ebx+18h],eax |
198 | mov [ebx+18h],eax |
190 | continue_line: |
199 | continue_line: |
191 | cmp byte [esi],0Fh |
200 | cmp byte [esi],0Fh |
192 | je line_assembled |
201 | je line_assembled |
193 | jmp assemble_line |
202 | jmp assemble_line |
194 | define_label: |
203 | define_label: |
195 | lods dword [esi] |
204 | lods dword [esi] |
196 | cmp eax,0Fh |
205 | cmp eax,0Fh |
197 | jb invalid_use_of_symbol |
206 | jb invalid_use_of_symbol |
198 | je reserved_word_used_as_symbol |
207 | je reserved_word_used_as_symbol |
199 | mov ebx,eax |
208 | mov ebx,eax |
200 | lods byte [esi] |
209 | lods byte [esi] |
201 | mov cl,al |
210 | mov [label_size],al |
202 | mov eax,edi |
211 | call make_label |
- | 212 | jmp continue_line |
|
- | 213 | make_label: |
|
- | 214 | mov eax,edi |
|
203 | xor edx,edx |
215 | xor edx,edx |
204 | sub eax,dword [org_origin] |
216 | xor cl,cl |
- | 217 | sub eax,dword [org_origin] |
|
205 | sbb edx,dword [org_origin+4] |
218 | sbb edx,dword [org_origin+4] |
206 | mov ch,[labels_type] |
219 | sbb cl,[org_origin_sign] |
- | 220 | jp label_value_ok |
|
- | 221 | call recoverable_overflow |
|
- | 222 | label_value_ok: |
|
- | 223 | mov [address_sign],cl |
|
207 | cmp [virtual_data],0 |
224 | cmp [virtual_data],0 |
208 | jne make_virtual_label |
225 | jne make_virtual_label |
209 | or byte [ebx+9],1 |
226 | or byte [ebx+9],1 |
210 | xchg eax,[ebx] |
227 | xchg eax,[ebx] |
211 | xchg edx,[ebx+4] |
228 | xchg edx,[ebx+4] |
212 | sub eax,[ebx] |
229 | mov ch,[ebx+9] |
- | 230 | shr ch,1 |
|
- | 231 | and ch,1 |
|
- | 232 | neg ch |
|
- | 233 | sub eax,[ebx] |
|
213 | sbb edx,[ebx+4] |
234 | sbb edx,[ebx+4] |
214 | mov dword [adjustment],eax |
235 | sbb ch,cl |
- | 236 | mov dword [adjustment],eax |
|
215 | mov dword [adjustment+4],edx |
237 | mov dword [adjustment+4],edx |
216 | or eax,edx |
238 | mov [adjustment_sign],ch |
- | 239 | or al,ch |
|
- | 240 | or eax,edx |
|
217 | setnz ah |
241 | setnz ah |
218 | jmp finish_label_symbol |
242 | jmp finish_label |
219 | make_virtual_label: |
243 | make_virtual_label: |
220 | and byte [ebx+9],not 1 |
244 | and byte [ebx+9],not 1 |
221 | cmp eax,[ebx] |
245 | cmp eax,[ebx] |
222 | mov [ebx],eax |
246 | mov [ebx],eax |
223 | setne ah |
247 | setne ah |
224 | cmp edx,[ebx+4] |
248 | cmp edx,[ebx+4] |
225 | mov [ebx+4],edx |
249 | mov [ebx+4],edx |
226 | setne al |
250 | setne al |
227 | or ah,al |
251 | or ah,al |
228 | finish_label_symbol: |
252 | finish_label: |
- | 253 | mov ch,[labels_type] |
|
- | 254 | mov cl,[label_size] |
|
- | 255 | mov ebp,[org_registers] |
|
- | 256 | mov edx,[org_symbol] |
|
- | 257 | finish_label_symbol: |
|
229 | cmp cl,[ebx+10] |
258 | mov al,[address_sign] |
- | 259 | xor al,[ebx+9] |
|
- | 260 | and al,10b |
|
- | 261 | or ah,al |
|
- | 262 | xor [ebx+9],al |
|
- | 263 | cmp cl,[ebx+10] |
|
230 | mov [ebx+10],cl |
264 | mov [ebx+10],cl |
231 | setne al |
265 | setne al |
232 | or ah,al |
266 | or ah,al |
233 | cmp ch,[ebx+11] |
267 | cmp ch,[ebx+11] |
234 | mov [ebx+11],ch |
268 | mov [ebx+11],ch |
235 | setne al |
269 | setne al |
236 | or ah,al |
270 | or ah,al |
237 | mov edx,[org_registers] |
271 | cmp ebp,[ebx+12] |
238 | cmp edx,[ebx+12] |
- | |
239 | mov [ebx+12],edx |
272 | mov [ebx+12],ebp |
240 | setne al |
273 | setne al |
241 | or ah,al |
274 | or ah,al |
242 | or ch,ch |
275 | or ch,ch |
243 | jz label_symbol_ok |
276 | jz label_symbol_ok |
244 | mov edx,[org_symbol] |
277 | cmp edx,[ebx+20] |
245 | cmp edx,[ebx+20] |
- | |
246 | mov [ebx+20],edx |
278 | mov [ebx+20],edx |
247 | setne al |
279 | setne al |
248 | or ah,al |
280 | or ah,al |
249 | label_symbol_ok: |
281 | label_symbol_ok: |
250 | mov cx,[current_pass] |
282 | mov cx,[current_pass] |
251 | xchg [ebx+16],cx |
283 | xchg [ebx+16],cx |
252 | mov edx,[current_line] |
284 | mov edx,[current_line] |
253 | mov [ebx+28],edx |
285 | mov [ebx+28],edx |
254 | and byte [ebx+8],not 2 |
286 | and byte [ebx+8],not 2 |
255 | test byte [ebx+8],1 |
287 | test byte [ebx+8],1 |
256 | jz new_label |
288 | jz new_label |
257 | cmp cx,[ebx+16] |
289 | cmp cx,[ebx+16] |
258 | je symbol_already_defined |
290 | je symbol_already_defined |
259 | inc cx |
291 | inc cx |
260 | sub cx,[ebx+16] |
292 | sub cx,[ebx+16] |
261 | setnz al |
293 | setnz al |
262 | or ah,al |
294 | or ah,al |
263 | jz continue_line |
295 | jz label_made |
264 | test byte [ebx+8],8 |
296 | test byte [ebx+8],8 |
265 | jz continue_line |
297 | jz label_made |
266 | mov cx,[current_pass] |
298 | mov cx,[current_pass] |
267 | cmp cx,[ebx+18] |
299 | cmp cx,[ebx+18] |
268 | jne continue_line |
300 | jne label_made |
269 | or [next_pass_needed],-1 |
301 | or [next_pass_needed],-1 |
270 | jmp continue_line |
302 | label_made: |
271 | new_label: |
303 | ret |
- | 304 | new_label: |
|
272 | or byte [ebx+8],1 |
305 | or byte [ebx+8],1 |
273 | jmp continue_line |
306 | ret |
274 | define_constant: |
307 | define_constant: |
275 | lods dword [esi] |
308 | lods dword [esi] |
276 | inc esi |
309 | inc esi |
277 | cmp eax,0Fh |
310 | cmp eax,0Fh |
278 | jb invalid_use_of_symbol |
311 | jb invalid_use_of_symbol |
279 | je reserved_word_used_as_symbol |
312 | je reserved_word_used_as_symbol |
280 | mov edx,[eax+8] |
313 | mov edx,[eax+8] |
281 | push edx |
314 | push edx |
282 | cmp [current_pass],0 |
315 | cmp [current_pass],0 |
283 | je get_constant_value |
316 | je get_constant_value |
284 | test dl,4 |
317 | test dl,4 |
285 | jnz get_constant_value |
318 | jnz get_constant_value |
286 | mov cx,[current_pass] |
319 | mov cx,[current_pass] |
287 | cmp cx,[eax+16] |
320 | cmp cx,[eax+16] |
288 | je get_constant_value |
321 | je get_constant_value |
289 | and dl,not 1 |
322 | and dl,not 1 |
290 | mov [eax+8],dl |
323 | mov [eax+8],dl |
291 | get_constant_value: |
324 | get_constant_value: |
292 | push eax |
325 | push eax |
293 | mov al,byte [esi-1] |
326 | mov al,byte [esi-1] |
294 | push eax |
327 | push eax |
295 | call get_value |
328 | or [size_override],-1 |
- | 329 | call get_value |
|
296 | pop ebx |
330 | pop ebx |
297 | mov ch,bl |
331 | mov ch,bl |
298 | pop ebx |
332 | pop ebx |
299 | pop dword [ebx+8] |
333 | pop dword [ebx+8] |
300 | cmp ebx,0Fh |
334 | cmp ebx,0Fh |
301 | jb invalid_use_of_symbol |
335 | jb invalid_use_of_symbol |
302 | je reserved_word_used_as_symbol |
336 | je reserved_word_used_as_symbol |
303 | xor cl,cl |
337 | xor cl,cl |
304 | mov ch,[value_type] |
338 | mov ch,[value_type] |
305 | cmp ch,3 |
339 | cmp ch,3 |
306 | je invalid_use_of_symbol |
340 | je invalid_use_of_symbol |
307 | make_constant: |
341 | make_constant: |
308 | and byte [ebx+9],not 1 |
342 | and byte [ebx+9],not 1 |
309 | cmp eax,[ebx] |
343 | cmp eax,[ebx] |
310 | mov [ebx],eax |
344 | mov [ebx],eax |
311 | setne ah |
345 | setne ah |
312 | cmp edx,[ebx+4] |
346 | cmp edx,[ebx+4] |
313 | mov [ebx+4],edx |
347 | mov [ebx+4],edx |
314 | setne al |
348 | setne al |
315 | or ah,al |
349 | or ah,al |
316 | cmp cl,[ebx+10] |
350 | mov al,[value_sign] |
- | 351 | xor al,[ebx+9] |
|
- | 352 | and al,10b |
|
- | 353 | or ah,al |
|
- | 354 | xor [ebx+9],al |
|
- | 355 | cmp cl,[ebx+10] |
|
317 | mov [ebx+10],cl |
356 | mov [ebx+10],cl |
318 | setne al |
357 | setne al |
319 | or ah,al |
358 | or ah,al |
320 | cmp ch,[ebx+11] |
359 | cmp ch,[ebx+11] |
321 | mov [ebx+11],ch |
360 | mov [ebx+11],ch |
322 | setne al |
361 | setne al |
323 | or ah,al |
362 | or ah,al |
324 | xor edx,edx |
363 | xor edx,edx |
325 | cmp edx,[ebx+12] |
364 | cmp edx,[ebx+12] |
326 | mov [ebx+12],edx |
365 | mov [ebx+12],edx |
327 | setne al |
366 | setne al |
328 | or ah,al |
367 | or ah,al |
329 | or ch,ch |
368 | or ch,ch |
330 | jz constant_symbol_ok |
369 | jz constant_symbol_ok |
331 | mov edx,[symbol_identifier] |
370 | mov edx,[symbol_identifier] |
332 | cmp edx,[ebx+20] |
371 | cmp edx,[ebx+20] |
333 | mov [ebx+20],edx |
372 | mov [ebx+20],edx |
334 | setne al |
373 | setne al |
335 | or ah,al |
374 | or ah,al |
336 | constant_symbol_ok: |
375 | constant_symbol_ok: |
337 | mov cx,[current_pass] |
376 | mov cx,[current_pass] |
338 | xchg [ebx+16],cx |
377 | xchg [ebx+16],cx |
339 | mov edx,[current_line] |
378 | mov edx,[current_line] |
340 | mov [ebx+28],edx |
379 | mov [ebx+28],edx |
341 | test byte [ebx+8],1 |
380 | test byte [ebx+8],1 |
342 | jz new_constant |
381 | jz new_constant |
343 | cmp cx,[ebx+16] |
382 | cmp cx,[ebx+16] |
344 | jne redeclare_constant |
383 | jne redeclare_constant |
345 | test byte [ebx+8],2 |
384 | test byte [ebx+8],2 |
346 | jz symbol_already_defined |
385 | jz symbol_already_defined |
347 | or byte [ebx+8],4 |
386 | or byte [ebx+8],4 |
348 | jmp instruction_assembled |
387 | jmp instruction_assembled |
349 | redeclare_constant: |
388 | redeclare_constant: |
350 | inc cx |
389 | inc cx |
351 | sub cx,[ebx+16] |
390 | sub cx,[ebx+16] |
352 | setnz al |
391 | setnz al |
353 | or ah,al |
392 | or ah,al |
354 | jz instruction_assembled |
393 | jz instruction_assembled |
355 | test byte [ebx+8],4 |
394 | test byte [ebx+8],4 |
356 | jnz instruction_assembled |
395 | jnz instruction_assembled |
357 | test byte [ebx+8],8 |
396 | test byte [ebx+8],8 |
358 | jz instruction_assembled |
397 | jz instruction_assembled |
359 | mov cx,[current_pass] |
398 | mov cx,[current_pass] |
360 | cmp cx,[ebx+18] |
399 | cmp cx,[ebx+18] |
361 | jne instruction_assembled |
400 | jne instruction_assembled |
362 | or [next_pass_needed],-1 |
401 | or [next_pass_needed],-1 |
363 | jmp instruction_assembled |
402 | jmp instruction_assembled |
364 | new_constant: |
403 | new_constant: |
365 | or byte [ebx+8],1+2 |
404 | or byte [ebx+8],1+2 |
366 | jmp instruction_assembled |
405 | jmp instruction_assembled |
367 | assemble_instruction: |
406 | assemble_instruction: |
368 | ; mov [operand_size],0 |
407 | ; mov [operand_size],0 |
369 | ; mov [size_override],0 |
408 | ; mov [size_override],0 |
370 | ; mov [operand_prefix],0 |
409 | ; mov [operand_prefix],0 |
371 | ; mov [opcode_prefix],0 |
410 | ; mov [opcode_prefix],0 |
372 | mov dword [operand_size],0 |
411 | and dword [operand_size],0 |
373 | ; mov [rex_prefix],0 |
412 | ; mov [rex_prefix],0 |
374 | ; mov [vex_required],0 |
413 | ; mov [vex_required],0 |
375 | ; mov [vex_register],0 |
414 | ; mov [vex_register],0 |
376 | ; mov [immediate_size],0 |
415 | ; mov [immediate_size],0 |
377 | mov dword [rex_prefix],0 |
416 | and dword [rex_prefix],0 |
378 | call instruction_handler |
417 | call instruction_handler |
379 | instruction_handler: |
418 | instruction_handler: |
380 | movzx ebx,word [esi] |
419 | movzx ebx,word [esi] |
381 | mov al,[esi+2] |
420 | mov al,[esi+2] |
382 | add esi,3 |
421 | add esi,3 |
383 | add [esp],ebx |
422 | add [esp],ebx |
384 | ret |
423 | ret |
385 | instruction_assembled: |
424 | instruction_assembled: |
386 | mov al,[esi] |
425 | mov al,[esi] |
387 | cmp al,0Fh |
426 | cmp al,0Fh |
388 | je line_assembled |
427 | je line_assembled |
389 | or al,al |
428 | or al,al |
390 | jnz extra_characters_on_line |
429 | jnz extra_characters_on_line |
391 | line_assembled: |
430 | line_assembled: |
392 | clc |
431 | clc |
393 | ret |
432 | ret |
394 | source_end: |
433 | source_end: |
395 | dec esi |
434 | dec esi |
396 | stc |
435 | stc |
397 | ret |
436 | ret |
398 | 437 | ||
399 | org_directive: |
438 | org_directive: |
400 | lods byte [esi] |
439 | lods byte [esi] |
401 | cmp al,'(' |
440 | cmp al,'(' |
402 | jne invalid_argument |
441 | jne invalid_argument |
403 | cmp byte [esi],'.' |
442 | cmp byte [esi],'.' |
404 | je invalid_value |
443 | je invalid_value |
405 | call get_qword_value |
444 | call get_qword_value |
406 | mov cl,[value_type] |
445 | mov cl,[value_type] |
407 | test cl,1 |
446 | test cl,1 |
408 | jnz invalid_use_of_symbol |
447 | jnz invalid_use_of_symbol |
409 | mov [labels_type],cl |
448 | mov [labels_type],cl |
410 | mov ecx,edi |
449 | mov dword [org_origin],edi |
411 | sub ecx,eax |
450 | xor ecx,ecx |
412 | adc edx,0 |
451 | mov dword [org_origin+4],ecx |
- | 452 | mov [org_origin_sign],cl |
|
- | 453 | mov [org_registers],ecx |
|
413 | neg edx |
454 | mov cl,[value_sign] |
414 | mov dword [org_origin],ecx |
455 | sub dword [org_origin],eax |
415 | mov dword [org_origin+4],edx |
456 | sbb dword [org_origin+4],edx |
416 | mov [org_registers],0 |
457 | sbb [org_origin_sign],cl |
417 | mov [org_start],edi |
458 | jp org_value_ok |
- | 459 | call recoverable_overflow |
|
- | 460 | org_value_ok: |
|
- | 461 | mov [org_start],edi |
|
418 | mov edx,[symbol_identifier] |
462 | mov edx,[symbol_identifier] |
419 | mov [org_symbol],edx |
463 | mov [org_symbol],edx |
420 | cmp [output_format],1 |
464 | cmp [output_format],1 |
421 | ja instruction_assembled |
465 | ja instruction_assembled |
422 | cmp edi,[code_start] |
466 | cmp edi,[code_start] |
423 | jne instruction_assembled |
467 | jne instruction_assembled |
424 | cmp eax,100h |
468 | cmp eax,100h |
425 | jne instruction_assembled |
469 | jne instruction_assembled |
426 | bts [format_flags],0 |
470 | bts [format_flags],0 |
427 | jmp instruction_assembled |
471 | jmp instruction_assembled |
428 | label_directive: |
472 | label_directive: |
429 | lods byte [esi] |
473 | lods byte [esi] |
430 | cmp al,2 |
474 | cmp al,2 |
431 | jne invalid_argument |
475 | jne invalid_argument |
432 | lods dword [esi] |
476 | lods dword [esi] |
433 | cmp eax,0Fh |
477 | cmp eax,0Fh |
434 | jb invalid_use_of_symbol |
478 | jb invalid_use_of_symbol |
435 | je reserved_word_used_as_symbol |
479 | je reserved_word_used_as_symbol |
436 | inc esi |
480 | inc esi |
437 | mov ebx,eax |
481 | mov ebx,eax |
438 | xor cl,cl |
482 | mov [label_size],0 |
439 | lods byte [esi] |
483 | lods byte [esi] |
440 | cmp al,':' |
484 | cmp al,':' |
441 | je get_label_size |
485 | je get_label_size |
442 | dec esi |
486 | dec esi |
443 | cmp al,11h |
487 | cmp al,11h |
444 | jne label_size_ok |
488 | jne label_size_ok |
445 | get_label_size: |
489 | get_label_size: |
446 | lods word [esi] |
490 | lods word [esi] |
447 | cmp al,11h |
491 | cmp al,11h |
448 | jne invalid_argument |
492 | jne invalid_argument |
449 | mov cl,ah |
493 | mov [label_size],ah |
450 | label_size_ok: |
494 | label_size_ok: |
451 | mov eax,edi |
495 | cmp byte [esi],80h |
452 | xor edx,edx |
- | |
453 | sub eax,dword [org_origin] |
- | |
454 | sbb edx,dword [org_origin+4] |
- | |
455 | mov ebp,[org_registers] |
- | |
456 | cmp byte [esi],80h |
- | |
457 | je get_free_label_value |
496 | je get_free_label_value |
458 | mov ch,[labels_type] |
497 | call make_label |
459 | push [org_symbol] |
- | |
460 | pop [address_symbol] |
- | |
461 | cmp [virtual_data],0 |
- | |
462 | jne make_free_label |
- | |
463 | or byte [ebx+9],1 |
498 | jmp instruction_assembled |
464 | xchg eax,[ebx] |
- | |
465 | xchg edx,[ebx+4] |
- | |
466 | sub eax,[ebx] |
- | |
467 | sbb edx,[ebx+4] |
- | |
468 | mov dword [adjustment],eax |
- | |
469 | mov dword [adjustment+4],edx |
- | |
470 | or eax,edx |
- | |
471 | setne ah |
- | |
472 | jmp finish_label |
- | |
473 | get_free_label_value: |
499 | get_free_label_value: |
474 | inc esi |
500 | inc esi |
475 | lods byte [esi] |
501 | lods byte [esi] |
476 | cmp al,'(' |
502 | cmp al,'(' |
477 | jne invalid_argument |
503 | jne invalid_argument |
478 | push dword [ebx+8] |
504 | push dword [ebx+8] |
479 | push ebx ecx |
505 | push ebx ecx |
480 | and byte [ebx+8],not 1 |
506 | and byte [ebx+8],not 1 |
481 | cmp byte [esi],'.' |
507 | cmp byte [esi],'.' |
482 | je invalid_value |
508 | je invalid_value |
483 | call get_address_value |
509 | call get_address_value |
484 | or bh,bh |
510 | or bh,bh |
485 | setnz ch |
511 | setnz ch |
486 | xchg ch,cl |
512 | xchg ch,cl |
487 | mov bp,cx |
513 | mov bp,cx |
488 | shl ebp,16 |
514 | shl ebp,16 |
489 | xchg bl,bh |
515 | xchg bl,bh |
490 | mov bp,bx |
516 | mov bp,bx |
491 | pop ecx ebx |
517 | pop ecx ebx |
492 | pop dword [ebx+8] |
518 | pop dword [ebx+8] |
493 | mov ch,[value_type] |
519 | mov ch,[value_type] |
494 | or ch,ch |
520 | or ch,ch |
495 | jz make_free_label |
521 | jz make_free_label |
496 | cmp ch,4 |
522 | cmp ch,4 |
497 | je make_free_label |
523 | je make_free_label |
498 | cmp ch,2 |
524 | cmp ch,2 |
499 | jne invalid_use_of_symbol |
525 | jne invalid_use_of_symbol |
500 | make_free_label: |
526 | make_free_label: |
501 | and byte [ebx+9],not 1 |
527 | and byte [ebx+9],not 1 |
502 | cmp eax,[ebx] |
528 | cmp eax,[ebx] |
503 | mov [ebx],eax |
529 | mov [ebx],eax |
504 | setne ah |
530 | setne ah |
505 | cmp edx,[ebx+4] |
531 | cmp edx,[ebx+4] |
506 | mov [ebx+4],edx |
532 | mov [ebx+4],edx |
507 | setne al |
533 | setne al |
508 | or ah,al |
534 | or ah,al |
509 | finish_label: |
535 | mov edx,[address_symbol] |
510 | cmp cl,[ebx+10] |
- | |
511 | mov [ebx+10],cl |
- | |
512 | setne al |
- | |
513 | or ah,al |
- | |
514 | cmp ch,[ebx+11] |
- | |
515 | mov [ebx+11],ch |
- | |
516 | setne al |
- | |
517 | or ah,al |
- | |
518 | cmp ebp,[ebx+12] |
- | |
519 | mov [ebx+12],ebp |
- | |
520 | setne al |
- | |
521 | or ah,al |
- | |
522 | or ch,ch |
- | |
523 | jz free_label_symbol_ok |
- | |
524 | mov edx,[address_symbol] |
- | |
525 | cmp edx,[ebx+20] |
536 | mov cl,[label_size] |
526 | mov [ebx+20],edx |
- | |
527 | setne al |
537 | call finish_label_symbol |
528 | or ah,al |
- | |
529 | free_label_symbol_ok: |
- | |
530 | mov cx,[current_pass] |
538 | jmp instruction_assembled |
531 | xchg [ebx+16],cx |
- | |
532 | mov edx,[current_line] |
- | |
533 | mov [ebx+28],edx |
- | |
534 | and byte [ebx+8],not 2 |
- | |
535 | test byte [ebx+8],1 |
- | |
536 | jz new_free_label |
- | |
537 | cmp cx,[ebx+16] |
- | |
538 | je symbol_already_defined |
- | |
539 | inc cx |
- | |
540 | sub cx,[ebx+16] |
- | |
541 | setnz al |
- | |
542 | or ah,al |
- | |
543 | jz instruction_assembled |
- | |
544 | test byte [ebx+8],8 |
- | |
545 | jz instruction_assembled |
- | |
546 | mov cx,[current_pass] |
- | |
547 | cmp cx,[ebx+18] |
- | |
548 | jne instruction_assembled |
- | |
549 | or [next_pass_needed],-1 |
- | |
550 | jmp instruction_assembled |
- | |
551 | new_free_label: |
- | |
552 | or byte [ebx+8],1 |
- | |
553 | jmp instruction_assembled |
- | |
554 | load_directive: |
539 | load_directive: |
555 | lods byte [esi] |
540 | lods byte [esi] |
556 | cmp al,2 |
541 | cmp al,2 |
557 | jne invalid_argument |
542 | jne invalid_argument |
558 | lods dword [esi] |
543 | lods dword [esi] |
559 | cmp eax,0Fh |
544 | cmp eax,0Fh |
560 | jb invalid_use_of_symbol |
545 | jb invalid_use_of_symbol |
561 | je reserved_word_used_as_symbol |
546 | je reserved_word_used_as_symbol |
562 | inc esi |
547 | inc esi |
563 | push eax |
548 | push eax |
564 | mov al,1 |
549 | mov al,1 |
565 | cmp byte [esi],11h |
550 | cmp byte [esi],11h |
566 | jne load_size_ok |
551 | jne load_size_ok |
567 | lods byte [esi] |
552 | lods byte [esi] |
568 | lods byte [esi] |
553 | lods byte [esi] |
569 | load_size_ok: |
554 | load_size_ok: |
570 | cmp al,8 |
555 | cmp al,8 |
571 | ja invalid_value |
556 | ja invalid_value |
572 | mov [operand_size],al |
557 | mov [operand_size],al |
573 | mov dword [value],0 |
558 | and dword [value],0 |
574 | mov dword [value+4],0 |
559 | and dword [value+4],0 |
575 | lods word [esi] |
560 | lods word [esi] |
576 | cmp ax,82h+'(' shl 8 |
561 | cmp ax,82h+'(' shl 8 |
577 | jne invalid_argument |
562 | jne invalid_argument |
578 | load_from_code: |
563 | load_from_code: |
579 | cmp byte [esi],'.' |
564 | cmp byte [esi],'.' |
580 | je invalid_value |
565 | je invalid_value |
581 | or [size_override],-1 |
566 | or [size_override],-1 |
582 | call get_address_value |
567 | call get_address_value |
583 | call calculate_relative_offset |
568 | call calculate_relative_offset |
584 | push esi edi |
569 | push esi edi |
585 | cmp [next_pass_needed],0 |
570 | cmp [next_pass_needed],0 |
586 | jne load_address_type_ok |
571 | jne load_address_type_ok |
587 | cmp [value_type],0 |
572 | cmp [value_type],0 |
588 | jne invalid_use_of_symbol |
573 | jne invalid_use_of_symbol |
589 | load_address_type_ok: |
574 | load_address_type_ok: |
590 | cmp edx,-1 |
575 | cmp edx,-1 |
591 | jne bad_load_address |
576 | jne bad_load_address |
592 | neg eax |
577 | neg eax |
593 | mov esi,edi |
578 | mov esi,edi |
594 | sub esi,eax |
579 | sub esi,eax |
595 | jc bad_load_address |
580 | jc bad_load_address |
596 | cmp esi,[org_start] |
581 | cmp esi,[org_start] |
597 | jb bad_load_address |
582 | jb bad_load_address |
598 | mov edi,value |
583 | mov edi,value |
599 | movzx ecx,[operand_size] |
584 | movzx ecx,[operand_size] |
600 | cmp ecx,eax |
585 | cmp ecx,eax |
601 | ja bad_load_address |
586 | ja bad_load_address |
602 | rep movs byte [edi],[esi] |
587 | rep movs byte [edi],[esi] |
603 | jmp value_loaded |
588 | jmp value_loaded |
604 | bad_load_address: |
589 | bad_load_address: |
605 | cmp [error_line],0 |
590 | call recoverable_overflow |
606 | jne value_loaded |
- | |
607 | mov eax,[current_line] |
- | |
608 | mov [error_line],eax |
- | |
609 | mov [error],value_out_of_range |
- | |
610 | value_loaded: |
591 | value_loaded: |
611 | pop edi esi |
592 | pop edi esi |
612 | mov eax,dword [value] |
593 | mov [value_sign],0 |
- | 594 | mov eax,dword [value] |
|
613 | mov edx,dword [value+4] |
595 | mov edx,dword [value+4] |
614 | pop ebx |
596 | pop ebx |
615 | xor cx,cx |
597 | xor cx,cx |
616 | jmp make_constant |
598 | jmp make_constant |
617 | store_directive: |
599 | store_directive: |
618 | cmp byte [esi],11h |
600 | cmp byte [esi],11h |
619 | je sized_store |
601 | je sized_store |
620 | lods byte [esi] |
602 | lods byte [esi] |
621 | cmp al,'(' |
603 | cmp al,'(' |
622 | jne invalid_argument |
604 | jne invalid_argument |
623 | call get_byte_value |
605 | call get_byte_value |
624 | xor edx,edx |
606 | xor edx,edx |
625 | movzx eax,al |
607 | movzx eax,al |
626 | mov [operand_size],1 |
608 | mov [operand_size],1 |
627 | jmp store_value_ok |
609 | jmp store_value_ok |
628 | sized_store: |
610 | sized_store: |
629 | call get_value |
611 | or [size_override],-1 |
- | 612 | call get_value |
|
630 | store_value_ok: |
613 | store_value_ok: |
631 | cmp [value_type],0 |
614 | cmp [value_type],0 |
632 | jne invalid_use_of_symbol |
615 | jne invalid_use_of_symbol |
633 | mov dword [value],eax |
616 | mov dword [value],eax |
634 | mov dword [value+4],edx |
617 | mov dword [value+4],edx |
635 | lods word [esi] |
618 | lods word [esi] |
636 | cmp ax,80h+'(' shl 8 |
619 | cmp ax,80h+'(' shl 8 |
637 | jne invalid_argument |
620 | jne invalid_argument |
638 | cmp byte [esi],'.' |
621 | cmp byte [esi],'.' |
639 | je invalid_value |
622 | je invalid_value |
640 | or [size_override],-1 |
623 | or [size_override],-1 |
641 | call get_address_value |
624 | call get_address_value |
642 | call calculate_relative_offset |
625 | call calculate_relative_offset |
643 | push esi edi |
626 | push esi edi |
644 | cmp [next_pass_needed],0 |
627 | cmp [next_pass_needed],0 |
645 | jne store_address_type_ok |
628 | jne store_address_type_ok |
646 | cmp [value_type],0 |
629 | cmp [value_type],0 |
647 | jne invalid_use_of_symbol |
630 | jne invalid_use_of_symbol |
648 | store_address_type_ok: |
631 | store_address_type_ok: |
649 | cmp edx,-1 |
632 | cmp edx,-1 |
650 | jne bad_store_address |
633 | jne bad_store_address |
651 | neg eax |
634 | neg eax |
652 | sub edi,eax |
635 | sub edi,eax |
653 | jc bad_store_address |
636 | jc bad_store_address |
654 | cmp edi,[org_start] |
637 | cmp edi,[org_start] |
655 | jb bad_store_address |
638 | jb bad_store_address |
656 | mov esi,value |
639 | mov esi,value |
657 | movzx ecx,[operand_size] |
640 | movzx ecx,[operand_size] |
658 | cmp ecx,eax |
641 | cmp ecx,eax |
659 | ja bad_store_address |
642 | ja bad_store_address |
660 | rep movs byte [edi],[esi] |
643 | rep movs byte [edi],[esi] |
661 | mov eax,edi |
644 | mov eax,edi |
662 | pop edi esi |
645 | pop edi esi |
663 | cmp edi,[undefined_data_end] |
646 | cmp edi,[undefined_data_end] |
664 | jne instruction_assembled |
647 | jne instruction_assembled |
665 | cmp eax,[undefined_data_start] |
648 | cmp eax,[undefined_data_start] |
666 | jbe instruction_assembled |
649 | jbe instruction_assembled |
667 | mov [undefined_data_start],eax |
650 | mov [undefined_data_start],eax |
668 | jmp instruction_assembled |
651 | jmp instruction_assembled |
669 | bad_store_address: |
652 | bad_store_address: |
670 | pop edi esi |
653 | pop edi esi |
671 | cmp [error_line],0 |
654 | call recoverable_overflow |
672 | jne instruction_assembled |
- | |
673 | mov eax,[current_line] |
- | |
674 | mov [error_line],eax |
- | |
675 | mov [error],value_out_of_range |
- | |
676 | jmp instruction_assembled |
655 | jmp instruction_assembled |
677 | 656 | ||
678 | display_directive: |
657 | display_directive: |
679 | lods byte [esi] |
658 | lods byte [esi] |
680 | cmp al,'(' |
659 | cmp al,'(' |
681 | jne invalid_argument |
660 | jne invalid_argument |
682 | cmp byte [esi],0 |
661 | cmp byte [esi],0 |
683 | jne display_byte |
662 | jne display_byte |
684 | inc esi |
663 | inc esi |
685 | lods dword [esi] |
664 | lods dword [esi] |
686 | mov ecx,eax |
665 | mov ecx,eax |
687 | push edi |
666 | push edi |
688 | mov edi,[display_buffer] |
667 | mov edi,[display_buffer] |
689 | sub edi,8 |
668 | sub edi,8 |
690 | sub edi,eax |
669 | sub edi,eax |
691 | cmp edi,[esp] |
670 | cmp edi,[esp] |
692 | jbe out_of_memory |
671 | jbe out_of_memory |
693 | mov [display_buffer],edi |
672 | mov [display_buffer],edi |
694 | rep movs byte [edi],[esi] |
673 | rep movs byte [edi],[esi] |
695 | stos dword [edi] |
674 | stos dword [edi] |
696 | xor eax,eax |
675 | xor eax,eax |
697 | stos dword [edi] |
676 | stos dword [edi] |
698 | pop edi |
677 | pop edi |
699 | inc esi |
678 | inc esi |
700 | jmp display_next |
679 | jmp display_next |
701 | display_byte: |
680 | display_byte: |
702 | call get_byte_value |
681 | call get_byte_value |
703 | push edi |
682 | push edi |
704 | mov edi,[display_buffer] |
683 | mov edi,[display_buffer] |
705 | sub edi,8+1 |
684 | sub edi,8+1 |
706 | mov [display_buffer],edi |
685 | mov [display_buffer],edi |
707 | stos byte [edi] |
686 | stos byte [edi] |
708 | mov eax,1 |
687 | mov eax,1 |
709 | stos dword [edi] |
688 | stos dword [edi] |
710 | dec eax |
689 | dec eax |
711 | stos dword [edi] |
690 | stos dword [edi] |
712 | pop edi |
691 | pop edi |
713 | display_next: |
692 | display_next: |
714 | cmp edi,[display_buffer] |
693 | cmp edi,[display_buffer] |
715 | ja out_of_memory |
694 | ja out_of_memory |
716 | lods byte [esi] |
695 | lods byte [esi] |
717 | cmp al,',' |
696 | cmp al,',' |
718 | je display_directive |
697 | je display_directive |
719 | dec esi |
698 | dec esi |
720 | jmp instruction_assembled |
699 | jmp instruction_assembled |
721 | show_display_buffer: |
700 | show_display_buffer: |
722 | mov eax,[display_buffer] |
701 | mov eax,[display_buffer] |
723 | or eax,eax |
702 | or eax,eax |
724 | jz display_done |
703 | jz display_done |
725 | mov esi,[labels_list] |
704 | mov esi,[labels_list] |
726 | cmp esi,eax |
705 | cmp esi,eax |
727 | je display_done |
706 | je display_done |
728 | display_messages: |
707 | display_messages: |
729 | sub esi,8 |
708 | sub esi,8 |
730 | mov eax,[esi+4] |
709 | mov eax,[esi+4] |
731 | mov ecx,[esi] |
710 | mov ecx,[esi] |
732 | sub esi,ecx |
711 | sub esi,ecx |
733 | test eax,eax |
712 | test eax,eax |
734 | jnz skip_internal_message |
713 | jnz skip_internal_message |
735 | push esi |
714 | push esi |
736 | call display_block |
715 | call display_block |
737 | pop esi |
716 | pop esi |
738 | skip_internal_message: |
717 | skip_internal_message: |
739 | cmp esi,[display_buffer] |
718 | cmp esi,[display_buffer] |
740 | jne display_messages |
719 | jne display_messages |
741 | display_done: |
720 | display_done: |
742 | ret |
721 | ret |
743 | 722 | ||
744 | times_directive: |
723 | times_directive: |
745 | lods byte [esi] |
724 | lods byte [esi] |
746 | cmp al,'(' |
725 | cmp al,'(' |
747 | jne invalid_argument |
726 | jne invalid_argument |
748 | cmp byte [esi],'.' |
727 | cmp byte [esi],'.' |
749 | je invalid_value |
728 | je invalid_value |
750 | call get_count_value |
729 | call get_count_value |
751 | cmp eax,0 |
730 | cmp eax,0 |
752 | je zero_times |
731 | je zero_times |
753 | cmp byte [esi],':' |
732 | cmp byte [esi],':' |
754 | jne times_argument_ok |
733 | jne times_argument_ok |
755 | inc esi |
734 | inc esi |
756 | times_argument_ok: |
735 | times_argument_ok: |
757 | push [counter] |
736 | push [counter] |
758 | push [counter_limit] |
737 | push [counter_limit] |
759 | mov [counter_limit],eax |
738 | mov [counter_limit],eax |
760 | mov [counter],1 |
739 | mov [counter],1 |
761 | times_loop: |
740 | times_loop: |
762 | mov eax,esp |
741 | mov eax,esp |
763 | sub eax,100h |
742 | sub eax,100h |
764 | jc stack_overflow |
743 | jc stack_overflow |
765 | cmp eax,[stack_limit] |
744 | cmp eax,[stack_limit] |
766 | jb stack_overflow |
745 | jb stack_overflow |
767 | push esi |
746 | push esi |
768 | or [prefixed_instruction],-1 |
747 | or [prefixed_instruction],-1 |
769 | call continue_line |
748 | call continue_line |
770 | mov eax,[counter_limit] |
749 | mov eax,[counter_limit] |
771 | cmp [counter],eax |
750 | cmp [counter],eax |
772 | je times_done |
751 | je times_done |
773 | inc [counter] |
752 | inc [counter] |
774 | pop esi |
753 | pop esi |
775 | jmp times_loop |
754 | jmp times_loop |
776 | times_done: |
755 | times_done: |
777 | pop eax |
756 | pop eax |
778 | pop [counter_limit] |
757 | pop [counter_limit] |
779 | pop [counter] |
758 | pop [counter] |
780 | jmp instruction_assembled |
759 | jmp instruction_assembled |
781 | zero_times: |
760 | zero_times: |
782 | call skip_symbol |
761 | call skip_symbol |
783 | jnc zero_times |
762 | jnc zero_times |
784 | jmp instruction_assembled |
763 | jmp instruction_assembled |
785 | 764 | ||
786 | virtual_directive: |
765 | virtual_directive: |
787 | lods byte [esi] |
766 | lods byte [esi] |
788 | cmp al,80h |
767 | cmp al,80h |
789 | jne virtual_at_current |
768 | jne virtual_at_current |
790 | lods byte [esi] |
769 | lods byte [esi] |
791 | cmp al,'(' |
770 | cmp al,'(' |
792 | jne invalid_argument |
771 | jne invalid_argument |
793 | cmp byte [esi],'.' |
772 | cmp byte [esi],'.' |
794 | je invalid_value |
773 | je invalid_value |
795 | call get_address_value |
774 | call get_address_value |
796 | mov ebp,[address_symbol] |
775 | mov ebp,[address_symbol] |
797 | xor ch,ch |
776 | or bh,bh |
798 | or bh,bh |
- | |
799 | jz set_virtual |
777 | setnz ch |
800 | mov ch,1 |
- | |
801 | jmp set_virtual |
778 | jmp set_virtual |
802 | virtual_at_current: |
779 | virtual_at_current: |
803 | dec esi |
780 | dec esi |
804 | mov al,[labels_type] |
781 | mov al,[labels_type] |
805 | mov [value_type],al |
782 | mov [value_type],al |
806 | mov ebp,[org_symbol] |
783 | mov ebp,[org_symbol] |
807 | mov eax,edi |
784 | mov eax,edi |
808 | xor edx,edx |
785 | xor edx,edx |
809 | sub eax,dword [org_origin] |
786 | xor cl,cl |
- | 787 | sub eax,dword [org_origin] |
|
810 | sbb edx,dword [org_origin+4] |
788 | sbb edx,dword [org_origin+4] |
811 | mov bx,word [org_registers] |
789 | sbb cl,[org_origin_sign] |
- | 790 | mov [address_sign],cl |
|
- | 791 | mov bx,word [org_registers] |
|
812 | mov cx,word [org_registers+2] |
792 | mov cx,word [org_registers+2] |
813 | xchg bh,bl |
793 | xchg bh,bl |
814 | xchg ch,cl |
794 | xchg ch,cl |
815 | set_virtual: |
795 | set_virtual: |
816 | push [org_registers] |
796 | push [org_registers] |
817 | mov byte [org_registers],bh |
797 | mov byte [org_registers],bh |
818 | mov byte [org_registers+1],bl |
798 | mov byte [org_registers+1],bl |
819 | mov byte [org_registers+2],ch |
799 | mov byte [org_registers+2],ch |
820 | mov byte [org_registers+3],cl |
800 | mov byte [org_registers+3],cl |
821 | call allocate_structure_data |
801 | call allocate_structure_data |
822 | mov word [ebx],virtual_directive-instruction_handler |
802 | mov word [ebx],virtual_directive-instruction_handler |
823 | not eax |
803 | mov cl,[address_sign] |
- | 804 | not eax |
|
824 | not edx |
805 | not edx |
825 | add eax,1 |
806 | not cl |
- | 807 | add eax,1 |
|
826 | adc edx,0 |
808 | adc edx,0 |
827 | add eax,edi |
809 | adc cl,0 |
- | 810 | add eax,edi |
|
828 | adc edx,0 |
811 | adc edx,0 |
829 | xchg dword [org_origin],eax |
812 | adc cl,0 |
- | 813 | xchg dword [org_origin],eax |
|
830 | xchg dword [org_origin+4],edx |
814 | xchg dword [org_origin+4],edx |
831 | mov [ebx+10h],eax |
815 | xchg [org_origin_sign],cl |
- | 816 | mov [ebx+10h],eax |
|
832 | mov [ebx+14h],edx |
817 | mov [ebx+14h],edx |
833 | pop eax |
818 | pop eax |
834 | mov [ebx+18h],eax |
819 | mov [ebx+18h],eax |
835 | mov al,[virtual_data] |
820 | mov al,[virtual_data] |
836 | mov [ebx+2],al |
821 | and al,0Fh |
- | 822 | shl cl,4 |
|
- | 823 | or al,cl |
|
- | 824 | mov [ebx+2],al |
|
837 | mov al,[labels_type] |
825 | mov al,[labels_type] |
838 | mov [ebx+3],al |
826 | mov [ebx+3],al |
839 | mov eax,edi |
827 | mov eax,edi |
840 | xchg eax,[org_start] |
828 | xchg eax,[org_start] |
841 | mov [ebx+0Ch],eax |
829 | mov [ebx+0Ch],eax |
842 | xchg ebp,[org_symbol] |
830 | xchg ebp,[org_symbol] |
843 | mov [ebx+1Ch],ebp |
831 | mov [ebx+1Ch],ebp |
844 | mov [ebx+8],edi |
832 | mov [ebx+8],edi |
845 | mov eax,[current_line] |
833 | mov eax,[current_line] |
846 | mov [ebx+4],eax |
834 | mov [ebx+4],eax |
847 | or [virtual_data],-1 |
835 | or [virtual_data],-1 |
848 | mov al,[value_type] |
836 | mov al,[value_type] |
849 | test al,1 |
837 | test al,1 |
850 | jnz invalid_use_of_symbol |
838 | jnz invalid_use_of_symbol |
851 | mov [labels_type],al |
839 | mov [labels_type],al |
852 | jmp instruction_assembled |
840 | jmp instruction_assembled |
853 | allocate_structure_data: |
841 | allocate_structure_data: |
854 | mov ebx,[structures_buffer] |
842 | mov ebx,[structures_buffer] |
855 | sub ebx,20h |
843 | sub ebx,20h |
856 | cmp ebx,[free_additional_memory] |
844 | cmp ebx,[free_additional_memory] |
857 | jb out_of_memory |
845 | jb out_of_memory |
858 | mov [structures_buffer],ebx |
846 | mov [structures_buffer],ebx |
859 | ret |
847 | ret |
860 | find_structure_data: |
848 | find_structure_data: |
861 | mov ebx,[structures_buffer] |
849 | mov ebx,[structures_buffer] |
862 | scan_structures: |
850 | scan_structures: |
863 | cmp ebx,[additional_memory_end] |
851 | cmp ebx,[additional_memory_end] |
864 | je no_such_structure |
852 | je no_such_structure |
865 | cmp ax,[ebx] |
853 | cmp ax,[ebx] |
866 | je structure_data_found |
854 | je structure_data_found |
867 | add ebx,20h |
855 | add ebx,20h |
868 | jmp scan_structures |
856 | jmp scan_structures |
869 | structure_data_found: |
857 | structure_data_found: |
870 | ret |
858 | ret |
871 | no_such_structure: |
859 | no_such_structure: |
872 | stc |
860 | stc |
873 | ret |
861 | ret |
874 | end_virtual: |
862 | end_virtual: |
875 | call find_structure_data |
863 | call find_structure_data |
876 | jc unexpected_instruction |
864 | jc unexpected_instruction |
877 | mov al,[ebx+2] |
865 | mov al,[ebx+2] |
878 | mov [virtual_data],al |
866 | mov ah,al |
- | 867 | shr ah,4 |
|
- | 868 | and al,1 |
|
- | 869 | neg al |
|
- | 870 | and ah,1 |
|
- | 871 | neg ah |
|
- | 872 | mov [virtual_data],al |
|
879 | mov al,[ebx+3] |
873 | mov [org_origin_sign],ah |
- | 874 | mov al,[ebx+3] |
|
880 | mov [labels_type],al |
875 | mov [labels_type],al |
881 | mov eax,[ebx+10h] |
876 | mov eax,[ebx+10h] |
882 | mov dword [org_origin],eax |
877 | mov dword [org_origin],eax |
883 | mov eax,[ebx+14h] |
878 | mov eax,[ebx+14h] |
884 | mov dword [org_origin+4],eax |
879 | mov dword [org_origin+4],eax |
885 | mov eax,[ebx+18h] |
880 | mov eax,[ebx+18h] |
886 | mov [org_registers],eax |
881 | mov [org_registers],eax |
887 | mov eax,[ebx+0Ch] |
882 | mov eax,[ebx+0Ch] |
888 | mov [org_start],eax |
883 | mov [org_start],eax |
889 | mov eax,[ebx+1Ch] |
884 | mov eax,[ebx+1Ch] |
890 | mov [org_symbol],eax |
885 | mov [org_symbol],eax |
891 | mov edi,[ebx+8] |
886 | mov edi,[ebx+8] |
892 | remove_structure_data: |
887 | remove_structure_data: |
893 | push esi edi |
888 | push esi edi |
894 | mov ecx,ebx |
889 | mov ecx,ebx |
895 | sub ecx,[structures_buffer] |
890 | sub ecx,[structures_buffer] |
896 | shr ecx,2 |
891 | shr ecx,2 |
897 | lea esi,[ebx-4] |
892 | lea esi,[ebx-4] |
898 | lea edi,[esi+20h] |
893 | lea edi,[esi+20h] |
899 | std |
894 | std |
900 | rep movs dword [edi],[esi] |
895 | rep movs dword [edi],[esi] |
901 | cld |
896 | cld |
902 | add [structures_buffer],20h |
897 | add [structures_buffer],20h |
903 | pop edi esi |
898 | pop edi esi |
904 | ret |
899 | ret |
905 | repeat_directive: |
900 | repeat_directive: |
906 | cmp [prefixed_instruction],0 |
901 | cmp [prefixed_instruction],0 |
907 | jne unexpected_instruction |
902 | jne unexpected_instruction |
908 | lods byte [esi] |
903 | lods byte [esi] |
909 | cmp al,'(' |
904 | cmp al,'(' |
910 | jne invalid_argument |
905 | jne invalid_argument |
911 | cmp byte [esi],'.' |
906 | cmp byte [esi],'.' |
912 | je invalid_value |
907 | je invalid_value |
913 | call get_count_value |
908 | call get_count_value |
914 | cmp eax,0 |
909 | cmp eax,0 |
915 | je zero_repeat |
910 | je zero_repeat |
916 | call allocate_structure_data |
911 | call allocate_structure_data |
917 | mov word [ebx],repeat_directive-instruction_handler |
912 | mov word [ebx],repeat_directive-instruction_handler |
918 | xchg eax,[counter_limit] |
913 | xchg eax,[counter_limit] |
919 | mov [ebx+10h],eax |
914 | mov [ebx+10h],eax |
920 | mov eax,1 |
915 | mov eax,1 |
921 | xchg eax,[counter] |
916 | xchg eax,[counter] |
922 | mov [ebx+14h],eax |
917 | mov [ebx+14h],eax |
923 | mov [ebx+8],esi |
918 | mov [ebx+8],esi |
924 | mov eax,[current_line] |
919 | mov eax,[current_line] |
925 | mov [ebx+4],eax |
920 | mov [ebx+4],eax |
926 | jmp instruction_assembled |
921 | jmp instruction_assembled |
927 | end_repeat: |
922 | end_repeat: |
928 | cmp [prefixed_instruction],0 |
923 | cmp [prefixed_instruction],0 |
929 | jne unexpected_instruction |
924 | jne unexpected_instruction |
930 | call find_structure_data |
925 | call find_structure_data |
931 | jc unexpected_instruction |
926 | jc unexpected_instruction |
932 | mov eax,[counter_limit] |
927 | mov eax,[counter_limit] |
933 | inc [counter] |
928 | inc [counter] |
934 | cmp [counter],eax |
929 | cmp [counter],eax |
935 | jbe continue_repeating |
930 | jbe continue_repeating |
936 | stop_repeat: |
931 | stop_repeat: |
937 | mov eax,[ebx+10h] |
932 | mov eax,[ebx+10h] |
938 | mov [counter_limit],eax |
933 | mov [counter_limit],eax |
939 | mov eax,[ebx+14h] |
934 | mov eax,[ebx+14h] |
940 | mov [counter],eax |
935 | mov [counter],eax |
941 | call remove_structure_data |
936 | call remove_structure_data |
942 | jmp instruction_assembled |
937 | jmp instruction_assembled |
943 | continue_repeating: |
938 | continue_repeating: |
944 | mov esi,[ebx+8] |
939 | mov esi,[ebx+8] |
945 | jmp instruction_assembled |
940 | jmp instruction_assembled |
946 | zero_repeat: |
941 | zero_repeat: |
947 | mov al,[esi] |
942 | mov al,[esi] |
948 | or al,al |
943 | or al,al |
949 | jz missing_end_directive |
944 | jz missing_end_directive |
950 | cmp al,0Fh |
945 | cmp al,0Fh |
951 | jne extra_characters_on_line |
946 | jne extra_characters_on_line |
952 | call find_end_repeat |
947 | call find_end_repeat |
953 | jmp instruction_assembled |
948 | jmp instruction_assembled |
954 | find_end_repeat: |
949 | find_end_repeat: |
955 | call find_structure_end |
950 | call find_structure_end |
956 | cmp ax,repeat_directive-instruction_handler |
951 | cmp ax,repeat_directive-instruction_handler |
957 | jne unexpected_instruction |
952 | jne unexpected_instruction |
958 | ret |
953 | ret |
959 | while_directive: |
954 | while_directive: |
960 | cmp [prefixed_instruction],0 |
955 | cmp [prefixed_instruction],0 |
961 | jne unexpected_instruction |
956 | jne unexpected_instruction |
962 | call allocate_structure_data |
957 | call allocate_structure_data |
963 | mov word [ebx],while_directive-instruction_handler |
958 | mov word [ebx],while_directive-instruction_handler |
964 | mov eax,1 |
959 | mov eax,1 |
965 | xchg eax,[counter] |
960 | xchg eax,[counter] |
966 | mov [ebx+10h],eax |
961 | mov [ebx+10h],eax |
967 | mov [ebx+8],esi |
962 | mov [ebx+8],esi |
968 | mov eax,[current_line] |
963 | mov eax,[current_line] |
969 | mov [ebx+4],eax |
964 | mov [ebx+4],eax |
970 | do_while: |
965 | do_while: |
971 | push ebx |
966 | push ebx |
972 | call calculate_logical_expression |
967 | call calculate_logical_expression |
973 | or al,al |
968 | or al,al |
974 | jnz while_true |
969 | jnz while_true |
975 | mov al,[esi] |
970 | mov al,[esi] |
976 | or al,al |
971 | or al,al |
977 | jz missing_end_directive |
972 | jz missing_end_directive |
978 | cmp al,0Fh |
973 | cmp al,0Fh |
979 | jne extra_characters_on_line |
974 | jne extra_characters_on_line |
980 | stop_while: |
975 | stop_while: |
981 | call find_end_while |
976 | call find_end_while |
982 | pop ebx |
977 | pop ebx |
983 | mov eax,[ebx+10h] |
978 | mov eax,[ebx+10h] |
984 | mov [counter],eax |
979 | mov [counter],eax |
985 | call remove_structure_data |
980 | call remove_structure_data |
986 | jmp instruction_assembled |
981 | jmp instruction_assembled |
987 | while_true: |
982 | while_true: |
988 | pop ebx |
983 | pop ebx |
989 | jmp instruction_assembled |
984 | jmp instruction_assembled |
990 | end_while: |
985 | end_while: |
991 | cmp [prefixed_instruction],0 |
986 | cmp [prefixed_instruction],0 |
992 | jne unexpected_instruction |
987 | jne unexpected_instruction |
993 | call find_structure_data |
988 | call find_structure_data |
994 | jc unexpected_instruction |
989 | jc unexpected_instruction |
995 | mov eax,[ebx+4] |
990 | mov eax,[ebx+4] |
996 | mov [current_line],eax |
991 | mov [current_line],eax |
997 | inc [counter] |
992 | inc [counter] |
998 | jz too_many_repeats |
993 | jz too_many_repeats |
999 | mov esi,[ebx+8] |
994 | mov esi,[ebx+8] |
1000 | jmp do_while |
995 | jmp do_while |
1001 | find_end_while: |
996 | find_end_while: |
1002 | call find_structure_end |
997 | call find_structure_end |
1003 | cmp ax,while_directive-instruction_handler |
998 | cmp ax,while_directive-instruction_handler |
1004 | jne unexpected_instruction |
999 | jne unexpected_instruction |
1005 | ret |
1000 | ret |
1006 | if_directive: |
1001 | if_directive: |
1007 | cmp [prefixed_instruction],0 |
1002 | cmp [prefixed_instruction],0 |
1008 | jne unexpected_instruction |
1003 | jne unexpected_instruction |
1009 | call calculate_logical_expression |
1004 | call calculate_logical_expression |
1010 | mov dl,al |
1005 | mov dl,al |
1011 | mov al,[esi] |
1006 | mov al,[esi] |
1012 | or al,al |
1007 | or al,al |
1013 | jz missing_end_directive |
1008 | jz missing_end_directive |
1014 | cmp al,0Fh |
1009 | cmp al,0Fh |
1015 | jne extra_characters_on_line |
1010 | jne extra_characters_on_line |
1016 | or dl,dl |
1011 | or dl,dl |
1017 | jnz if_true |
1012 | jnz if_true |
1018 | call find_else |
1013 | call find_else |
1019 | jc instruction_assembled |
1014 | jc instruction_assembled |
1020 | mov al,[esi] |
1015 | mov al,[esi] |
1021 | cmp al,1 |
1016 | cmp al,1 |
1022 | jne else_true |
1017 | jne else_true |
1023 | cmp word [esi+1],if_directive-instruction_handler |
1018 | cmp word [esi+1],if_directive-instruction_handler |
1024 | jne else_true |
1019 | jne else_true |
1025 | add esi,4 |
1020 | add esi,4 |
1026 | jmp if_directive |
1021 | jmp if_directive |
1027 | if_true: |
1022 | if_true: |
1028 | xor al,al |
1023 | xor al,al |
1029 | make_if_structure: |
1024 | make_if_structure: |
1030 | call allocate_structure_data |
1025 | call allocate_structure_data |
1031 | mov word [ebx],if_directive-instruction_handler |
1026 | mov word [ebx],if_directive-instruction_handler |
1032 | mov byte [ebx+2],al |
1027 | mov byte [ebx+2],al |
1033 | mov eax,[current_line] |
1028 | mov eax,[current_line] |
1034 | mov [ebx+4],eax |
1029 | mov [ebx+4],eax |
1035 | jmp instruction_assembled |
1030 | jmp instruction_assembled |
1036 | else_true: |
1031 | else_true: |
1037 | or al,al |
1032 | or al,al |
1038 | jz missing_end_directive |
1033 | jz missing_end_directive |
1039 | cmp al,0Fh |
1034 | cmp al,0Fh |
1040 | jne extra_characters_on_line |
1035 | jne extra_characters_on_line |
1041 | or al,-1 |
1036 | or al,-1 |
1042 | jmp make_if_structure |
1037 | jmp make_if_structure |
1043 | else_directive: |
1038 | else_directive: |
1044 | cmp [prefixed_instruction],0 |
1039 | cmp [prefixed_instruction],0 |
1045 | jne unexpected_instruction |
1040 | jne unexpected_instruction |
1046 | mov ax,if_directive-instruction_handler |
1041 | mov ax,if_directive-instruction_handler |
1047 | call find_structure_data |
1042 | call find_structure_data |
1048 | jc unexpected_instruction |
1043 | jc unexpected_instruction |
1049 | cmp byte [ebx+2],0 |
1044 | cmp byte [ebx+2],0 |
1050 | jne unexpected_instruction |
1045 | jne unexpected_instruction |
1051 | found_else: |
1046 | found_else: |
1052 | mov al,[esi] |
1047 | mov al,[esi] |
1053 | cmp al,1 |
1048 | cmp al,1 |
1054 | jne skip_else |
1049 | jne skip_else |
1055 | cmp word [esi+1],if_directive-instruction_handler |
1050 | cmp word [esi+1],if_directive-instruction_handler |
1056 | jne skip_else |
1051 | jne skip_else |
1057 | add esi,4 |
1052 | add esi,4 |
1058 | call find_else |
1053 | call find_else |
1059 | jnc found_else |
1054 | jnc found_else |
1060 | call remove_structure_data |
1055 | call remove_structure_data |
1061 | jmp instruction_assembled |
1056 | jmp instruction_assembled |
1062 | skip_else: |
1057 | skip_else: |
1063 | or al,al |
1058 | or al,al |
1064 | jz missing_end_directive |
1059 | jz missing_end_directive |
1065 | cmp al,0Fh |
1060 | cmp al,0Fh |
1066 | jne extra_characters_on_line |
1061 | jne extra_characters_on_line |
1067 | call find_end_if |
1062 | call find_end_if |
1068 | call remove_structure_data |
1063 | call remove_structure_data |
1069 | jmp instruction_assembled |
1064 | jmp instruction_assembled |
1070 | end_if: |
1065 | end_if: |
1071 | cmp [prefixed_instruction],0 |
1066 | cmp [prefixed_instruction],0 |
1072 | jne unexpected_instruction |
1067 | jne unexpected_instruction |
1073 | call find_structure_data |
1068 | call find_structure_data |
1074 | jc unexpected_instruction |
1069 | jc unexpected_instruction |
1075 | call remove_structure_data |
1070 | call remove_structure_data |
1076 | jmp instruction_assembled |
1071 | jmp instruction_assembled |
1077 | find_else: |
1072 | find_else: |
1078 | call find_structure_end |
1073 | call find_structure_end |
1079 | cmp ax,else_directive-instruction_handler |
1074 | cmp ax,else_directive-instruction_handler |
1080 | je else_found |
1075 | je else_found |
1081 | cmp ax,if_directive-instruction_handler |
1076 | cmp ax,if_directive-instruction_handler |
1082 | jne unexpected_instruction |
1077 | jne unexpected_instruction |
1083 | stc |
1078 | stc |
1084 | ret |
1079 | ret |
1085 | else_found: |
1080 | else_found: |
1086 | clc |
1081 | clc |
1087 | ret |
1082 | ret |
1088 | find_end_if: |
1083 | find_end_if: |
1089 | call find_structure_end |
1084 | call find_structure_end |
1090 | cmp ax,if_directive-instruction_handler |
1085 | cmp ax,if_directive-instruction_handler |
1091 | jne unexpected_instruction |
1086 | jne unexpected_instruction |
1092 | ret |
1087 | ret |
1093 | find_structure_end: |
1088 | find_structure_end: |
1094 | push [error_line] |
1089 | push [error_line] |
1095 | mov eax,[current_line] |
1090 | mov eax,[current_line] |
1096 | mov [error_line],eax |
1091 | mov [error_line],eax |
1097 | find_end_directive: |
1092 | find_end_directive: |
1098 | call skip_symbol |
1093 | call skip_symbol |
1099 | jnc find_end_directive |
1094 | jnc find_end_directive |
1100 | lods byte [esi] |
1095 | lods byte [esi] |
1101 | cmp al,0Fh |
1096 | cmp al,0Fh |
1102 | jne no_end_directive |
1097 | jne no_end_directive |
1103 | lods dword [esi] |
1098 | lods dword [esi] |
1104 | mov [current_line],eax |
1099 | mov [current_line],eax |
1105 | skip_labels: |
1100 | skip_labels: |
1106 | cmp byte [esi],2 |
1101 | cmp byte [esi],2 |
1107 | jne labels_ok |
1102 | jne labels_ok |
1108 | add esi,6 |
1103 | add esi,6 |
1109 | jmp skip_labels |
1104 | jmp skip_labels |
1110 | labels_ok: |
1105 | labels_ok: |
1111 | cmp byte [esi],1 |
1106 | cmp byte [esi],1 |
1112 | jne find_end_directive |
1107 | jne find_end_directive |
1113 | mov ax,[esi+1] |
1108 | mov ax,[esi+1] |
1114 | cmp ax,prefix_instruction-instruction_handler |
1109 | cmp ax,prefix_instruction-instruction_handler |
1115 | je find_end_directive |
1110 | je find_end_directive |
1116 | add esi,4 |
1111 | add esi,4 |
1117 | cmp ax,repeat_directive-instruction_handler |
1112 | cmp ax,repeat_directive-instruction_handler |
1118 | je skip_repeat |
1113 | je skip_repeat |
1119 | cmp ax,while_directive-instruction_handler |
1114 | cmp ax,while_directive-instruction_handler |
1120 | je skip_while |
1115 | je skip_while |
1121 | cmp ax,if_directive-instruction_handler |
1116 | cmp ax,if_directive-instruction_handler |
1122 | je skip_if |
1117 | je skip_if |
1123 | cmp ax,else_directive-instruction_handler |
1118 | cmp ax,else_directive-instruction_handler |
1124 | je structure_end |
1119 | je structure_end |
1125 | cmp ax,end_directive-instruction_handler |
1120 | cmp ax,end_directive-instruction_handler |
1126 | jne find_end_directive |
1121 | jne find_end_directive |
1127 | cmp byte [esi],1 |
1122 | cmp byte [esi],1 |
1128 | jne find_end_directive |
1123 | jne find_end_directive |
1129 | mov ax,[esi+1] |
1124 | mov ax,[esi+1] |
1130 | add esi,4 |
1125 | add esi,4 |
1131 | cmp ax,repeat_directive-instruction_handler |
1126 | cmp ax,repeat_directive-instruction_handler |
1132 | je structure_end |
1127 | je structure_end |
1133 | cmp ax,while_directive-instruction_handler |
1128 | cmp ax,while_directive-instruction_handler |
1134 | je structure_end |
1129 | je structure_end |
1135 | cmp ax,if_directive-instruction_handler |
1130 | cmp ax,if_directive-instruction_handler |
1136 | jne find_end_directive |
1131 | jne find_end_directive |
1137 | structure_end: |
1132 | structure_end: |
1138 | pop [error_line] |
1133 | pop [error_line] |
1139 | ret |
1134 | ret |
1140 | no_end_directive: |
1135 | no_end_directive: |
1141 | mov eax,[error_line] |
1136 | mov eax,[error_line] |
1142 | mov [current_line],eax |
1137 | mov [current_line],eax |
1143 | jmp missing_end_directive |
1138 | jmp missing_end_directive |
1144 | skip_repeat: |
1139 | skip_repeat: |
1145 | call find_end_repeat |
1140 | call find_end_repeat |
1146 | jmp find_end_directive |
1141 | jmp find_end_directive |
1147 | skip_while: |
1142 | skip_while: |
1148 | call find_end_while |
1143 | call find_end_while |
1149 | jmp find_end_directive |
1144 | jmp find_end_directive |
1150 | skip_if: |
1145 | skip_if: |
1151 | call skip_if_block |
1146 | call skip_if_block |
1152 | jmp find_end_directive |
1147 | jmp find_end_directive |
1153 | skip_if_block: |
1148 | skip_if_block: |
1154 | call find_else |
1149 | call find_else |
1155 | jc if_block_skipped |
1150 | jc if_block_skipped |
1156 | cmp byte [esi],1 |
1151 | cmp byte [esi],1 |
1157 | jne skip_after_else |
1152 | jne skip_after_else |
1158 | cmp word [esi+1],if_directive-instruction_handler |
1153 | cmp word [esi+1],if_directive-instruction_handler |
1159 | jne skip_after_else |
1154 | jne skip_after_else |
1160 | add esi,4 |
1155 | add esi,4 |
1161 | jmp skip_if_block |
1156 | jmp skip_if_block |
1162 | skip_after_else: |
1157 | skip_after_else: |
1163 | call find_end_if |
1158 | call find_end_if |
1164 | if_block_skipped: |
1159 | if_block_skipped: |
1165 | ret |
1160 | ret |
1166 | end_directive: |
1161 | end_directive: |
1167 | lods byte [esi] |
1162 | lods byte [esi] |
1168 | cmp al,1 |
1163 | cmp al,1 |
1169 | jne invalid_argument |
1164 | jne invalid_argument |
1170 | lods word [esi] |
1165 | lods word [esi] |
1171 | inc esi |
1166 | inc esi |
1172 | cmp ax,virtual_directive-instruction_handler |
1167 | cmp ax,virtual_directive-instruction_handler |
1173 | je end_virtual |
1168 | je end_virtual |
1174 | cmp ax,repeat_directive-instruction_handler |
1169 | cmp ax,repeat_directive-instruction_handler |
1175 | je end_repeat |
1170 | je end_repeat |
1176 | cmp ax,while_directive-instruction_handler |
1171 | cmp ax,while_directive-instruction_handler |
1177 | je end_while |
1172 | je end_while |
1178 | cmp ax,if_directive-instruction_handler |
1173 | cmp ax,if_directive-instruction_handler |
1179 | je end_if |
1174 | je end_if |
1180 | cmp ax,data_directive-instruction_handler |
1175 | cmp ax,data_directive-instruction_handler |
1181 | je end_data |
1176 | je end_data |
1182 | jmp invalid_argument |
1177 | jmp invalid_argument |
1183 | break_directive: |
1178 | break_directive: |
1184 | mov ebx,[structures_buffer] |
1179 | mov ebx,[structures_buffer] |
1185 | mov al,[esi] |
1180 | mov al,[esi] |
1186 | or al,al |
1181 | or al,al |
1187 | jz find_breakable_structure |
1182 | jz find_breakable_structure |
1188 | cmp al,0Fh |
1183 | cmp al,0Fh |
1189 | jne extra_characters_on_line |
1184 | jne extra_characters_on_line |
1190 | find_breakable_structure: |
1185 | find_breakable_structure: |
1191 | cmp ebx,[additional_memory_end] |
1186 | cmp ebx,[additional_memory_end] |
1192 | je unexpected_instruction |
1187 | je unexpected_instruction |
1193 | mov ax,[ebx] |
1188 | mov ax,[ebx] |
1194 | cmp ax,repeat_directive-instruction_handler |
1189 | cmp ax,repeat_directive-instruction_handler |
1195 | je break_repeat |
1190 | je break_repeat |
1196 | cmp ax,while_directive-instruction_handler |
1191 | cmp ax,while_directive-instruction_handler |
1197 | je break_while |
1192 | je break_while |
1198 | cmp ax,if_directive-instruction_handler |
1193 | cmp ax,if_directive-instruction_handler |
1199 | je break_if |
1194 | je break_if |
1200 | add ebx,20h |
1195 | add ebx,20h |
1201 | jmp find_breakable_structure |
1196 | jmp find_breakable_structure |
1202 | break_if: |
1197 | break_if: |
1203 | push [current_line] |
1198 | push [current_line] |
1204 | mov eax,[ebx+4] |
1199 | mov eax,[ebx+4] |
1205 | mov [current_line],eax |
1200 | mov [current_line],eax |
1206 | call remove_structure_data |
1201 | call remove_structure_data |
1207 | call skip_if_block |
1202 | call skip_if_block |
1208 | pop [current_line] |
1203 | pop [current_line] |
1209 | mov ebx,[structures_buffer] |
1204 | mov ebx,[structures_buffer] |
1210 | jmp find_breakable_structure |
1205 | jmp find_breakable_structure |
1211 | break_repeat: |
1206 | break_repeat: |
1212 | push ebx |
1207 | push ebx |
1213 | call find_end_repeat |
1208 | call find_end_repeat |
1214 | pop ebx |
1209 | pop ebx |
1215 | jmp stop_repeat |
1210 | jmp stop_repeat |
1216 | break_while: |
1211 | break_while: |
1217 | push ebx |
1212 | push ebx |
1218 | jmp stop_while |
1213 | jmp stop_while |
1219 | 1214 | ||
1220 | data_bytes: |
1215 | data_bytes: |
1221 | call define_data |
1216 | call define_data |
1222 | lods byte [esi] |
1217 | lods byte [esi] |
1223 | cmp al,'(' |
1218 | cmp al,'(' |
1224 | je get_byte |
1219 | je get_byte |
1225 | cmp al,'?' |
1220 | cmp al,'?' |
1226 | jne invalid_argument |
1221 | jne invalid_argument |
1227 | mov eax,edi |
1222 | mov eax,edi |
1228 | mov byte [edi],0 |
1223 | mov byte [edi],0 |
1229 | inc edi |
1224 | inc edi |
1230 | jmp undefined_data |
1225 | jmp undefined_data |
1231 | get_byte: |
1226 | get_byte: |
1232 | cmp byte [esi],0 |
1227 | cmp byte [esi],0 |
1233 | je get_string |
1228 | je get_string |
1234 | call get_byte_value |
1229 | call get_byte_value |
1235 | stos byte [edi] |
1230 | stos byte [edi] |
1236 | ret |
1231 | ret |
1237 | get_string: |
1232 | get_string: |
1238 | inc esi |
1233 | inc esi |
1239 | lods dword [esi] |
1234 | lods dword [esi] |
1240 | mov ecx,eax |
1235 | mov ecx,eax |
1241 | lea eax,[edi+ecx] |
1236 | lea eax,[edi+ecx] |
1242 | cmp eax,[display_buffer] |
1237 | cmp eax,[display_buffer] |
1243 | ja out_of_memory |
1238 | ja out_of_memory |
1244 | rep movs byte [edi],[esi] |
1239 | rep movs byte [edi],[esi] |
1245 | inc esi |
1240 | inc esi |
1246 | ret |
1241 | ret |
1247 | undefined_data: |
1242 | undefined_data: |
1248 | cmp [virtual_data],0 |
1243 | cmp [virtual_data],0 |
1249 | je mark_undefined_data |
1244 | je mark_undefined_data |
1250 | ret |
1245 | ret |
1251 | mark_undefined_data: |
1246 | mark_undefined_data: |
1252 | cmp eax,[undefined_data_end] |
1247 | cmp eax,[undefined_data_end] |
1253 | je undefined_data_ok |
1248 | je undefined_data_ok |
1254 | mov [undefined_data_start],eax |
1249 | mov [undefined_data_start],eax |
1255 | undefined_data_ok: |
1250 | undefined_data_ok: |
1256 | mov [undefined_data_end],edi |
1251 | mov [undefined_data_end],edi |
1257 | ret |
1252 | ret |
1258 | define_data: |
1253 | define_data: |
1259 | cmp edi,[display_buffer] |
1254 | cmp edi,[display_buffer] |
1260 | jae out_of_memory |
1255 | jae out_of_memory |
1261 | cmp byte [esi],'(' |
1256 | cmp byte [esi],'(' |
1262 | jne simple_data_value |
1257 | jne simple_data_value |
1263 | mov ebx,esi |
1258 | mov ebx,esi |
1264 | inc esi |
1259 | inc esi |
1265 | call skip_expression |
1260 | call skip_expression |
1266 | xchg esi,ebx |
1261 | xchg esi,ebx |
1267 | cmp byte [ebx],81h |
1262 | cmp byte [ebx],81h |
1268 | jne simple_data_value |
1263 | jne simple_data_value |
1269 | inc esi |
1264 | inc esi |
1270 | call get_count_value |
1265 | call get_count_value |
1271 | inc esi |
1266 | inc esi |
1272 | or eax,eax |
1267 | or eax,eax |
1273 | jz duplicate_zero_times |
1268 | jz duplicate_zero_times |
1274 | cmp byte [esi],'{' |
1269 | cmp byte [esi],'{' |
1275 | jne duplicate_single_data_value |
1270 | jne duplicate_single_data_value |
1276 | inc esi |
1271 | inc esi |
1277 | duplicate_data: |
1272 | duplicate_data: |
1278 | push eax esi |
1273 | push eax esi |
1279 | duplicated_values: |
1274 | duplicated_values: |
1280 | cmp edi,[display_buffer] |
1275 | cmp edi,[display_buffer] |
1281 | jae out_of_memory |
1276 | jae out_of_memory |
1282 | call near dword [esp+8] |
1277 | call near dword [esp+8] |
1283 | lods byte [esi] |
1278 | lods byte [esi] |
1284 | cmp al,',' |
1279 | cmp al,',' |
1285 | je duplicated_values |
1280 | je duplicated_values |
1286 | cmp al,'}' |
1281 | cmp al,'}' |
1287 | jne invalid_argument |
1282 | jne invalid_argument |
1288 | pop ebx eax |
1283 | pop ebx eax |
1289 | dec eax |
1284 | dec eax |
1290 | jz data_defined |
1285 | jz data_defined |
1291 | mov esi,ebx |
1286 | mov esi,ebx |
1292 | jmp duplicate_data |
1287 | jmp duplicate_data |
1293 | duplicate_single_data_value: |
1288 | duplicate_single_data_value: |
1294 | cmp edi,[display_buffer] |
1289 | cmp edi,[display_buffer] |
1295 | jae out_of_memory |
1290 | jae out_of_memory |
1296 | push eax esi |
1291 | push eax esi |
1297 | call near dword [esp+8] |
1292 | call near dword [esp+8] |
1298 | pop ebx eax |
1293 | pop ebx eax |
1299 | dec eax |
1294 | dec eax |
1300 | jz data_defined |
1295 | jz data_defined |
1301 | mov esi,ebx |
1296 | mov esi,ebx |
1302 | jmp duplicate_single_data_value |
1297 | jmp duplicate_single_data_value |
1303 | duplicate_zero_times: |
1298 | duplicate_zero_times: |
1304 | cmp byte [esi],'{' |
1299 | cmp byte [esi],'{' |
1305 | jne skip_single_data_value |
1300 | jne skip_single_data_value |
1306 | inc esi |
1301 | inc esi |
1307 | skip_data_value: |
1302 | skip_data_value: |
1308 | call skip_symbol |
1303 | call skip_symbol |
1309 | jc invalid_argument |
1304 | jc invalid_argument |
1310 | cmp byte [esi],'}' |
1305 | cmp byte [esi],'}' |
1311 | jne skip_data_value |
1306 | jne skip_data_value |
1312 | inc esi |
1307 | inc esi |
1313 | jmp data_defined |
1308 | jmp data_defined |
1314 | skip_single_data_value: |
1309 | skip_single_data_value: |
1315 | call skip_symbol |
1310 | call skip_symbol |
1316 | jmp data_defined |
1311 | jmp data_defined |
1317 | simple_data_value: |
1312 | simple_data_value: |
1318 | cmp edi,[display_buffer] |
1313 | cmp edi,[display_buffer] |
1319 | jae out_of_memory |
1314 | jae out_of_memory |
1320 | call near dword [esp] |
1315 | call near dword [esp] |
1321 | data_defined: |
1316 | data_defined: |
1322 | lods byte [esi] |
1317 | lods byte [esi] |
1323 | cmp al,',' |
1318 | cmp al,',' |
1324 | je define_data |
1319 | je define_data |
1325 | dec esi |
1320 | dec esi |
1326 | add esp,4 |
1321 | add esp,4 |
1327 | jmp instruction_assembled |
1322 | jmp instruction_assembled |
1328 | data_unicode: |
1323 | data_unicode: |
1329 | or [base_code],-1 |
1324 | or [base_code],-1 |
1330 | jmp define_words |
1325 | jmp define_words |
1331 | data_words: |
1326 | data_words: |
1332 | mov [base_code],0 |
1327 | mov [base_code],0 |
1333 | define_words: |
1328 | define_words: |
1334 | call define_data |
1329 | call define_data |
1335 | lods byte [esi] |
1330 | lods byte [esi] |
1336 | cmp al,'(' |
1331 | cmp al,'(' |
1337 | je get_word |
1332 | je get_word |
1338 | cmp al,'?' |
1333 | cmp al,'?' |
1339 | jne invalid_argument |
1334 | jne invalid_argument |
1340 | mov eax,edi |
1335 | mov eax,edi |
1341 | mov word [edi],0 |
1336 | and word [edi],0 |
1342 | scas word [edi] |
1337 | scas word [edi] |
1343 | jmp undefined_data |
1338 | jmp undefined_data |
1344 | ret |
1339 | ret |
1345 | get_word: |
1340 | get_word: |
1346 | cmp [base_code],0 |
1341 | cmp [base_code],0 |
1347 | je word_data_value |
1342 | je word_data_value |
1348 | cmp byte [esi],0 |
1343 | cmp byte [esi],0 |
1349 | je word_string |
1344 | je word_string |
1350 | word_data_value: |
1345 | word_data_value: |
1351 | call get_word_value |
1346 | call get_word_value |
1352 | call mark_relocation |
1347 | call mark_relocation |
1353 | stos word [edi] |
1348 | stos word [edi] |
1354 | ret |
1349 | ret |
1355 | word_string: |
1350 | word_string: |
1356 | inc esi |
1351 | inc esi |
1357 | lods dword [esi] |
1352 | lods dword [esi] |
1358 | mov ecx,eax |
1353 | mov ecx,eax |
1359 | jecxz word_string_ok |
1354 | jecxz word_string_ok |
1360 | lea eax,[edi+ecx*2] |
1355 | lea eax,[edi+ecx*2] |
1361 | cmp eax,[display_buffer] |
1356 | cmp eax,[display_buffer] |
1362 | ja out_of_memory |
1357 | ja out_of_memory |
1363 | xor ah,ah |
1358 | xor ah,ah |
1364 | copy_word_string: |
1359 | copy_word_string: |
1365 | lods byte [esi] |
1360 | lods byte [esi] |
1366 | stos word [edi] |
1361 | stos word [edi] |
1367 | loop copy_word_string |
1362 | loop copy_word_string |
1368 | word_string_ok: |
1363 | word_string_ok: |
1369 | inc esi |
1364 | inc esi |
1370 | ret |
1365 | ret |
1371 | data_dwords: |
1366 | data_dwords: |
1372 | call define_data |
1367 | call define_data |
1373 | lods byte [esi] |
1368 | lods byte [esi] |
1374 | cmp al,'(' |
1369 | cmp al,'(' |
1375 | je get_dword |
1370 | je get_dword |
1376 | cmp al,'?' |
1371 | cmp al,'?' |
1377 | jne invalid_argument |
1372 | jne invalid_argument |
1378 | mov eax,edi |
1373 | mov eax,edi |
1379 | mov dword [edi],0 |
1374 | and dword [edi],0 |
1380 | scas dword [edi] |
1375 | scas dword [edi] |
1381 | jmp undefined_data |
1376 | jmp undefined_data |
1382 | get_dword: |
1377 | get_dword: |
1383 | push esi |
1378 | push esi |
1384 | call get_dword_value |
1379 | call get_dword_value |
1385 | pop ebx |
1380 | pop ebx |
1386 | cmp byte [esi],':' |
1381 | cmp byte [esi],':' |
1387 | je complex_dword |
1382 | je complex_dword |
1388 | call mark_relocation |
1383 | call mark_relocation |
1389 | stos dword [edi] |
1384 | stos dword [edi] |
1390 | ret |
1385 | ret |
1391 | complex_dword: |
1386 | complex_dword: |
1392 | mov esi,ebx |
1387 | mov esi,ebx |
1393 | cmp byte [esi],'.' |
1388 | cmp byte [esi],'.' |
1394 | je invalid_value |
1389 | je invalid_value |
1395 | call get_word_value |
1390 | call get_word_value |
1396 | push eax |
1391 | push eax |
1397 | inc esi |
1392 | inc esi |
1398 | lods byte [esi] |
1393 | lods byte [esi] |
1399 | cmp al,'(' |
1394 | cmp al,'(' |
1400 | jne invalid_operand |
1395 | jne invalid_operand |
1401 | mov al,[value_type] |
1396 | mov al,[value_type] |
1402 | push eax |
1397 | push eax |
1403 | cmp byte [esi],'.' |
1398 | cmp byte [esi],'.' |
1404 | je invalid_value |
1399 | je invalid_value |
1405 | call get_word_value |
1400 | call get_word_value |
1406 | call mark_relocation |
1401 | call mark_relocation |
1407 | stos word [edi] |
1402 | stos word [edi] |
1408 | pop eax |
1403 | pop eax |
1409 | mov [value_type],al |
1404 | mov [value_type],al |
1410 | pop eax |
1405 | pop eax |
1411 | call mark_relocation |
1406 | call mark_relocation |
1412 | stos word [edi] |
1407 | stos word [edi] |
1413 | ret |
1408 | ret |
1414 | data_pwords: |
1409 | data_pwords: |
1415 | call define_data |
1410 | call define_data |
1416 | lods byte [esi] |
1411 | lods byte [esi] |
1417 | cmp al,'(' |
1412 | cmp al,'(' |
1418 | je get_pword |
1413 | je get_pword |
1419 | cmp al,'?' |
1414 | cmp al,'?' |
1420 | jne invalid_argument |
1415 | jne invalid_argument |
1421 | mov eax,edi |
1416 | mov eax,edi |
1422 | mov dword [edi],0 |
1417 | and dword [edi],0 |
1423 | scas dword [edi] |
1418 | scas dword [edi] |
1424 | mov word [edi],0 |
1419 | and word [edi],0 |
1425 | scas word [edi] |
1420 | scas word [edi] |
1426 | jmp undefined_data |
1421 | jmp undefined_data |
1427 | get_pword: |
1422 | get_pword: |
1428 | push esi |
1423 | push esi |
1429 | call get_pword_value |
1424 | call get_pword_value |
1430 | pop ebx |
1425 | pop ebx |
1431 | cmp byte [esi],':' |
1426 | cmp byte [esi],':' |
1432 | je complex_pword |
1427 | je complex_pword |
1433 | call mark_relocation |
1428 | call mark_relocation |
1434 | stos dword [edi] |
1429 | stos dword [edi] |
1435 | mov ax,dx |
1430 | mov ax,dx |
1436 | stos word [edi] |
1431 | stos word [edi] |
1437 | ret |
1432 | ret |
1438 | complex_pword: |
1433 | complex_pword: |
1439 | mov esi,ebx |
1434 | mov esi,ebx |
1440 | cmp byte [esi],'.' |
1435 | cmp byte [esi],'.' |
1441 | je invalid_value |
1436 | je invalid_value |
1442 | call get_word_value |
1437 | call get_word_value |
1443 | push eax |
1438 | push eax |
1444 | inc esi |
1439 | inc esi |
1445 | lods byte [esi] |
1440 | lods byte [esi] |
1446 | cmp al,'(' |
1441 | cmp al,'(' |
1447 | jne invalid_operand |
1442 | jne invalid_operand |
1448 | mov al,[value_type] |
1443 | mov al,[value_type] |
1449 | push eax |
1444 | push eax |
1450 | cmp byte [esi],'.' |
1445 | cmp byte [esi],'.' |
1451 | je invalid_value |
1446 | je invalid_value |
1452 | call get_dword_value |
1447 | call get_dword_value |
1453 | call mark_relocation |
1448 | call mark_relocation |
1454 | stos dword [edi] |
1449 | stos dword [edi] |
1455 | pop eax |
1450 | pop eax |
1456 | mov [value_type],al |
1451 | mov [value_type],al |
1457 | pop eax |
1452 | pop eax |
1458 | call mark_relocation |
1453 | call mark_relocation |
1459 | stos word [edi] |
1454 | stos word [edi] |
1460 | ret |
1455 | ret |
1461 | data_qwords: |
1456 | data_qwords: |
1462 | call define_data |
1457 | call define_data |
1463 | lods byte [esi] |
1458 | lods byte [esi] |
1464 | cmp al,'(' |
1459 | cmp al,'(' |
1465 | je get_qword |
1460 | je get_qword |
1466 | cmp al,'?' |
1461 | cmp al,'?' |
1467 | jne invalid_argument |
1462 | jne invalid_argument |
1468 | mov eax,edi |
1463 | mov eax,edi |
1469 | mov dword [edi],0 |
1464 | and dword [edi],0 |
1470 | scas dword [edi] |
1465 | scas dword [edi] |
1471 | mov dword [edi],0 |
1466 | and dword [edi],0 |
1472 | scas dword [edi] |
1467 | scas dword [edi] |
1473 | jmp undefined_data |
1468 | jmp undefined_data |
1474 | get_qword: |
1469 | get_qword: |
1475 | call get_qword_value |
1470 | call get_qword_value |
1476 | call mark_relocation |
1471 | call mark_relocation |
1477 | stos dword [edi] |
1472 | stos dword [edi] |
1478 | mov eax,edx |
1473 | mov eax,edx |
1479 | stos dword [edi] |
1474 | stos dword [edi] |
1480 | ret |
1475 | ret |
1481 | data_twords: |
1476 | data_twords: |
1482 | call define_data |
1477 | call define_data |
1483 | lods byte [esi] |
1478 | lods byte [esi] |
1484 | cmp al,'(' |
1479 | cmp al,'(' |
1485 | je get_tword |
1480 | je get_tword |
1486 | cmp al,'?' |
1481 | cmp al,'?' |
1487 | jne invalid_argument |
1482 | jne invalid_argument |
1488 | mov eax,edi |
1483 | mov eax,edi |
1489 | mov dword [edi],0 |
1484 | and dword [edi],0 |
1490 | scas dword [edi] |
1485 | scas dword [edi] |
1491 | mov dword [edi],0 |
1486 | and dword [edi],0 |
1492 | scas dword [edi] |
1487 | scas dword [edi] |
1493 | mov word [edi],0 |
1488 | and word [edi],0 |
1494 | scas word [edi] |
1489 | scas word [edi] |
1495 | jmp undefined_data |
1490 | jmp undefined_data |
1496 | get_tword: |
1491 | get_tword: |
1497 | cmp byte [esi],'.' |
1492 | cmp byte [esi],'.' |
1498 | jne complex_tword |
1493 | jne complex_tword |
1499 | inc esi |
1494 | inc esi |
1500 | cmp word [esi+8],8000h |
1495 | cmp word [esi+8],8000h |
1501 | je fp_zero_tword |
1496 | je fp_zero_tword |
1502 | mov eax,[esi] |
1497 | mov eax,[esi] |
1503 | stos dword [edi] |
1498 | stos dword [edi] |
1504 | mov eax,[esi+4] |
1499 | mov eax,[esi+4] |
1505 | stos dword [edi] |
1500 | stos dword [edi] |
1506 | mov ax,[esi+8] |
1501 | mov ax,[esi+8] |
1507 | add ax,3FFFh |
1502 | add ax,3FFFh |
1508 | jo value_out_of_range |
1503 | jo value_out_of_range |
1509 | cmp ax,7FFFh |
1504 | cmp ax,7FFFh |
1510 | jge value_out_of_range |
1505 | jge value_out_of_range |
1511 | cmp ax,0 |
1506 | cmp ax,0 |
1512 | jg tword_exp_ok |
1507 | jg tword_exp_ok |
1513 | mov cx,ax |
1508 | mov cx,ax |
1514 | neg cx |
1509 | neg cx |
1515 | inc cx |
1510 | inc cx |
1516 | cmp cx,64 |
1511 | cmp cx,64 |
1517 | jae value_out_of_range |
1512 | jae value_out_of_range |
1518 | cmp cx,32 |
1513 | cmp cx,32 |
1519 | ja large_shift |
1514 | ja large_shift |
1520 | mov eax,[esi] |
1515 | mov eax,[esi] |
1521 | mov edx,[esi+4] |
1516 | mov edx,[esi+4] |
1522 | mov ebx,edx |
1517 | mov ebx,edx |
1523 | shr edx,cl |
1518 | shr edx,cl |
1524 | shrd eax,ebx,cl |
1519 | shrd eax,ebx,cl |
1525 | jmp tword_mantissa_shift_done |
1520 | jmp tword_mantissa_shift_done |
1526 | large_shift: |
1521 | large_shift: |
1527 | sub cx,32 |
1522 | sub cx,32 |
1528 | xor edx,edx |
1523 | xor edx,edx |
1529 | mov eax,[esi+4] |
1524 | mov eax,[esi+4] |
1530 | shr eax,cl |
1525 | shr eax,cl |
1531 | tword_mantissa_shift_done: |
1526 | tword_mantissa_shift_done: |
1532 | jnc store_shifted_mantissa |
1527 | jnc store_shifted_mantissa |
1533 | add eax,1 |
1528 | add eax,1 |
1534 | adc edx,0 |
1529 | adc edx,0 |
1535 | store_shifted_mantissa: |
1530 | store_shifted_mantissa: |
1536 | mov [edi-8],eax |
1531 | mov [edi-8],eax |
1537 | mov [edi-4],edx |
1532 | mov [edi-4],edx |
1538 | xor ax,ax |
1533 | xor ax,ax |
1539 | test edx,1 shl 31 |
1534 | test edx,1 shl 31 |
1540 | jz tword_exp_ok |
1535 | jz tword_exp_ok |
1541 | inc ax |
1536 | inc ax |
1542 | tword_exp_ok: |
1537 | tword_exp_ok: |
1543 | mov bl,[esi+11] |
1538 | mov bl,[esi+11] |
1544 | shl bx,15 |
1539 | shl bx,15 |
1545 | or ax,bx |
1540 | or ax,bx |
1546 | stos word [edi] |
1541 | stos word [edi] |
1547 | add esi,13 |
1542 | add esi,13 |
1548 | ret |
1543 | ret |
1549 | fp_zero_tword: |
1544 | fp_zero_tword: |
1550 | xor eax,eax |
1545 | xor eax,eax |
1551 | stos dword [edi] |
1546 | stos dword [edi] |
1552 | stos dword [edi] |
1547 | stos dword [edi] |
1553 | mov al,[esi+11] |
1548 | mov al,[esi+11] |
1554 | shl ax,15 |
1549 | shl ax,15 |
1555 | stos word [edi] |
1550 | stos word [edi] |
1556 | add esi,13 |
1551 | add esi,13 |
1557 | ret |
1552 | ret |
1558 | complex_tword: |
1553 | complex_tword: |
1559 | call get_word_value |
1554 | call get_word_value |
1560 | push eax |
1555 | push eax |
1561 | cmp byte [esi],':' |
1556 | cmp byte [esi],':' |
1562 | jne invalid_operand |
1557 | jne invalid_operand |
1563 | inc esi |
1558 | inc esi |
1564 | lods byte [esi] |
1559 | lods byte [esi] |
1565 | cmp al,'(' |
1560 | cmp al,'(' |
1566 | jne invalid_operand |
1561 | jne invalid_operand |
1567 | mov al,[value_type] |
1562 | mov al,[value_type] |
1568 | push eax |
1563 | push eax |
1569 | cmp byte [esi],'.' |
1564 | cmp byte [esi],'.' |
1570 | je invalid_value |
1565 | je invalid_value |
1571 | call get_qword_value |
1566 | call get_qword_value |
1572 | call mark_relocation |
1567 | call mark_relocation |
1573 | stos dword [edi] |
1568 | stos dword [edi] |
1574 | mov eax,edx |
1569 | mov eax,edx |
1575 | stos dword [edi] |
1570 | stos dword [edi] |
1576 | pop eax |
1571 | pop eax |
1577 | mov [value_type],al |
1572 | mov [value_type],al |
1578 | pop eax |
1573 | pop eax |
1579 | call mark_relocation |
1574 | call mark_relocation |
1580 | stos word [edi] |
1575 | stos word [edi] |
1581 | ret |
1576 | ret |
1582 | data_file: |
1577 | data_file: |
1583 | lods word [esi] |
1578 | lods word [esi] |
1584 | cmp ax,'(' |
1579 | cmp ax,'(' |
1585 | jne invalid_argument |
1580 | jne invalid_argument |
1586 | add esi,4 |
1581 | add esi,4 |
1587 | call open_binary_file |
1582 | call open_binary_file |
1588 | mov eax,[esi-4] |
1583 | mov eax,[esi-4] |
1589 | lea esi,[esi+eax+1] |
1584 | lea esi,[esi+eax+1] |
1590 | mov al,2 |
1585 | mov al,2 |
1591 | xor edx,edx |
1586 | xor edx,edx |
1592 | call lseek |
1587 | call lseek |
1593 | push eax |
1588 | push eax |
1594 | xor edx,edx |
1589 | xor edx,edx |
1595 | cmp byte [esi],':' |
1590 | cmp byte [esi],':' |
1596 | jne position_ok |
1591 | jne position_ok |
1597 | inc esi |
1592 | inc esi |
1598 | cmp byte [esi],'(' |
1593 | cmp byte [esi],'(' |
1599 | jne invalid_argument |
1594 | jne invalid_argument |
1600 | inc esi |
1595 | inc esi |
1601 | cmp byte [esi],'.' |
1596 | cmp byte [esi],'.' |
1602 | je invalid_value |
1597 | je invalid_value |
1603 | push ebx |
1598 | push ebx |
1604 | call get_count_value |
1599 | call get_count_value |
1605 | pop ebx |
1600 | pop ebx |
1606 | mov edx,eax |
1601 | mov edx,eax |
1607 | sub [esp],edx |
1602 | sub [esp],edx |
1608 | jc value_out_of_range |
1603 | jc value_out_of_range |
1609 | position_ok: |
1604 | position_ok: |
1610 | cmp byte [esi],',' |
1605 | cmp byte [esi],',' |
1611 | jne size_ok |
1606 | jne size_ok |
1612 | inc esi |
1607 | inc esi |
1613 | cmp byte [esi],'(' |
1608 | cmp byte [esi],'(' |
1614 | jne invalid_argument |
1609 | jne invalid_argument |
1615 | inc esi |
1610 | inc esi |
1616 | cmp byte [esi],'.' |
1611 | cmp byte [esi],'.' |
1617 | je invalid_value |
1612 | je invalid_value |
1618 | push ebx edx |
1613 | push ebx edx |
1619 | call get_count_value |
1614 | call get_count_value |
1620 | pop edx ebx |
1615 | pop edx ebx |
1621 | cmp eax,[esp] |
1616 | cmp eax,[esp] |
1622 | ja value_out_of_range |
1617 | ja value_out_of_range |
1623 | mov [esp],eax |
1618 | mov [esp],eax |
1624 | size_ok: |
1619 | size_ok: |
1625 | xor al,al |
1620 | xor al,al |
1626 | call lseek |
1621 | call lseek |
1627 | pop ecx |
1622 | pop ecx |
1628 | mov edx,edi |
1623 | mov edx,edi |
1629 | add edi,ecx |
1624 | add edi,ecx |
1630 | jc out_of_memory |
1625 | jc out_of_memory |
1631 | cmp edi,[display_buffer] |
1626 | cmp edi,[display_buffer] |
1632 | ja out_of_memory |
1627 | ja out_of_memory |
1633 | call read |
1628 | call read |
1634 | jc error_reading_file |
1629 | jc error_reading_file |
1635 | call close |
1630 | call close |
1636 | lods byte [esi] |
1631 | lods byte [esi] |
1637 | cmp al,',' |
1632 | cmp al,',' |
1638 | je data_file |
1633 | je data_file |
1639 | dec esi |
1634 | dec esi |
1640 | jmp instruction_assembled |
1635 | jmp instruction_assembled |
1641 | open_binary_file: |
1636 | open_binary_file: |
1642 | push esi |
1637 | push esi |
1643 | push edi |
1638 | push edi |
1644 | mov eax,[current_line] |
1639 | mov eax,[current_line] |
1645 | find_current_source_path: |
1640 | find_current_source_path: |
1646 | mov esi,[eax] |
1641 | mov esi,[eax] |
1647 | test byte [eax+7],80h |
1642 | test byte [eax+7],80h |
1648 | jz get_current_path |
1643 | jz get_current_path |
1649 | mov eax,[eax+12] |
1644 | mov eax,[eax+8] |
1650 | jmp find_current_source_path |
1645 | jmp find_current_source_path |
1651 | get_current_path: |
1646 | get_current_path: |
1652 | lodsb |
1647 | lodsb |
1653 | stosb |
1648 | stosb |
1654 | or al,al |
1649 | or al,al |
1655 | jnz get_current_path |
1650 | jnz get_current_path |
1656 | cut_current_path: |
1651 | cut_current_path: |
1657 | cmp edi,[esp] |
1652 | cmp edi,[esp] |
1658 | je current_path_ok |
1653 | je current_path_ok |
1659 | cmp byte [edi-1],'\' |
1654 | cmp byte [edi-1],'\' |
1660 | je current_path_ok |
1655 | je current_path_ok |
1661 | cmp byte [edi-1],'/' |
1656 | cmp byte [edi-1],'/' |
1662 | je current_path_ok |
1657 | je current_path_ok |
1663 | dec edi |
1658 | dec edi |
1664 | jmp cut_current_path |
1659 | jmp cut_current_path |
1665 | current_path_ok: |
1660 | current_path_ok: |
1666 | mov esi,[esp+4] |
1661 | mov esi,[esp+4] |
1667 | call preprocess_path |
1662 | call expand_path |
1668 | pop edx |
1663 | pop edx |
- | 1664 | mov esi,edx |
|
- | 1665 | call open |
|
- | 1666 | jnc file_opened |
|
- | 1667 | mov edx,[include_paths] |
|
- | 1668 | search_in_include_paths: |
|
- | 1669 | push edx esi |
|
- | 1670 | mov edi,esi |
|
- | 1671 | mov esi,[esp+4] |
|
- | 1672 | call get_include_directory |
|
- | 1673 | mov [esp+4],esi |
|
- | 1674 | mov esi,[esp+8] |
|
- | 1675 | call expand_path |
|
- | 1676 | pop edx |
|
1669 | mov esi,edx |
1677 | mov esi,edx |
1670 | call open |
1678 | call open |
1671 | jnc file_opened |
1679 | pop edx |
- | 1680 | jnc file_opened |
|
1672 | mov edi,esi |
1681 | cmp byte [edx],0 |
- | 1682 | jne search_in_include_paths |
|
- | 1683 | mov edi,esi |
|
1673 | mov esi,[esp] |
1684 | mov esi,[esp] |
1674 | push edi |
1685 | push edi |
1675 | call preprocess_path |
1686 | call expand_path |
1676 | pop edx |
1687 | pop edx |
1677 | mov esi,edx |
1688 | mov esi,edx |
1678 | call open |
1689 | call open |
1679 | jc file_not_found |
1690 | jc file_not_found |
1680 | file_opened: |
1691 | file_opened: |
1681 | mov edi,esi |
1692 | mov edi,esi |
1682 | pop esi |
1693 | pop esi |
1683 | ret |
1694 | ret |
1684 | reserve_bytes: |
1695 | reserve_bytes: |
1685 | lods byte [esi] |
1696 | lods byte [esi] |
1686 | cmp al,'(' |
1697 | cmp al,'(' |
1687 | jne invalid_argument |
1698 | jne invalid_argument |
1688 | cmp byte [esi],'.' |
1699 | cmp byte [esi],'.' |
1689 | je invalid_value |
1700 | je invalid_value |
1690 | call get_count_value |
1701 | call get_count_value |
1691 | mov ecx,eax |
1702 | mov ecx,eax |
1692 | mov edx,ecx |
1703 | mov edx,ecx |
1693 | add edx,edi |
1704 | add edx,edi |
1694 | jc out_of_memory |
1705 | jc out_of_memory |
1695 | cmp edx,[display_buffer] |
1706 | cmp edx,[display_buffer] |
1696 | ja out_of_memory |
1707 | ja out_of_memory |
1697 | push edi |
1708 | push edi |
1698 | cmp [next_pass_needed],0 |
1709 | cmp [next_pass_needed],0 |
1699 | je zero_bytes |
1710 | je zero_bytes |
1700 | add edi,ecx |
1711 | add edi,ecx |
1701 | jmp reserved_data |
1712 | jmp reserved_data |
1702 | zero_bytes: |
1713 | zero_bytes: |
1703 | xor eax,eax |
1714 | xor eax,eax |
1704 | shr ecx,1 |
1715 | shr ecx,1 |
1705 | jnc bytes_stosb_ok |
1716 | jnc bytes_stosb_ok |
1706 | stos byte [edi] |
1717 | stos byte [edi] |
1707 | bytes_stosb_ok: |
1718 | bytes_stosb_ok: |
1708 | shr ecx,1 |
1719 | shr ecx,1 |
1709 | jnc bytes_stosw_ok |
1720 | jnc bytes_stosw_ok |
1710 | stos word [edi] |
1721 | stos word [edi] |
1711 | bytes_stosw_ok: |
1722 | bytes_stosw_ok: |
1712 | rep stos dword [edi] |
1723 | rep stos dword [edi] |
1713 | reserved_data: |
1724 | reserved_data: |
1714 | pop eax |
1725 | pop eax |
1715 | call undefined_data |
1726 | call undefined_data |
1716 | jmp instruction_assembled |
1727 | jmp instruction_assembled |
1717 | reserve_words: |
1728 | reserve_words: |
1718 | lods byte [esi] |
1729 | lods byte [esi] |
1719 | cmp al,'(' |
1730 | cmp al,'(' |
1720 | jne invalid_argument |
1731 | jne invalid_argument |
1721 | cmp byte [esi],'.' |
1732 | cmp byte [esi],'.' |
1722 | je invalid_value |
1733 | je invalid_value |
1723 | call get_count_value |
1734 | call get_count_value |
1724 | mov ecx,eax |
1735 | mov ecx,eax |
1725 | mov edx,ecx |
1736 | mov edx,ecx |
1726 | shl edx,1 |
1737 | shl edx,1 |
1727 | jc out_of_memory |
1738 | jc out_of_memory |
1728 | add edx,edi |
1739 | add edx,edi |
1729 | jc out_of_memory |
1740 | jc out_of_memory |
1730 | cmp edx,[display_buffer] |
1741 | cmp edx,[display_buffer] |
1731 | ja out_of_memory |
1742 | ja out_of_memory |
1732 | push edi |
1743 | push edi |
1733 | cmp [next_pass_needed],0 |
1744 | cmp [next_pass_needed],0 |
1734 | je zero_words |
1745 | je zero_words |
1735 | lea edi,[edi+ecx*2] |
1746 | lea edi,[edi+ecx*2] |
1736 | jmp reserved_data |
1747 | jmp reserved_data |
1737 | zero_words: |
1748 | zero_words: |
1738 | xor eax,eax |
1749 | xor eax,eax |
1739 | shr ecx,1 |
1750 | shr ecx,1 |
1740 | jnc words_stosw_ok |
1751 | jnc words_stosw_ok |
1741 | stos word [edi] |
1752 | stos word [edi] |
1742 | words_stosw_ok: |
1753 | words_stosw_ok: |
1743 | rep stos dword [edi] |
1754 | rep stos dword [edi] |
1744 | jmp reserved_data |
1755 | jmp reserved_data |
1745 | reserve_dwords: |
1756 | reserve_dwords: |
1746 | lods byte [esi] |
1757 | lods byte [esi] |
1747 | cmp al,'(' |
1758 | cmp al,'(' |
1748 | jne invalid_argument |
1759 | jne invalid_argument |
1749 | cmp byte [esi],'.' |
1760 | cmp byte [esi],'.' |
1750 | je invalid_value |
1761 | je invalid_value |
1751 | call get_count_value |
1762 | call get_count_value |
1752 | mov ecx,eax |
1763 | mov ecx,eax |
1753 | mov edx,ecx |
1764 | mov edx,ecx |
1754 | shl edx,1 |
1765 | shl edx,1 |
1755 | jc out_of_memory |
1766 | jc out_of_memory |
1756 | shl edx,1 |
1767 | shl edx,1 |
1757 | jc out_of_memory |
1768 | jc out_of_memory |
1758 | add edx,edi |
1769 | add edx,edi |
1759 | jc out_of_memory |
1770 | jc out_of_memory |
1760 | cmp edx,[display_buffer] |
1771 | cmp edx,[display_buffer] |
1761 | ja out_of_memory |
1772 | ja out_of_memory |
1762 | push edi |
1773 | push edi |
1763 | cmp [next_pass_needed],0 |
1774 | cmp [next_pass_needed],0 |
1764 | je zero_dwords |
1775 | je zero_dwords |
1765 | lea edi,[edi+ecx*4] |
1776 | lea edi,[edi+ecx*4] |
1766 | jmp reserved_data |
1777 | jmp reserved_data |
1767 | zero_dwords: |
1778 | zero_dwords: |
1768 | xor eax,eax |
1779 | xor eax,eax |
1769 | rep stos dword [edi] |
1780 | rep stos dword [edi] |
1770 | jmp reserved_data |
1781 | jmp reserved_data |
1771 | reserve_pwords: |
1782 | reserve_pwords: |
1772 | lods byte [esi] |
1783 | lods byte [esi] |
1773 | cmp al,'(' |
1784 | cmp al,'(' |
1774 | jne invalid_argument |
1785 | jne invalid_argument |
1775 | cmp byte [esi],'.' |
1786 | cmp byte [esi],'.' |
1776 | je invalid_value |
1787 | je invalid_value |
1777 | call get_count_value |
1788 | call get_count_value |
1778 | mov ecx,eax |
1789 | mov ecx,eax |
1779 | shl ecx,1 |
1790 | shl ecx,1 |
1780 | jc out_of_memory |
1791 | jc out_of_memory |
1781 | add ecx,eax |
1792 | add ecx,eax |
1782 | mov edx,ecx |
1793 | mov edx,ecx |
1783 | shl edx,1 |
1794 | shl edx,1 |
1784 | jc out_of_memory |
1795 | jc out_of_memory |
1785 | add edx,edi |
1796 | add edx,edi |
1786 | jc out_of_memory |
1797 | jc out_of_memory |
1787 | cmp edx,[display_buffer] |
1798 | cmp edx,[display_buffer] |
1788 | ja out_of_memory |
1799 | ja out_of_memory |
1789 | push edi |
1800 | push edi |
1790 | cmp [next_pass_needed],0 |
1801 | cmp [next_pass_needed],0 |
1791 | je zero_words |
1802 | je zero_words |
1792 | lea edi,[edi+ecx*2] |
1803 | lea edi,[edi+ecx*2] |
1793 | jmp reserved_data |
1804 | jmp reserved_data |
1794 | reserve_qwords: |
1805 | reserve_qwords: |
1795 | lods byte [esi] |
1806 | lods byte [esi] |
1796 | cmp al,'(' |
1807 | cmp al,'(' |
1797 | jne invalid_argument |
1808 | jne invalid_argument |
1798 | cmp byte [esi],'.' |
1809 | cmp byte [esi],'.' |
1799 | je invalid_value |
1810 | je invalid_value |
1800 | call get_count_value |
1811 | call get_count_value |
1801 | mov ecx,eax |
1812 | mov ecx,eax |
1802 | shl ecx,1 |
1813 | shl ecx,1 |
1803 | jc out_of_memory |
1814 | jc out_of_memory |
1804 | mov edx,ecx |
1815 | mov edx,ecx |
1805 | shl edx,1 |
1816 | shl edx,1 |
1806 | jc out_of_memory |
1817 | jc out_of_memory |
1807 | shl edx,1 |
1818 | shl edx,1 |
1808 | jc out_of_memory |
1819 | jc out_of_memory |
1809 | add edx,edi |
1820 | add edx,edi |
1810 | jc out_of_memory |
1821 | jc out_of_memory |
1811 | cmp edx,[display_buffer] |
1822 | cmp edx,[display_buffer] |
1812 | ja out_of_memory |
1823 | ja out_of_memory |
1813 | push edi |
1824 | push edi |
1814 | cmp [next_pass_needed],0 |
1825 | cmp [next_pass_needed],0 |
1815 | je zero_dwords |
1826 | je zero_dwords |
1816 | lea edi,[edi+ecx*4] |
1827 | lea edi,[edi+ecx*4] |
1817 | jmp reserved_data |
1828 | jmp reserved_data |
1818 | reserve_twords: |
1829 | reserve_twords: |
1819 | lods byte [esi] |
1830 | lods byte [esi] |
1820 | cmp al,'(' |
1831 | cmp al,'(' |
1821 | jne invalid_argument |
1832 | jne invalid_argument |
1822 | cmp byte [esi],'.' |
1833 | cmp byte [esi],'.' |
1823 | je invalid_value |
1834 | je invalid_value |
1824 | call get_count_value |
1835 | call get_count_value |
1825 | mov ecx,eax |
1836 | mov ecx,eax |
1826 | shl ecx,2 |
1837 | shl ecx,2 |
1827 | jc out_of_memory |
1838 | jc out_of_memory |
1828 | add ecx,eax |
1839 | add ecx,eax |
1829 | mov edx,ecx |
1840 | mov edx,ecx |
1830 | shl edx,1 |
1841 | shl edx,1 |
1831 | jc out_of_memory |
1842 | jc out_of_memory |
1832 | add edx,edi |
1843 | add edx,edi |
1833 | jc out_of_memory |
1844 | jc out_of_memory |
1834 | cmp edx,[display_buffer] |
1845 | cmp edx,[display_buffer] |
1835 | ja out_of_memory |
1846 | ja out_of_memory |
1836 | push edi |
1847 | push edi |
1837 | cmp [next_pass_needed],0 |
1848 | cmp [next_pass_needed],0 |
1838 | je zero_words |
1849 | je zero_words |
1839 | lea edi,[edi+ecx*2] |
1850 | lea edi,[edi+ecx*2] |
1840 | jmp reserved_data |
1851 | jmp reserved_data |
1841 | align_directive: |
1852 | align_directive: |
1842 | lods byte [esi] |
1853 | lods byte [esi] |
1843 | cmp al,'(' |
1854 | cmp al,'(' |
1844 | jne invalid_argument |
1855 | jne invalid_argument |
1845 | cmp byte [esi],'.' |
1856 | cmp byte [esi],'.' |
1846 | je invalid_value |
1857 | je invalid_value |
1847 | call get_count_value |
1858 | call get_count_value |
1848 | mov edx,eax |
1859 | mov edx,eax |
1849 | dec edx |
1860 | dec edx |
1850 | test eax,edx |
1861 | test eax,edx |
1851 | jnz invalid_align_value |
1862 | jnz invalid_align_value |
1852 | or eax,eax |
1863 | or eax,eax |
1853 | jz invalid_align_value |
1864 | jz invalid_align_value |
1854 | cmp eax,1 |
1865 | cmp eax,1 |
1855 | je instruction_assembled |
1866 | je instruction_assembled |
1856 | mov ecx,edi |
1867 | mov ecx,edi |
1857 | sub ecx,dword [org_origin] |
1868 | sub ecx,dword [org_origin] |
1858 | cmp [org_registers],0 |
1869 | cmp [org_registers],0 |
1859 | jne section_not_aligned_enough |
1870 | jne section_not_aligned_enough |
1860 | cmp [labels_type],0 |
1871 | cmp [labels_type],0 |
1861 | je make_alignment |
1872 | je make_alignment |
1862 | cmp [output_format],3 |
1873 | cmp [output_format],3 |
1863 | je pe_alignment |
1874 | je pe_alignment |
1864 | mov ebx,[org_symbol] |
1875 | mov ebx,[org_symbol] |
1865 | cmp byte [ebx],0 |
1876 | cmp byte [ebx],0 |
1866 | jne section_not_aligned_enough |
1877 | jne section_not_aligned_enough |
1867 | cmp eax,[ebx+10h] |
1878 | cmp eax,[ebx+10h] |
1868 | jbe make_alignment |
1879 | jbe make_alignment |
1869 | jmp section_not_aligned_enough |
1880 | jmp section_not_aligned_enough |
1870 | pe_alignment: |
1881 | pe_alignment: |
1871 | cmp eax,1000h |
1882 | cmp eax,1000h |
1872 | ja section_not_aligned_enough |
1883 | ja section_not_aligned_enough |
1873 | make_alignment: |
1884 | make_alignment: |
1874 | dec eax |
1885 | dec eax |
1875 | and ecx,eax |
1886 | and ecx,eax |
1876 | jz instruction_assembled |
1887 | jz instruction_assembled |
1877 | neg ecx |
1888 | neg ecx |
1878 | add ecx,eax |
1889 | add ecx,eax |
1879 | inc ecx |
1890 | inc ecx |
1880 | mov edx,ecx |
1891 | mov edx,ecx |
1881 | add edx,edi |
1892 | add edx,edi |
1882 | jc out_of_memory |
1893 | jc out_of_memory |
1883 | cmp edx,[display_buffer] |
1894 | cmp edx,[display_buffer] |
1884 | ja out_of_memory |
1895 | ja out_of_memory |
1885 | push edi |
1896 | push edi |
1886 | cmp [next_pass_needed],0 |
1897 | cmp [next_pass_needed],0 |
1887 | je nops |
1898 | je nops |
1888 | add edi,ecx |
1899 | add edi,ecx |
1889 | jmp reserved_data |
1900 | jmp reserved_data |
1890 | invalid_align_value: |
1901 | invalid_align_value: |
1891 | cmp [error_line],0 |
1902 | cmp [error_line],0 |
1892 | jne instruction_assembled |
1903 | jne instruction_assembled |
1893 | mov eax,[current_line] |
1904 | mov eax,[current_line] |
1894 | mov [error_line],eax |
1905 | mov [error_line],eax |
1895 | mov [error],invalid_value |
1906 | mov [error],invalid_value |
1896 | jmp instruction_assembled |
1907 | jmp instruction_assembled |
1897 | nops: |
1908 | nops: |
1898 | mov eax,90909090h |
1909 | mov eax,90909090h |
1899 | shr ecx,1 |
1910 | shr ecx,1 |
1900 | jnc nops_stosb_ok |
1911 | jnc nops_stosb_ok |
1901 | stos byte [edi] |
1912 | stos byte [edi] |
1902 | nops_stosb_ok: |
1913 | nops_stosb_ok: |
1903 | shr ecx,1 |
1914 | shr ecx,1 |
1904 | jnc nops_stosw_ok |
1915 | jnc nops_stosw_ok |
1905 | stos word [edi] |
1916 | stos word [edi] |
1906 | nops_stosw_ok: |
1917 | nops_stosw_ok: |
1907 | rep stos dword [edi] |
1918 | rep stos dword [edi] |
1908 | jmp reserved_data |
1919 | jmp reserved_data |
1909 | err_directive: |
1920 | err_directive: |
1910 | mov al,[esi] |
1921 | mov al,[esi] |
1911 | cmp al,0Fh |
1922 | cmp al,0Fh |
1912 | je invoked_error |
1923 | je invoked_error |
1913 | or al,al |
1924 | or al,al |
1914 | jz invoked_error |
1925 | jz invoked_error |
1915 | jmp extra_characters_on_line |
1926 | jmp extra_characters_on_line |
1916 | assert_directive: |
1927 | assert_directive: |
1917 | call calculate_logical_expression |
1928 | call calculate_logical_expression |
1918 | or al,al |
1929 | or al,al |
1919 | jnz instruction_assembled |
1930 | jnz instruction_assembled |
1920 | cmp [error_line],0 |
1931 | cmp [error_line],0 |
1921 | jne instruction_assembled |
1932 | jne instruction_assembled |
1922 | mov eax,[current_line] |
1933 | mov eax,[current_line] |
1923 | mov [error_line],eax |
1934 | mov [error_line],eax |
1924 | mov [error],assertion_failed |
1935 | mov [error],assertion_failed |
1925 | jmp instruction_assembled |
1936 | jmp instruction_assembled |