2022-08-07 20:10:08 +00:00
|
|
|
#
|
|
|
|
! $Source$
|
|
|
|
! $State$
|
|
|
|
! $Revision$
|
|
|
|
|
|
|
|
! Declare segments (the order is important).
|
|
|
|
|
|
|
|
.sect .text
|
|
|
|
.sect .rom
|
|
|
|
.sect .data
|
|
|
|
.sect .bss
|
|
|
|
|
|
|
|
.sect .text
|
|
|
|
|
2022-08-17 20:34:06 +00:00
|
|
|
! Read bytes from a file descriptor. These routines do not do any
|
2022-08-07 20:10:08 +00:00
|
|
|
! 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:
|
2022-08-18 19:21:33 +00:00
|
|
|
enter 0, 0
|
2022-08-18 22:08:57 +00:00
|
|
|
push esi
|
|
|
|
push edi
|
2022-08-17 22:24:08 +00:00
|
|
|
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)
|
|
|
|
o16 mov bx, file_handle(ebp)
|
|
|
|
or ebx, 0x210000
|
|
|
|
callf (interrupt_ptr)
|
2022-08-18 19:21:33 +00:00
|
|
|
jnc success
|
|
|
|
|
|
|
|
! Process errors.
|
|
|
|
|
|
|
|
push eax
|
|
|
|
call __sys_seterrno
|
2022-08-18 22:08:57 +00:00
|
|
|
pop ecx
|
|
|
|
jmp exit
|
2022-08-18 19:21:33 +00:00
|
|
|
success:
|
2022-08-17 22:24:08 +00:00
|
|
|
|
|
|
|
! Copy eax bytes out of the transfer buffer.
|
|
|
|
|
|
|
|
push eax
|
2022-08-18 19:21:33 +00:00
|
|
|
mov ecx, eax
|
2022-08-17 22:24:08 +00:00
|
|
|
movzx esi, (transfer_buffer_ptr)
|
|
|
|
mov edi, write_buffer(ebp)
|
|
|
|
mov es, (pmode_ds)
|
|
|
|
cld
|
|
|
|
1:
|
2022-08-18 19:21:33 +00:00
|
|
|
eseg lodsb
|
2022-08-17 22:24:08 +00:00
|
|
|
movb (edi), al
|
2022-08-18 19:21:33 +00:00
|
|
|
inc edi
|
2022-08-17 22:24:08 +00:00
|
|
|
loop 1b
|
|
|
|
pop eax
|
|
|
|
|
2022-08-18 22:08:57 +00:00
|
|
|
exit:
|
|
|
|
pop edi
|
|
|
|
pop esi
|
2022-08-17 22:24:08 +00:00
|
|
|
leave
|
|
|
|
ret
|
|
|
|
|