ack/plat/msdos386/libsys/sys_xret.s
tkchia 15955282f6 plat/msdos386: fix some issues in libsys code
- 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
2022-08-24 15:17:04 +00:00

52 lines
861 B
ArmAsm

#
! $Source$
! $State$
! $Revision$
! Declare segments (the order is important).
.sect .text
.sect .rom
.sect .data
.sect .bss
.sect .text
! .sys_zret: if the carry flag is set, then set `errno' from the DOS error
! code in ax, and return an int -1. If the carry flag is clear, just
! return an int zero.
!
! .sys_axret: if the carry flag is set, then set `errno' from the DOS error
! code in ax, and return a shortword -1. If the carry flag is clear, just
! return ax as a return value.
!
! .sys_dxaxret: same as .sys_axret, but return -1 or eax := dx:ax as a
! return value.
.extern .sys_zret
.extern .sys_axret
.extern .sys_dxaxret
.sys_zret:
jc error
xor eax, eax
no_error:
ret
.sys_axret:
jc error
ret
.sys_dxaxret:
jc error
shl edx, 16
o16 mov dx, ax
mov eax, edx
ret
error:
movzx eax, ax
push eax
call __sys_seterrno
pop ecx
ret