2020-04-29 01:24:56 +02:00
|
|
|
; flat assembler
|
2021-12-22 21:19:48 +01:00
|
|
|
; Copyright (c) 1999-2021, Tomasz Grysztar
|
2020-04-29 01:24:56 +02:00
|
|
|
; All rights reserved.
|
|
|
|
|
|
|
|
init_memory:
|
|
|
|
|
2021-12-22 21:19:48 +01:00
|
|
|
; mov ecx, 16*1024*1024
|
2020-04-29 01:24:56 +02:00
|
|
|
;
|
|
|
|
; allocate_memory:
|
|
|
|
mcall SF_SYSTEM, SSF_GET_FREE_RAM
|
|
|
|
cmp eax, 0x38000000 shr 9
|
|
|
|
jbe @f
|
|
|
|
mov eax, 0x38000000 shr 9
|
|
|
|
@@:
|
|
|
|
shl eax, 9
|
|
|
|
xchg eax, ecx
|
|
|
|
mov [memory_setting],ecx
|
|
|
|
mcall SF_SYS_MISC, SSF_MEM_ALLOC
|
|
|
|
or eax,eax
|
|
|
|
jz out_of_memory
|
|
|
|
mov [memblock], eax
|
|
|
|
mov [additional_memory],eax
|
|
|
|
add eax,[memory_setting]
|
|
|
|
mov [memory_end],eax
|
|
|
|
mov eax,[memory_setting]
|
|
|
|
shr eax,2
|
|
|
|
add eax,[additional_memory]
|
|
|
|
mov [additional_memory_end],eax
|
|
|
|
mov [memory_start],eax
|
2020-05-03 15:24:00 +02:00
|
|
|
retn
|
2020-04-29 01:24:56 +02:00
|
|
|
|
|
|
|
exit_program:
|
|
|
|
cmp [_mode],NORMAL_MODE
|
|
|
|
jne @f
|
|
|
|
mcall SF_SYS_MISC, SSF_MEM_FREE, [memblock]
|
2021-12-22 21:19:48 +01:00
|
|
|
mov edi, file_IO_slots
|
|
|
|
mov ecx, (file_IO_end-file_IO_slots)/4
|
|
|
|
or eax, -1
|
|
|
|
rep stosd
|
2020-04-29 01:24:56 +02:00
|
|
|
mov esp,[processing_esp]
|
2021-12-22 21:19:48 +01:00
|
|
|
ret;jmp still
|
2020-04-29 01:24:56 +02:00
|
|
|
@@:
|
|
|
|
or eax,-1
|
|
|
|
mcall
|
|
|
|
|
2020-05-05 01:50:41 +02:00
|
|
|
get_tickcount:
|
2020-04-29 01:24:56 +02:00
|
|
|
push ebx
|
|
|
|
mcall SF_SYSTEM_GET,SSF_TIME_COUNT
|
|
|
|
imul eax,10
|
|
|
|
pop ebx
|
2020-05-03 15:24:00 +02:00
|
|
|
retn
|
2020-04-29 01:24:56 +02:00
|
|
|
|
2020-05-05 01:50:41 +02:00
|
|
|
macro BCDtoHEX al {
|
|
|
|
aam 16
|
|
|
|
aad 10 }
|
|
|
|
|
|
|
|
make_timestamp:
|
|
|
|
mcall SF_GET_SYS_DATE ; $00SSMMHH (BCD)
|
|
|
|
mov edx,eax
|
|
|
|
shr eax,16
|
|
|
|
BCDtoHEX al
|
|
|
|
push eax ; SECONDS
|
|
|
|
mov al,dh
|
|
|
|
BCDtoHEX al
|
|
|
|
push eax ; MINUTES
|
|
|
|
mov al,dl
|
|
|
|
BCDtoHEX al
|
|
|
|
push eax ; HOURS
|
|
|
|
mcall SF_GET_SYS_DATE ; $00DDMMYY (BCD)
|
|
|
|
mov edx,eax
|
|
|
|
shr eax,16
|
|
|
|
BCDtoHEX al
|
|
|
|
push eax ; DAY
|
|
|
|
mov al,dl
|
|
|
|
BCDtoHEX al
|
|
|
|
add eax,2000
|
|
|
|
push eax ; YEAR
|
|
|
|
mov ecx,eax
|
|
|
|
mov al,dh
|
|
|
|
BCDtoHEX al
|
|
|
|
push eax ; MONTH
|
|
|
|
; ecx: YEAR
|
|
|
|
; stack: MONTH, YEAR, DAY, HOURS, MINUTES, SECONDS, retaddr
|
|
|
|
mov eax,ecx
|
|
|
|
sub eax,1970
|
|
|
|
mov ebx,365
|
|
|
|
mul ebx
|
|
|
|
mov ebp,eax
|
|
|
|
mov eax,ecx
|
|
|
|
sub eax,1969
|
|
|
|
shr eax,2
|
|
|
|
add ebp,eax
|
|
|
|
mov eax,ecx
|
|
|
|
xor edx,edx
|
|
|
|
sub eax,1901
|
|
|
|
mov ebx,100
|
|
|
|
div ebx
|
|
|
|
sub ebp,eax
|
|
|
|
mov eax,ecx
|
|
|
|
xor edx,edx
|
|
|
|
sub eax,1601
|
|
|
|
mov ebx,400
|
|
|
|
div ebx
|
|
|
|
add ebp,eax
|
|
|
|
pop ecx
|
|
|
|
; ecx: MONTH
|
|
|
|
; stack: YEAR, DAY, HOURS, MINUTES, SECONDS, retaddr
|
|
|
|
mov eax,ecx
|
|
|
|
dec eax
|
|
|
|
mov ebx,30
|
|
|
|
mul ebx
|
|
|
|
add ebp,eax
|
|
|
|
cmp ecx,8
|
|
|
|
jbe months_correction
|
|
|
|
mov eax,ecx
|
|
|
|
sub eax,7
|
|
|
|
shr eax,1
|
|
|
|
add ebp,eax
|
|
|
|
mov ecx,8
|
|
|
|
months_correction:
|
|
|
|
mov eax,ecx
|
|
|
|
shr eax,1
|
|
|
|
add ebp,eax
|
|
|
|
cmp ecx,2
|
|
|
|
pop ecx
|
|
|
|
; ecx: YEAR
|
|
|
|
; stack: DAY, HOURS, MINUTES, SECONDS, retaddr
|
|
|
|
jbe day_correction_ok
|
|
|
|
sub ebp,2
|
|
|
|
test ecx,11b
|
|
|
|
jnz day_correction_ok
|
|
|
|
xor edx,edx
|
|
|
|
mov eax,ecx
|
|
|
|
mov ebx,100
|
|
|
|
div ebx
|
|
|
|
or edx,edx
|
|
|
|
jnz day_correction
|
|
|
|
mov eax,ecx
|
|
|
|
mov ebx,400
|
|
|
|
div ebx
|
|
|
|
or edx,edx
|
|
|
|
jnz day_correction_ok
|
|
|
|
day_correction:
|
|
|
|
inc ebp
|
|
|
|
day_correction_ok:
|
|
|
|
pop eax
|
|
|
|
; eax: DAY
|
|
|
|
; stack: HOURS, MINUTES, SECONDS, retaddr
|
|
|
|
dec eax
|
|
|
|
add eax,ebp
|
|
|
|
mov ebx,24
|
|
|
|
mul ebx
|
|
|
|
pop ecx
|
|
|
|
; ecx: HOURS
|
|
|
|
; stack: MINUTES, SECONDS, retaddr
|
|
|
|
add eax,ecx
|
|
|
|
mov ebx,60
|
|
|
|
mul ebx
|
|
|
|
pop ecx
|
|
|
|
; ecx: MINUTES
|
|
|
|
; stack: SECONDS, retaddr
|
|
|
|
add eax,ecx
|
|
|
|
mov ebx,60
|
|
|
|
mul ebx
|
|
|
|
pop ecx
|
|
|
|
; ecx: SECONDS
|
|
|
|
; stack: retaddr
|
|
|
|
add eax,ecx
|
|
|
|
retn
|
|
|
|
|
2020-04-29 01:24:56 +02:00
|
|
|
symbol_dump:
|
|
|
|
|
|
|
|
push edi
|
|
|
|
mov edx,[memory_end]
|
|
|
|
symb_dump:
|
|
|
|
cmp edx,[labels_list]
|
|
|
|
jbe symbols_dumped
|
|
|
|
sub edx,LABEL_STRUCTURE_SIZE
|
|
|
|
cmp dword [edx+24],0
|
|
|
|
je symb_dump ; do not dump anonymous symbols
|
|
|
|
test byte [edx+8],1
|
|
|
|
jz symb_dump ; do not dump symbols that didn't get defined
|
|
|
|
mov ax,[current_pass]
|
|
|
|
cmp ax,[edx+16]
|
|
|
|
jne symb_dump
|
|
|
|
test byte [edx+8],4 or 2
|
|
|
|
jnz symb_dump ; do not dump assembly-time variables
|
|
|
|
; do not dump variables defined with '='
|
|
|
|
cmp word [edx+12], 0
|
|
|
|
jnz symb_dump ; do not dump register-based variables
|
|
|
|
|
|
|
|
mov al, '0'
|
|
|
|
stosb
|
|
|
|
mov al, 'x'
|
|
|
|
stosb
|
|
|
|
mov eax, [edx+4]
|
|
|
|
mov ecx, 8
|
|
|
|
@@:
|
|
|
|
rol eax, 4
|
|
|
|
test al, 0xF
|
|
|
|
loopz @b
|
|
|
|
jz .nohigh
|
|
|
|
inc ecx
|
|
|
|
@@:
|
|
|
|
push eax
|
|
|
|
and al, 0xF
|
|
|
|
cmp al, 10
|
|
|
|
sbb al, 69h
|
|
|
|
das
|
|
|
|
stosb
|
|
|
|
pop eax
|
|
|
|
rol eax, 4
|
|
|
|
loop @b
|
|
|
|
mov eax, [edx]
|
|
|
|
mov ecx, 8
|
|
|
|
jmp .low
|
|
|
|
.nohigh:
|
|
|
|
mov eax, [edx]
|
|
|
|
mov ecx, 8
|
|
|
|
@@:
|
|
|
|
rol eax, 4
|
|
|
|
test al, 0xF
|
|
|
|
loopz @b
|
|
|
|
inc ecx
|
|
|
|
.low:
|
|
|
|
push eax
|
|
|
|
and al, 0xF
|
|
|
|
cmp al, 10
|
|
|
|
sbb al, 69h
|
|
|
|
das
|
|
|
|
stosb
|
|
|
|
pop eax
|
|
|
|
rol eax, 4
|
|
|
|
loop .low
|
|
|
|
|
|
|
|
mov al, ' '
|
|
|
|
stosb
|
|
|
|
|
|
|
|
mov esi,[edx+24]
|
|
|
|
movzx ecx,byte [esi-1]
|
|
|
|
rep movsb
|
|
|
|
|
|
|
|
mov ax,0A0Dh
|
|
|
|
stosw
|
|
|
|
|
|
|
|
jmp symb_dump
|
|
|
|
|
|
|
|
symbols_dumped:
|
|
|
|
mov edx,dbgfilename
|
|
|
|
push esi edi
|
|
|
|
mov esi, outfile
|
|
|
|
mov edi, edx
|
|
|
|
@@:
|
|
|
|
lodsb
|
|
|
|
stosb
|
|
|
|
test al, al
|
|
|
|
jnz @b
|
|
|
|
lea ecx, [edi-1]
|
|
|
|
@@:
|
|
|
|
dec edi
|
|
|
|
cmp edi, edx
|
|
|
|
jb @f
|
|
|
|
cmp byte [edi], '/'
|
|
|
|
jz @f
|
|
|
|
cmp byte [edi], '.'
|
|
|
|
jnz @b
|
|
|
|
mov ecx, edi
|
|
|
|
@@:
|
|
|
|
mov dword [ecx], '.dbg'
|
|
|
|
mov byte [ecx+4], 0
|
|
|
|
pop edi esi
|
|
|
|
call create
|
|
|
|
mov edx,[esp]
|
|
|
|
mov ecx,edi
|
|
|
|
sub ecx,edx
|
|
|
|
call write
|
|
|
|
call close
|
|
|
|
pop edi
|
|
|
|
|
2020-05-03 15:24:00 +02:00
|
|
|
retn
|
2020-04-29 01:24:56 +02:00
|
|
|
|
|
|
|
get_environment_variable:
|
|
|
|
mov ecx,[memory_end]
|
|
|
|
sub ecx,edi
|
|
|
|
cmp ecx,7
|
|
|
|
jb out_of_memory
|
|
|
|
cmp dword[esi],'INCL'
|
|
|
|
jne .finish
|
|
|
|
mov esi,_ramdisk
|
|
|
|
mov ecx,6
|
|
|
|
cld
|
|
|
|
rep movsb
|
|
|
|
.finish:
|
2021-12-22 21:19:48 +01:00
|
|
|
; stc
|
2020-05-03 15:24:00 +02:00
|
|
|
retn
|
2020-04-29 01:24:56 +02:00
|
|
|
|
|
|
|
alloc_handle:
|
2020-05-03 15:24:00 +02:00
|
|
|
; in:
|
|
|
|
; out: ebx = file handle
|
|
|
|
; on error: return to caller of caller with cf set
|
|
|
|
; preserves: esi, edi
|
2020-04-29 01:24:56 +02:00
|
|
|
call make_fullpaths
|
2020-05-03 15:24:00 +02:00
|
|
|
mov ebx, file_IO_slots+4
|
|
|
|
jmp check_file_IO_slot
|
|
|
|
next_file_IO_slot:
|
2020-04-29 01:24:56 +02:00
|
|
|
add ebx, 4+20+MAX_PATH
|
2020-05-03 15:24:00 +02:00
|
|
|
cmp ebx, file_IO_end
|
|
|
|
jae send_error_to_caller_of_caller
|
|
|
|
check_file_IO_slot:
|
|
|
|
cmp [ebx+FILEIO.cmd], -1
|
|
|
|
jnz next_file_IO_slot
|
|
|
|
and [ebx+FILEIO.offset], 0
|
|
|
|
and [ebx+FILEIO.flags], 0
|
|
|
|
adapt_path:
|
2020-04-29 01:24:56 +02:00
|
|
|
push esi edi ecx
|
|
|
|
mov esi, fullpath_open
|
2020-05-03 15:24:00 +02:00
|
|
|
lea edi, [ebx+namedFILEIO.name]
|
2020-04-29 01:24:56 +02:00
|
|
|
mov ecx, MAX_PATH
|
2020-05-03 15:24:00 +02:00
|
|
|
copy_path:
|
|
|
|
lodsb
|
|
|
|
cmp al,'\'
|
|
|
|
jne path_char_ok
|
|
|
|
mov al,'/'
|
|
|
|
path_char_ok:
|
|
|
|
stosb
|
|
|
|
or al,al
|
|
|
|
loopnz copy_path
|
2020-04-29 01:24:56 +02:00
|
|
|
pop ecx edi esi
|
2020-05-03 15:24:00 +02:00
|
|
|
jz adapt_path.done
|
|
|
|
send_error_to_caller_of_caller:
|
|
|
|
stc
|
|
|
|
pop eax
|
|
|
|
adapt_path.done:
|
|
|
|
ret
|
2020-04-29 01:24:56 +02:00
|
|
|
|
|
|
|
create:
|
2020-05-03 15:24:00 +02:00
|
|
|
; in:
|
|
|
|
; out: ebx = file handle, cf set on error
|
|
|
|
; preserves: esi, edi
|
2020-04-29 01:24:56 +02:00
|
|
|
call alloc_handle
|
2020-05-03 15:24:00 +02:00
|
|
|
and [ebx+FILEIO.filesize], 0
|
|
|
|
mov [ebx+FILEIO.cmd], SSF_CREATE_FILE
|
|
|
|
retn
|
2020-04-29 01:24:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
open:
|
2020-05-03 15:24:00 +02:00
|
|
|
; in:
|
|
|
|
; out: ebx = file handle, cf set on error
|
|
|
|
; preserves: esi, edi
|
2020-04-29 01:24:56 +02:00
|
|
|
call alloc_handle
|
2020-05-03 15:24:00 +02:00
|
|
|
mov [ebx+FILEIO.cmd], SSF_GET_INFO
|
|
|
|
and [ebx+FILEIO.count], 0
|
|
|
|
mov [ebx+FILEIO.buffer], fileinfo
|
2020-04-29 01:24:56 +02:00
|
|
|
push ebx
|
2020-05-03 15:24:00 +02:00
|
|
|
mcall SF_FILE
|
2020-04-29 01:24:56 +02:00
|
|
|
pop ebx
|
|
|
|
test eax, eax
|
2020-05-03 15:24:00 +02:00
|
|
|
jnz fail_close
|
2020-04-29 01:24:56 +02:00
|
|
|
mov eax, dword[fileinfo.size]
|
2020-05-03 15:24:00 +02:00
|
|
|
mov [ebx+FILEIO.filesize], eax
|
|
|
|
and [ebx+FILEIO.cmd], SSF_READ_FILE
|
|
|
|
retn
|
2020-04-29 01:24:56 +02:00
|
|
|
|
2020-05-03 15:24:00 +02:00
|
|
|
fail_close:
|
2020-04-29 01:24:56 +02:00
|
|
|
stc
|
|
|
|
close:
|
2020-05-03 15:24:00 +02:00
|
|
|
; in: ebx = file handle
|
|
|
|
; preserves: ebx, esi, edi, cf
|
|
|
|
mov [ebx+FILEIO.cmd], -1 ; close handle
|
|
|
|
retn
|
2020-04-29 01:24:56 +02:00
|
|
|
write:
|
2020-05-03 15:24:00 +02:00
|
|
|
; in: ebx = file handle, edx - data, ecx = number of bytes
|
|
|
|
; out: cf set on error
|
|
|
|
; preserves: ebx, esi, edi
|
|
|
|
call read_write
|
|
|
|
mov [ebx+FILEIO.cmd], SSF_WRITE_FILE
|
|
|
|
jmp read_write_check_S_OK
|
|
|
|
read:
|
|
|
|
; in: ebx = file handle, edx - buffer, ecx = number of bytes
|
|
|
|
; out: cf set on error
|
|
|
|
; preserves: ebx, esi, edi
|
|
|
|
call read_write
|
|
|
|
cmp eax, 6
|
|
|
|
jz read_write_OK
|
|
|
|
read_write_check_S_OK:
|
|
|
|
test eax, eax
|
|
|
|
jz read_write_OK
|
|
|
|
stc
|
|
|
|
retn
|
|
|
|
read_write:
|
|
|
|
mov [ebx+FILEIO.count], ecx
|
|
|
|
mov [ebx+FILEIO.buffer], edx
|
2020-04-29 01:24:56 +02:00
|
|
|
push ebx
|
2020-05-03 15:24:00 +02:00
|
|
|
mcall SF_FILE
|
2020-04-29 01:24:56 +02:00
|
|
|
xchg eax, [esp]
|
2020-05-03 15:24:00 +02:00
|
|
|
add [eax+FILEIO.offset], ebx
|
|
|
|
adc [eax+FILEIO.offshigh], 0
|
2020-04-29 01:24:56 +02:00
|
|
|
mov ebx, eax
|
|
|
|
pop eax
|
2020-05-03 15:24:00 +02:00
|
|
|
read_write_OK:
|
|
|
|
retn
|
|
|
|
|
2020-04-29 01:24:56 +02:00
|
|
|
|
|
|
|
make_fullpaths:
|
|
|
|
pusha
|
|
|
|
push edx
|
2020-05-03 15:24:00 +02:00
|
|
|
mov esi,edx
|
|
|
|
mov ecx, MAX_PATH
|
|
|
|
copy_edxpath:
|
|
|
|
lodsb
|
|
|
|
cmp al,'\'
|
|
|
|
jne edxpath_char_ok
|
|
|
|
mov byte[esi-1],'/'
|
|
|
|
edxpath_char_ok:
|
|
|
|
or al,al
|
|
|
|
loopnz copy_edxpath
|
2020-04-29 01:24:56 +02:00
|
|
|
|
|
|
|
mov esi,path ; open
|
2021-12-22 21:19:48 +01:00
|
|
|
; DEBUGF " '%s'",esi
|
2020-04-29 01:24:56 +02:00
|
|
|
mov edi,fullpath_open
|
|
|
|
cld
|
|
|
|
newc1:
|
|
|
|
movsb
|
|
|
|
cmp byte[esi],0;' '
|
|
|
|
jne newc1
|
|
|
|
mov esi,[esp]
|
|
|
|
|
|
|
|
cmp byte[esi],'/'
|
2021-12-22 21:19:48 +01:00
|
|
|
je absolute_path
|
2020-05-03 15:24:00 +02:00
|
|
|
cmp byte[esi],'\'
|
2021-12-22 21:19:48 +01:00
|
|
|
jne @F
|
|
|
|
absolute_path:
|
2020-04-29 01:24:56 +02:00
|
|
|
mov edi,fullpath_open
|
|
|
|
|
|
|
|
@@:
|
|
|
|
lodsb
|
|
|
|
stosb
|
|
|
|
cmp al,0
|
|
|
|
jne @b
|
|
|
|
|
|
|
|
mov esi,path ; write
|
|
|
|
mov edi,fullpath_write
|
|
|
|
cld
|
|
|
|
newc2:
|
|
|
|
movsb
|
|
|
|
cmp byte[esi],0;' '
|
|
|
|
jne newc2
|
|
|
|
mov esi,[esp]
|
|
|
|
|
|
|
|
cmp byte[esi],'/'
|
|
|
|
jne @f
|
2020-05-03 15:24:00 +02:00
|
|
|
cmp byte[esi],'\'
|
|
|
|
jne @f
|
2020-04-29 01:24:56 +02:00
|
|
|
mov edi,fullpath_write
|
|
|
|
|
|
|
|
@@:
|
|
|
|
lodsb
|
|
|
|
stosb
|
|
|
|
cmp al,0
|
|
|
|
jne @b
|
|
|
|
|
|
|
|
mov esi,path ; start
|
|
|
|
mov edi,file_io_start.path
|
|
|
|
cld
|
|
|
|
newc3:
|
|
|
|
movsb
|
|
|
|
cmp byte[esi],0;' '
|
|
|
|
jne newc3
|
|
|
|
pop esi
|
|
|
|
|
|
|
|
cmp byte[esi],'/'
|
|
|
|
jne @f
|
2020-05-03 15:24:00 +02:00
|
|
|
cmp byte[esi],'\'
|
|
|
|
jne @f
|
2020-04-29 01:24:56 +02:00
|
|
|
mov edi,file_io_start.path
|
|
|
|
|
|
|
|
@@:
|
|
|
|
lodsb
|
|
|
|
stosb
|
|
|
|
cmp al,0
|
|
|
|
jne @b
|
|
|
|
popa
|
2020-05-03 15:24:00 +02:00
|
|
|
retn
|
2020-04-29 01:24:56 +02:00
|
|
|
lseek:
|
2020-05-03 15:24:00 +02:00
|
|
|
; in: ebx = file handle, al = method, edx = delta offset
|
|
|
|
; out: cf set on error
|
|
|
|
; preserves: ebx, esi, edi
|
|
|
|
cmp al,FILE_BEGIN
|
2020-04-29 01:24:56 +02:00
|
|
|
jnz @f
|
2020-05-03 15:24:00 +02:00
|
|
|
and [ebx+FILEIO.offset], 0
|
|
|
|
jmp .common
|
|
|
|
@@: cmp al,FILE_END
|
2020-04-29 01:24:56 +02:00
|
|
|
jnz @f
|
2020-05-03 15:24:00 +02:00
|
|
|
mov eax, [ebx+FILEIO.filesize]
|
|
|
|
mov [ebx+FILEIO.offset], eax
|
|
|
|
jmp .common
|
|
|
|
@@:
|
|
|
|
.common:
|
|
|
|
add [ebx+FILEIO.offset], edx
|
|
|
|
retn
|
2020-04-29 01:24:56 +02:00
|
|
|
|
|
|
|
display_character:
|
|
|
|
pusha
|
|
|
|
cmp [_mode],NORMAL_MODE
|
|
|
|
jne @f
|
2020-05-03 15:24:00 +02:00
|
|
|
cmp al,$D
|
2020-04-29 01:24:56 +02:00
|
|
|
jz dc2
|
2020-05-03 15:24:00 +02:00
|
|
|
cmp al,$A
|
2020-04-29 01:24:56 +02:00
|
|
|
jnz dc1
|
|
|
|
and [textxy],0x0000FFFF
|
|
|
|
add [textxy], 8 shl 16 and 0xFFFF0000 + 18
|
2020-05-03 15:24:00 +02:00
|
|
|
popa
|
|
|
|
retn
|
2020-04-29 01:24:56 +02:00
|
|
|
dc1:
|
2020-05-03 15:24:00 +02:00
|
|
|
mov [dc],al
|
|
|
|
mov eax,[textxy]
|
2020-04-29 01:24:56 +02:00
|
|
|
cmp ax,word[bottom_right]
|
|
|
|
ja dc2
|
|
|
|
shr eax,16
|
|
|
|
cmp ax,word[bottom_right+2]
|
|
|
|
ja dc2
|
2020-05-03 15:24:00 +02:00
|
|
|
mov ecx,[sc.work_text]
|
|
|
|
or ecx,$10000000
|
|
|
|
mcall SF_DRAW_TEXT,[textxy],,dc,1
|
2020-04-29 01:24:56 +02:00
|
|
|
add [textxy],0x00080000
|
2020-05-03 15:24:00 +02:00
|
|
|
dc2:
|
2020-04-29 01:24:56 +02:00
|
|
|
popa
|
2020-05-03 15:24:00 +02:00
|
|
|
retn
|
2020-04-29 01:24:56 +02:00
|
|
|
@@:
|
2020-05-03 15:24:00 +02:00
|
|
|
mov cl,al
|
|
|
|
mcall SF_BOARD,SSF_DEBUG_WRITE
|
2020-04-29 01:24:56 +02:00
|
|
|
popa
|
2020-05-03 15:24:00 +02:00
|
|
|
retn
|
2020-04-29 01:24:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
display_string:
|
2020-05-03 15:24:00 +02:00
|
|
|
; in:
|
|
|
|
; esi - ASCIIZ string
|
|
|
|
; preserves: ebx, esi
|
|
|
|
push esi
|
|
|
|
@@: lodsb
|
|
|
|
test al,al
|
2020-04-29 01:24:56 +02:00
|
|
|
je @f
|
|
|
|
call display_character
|
|
|
|
jmp @b
|
|
|
|
@@:
|
2020-05-03 15:24:00 +02:00
|
|
|
pop esi
|
|
|
|
retn
|
2020-04-29 01:24:56 +02:00
|
|
|
|
|
|
|
display_number:
|
|
|
|
push ebx
|
|
|
|
mov ecx,1000000000
|
|
|
|
xor edx,edx
|
|
|
|
xor bl,bl
|
|
|
|
display_loop:
|
|
|
|
div ecx
|
|
|
|
push edx
|
|
|
|
cmp ecx,1
|
|
|
|
je display_digit
|
|
|
|
or bl,bl
|
|
|
|
jnz display_digit
|
|
|
|
or al,al
|
|
|
|
jz digit_ok
|
|
|
|
not bl
|
|
|
|
display_digit:
|
2020-05-03 15:24:00 +02:00
|
|
|
add al,'0'
|
2020-04-29 01:24:56 +02:00
|
|
|
push ebx ecx
|
|
|
|
call display_character
|
|
|
|
pop ecx ebx
|
|
|
|
digit_ok:
|
|
|
|
mov eax,ecx
|
|
|
|
xor edx,edx
|
|
|
|
mov ecx,10
|
|
|
|
div ecx
|
|
|
|
mov ecx,eax
|
|
|
|
pop eax
|
|
|
|
or ecx,ecx
|
|
|
|
jnz display_loop
|
|
|
|
pop ebx
|
2020-05-03 15:24:00 +02:00
|
|
|
retn
|
2020-04-29 01:24:56 +02:00
|
|
|
|
|
|
|
display_user_messages:
|
|
|
|
; push [skinh]
|
|
|
|
; pop [textxy]
|
|
|
|
; add [textxy], 7 shl 16 +53
|
|
|
|
mov [displayed_count],0
|
|
|
|
call show_display_buffer
|
|
|
|
cmp [displayed_count],1
|
|
|
|
jb line_break_ok
|
|
|
|
je make_line_break
|
|
|
|
mov ax,word[last_displayed]
|
|
|
|
cmp ax,0A0Dh
|
|
|
|
je line_break_ok
|
|
|
|
cmp ax,0D0Ah
|
|
|
|
je line_break_ok
|
|
|
|
make_line_break:
|
|
|
|
mov esi,crlf
|
|
|
|
call display_string
|
|
|
|
line_break_ok:
|
2020-05-03 15:24:00 +02:00
|
|
|
retn
|
2020-04-29 01:24:56 +02:00
|
|
|
|
|
|
|
display_block:
|
2020-05-03 15:24:00 +02:00
|
|
|
; in:
|
|
|
|
; esi - string
|
|
|
|
; ecx = string length
|
|
|
|
push esi
|
|
|
|
@@: lodsb
|
2020-04-29 01:24:56 +02:00
|
|
|
call display_character
|
|
|
|
loop @b
|
2020-05-03 15:24:00 +02:00
|
|
|
pop esi
|
|
|
|
retn
|
2020-04-29 01:24:56 +02:00
|
|
|
|
|
|
|
fatal_error:
|
2020-05-03 15:24:00 +02:00
|
|
|
; no return, trashes stack
|
|
|
|
|
2020-04-29 01:24:56 +02:00
|
|
|
mov esi,error_prefix
|
|
|
|
call display_string
|
|
|
|
pop esi
|
|
|
|
call display_string
|
|
|
|
mov esi,error_suffix
|
|
|
|
call display_string
|
|
|
|
mov esi,crlf
|
|
|
|
call display_string
|
|
|
|
mov al,0FFh
|
|
|
|
jmp exit_program
|
|
|
|
|
|
|
|
assembler_error:
|
|
|
|
call display_user_messages
|
2020-05-03 15:24:00 +02:00
|
|
|
push 0
|
2020-04-29 01:24:56 +02:00
|
|
|
mov ebx,[current_line]
|
|
|
|
get_error_lines:
|
|
|
|
push ebx
|
|
|
|
test byte [ebx+7],80h
|
|
|
|
jz display_error_line
|
|
|
|
mov edx,ebx
|
|
|
|
find_definition_origin:
|
|
|
|
mov edx,[edx+12]
|
|
|
|
test byte [edx+7],80h
|
|
|
|
jnz find_definition_origin
|
|
|
|
push edx
|
|
|
|
mov ebx,[ebx+8]
|
|
|
|
jmp get_error_lines
|
|
|
|
display_error_line:
|
|
|
|
mov esi,[ebx]
|
|
|
|
call display_string
|
|
|
|
mov esi,line_number_start
|
|
|
|
call display_string
|
|
|
|
mov eax,[ebx+4]
|
|
|
|
and eax,7FFFFFFFh
|
|
|
|
call display_number
|
2020-05-03 15:24:00 +02:00
|
|
|
mov al,']'
|
2020-04-29 01:24:56 +02:00
|
|
|
call display_character
|
|
|
|
pop esi
|
|
|
|
cmp ebx,esi
|
|
|
|
je line_number_ok
|
2020-05-03 15:24:00 +02:00
|
|
|
mov al,' '
|
2020-04-29 01:24:56 +02:00
|
|
|
call display_character
|
|
|
|
push esi
|
|
|
|
mov esi,[esi]
|
|
|
|
movzx ecx,byte [esi]
|
|
|
|
inc esi
|
|
|
|
call display_block
|
|
|
|
mov esi,line_number_start
|
|
|
|
call display_string
|
|
|
|
pop esi
|
|
|
|
mov eax,[esi+4]
|
|
|
|
and eax,7FFFFFFFh
|
|
|
|
call display_number
|
2020-05-03 15:24:00 +02:00
|
|
|
mov al,']'
|
2020-04-29 01:24:56 +02:00
|
|
|
call display_character
|
|
|
|
line_number_ok:
|
|
|
|
mov esi,line_data_start
|
|
|
|
call display_string
|
|
|
|
mov esi,ebx
|
|
|
|
mov edx,[esi]
|
|
|
|
call open
|
|
|
|
mov al,2
|
|
|
|
xor edx,edx
|
|
|
|
call lseek
|
|
|
|
mov edx,[esi+8]
|
|
|
|
sub eax,edx
|
|
|
|
push eax
|
|
|
|
xor al,al
|
|
|
|
call lseek
|
|
|
|
mov ecx,[esp]
|
|
|
|
mov edx,[additional_memory]
|
|
|
|
lea eax,[edx+ecx]
|
|
|
|
cmp eax,[additional_memory_end]
|
|
|
|
ja out_of_memory
|
|
|
|
call read
|
|
|
|
call close
|
|
|
|
pop ecx
|
|
|
|
mov esi,[additional_memory]
|
|
|
|
get_line_data:
|
|
|
|
mov al,[esi]
|
2020-05-03 15:24:00 +02:00
|
|
|
cmp al,$A
|
2020-04-29 01:24:56 +02:00
|
|
|
je display_line_data
|
2020-05-03 15:24:00 +02:00
|
|
|
cmp al,$D
|
2020-04-29 01:24:56 +02:00
|
|
|
je display_line_data
|
2020-05-03 15:24:00 +02:00
|
|
|
cmp al,$1A
|
2020-04-29 01:24:56 +02:00
|
|
|
je display_line_data
|
|
|
|
or al,al
|
|
|
|
jz display_line_data
|
|
|
|
inc esi
|
|
|
|
loop get_line_data
|
|
|
|
display_line_data:
|
|
|
|
mov ecx,esi
|
|
|
|
mov esi,[additional_memory]
|
|
|
|
sub ecx,esi
|
|
|
|
call display_block
|
|
|
|
mov esi,crlf
|
|
|
|
call display_string
|
|
|
|
pop ebx
|
|
|
|
or ebx,ebx
|
|
|
|
jnz display_error_line
|
|
|
|
mov esi,error_prefix
|
|
|
|
call display_string
|
|
|
|
pop esi
|
|
|
|
call display_string
|
|
|
|
mov esi,error_suffix
|
|
|
|
call display_string
|
|
|
|
jmp exit_program
|