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