2022-08-17 20:34:06 +00:00
|
|
|
#
|
|
|
|
! $Source$
|
|
|
|
! $State$
|
|
|
|
! $Revision$
|
|
|
|
|
|
|
|
! Declare segments (the order is important).
|
|
|
|
|
|
|
|
.sect .text
|
|
|
|
.sect .rom
|
|
|
|
.sect .data
|
|
|
|
.sect .bss
|
|
|
|
|
|
|
|
.sect .text
|
|
|
|
|
|
|
|
! Write bytes to/to 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_rawwrite
|
|
|
|
__sys_rawwrite:
|
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 20:34:06 +00:00
|
|
|
file_handle = 2*4
|
|
|
|
read_buffer = 3*4
|
|
|
|
amount_to_write = 4*4
|
|
|
|
|
2022-08-18 19:21:33 +00:00
|
|
|
mov eax, amount_to_write(ebp)
|
|
|
|
mov ecx, 32*1024 ! size of transfer buffer
|
|
|
|
cmp eax, ecx
|
|
|
|
jge 2f
|
|
|
|
mov ecx, eax
|
2022-08-17 20:34:06 +00:00
|
|
|
2:
|
2022-08-17 22:24:08 +00:00
|
|
|
|
2022-08-18 19:21:33 +00:00
|
|
|
! Copy ecx bytes into the transfer buffer.
|
2022-08-17 20:34:06 +00:00
|
|
|
|
2022-08-18 19:21:33 +00:00
|
|
|
push ecx
|
|
|
|
mov esi, read_buffer(ebp)
|
|
|
|
movzx edi, (transfer_buffer_ptr)
|
|
|
|
mov es, (pmode_ds)
|
|
|
|
cld
|
|
|
|
rep movsb
|
|
|
|
pop ecx
|
2022-08-17 22:24:08 +00:00
|
|
|
|
2022-08-18 19:21:33 +00:00
|
|
|
! Write from the transfer buffer to DOS.
|
2022-08-17 22:24:08 +00:00
|
|
|
|
2022-08-18 19:21:33 +00:00
|
|
|
movb ah, 0x40
|
|
|
|
o16 mov dx, (transfer_buffer_ptr)
|
|
|
|
o16 mov bx, file_handle(ebp)
|
|
|
|
or ebx, 0x210000
|
|
|
|
callf (interrupt_ptr)
|
|
|
|
jnc exit
|
2022-08-17 20:34:06 +00:00
|
|
|
|
2022-08-18 19:21:33 +00:00
|
|
|
push eax
|
|
|
|
call __sys_seterrno
|
2022-08-18 22:08:57 +00:00
|
|
|
pop ecx
|
2022-08-17 20:34:06 +00:00
|
|
|
exit:
|
2022-08-18 22:08:57 +00:00
|
|
|
pop edi
|
|
|
|
pop esi
|
2022-08-18 19:21:33 +00:00
|
|
|
leave
|
|
|
|
ret
|
|
|
|
|
|
|
|
! vim: sw=4 ts=4 et
|
2022-08-17 20:34:06 +00:00
|
|
|
|