15955282f6
- ensure es = ds = ss upon exit of each C runtime function - clear upper 16 bits of ebx before setting them to 0x0021, when invoking interrupt_ptr to simulate a RM int 0x21 - make _sys_exists use the transfer buffer (which it needs) - make _sys_rawread properly handle an end-of-file read (zero bytes read) - make argument to _sys_seterrno short --- after a failed int 0x21 call, only the lower 16 bits of eax hold the MS-DOs error code - _sys_rawlseek accepts only 3 longword arguments, not 4 (the offset is only 1 longword) - other minor fixes
79 lines
1.1 KiB
ArmAsm
79 lines
1.1 KiB
ArmAsm
#
|
|
! $Source$
|
|
! $State$
|
|
! $Revision$
|
|
|
|
! Declare segments (the order is important).
|
|
|
|
.sect .text
|
|
.sect .rom
|
|
.sect .data
|
|
.sect .bss
|
|
|
|
.sect .text
|
|
|
|
! Read bytes from a file descriptor. These routines do not do any
|
|
! translation between CRLF and LF line endings.
|
|
!
|
|
! Note that, for MS-DOS, a raw "write" request of zero bytes will truncate
|
|
! (or extend) the file to the current file position.
|
|
|
|
.define __sys_rawread
|
|
__sys_rawread:
|
|
enter 0, 0
|
|
push esi
|
|
push edi
|
|
file_handle = 2*4
|
|
write_buffer = 3*4
|
|
amount_to_read = 4*4
|
|
|
|
mov eax, amount_to_read(ebp)
|
|
mov ecx, 32*1024
|
|
cmp eax, ecx
|
|
jge 2f
|
|
mov ecx, eax
|
|
2:
|
|
|
|
! Read from DOS into the transfer buffer.
|
|
|
|
movb ah, 0x3f
|
|
o16 mov dx, (transfer_buffer_ptr)
|
|
movzx esi, dx
|
|
mov ebx, 0x210000
|
|
o16 mov bx, file_handle(ebp)
|
|
callf (interrupt_ptr)
|
|
jnc success
|
|
|
|
! Process errors.
|
|
|
|
push eax
|
|
call __sys_seterrno
|
|
pop ecx
|
|
jmp exit
|
|
success:
|
|
|
|
! Copy eax bytes out of the transfer buffer.
|
|
|
|
movzx eax, ax
|
|
mov ecx, eax
|
|
jcxz exit
|
|
push eax
|
|
mov edi, write_buffer(ebp)
|
|
mov es, (pmode_ds)
|
|
cld
|
|
1:
|
|
eseg lodsb
|
|
movb (edi), al
|
|
inc edi
|
|
loop 1b
|
|
pop eax
|
|
|
|
exit:
|
|
pop edi
|
|
pop esi
|
|
push ss
|
|
pop es
|
|
leave
|
|
ret
|
|
|