Rev 7859 | Rev 8213 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7836 | leency | 1 | ; flat assembler |
2 | ; Copyright (c) 1999-2020, Tomasz Grysztar |
||
3 | ; All rights reserved. |
||
4 | |||
5 | init_memory: |
||
6 | |||
7 | ; mov ecx, 16*1024*1024 |
||
8 | ; |
||
9 | ; allocate_memory: |
||
10 | mcall SF_SYSTEM, SSF_GET_FREE_RAM |
||
11 | cmp eax, 0x38000000 shr 9 |
||
12 | jbe @f |
||
13 | mov eax, 0x38000000 shr 9 |
||
14 | @@: |
||
15 | shl eax, 9 |
||
16 | xchg eax, ecx |
||
17 | mov [memory_setting],ecx |
||
18 | mcall SF_SYS_MISC, SSF_MEM_ALLOC |
||
19 | or eax,eax |
||
20 | jz out_of_memory |
||
21 | mov [memblock], eax |
||
22 | mov [additional_memory],eax |
||
23 | add eax,[memory_setting] |
||
24 | mov [memory_end],eax |
||
25 | mov eax,[memory_setting] |
||
26 | shr eax,2 |
||
27 | add eax,[additional_memory] |
||
28 | mov [additional_memory_end],eax |
||
29 | mov [memory_start],eax |
||
7859 | leency | 30 | retn |
7836 | leency | 31 | |
32 | exit_program: |
||
33 | cmp [_mode],NORMAL_MODE |
||
34 | jne @f |
||
35 | mcall SF_SYS_MISC, SSF_MEM_FREE, [memblock] |
||
36 | mov esp,[processing_esp] |
||
37 | jmp still |
||
38 | @@: |
||
39 | or eax,-1 |
||
40 | mcall |
||
41 | |||
7863 | leency | 42 | get_tickcount: |
7836 | leency | 43 | push ebx |
44 | mcall SF_SYSTEM_GET,SSF_TIME_COUNT |
||
45 | imul eax,10 |
||
46 | pop ebx |
||
7859 | leency | 47 | retn |
7836 | leency | 48 | |
7863 | leency | 49 | macro BCDtoHEX al { |
50 | aam 16 |
||
51 | aad 10 } |
||
52 | |||
53 | make_timestamp: |
||
54 | mcall SF_GET_SYS_DATE ; $00SSMMHH (BCD) |
||
55 | mov edx,eax |
||
56 | shr eax,16 |
||
57 | BCDtoHEX al |
||
58 | push eax ; SECONDS |
||
59 | mov al,dh |
||
60 | BCDtoHEX al |
||
61 | push eax ; MINUTES |
||
62 | mov al,dl |
||
63 | BCDtoHEX al |
||
64 | push eax ; HOURS |
||
65 | mcall SF_GET_SYS_DATE ; $00DDMMYY (BCD) |
||
66 | mov edx,eax |
||
67 | shr eax,16 |
||
68 | BCDtoHEX al |
||
69 | push eax ; DAY |
||
70 | mov al,dl |
||
71 | BCDtoHEX al |
||
72 | add eax,2000 |
||
73 | push eax ; YEAR |
||
74 | mov ecx,eax |
||
75 | mov al,dh |
||
76 | BCDtoHEX al |
||
77 | push eax ; MONTH |
||
78 | ; ecx: YEAR |
||
79 | ; stack: MONTH, YEAR, DAY, HOURS, MINUTES, SECONDS, retaddr |
||
80 | mov eax,ecx |
||
81 | sub eax,1970 |
||
82 | mov ebx,365 |
||
83 | mul ebx |
||
84 | mov ebp,eax |
||
85 | mov eax,ecx |
||
86 | sub eax,1969 |
||
87 | shr eax,2 |
||
88 | add ebp,eax |
||
89 | mov eax,ecx |
||
90 | xor edx,edx |
||
91 | sub eax,1901 |
||
92 | mov ebx,100 |
||
93 | div ebx |
||
94 | sub ebp,eax |
||
95 | mov eax,ecx |
||
96 | xor edx,edx |
||
97 | sub eax,1601 |
||
98 | mov ebx,400 |
||
99 | div ebx |
||
100 | add ebp,eax |
||
101 | pop ecx |
||
102 | ; ecx: MONTH |
||
103 | ; stack: YEAR, DAY, HOURS, MINUTES, SECONDS, retaddr |
||
104 | mov eax,ecx |
||
105 | dec eax |
||
106 | mov ebx,30 |
||
107 | mul ebx |
||
108 | add ebp,eax |
||
109 | cmp ecx,8 |
||
110 | jbe months_correction |
||
111 | mov eax,ecx |
||
112 | sub eax,7 |
||
113 | shr eax,1 |
||
114 | add ebp,eax |
||
115 | mov ecx,8 |
||
116 | months_correction: |
||
117 | mov eax,ecx |
||
118 | shr eax,1 |
||
119 | add ebp,eax |
||
120 | cmp ecx,2 |
||
121 | pop ecx |
||
122 | ; ecx: YEAR |
||
123 | ; stack: DAY, HOURS, MINUTES, SECONDS, retaddr |
||
124 | jbe day_correction_ok |
||
125 | sub ebp,2 |
||
126 | test ecx,11b |
||
127 | jnz day_correction_ok |
||
128 | xor edx,edx |
||
129 | mov eax,ecx |
||
130 | mov ebx,100 |
||
131 | div ebx |
||
132 | or edx,edx |
||
133 | jnz day_correction |
||
134 | mov eax,ecx |
||
135 | mov ebx,400 |
||
136 | div ebx |
||
137 | or edx,edx |
||
138 | jnz day_correction_ok |
||
139 | day_correction: |
||
140 | inc ebp |
||
141 | day_correction_ok: |
||
142 | pop eax |
||
143 | ; eax: DAY |
||
144 | ; stack: HOURS, MINUTES, SECONDS, retaddr |
||
145 | dec eax |
||
146 | add eax,ebp |
||
147 | mov ebx,24 |
||
148 | mul ebx |
||
149 | pop ecx |
||
150 | ; ecx: HOURS |
||
151 | ; stack: MINUTES, SECONDS, retaddr |
||
152 | add eax,ecx |
||
153 | mov ebx,60 |
||
154 | mul ebx |
||
155 | pop ecx |
||
156 | ; ecx: MINUTES |
||
157 | ; stack: SECONDS, retaddr |
||
158 | add eax,ecx |
||
159 | mov ebx,60 |
||
160 | mul ebx |
||
161 | pop ecx |
||
162 | ; ecx: SECONDS |
||
163 | ; stack: retaddr |
||
164 | add eax,ecx |
||
165 | retn |
||
166 | |||
7836 | leency | 167 | symbol_dump: |
168 | |||
169 | push edi |
||
170 | mov edx,[memory_end] |
||
171 | symb_dump: |
||
172 | cmp edx,[labels_list] |
||
173 | jbe symbols_dumped |
||
174 | sub edx,LABEL_STRUCTURE_SIZE |
||
175 | cmp dword [edx+24],0 |
||
176 | je symb_dump ; do not dump anonymous symbols |
||
177 | test byte [edx+8],1 |
||
178 | jz symb_dump ; do not dump symbols that didn't get defined |
||
179 | mov ax,[current_pass] |
||
180 | cmp ax,[edx+16] |
||
181 | jne symb_dump |
||
182 | test byte [edx+8],4 or 2 |
||
183 | jnz symb_dump ; do not dump assembly-time variables |
||
184 | ; do not dump variables defined with '=' |
||
185 | cmp word [edx+12], 0 |
||
186 | jnz symb_dump ; do not dump register-based variables |
||
187 | |||
188 | mov al, '0' |
||
189 | stosb |
||
190 | mov al, 'x' |
||
191 | stosb |
||
192 | mov eax, [edx+4] |
||
193 | mov ecx, 8 |
||
194 | @@: |
||
195 | rol eax, 4 |
||
196 | test al, 0xF |
||
197 | loopz @b |
||
198 | jz .nohigh |
||
199 | inc ecx |
||
200 | @@: |
||
201 | push eax |
||
202 | and al, 0xF |
||
203 | cmp al, 10 |
||
204 | sbb al, 69h |
||
205 | das |
||
206 | stosb |
||
207 | pop eax |
||
208 | rol eax, 4 |
||
209 | loop @b |
||
210 | mov eax, [edx] |
||
211 | mov ecx, 8 |
||
212 | jmp .low |
||
213 | .nohigh: |
||
214 | mov eax, [edx] |
||
215 | mov ecx, 8 |
||
216 | @@: |
||
217 | rol eax, 4 |
||
218 | test al, 0xF |
||
219 | loopz @b |
||
220 | inc ecx |
||
221 | .low: |
||
222 | push eax |
||
223 | and al, 0xF |
||
224 | cmp al, 10 |
||
225 | sbb al, 69h |
||
226 | das |
||
227 | stosb |
||
228 | pop eax |
||
229 | rol eax, 4 |
||
230 | loop .low |
||
231 | |||
232 | mov al, ' ' |
||
233 | stosb |
||
234 | |||
235 | mov esi,[edx+24] |
||
236 | movzx ecx,byte [esi-1] |
||
237 | rep movsb |
||
238 | |||
239 | mov ax,0A0Dh |
||
240 | stosw |
||
241 | |||
242 | jmp symb_dump |
||
243 | |||
244 | symbols_dumped: |
||
245 | mov edx,dbgfilename |
||
246 | push esi edi |
||
247 | mov esi, outfile |
||
248 | mov edi, edx |
||
249 | @@: |
||
250 | lodsb |
||
251 | stosb |
||
252 | test al, al |
||
253 | jnz @b |
||
254 | lea ecx, [edi-1] |
||
255 | @@: |
||
256 | dec edi |
||
257 | cmp edi, edx |
||
258 | jb @f |
||
259 | cmp byte [edi], '/' |
||
260 | jz @f |
||
261 | cmp byte [edi], '.' |
||
262 | jnz @b |
||
263 | mov ecx, edi |
||
264 | @@: |
||
265 | mov dword [ecx], '.dbg' |
||
266 | mov byte [ecx+4], 0 |
||
267 | pop edi esi |
||
268 | call create |
||
269 | mov edx,[esp] |
||
270 | mov ecx,edi |
||
271 | sub ecx,edx |
||
272 | call write |
||
273 | call close |
||
274 | pop edi |
||
275 | |||
7859 | leency | 276 | retn |
7836 | leency | 277 | |
278 | get_environment_variable: |
||
279 | mov ecx,[memory_end] |
||
280 | sub ecx,edi |
||
281 | cmp ecx,7 |
||
282 | jb out_of_memory |
||
283 | cmp dword[esi],'INCL' |
||
284 | jne .finish |
||
285 | mov esi,_ramdisk |
||
286 | mov ecx,6 |
||
287 | cld |
||
288 | rep movsb |
||
289 | .finish: |
||
290 | ; stc |
||
7859 | leency | 291 | retn |
7836 | leency | 292 | |
293 | alloc_handle: |
||
7859 | leency | 294 | ; in: |
295 | ; out: ebx = file handle |
||
296 | ; on error: return to caller of caller with cf set |
||
297 | ; preserves: esi, edi |
||
7836 | leency | 298 | call make_fullpaths |
7859 | leency | 299 | mov ebx, file_IO_slots+4 |
300 | jmp check_file_IO_slot |
||
301 | next_file_IO_slot: |
||
7836 | leency | 302 | add ebx, 4+20+MAX_PATH |
7859 | leency | 303 | cmp ebx, file_IO_end |
304 | jae send_error_to_caller_of_caller |
||
305 | check_file_IO_slot: |
||
306 | cmp [ebx+FILEIO.cmd], -1 |
||
307 | jnz next_file_IO_slot |
||
308 | and [ebx+FILEIO.offset], 0 |
||
309 | and [ebx+FILEIO.flags], 0 |
||
310 | adapt_path: |
||
7836 | leency | 311 | push esi edi ecx |
312 | mov esi, fullpath_open |
||
7859 | leency | 313 | lea edi, [ebx+namedFILEIO.name] |
7836 | leency | 314 | mov ecx, MAX_PATH |
7859 | leency | 315 | copy_path: |
316 | lodsb |
||
317 | cmp al,'\' |
||
318 | jne path_char_ok |
||
319 | mov al,'/' |
||
320 | path_char_ok: |
||
321 | stosb |
||
322 | or al,al |
||
323 | loopnz copy_path |
||
7836 | leency | 324 | pop ecx edi esi |
7859 | leency | 325 | jz adapt_path.done |
326 | send_error_to_caller_of_caller: |
||
327 | stc |
||
328 | pop eax |
||
329 | adapt_path.done: |
||
330 | ret |
||
7836 | leency | 331 | |
332 | create: |
||
7859 | leency | 333 | ; in: |
334 | ; out: ebx = file handle, cf set on error |
||
335 | ; preserves: esi, edi |
||
7836 | leency | 336 | call alloc_handle |
7859 | leency | 337 | and [ebx+FILEIO.filesize], 0 |
338 | mov [ebx+FILEIO.cmd], SSF_CREATE_FILE |
||
339 | retn |
||
7836 | leency | 340 | |
341 | |||
342 | open: |
||
7859 | leency | 343 | ; in: |
344 | ; out: ebx = file handle, cf set on error |
||
345 | ; preserves: esi, edi |
||
7836 | leency | 346 | call alloc_handle |
7859 | leency | 347 | mov [ebx+FILEIO.cmd], SSF_GET_INFO |
348 | and [ebx+FILEIO.count], 0 |
||
349 | mov [ebx+FILEIO.buffer], fileinfo |
||
7836 | leency | 350 | push ebx |
7859 | leency | 351 | mcall SF_FILE |
7836 | leency | 352 | pop ebx |
353 | test eax, eax |
||
7859 | leency | 354 | jnz fail_close |
7836 | leency | 355 | mov eax, dword[fileinfo.size] |
7859 | leency | 356 | mov [ebx+FILEIO.filesize], eax |
357 | and [ebx+FILEIO.cmd], SSF_READ_FILE |
||
358 | retn |
||
359 | |||
360 | fail_close: |
||
7836 | leency | 361 | stc |
7859 | leency | 362 | close: |
363 | ; in: ebx = file handle |
||
364 | ; preserves: ebx, esi, edi, cf |
||
365 | mov [ebx+FILEIO.cmd], -1 ; close handle |
||
366 | retn |
||
367 | write: |
||
368 | ; in: ebx = file handle, edx - data, ecx = number of bytes |
||
369 | ; out: cf set on error |
||
370 | ; preserves: ebx, esi, edi |
||
371 | call read_write |
||
372 | mov [ebx+FILEIO.cmd], SSF_WRITE_FILE |
||
373 | jmp read_write_check_S_OK |
||
7836 | leency | 374 | read: |
7859 | leency | 375 | ; in: ebx = file handle, edx - buffer, ecx = number of bytes |
376 | ; out: cf set on error |
||
377 | ; preserves: ebx, esi, edi |
||
378 | call read_write |
||
379 | cmp eax, 6 |
||
380 | jz read_write_OK |
||
381 | read_write_check_S_OK: |
||
7836 | leency | 382 | test eax, eax |
7859 | leency | 383 | jz read_write_OK |
7836 | leency | 384 | stc |
7859 | leency | 385 | retn |
386 | read_write: |
||
387 | mov [ebx+FILEIO.count], ecx |
||
388 | mov [ebx+FILEIO.buffer], edx |
||
7836 | leency | 389 | push ebx |
7859 | leency | 390 | mcall SF_FILE |
7836 | leency | 391 | xchg eax, [esp] |
7859 | leency | 392 | add [eax+FILEIO.offset], ebx |
393 | adc [eax+FILEIO.offshigh], 0 |
||
7836 | leency | 394 | mov ebx, eax |
395 | pop eax |
||
7859 | leency | 396 | read_write_OK: |
397 | retn |
||
7836 | leency | 398 | |
7859 | leency | 399 | |
7836 | leency | 400 | make_fullpaths: |
401 | pusha |
||
402 | push edx |
||
7859 | leency | 403 | mov esi,edx |
404 | mov ecx, MAX_PATH |
||
405 | copy_edxpath: |
||
406 | lodsb |
||
407 | cmp al,'\' |
||
408 | jne edxpath_char_ok |
||
409 | mov byte[esi-1],'/' |
||
410 | edxpath_char_ok: |
||
411 | or al,al |
||
412 | loopnz copy_edxpath |
||
7836 | leency | 413 | |
414 | mov esi,path ; open |
||
415 | ; DEBUGF " '%s'",esi |
||
416 | mov edi,fullpath_open |
||
417 | cld |
||
418 | newc1: |
||
419 | movsb |
||
420 | cmp byte[esi],0;' ' |
||
421 | jne newc1 |
||
422 | mov esi,[esp] |
||
423 | |||
424 | cmp byte[esi],'/' |
||
425 | jne @f |
||
7859 | leency | 426 | cmp byte[esi],'\' |
427 | jne @f |
||
7836 | leency | 428 | mov edi,fullpath_open |
429 | |||
430 | @@: |
||
431 | lodsb |
||
432 | stosb |
||
433 | cmp al,0 |
||
434 | jne @b |
||
435 | |||
436 | mov esi,path ; write |
||
437 | mov edi,fullpath_write |
||
438 | cld |
||
439 | newc2: |
||
440 | movsb |
||
441 | cmp byte[esi],0;' ' |
||
442 | jne newc2 |
||
443 | mov esi,[esp] |
||
444 | |||
445 | cmp byte[esi],'/' |
||
446 | jne @f |
||
7859 | leency | 447 | cmp byte[esi],'\' |
448 | jne @f |
||
7836 | leency | 449 | mov edi,fullpath_write |
450 | |||
451 | @@: |
||
452 | lodsb |
||
453 | stosb |
||
454 | cmp al,0 |
||
455 | jne @b |
||
456 | |||
457 | mov esi,path ; start |
||
458 | mov edi,file_io_start.path |
||
459 | cld |
||
460 | newc3: |
||
461 | movsb |
||
462 | cmp byte[esi],0;' ' |
||
463 | jne newc3 |
||
464 | pop esi |
||
465 | |||
466 | cmp byte[esi],'/' |
||
467 | jne @f |
||
7859 | leency | 468 | cmp byte[esi],'\' |
469 | jne @f |
||
7836 | leency | 470 | mov edi,file_io_start.path |
471 | |||
472 | @@: |
||
473 | lodsb |
||
474 | stosb |
||
475 | cmp al,0 |
||
476 | jne @b |
||
477 | popa |
||
7859 | leency | 478 | retn |
7836 | leency | 479 | lseek: |
7859 | leency | 480 | ; in: ebx = file handle, al = method, edx = delta offset |
481 | ; out: cf set on error |
||
482 | ; preserves: ebx, esi, edi |
||
483 | cmp al,FILE_BEGIN |
||
7836 | leency | 484 | jnz @f |
7859 | leency | 485 | and [ebx+FILEIO.offset], 0 |
486 | jmp .common |
||
487 | @@: cmp al,FILE_END |
||
7836 | leency | 488 | jnz @f |
7859 | leency | 489 | mov eax, [ebx+FILEIO.filesize] |
490 | mov [ebx+FILEIO.offset], eax |
||
491 | jmp .common |
||
492 | @@: |
||
493 | .common: |
||
494 | add [ebx+FILEIO.offset], edx |
||
495 | retn |
||
7836 | leency | 496 | |
497 | display_character: |
||
498 | pusha |
||
499 | cmp [_mode],NORMAL_MODE |
||
500 | jne @f |
||
7859 | leency | 501 | cmp al,$D |
7836 | leency | 502 | jz dc2 |
7859 | leency | 503 | cmp al,$A |
7836 | leency | 504 | jnz dc1 |
505 | and [textxy],0x0000FFFF |
||
506 | add [textxy], 8 shl 16 and 0xFFFF0000 + 18 |
||
7859 | leency | 507 | popa |
508 | retn |
||
7836 | leency | 509 | dc1: |
7859 | leency | 510 | mov [dc],al |
511 | mov eax,[textxy] |
||
7836 | leency | 512 | cmp ax,word[bottom_right] |
513 | ja dc2 |
||
514 | shr eax,16 |
||
515 | cmp ax,word[bottom_right+2] |
||
516 | ja dc2 |
||
7859 | leency | 517 | mov ecx,[sc.work_text] |
518 | or ecx,$10000000 |
||
519 | mcall SF_DRAW_TEXT,[textxy],,dc,1 |
||
7836 | leency | 520 | add [textxy],0x00080000 |
7859 | leency | 521 | dc2: |
7836 | leency | 522 | popa |
7859 | leency | 523 | retn |
7836 | leency | 524 | @@: |
7859 | leency | 525 | mov cl,al |
526 | mcall SF_BOARD,SSF_DEBUG_WRITE |
||
7836 | leency | 527 | popa |
7859 | leency | 528 | retn |
7836 | leency | 529 | |
530 | |||
531 | display_string: |
||
7859 | leency | 532 | ; in: |
533 | ; esi - ASCIIZ string |
||
534 | ; preserves: ebx, esi |
||
535 | push esi |
||
536 | @@: lodsb |
||
537 | test al,al |
||
7836 | leency | 538 | je @f |
539 | call display_character |
||
540 | jmp @b |
||
541 | @@: |
||
7859 | leency | 542 | pop esi |
543 | retn |
||
7836 | leency | 544 | |
545 | display_number: |
||
546 | push ebx |
||
547 | mov ecx,1000000000 |
||
548 | xor edx,edx |
||
549 | xor bl,bl |
||
550 | display_loop: |
||
551 | div ecx |
||
552 | push edx |
||
553 | cmp ecx,1 |
||
554 | je display_digit |
||
555 | or bl,bl |
||
556 | jnz display_digit |
||
557 | or al,al |
||
558 | jz digit_ok |
||
559 | not bl |
||
560 | display_digit: |
||
7859 | leency | 561 | add al,'0' |
7836 | leency | 562 | push ebx ecx |
563 | call display_character |
||
564 | pop ecx ebx |
||
565 | digit_ok: |
||
566 | mov eax,ecx |
||
567 | xor edx,edx |
||
568 | mov ecx,10 |
||
569 | div ecx |
||
570 | mov ecx,eax |
||
571 | pop eax |
||
572 | or ecx,ecx |
||
573 | jnz display_loop |
||
574 | pop ebx |
||
7859 | leency | 575 | retn |
7836 | leency | 576 | |
577 | display_user_messages: |
||
578 | ; push [skinh] |
||
579 | ; pop [textxy] |
||
580 | ; add [textxy], 7 shl 16 +53 |
||
581 | mov [displayed_count],0 |
||
582 | call show_display_buffer |
||
583 | cmp [displayed_count],1 |
||
584 | jb line_break_ok |
||
585 | je make_line_break |
||
586 | mov ax,word[last_displayed] |
||
587 | cmp ax,0A0Dh |
||
588 | je line_break_ok |
||
589 | cmp ax,0D0Ah |
||
590 | je line_break_ok |
||
591 | make_line_break: |
||
592 | mov esi,crlf |
||
593 | call display_string |
||
594 | line_break_ok: |
||
7859 | leency | 595 | retn |
7836 | leency | 596 | |
597 | display_block: |
||
7859 | leency | 598 | ; in: |
599 | ; esi - string |
||
600 | ; ecx = string length |
||
601 | push esi |
||
602 | @@: lodsb |
||
7836 | leency | 603 | call display_character |
604 | loop @b |
||
7859 | leency | 605 | pop esi |
606 | retn |
||
7836 | leency | 607 | |
608 | fatal_error: |
||
7859 | leency | 609 | ; no return, trashes stack |
610 | |||
7836 | leency | 611 | mov esi,error_prefix |
612 | call display_string |
||
613 | pop esi |
||
614 | call display_string |
||
615 | mov esi,error_suffix |
||
616 | call display_string |
||
617 | mov esi,crlf |
||
618 | call display_string |
||
619 | mov al,0FFh |
||
620 | jmp exit_program |
||
621 | |||
622 | assembler_error: |
||
623 | call display_user_messages |
||
7859 | leency | 624 | push 0 |
7836 | leency | 625 | mov ebx,[current_line] |
626 | get_error_lines: |
||
627 | push ebx |
||
628 | test byte [ebx+7],80h |
||
629 | jz display_error_line |
||
630 | mov edx,ebx |
||
631 | find_definition_origin: |
||
632 | mov edx,[edx+12] |
||
633 | test byte [edx+7],80h |
||
634 | jnz find_definition_origin |
||
635 | push edx |
||
636 | mov ebx,[ebx+8] |
||
637 | jmp get_error_lines |
||
638 | display_error_line: |
||
639 | mov esi,[ebx] |
||
640 | call display_string |
||
641 | mov esi,line_number_start |
||
642 | call display_string |
||
643 | mov eax,[ebx+4] |
||
644 | and eax,7FFFFFFFh |
||
645 | call display_number |
||
7859 | leency | 646 | mov al,']' |
7836 | leency | 647 | call display_character |
648 | pop esi |
||
649 | cmp ebx,esi |
||
650 | je line_number_ok |
||
7859 | leency | 651 | mov al,' ' |
7836 | leency | 652 | call display_character |
653 | push esi |
||
654 | mov esi,[esi] |
||
655 | movzx ecx,byte [esi] |
||
656 | inc esi |
||
657 | call display_block |
||
658 | mov esi,line_number_start |
||
659 | call display_string |
||
660 | pop esi |
||
661 | mov eax,[esi+4] |
||
662 | and eax,7FFFFFFFh |
||
663 | call display_number |
||
7859 | leency | 664 | mov al,']' |
7836 | leency | 665 | call display_character |
666 | line_number_ok: |
||
667 | mov esi,line_data_start |
||
668 | call display_string |
||
669 | mov esi,ebx |
||
670 | mov edx,[esi] |
||
671 | call open |
||
672 | mov al,2 |
||
673 | xor edx,edx |
||
674 | call lseek |
||
675 | mov edx,[esi+8] |
||
676 | sub eax,edx |
||
677 | push eax |
||
678 | xor al,al |
||
679 | call lseek |
||
680 | mov ecx,[esp] |
||
681 | mov edx,[additional_memory] |
||
682 | lea eax,[edx+ecx] |
||
683 | cmp eax,[additional_memory_end] |
||
684 | ja out_of_memory |
||
685 | call read |
||
686 | call close |
||
687 | pop ecx |
||
688 | mov esi,[additional_memory] |
||
689 | get_line_data: |
||
690 | mov al,[esi] |
||
7859 | leency | 691 | cmp al,$A |
7836 | leency | 692 | je display_line_data |
7859 | leency | 693 | cmp al,$D |
7836 | leency | 694 | je display_line_data |
7859 | leency | 695 | cmp al,$1A |
7836 | leency | 696 | je display_line_data |
697 | or al,al |
||
698 | jz display_line_data |
||
699 | inc esi |
||
700 | loop get_line_data |
||
701 | display_line_data: |
||
702 | mov ecx,esi |
||
703 | mov esi,[additional_memory] |
||
704 | sub ecx,esi |
||
705 | call display_block |
||
706 | mov esi,crlf |
||
707 | call display_string |
||
708 | pop ebx |
||
709 | or ebx,ebx |
||
710 | jnz display_error_line |
||
711 | mov esi,error_prefix |
||
712 | call display_string |
||
713 | pop esi |
||
714 | call display_string |
||
715 | mov esi,error_suffix |
||
716 | call display_string |
||
717 | jmp exit_program |