push di
mov dx, di
+ ; Check if it is a binary hive file
+ cmp byte [bx-5],'.'
+ je .checkForSymbol
+ cmp byte [bx-4],'.'
+ je .checkForSymbol
+ cmp byte [bx-3],'.'
+ je .checkForSymbol
+ cmp byte [bx-2],'.'
+ je .checkForSymbol
+
+ call sym_load_module
+ jmp .after_copy
+
+.checkForSymbol:
; Check if it is a symbol file
cmp byte [bx-5],'.'
jne .checkForHive
jmp .after_copy
.checkForHive:
- ; Check if it is a symbol file
+ ; Check if it is a hive file
cmp byte [bx-5],'.'
jne .lst_copy
cmp byte [bx-4],'h'
mov dx, _cpe_doshdr
int 0x21
jnc .header_read
- mov dx, error_file_read_failed
+ mov di, error_file_read_failed
jmp error
.header_read
mov ax, word [_cpe_doshdr + e_magic]
cmp ax, 'MZ'
je .mz_hdr_good
- mov dx, error_bad_mz
+ mov di, error_bad_mz
jmp error
.mz_hdr_good
mov bx, [_current_filehandle]
int 0x21
jnc .start_seek1
- mov dx, error_file_seek_failed
+ mov di, error_file_seek_failed
jmp error
.start_seek1:
mov ah, 0x3F
mov dx, _mb_magic
int 0x21
jnc .mb_header_read
- mov dx, error_file_read_failed
+ mov di, error_file_read_failed
jmp error
.mb_header_read:
jmp .first
mov ax, 0x3d00
int 0x21
jnc .file_opened
- mov dx, error_file_open_failed
+ mov di, error_file_open_failed
jmp error
.file_opened:
mov dx, 0
int 0x21
jnc .seek_start
- mov dx, error_file_seek_failed
+ mov di, error_file_seek_failed
jmp error
.seek_start:
ret
mov bx, [_current_filehandle]
int 0x21
jnc .start_end
- mov dx, error_file_seek_failed
+ mov di, error_file_seek_failed
jmp error
.start_end
shl edx, 16
mov bx, [_current_filehandle]
int 0x21
jnc .start_seek
- mov dx, error_file_seek_failed
+ mov di, error_file_seek_failed
jmp error
.start_seek
int 0x21
jnc .read_data_succeeded
pop ds
- mov dx, error_file_read_failed
+ mov di, error_file_read_failed
jmp error
.read_data_succeeded:
%ifndef NDEBUG
int 0x21
jnc .read_last_data_succeeded
pop ds
- mov dx, error_file_read_failed
+ mov di, error_file_read_failed
jmp error
.read_last_data_succeeded:
;;
;; On error print a message and return zero
;;
error:
- mov ah, 0x9
- int 0x21
- mov eax, 0
- ret
+ call print_string
+ mov ax,04c00h
+ int 21h
;;
;; Copy to high memory
dw 0x0000
error_pmode_already:
+ db 0xa, 0xd
db 'Error: The processor is already in protected mode'
- db 0xa, 0xd, '$'
+ db 0xa, 0xd, 0
error_file_open_failed:
- db 'Error: Failed to open file'
- db 0xa, 0xd, '$'
+ db 0xa, 0xd
+ db 'Error: Failed to open file (code 0x%a)'
+ db 0xa, 0xd, 0
error_file_seek_failed:
- db 'Error: File seek failed'
- db 0xa, 0xd, '$'
+ db 0xa, 0xd
+ db 'Error: File seek failed (code 0x%a)'
+ db 0xa, 0xd, 0
error_file_read_failed:
- db 'Error: File read failed'
- db 0xa, 0xd, '$'
-error_coff_load_failed:
- db 'Error: Failed to load COFF file'
- db 0xa, 0xd, '$'
+ db 0xa, 0xd
+ db 'Error: File read failed (code 0x%a)'
+ db 0xa, 0xd, 0
error_bad_mz:
+ db 0xa, 0xd
db 'Error: Bad DOS EXE magic'
- db 0xa, 0xd, '$'
+ db 0xa, 0xd, 0