diff --git a/plat/msdos386/descr b/plat/msdos386/descr index d7be3eb1e..b6683871b 100644 --- a/plat/msdos386/descr +++ b/plat/msdos386/descr @@ -46,7 +46,7 @@ name led program {EM}/lib/ack/em_led mapflag -l* LNAME={PLATFORMDIR}/lib* mapflag -fp FLOATS={EM}/{ILIB}fp - args {ALIGN} {SEPID} \ + args {ALIGN} \ ({RTS}:.b=-u _i_main) \ (.e:{HEAD}={PLATFORMDIR}/boot.o) \ ({RTS}:.ocm.bas.b={PLATFORMDIR}/c-ansi.o) \ @@ -66,7 +66,6 @@ name led {PLATFORMDIR}/libc.a \ {PLATFORMDIR}/libem.a \ {PLATFORMDIR}/libend.a) - linker end name cv diff --git a/plat/msdos386/libsys/brk.s b/plat/msdos386/libsys/brk.s index 0e3170467..3032bc929 100644 --- a/plat/msdos386/libsys/brk.s +++ b/plat/msdos386/libsys/brk.s @@ -7,17 +7,12 @@ .sect .text -.extern realloc_ptr - .define _brk _brk: - enter 0, 0 -newsize = 2*4 - - mov eax, newsize(ebp) + mov ebx, esp + mov eax, 1*4(ebx) callf (realloc_ptr) xor eax, eax - leave ret diff --git a/plat/msdos386/libsys/close.s b/plat/msdos386/libsys/close.s index 5e52a638b..412307b62 100644 --- a/plat/msdos386/libsys/close.s +++ b/plat/msdos386/libsys/close.s @@ -16,8 +16,8 @@ .define _close _close: - mov ebx, sp - mov ebx, 4(ebx) + mov ebx, esp + mov ebx, 1*4(esp) movb ah, 0x3E int 0x21 jmp .sys_zret diff --git a/plat/msdos386/libsys/isatty.s b/plat/msdos386/libsys/isatty.s index 7ed92fffd..794274bfa 100644 --- a/plat/msdos386/libsys/isatty.s +++ b/plat/msdos386/libsys/isatty.s @@ -16,7 +16,7 @@ .define _isatty _isatty: - mov ebx, sp + mov ebx, esp mov ebx, 4(ebx) o16 mov ax, 0x4400 int 0x21 diff --git a/plat/msdos386/libsys/rename.s b/plat/msdos386/libsys/rename.s index 1550b73db..4b43a0d48 100644 --- a/plat/msdos386/libsys/rename.s +++ b/plat/msdos386/libsys/rename.s @@ -16,12 +16,39 @@ .define _rename _rename: - int 3 - mov bx, sp - push di - mov dx, 2(bx) - mov di, 4(bx) + mov ebx, esp + push esi + push edi + + ! Source filename. + + mov esi, 4(ebx) + movzx edi, (transfer_buffer_ptr) + mov es, (pmode_ds) + cld +1: + lodsb + stosb + testb al, al + jnz 1b + + ! Destination filename. + + mov eax, edi + mov esi, 8(ebx) +1: + lodsb + stosb + testb al, al + jnz 1b + + ! Make the DOS call. + + o16 mov dx, (transfer_buffer_ptr) + o16 mov di, ax movb ah, 0x56 - int 0x21 - pop di + or ebx, 0x210000 + callf (interrupt_ptr) + pop edi + pop esi jmp .sys_zret diff --git a/plat/msdos386/libsys/sys_exists.s b/plat/msdos386/libsys/sys_exists.s index 8786f4c2a..f57d28b3e 100644 --- a/plat/msdos386/libsys/sys_exists.s +++ b/plat/msdos386/libsys/sys_exists.s @@ -16,11 +16,10 @@ .define __sys_exists __sys_exists: - int 3 - mov bx, sp - mov dx, 2(bx) - mov ax, 0x4300 + mov ebx, esp + mov edx, 4(ebx) + mov eax, 0x4300 int 0x21 - sbb ax, ax - inc ax + sbb eax, eax + inc eax ret diff --git a/plat/msdos386/libsys/sys_getdate.s b/plat/msdos386/libsys/sys_getdate.s index eeb118923..981253b93 100644 --- a/plat/msdos386/libsys/sys_getdate.s +++ b/plat/msdos386/libsys/sys_getdate.s @@ -16,11 +16,10 @@ .define __sys_getdate __sys_getdate: - int 3 movb ah, 0x2a int 0x21 - mov bx, sp - mov bx, 2(bx) - mov (bx), dx - mov 2(bx), cx + mov ebx, esp + mov ebx, 4(ebx) + o16 mov 0(ebx), dx + o16 mov 2(ebx), cx ret diff --git a/plat/msdos386/libsys/sys_gettime.s b/plat/msdos386/libsys/sys_gettime.s index d3ea65847..a565ea860 100644 --- a/plat/msdos386/libsys/sys_gettime.s +++ b/plat/msdos386/libsys/sys_gettime.s @@ -16,11 +16,10 @@ .define __sys_gettime __sys_gettime: - int 3 movb ah, 0x2c int 0x21 - mov bx, sp - mov bx, 2(bx) - mov (bx), cx - mov 2(bx), dx + mov ebx, esp + mov ebx, 2(ebx) + o16 mov 0(ebx), cx + o16 mov 2(ebx), dx ret diff --git a/plat/msdos386/libsys/sys_isopen.s b/plat/msdos386/libsys/sys_isopen.s index 5da95a44e..5a5fed07c 100644 --- a/plat/msdos386/libsys/sys_isopen.s +++ b/plat/msdos386/libsys/sys_isopen.s @@ -17,11 +17,10 @@ .define __sys_isopen __sys_isopen: - int 3 - mov bx, sp - mov bx, 2(bx) - mov ax, 0x4400 + mov ebx, esp + mov ebx, 4(bx) + mov eax, 0x4400 int 0x21 - sbb ax, ax - inc ax + sbb eax, eax + inc eax ret diff --git a/plat/msdos386/libsys/sys_isreadyr.s b/plat/msdos386/libsys/sys_isreadyr.s index ff3960b27..9a646adc8 100644 --- a/plat/msdos386/libsys/sys_isreadyr.s +++ b/plat/msdos386/libsys/sys_isreadyr.s @@ -17,13 +17,13 @@ .define __sys_isreadyr __sys_isreadyr: - mov ebx, sp + mov ebx, esp mov eax, 0x4406 mov ebx, 4(ebx) int 0x21 jnc ok movb al, 0 ok: - cbw - cwd + o16 cbw + cwde ret diff --git a/plat/msdos386/libsys/sys_rawcreat.s b/plat/msdos386/libsys/sys_rawcreat.s index 0d765a27d..b15df3f4f 100644 --- a/plat/msdos386/libsys/sys_rawcreat.s +++ b/plat/msdos386/libsys/sys_rawcreat.s @@ -16,10 +16,30 @@ .define __sys_rawcreat __sys_rawcreat: - int 3 + ! Copy filename to transfer buffer. + + mov ebx, esp + push esi + push edi + mov esi, 4(ebx) + movzx edi, (transfer_buffer_ptr) + mov es, (pmode_ds) + cld +1: + lodsb + stosb + testb al, al + jnz 1b + + ! Make the DOS call. + movb ah, 0x3c - mov bx, sp - mov dx, 2(bx) - mov cx, 4(bx) - int 0x21 + movzx edx, (transfer_buffer_ptr) + movb al, 8(ebx) + or ebx, 0x210000 + callf (interrupt_ptr) + + pop edi + pop esi jmp .sys_axret + diff --git a/plat/msdos386/libsys/sys_rawlseek.s b/plat/msdos386/libsys/sys_rawlseek.s index 06a7783a7..c38a1e0b1 100644 --- a/plat/msdos386/libsys/sys_rawlseek.s +++ b/plat/msdos386/libsys/sys_rawlseek.s @@ -16,12 +16,11 @@ .define __sys_rawlseek __sys_rawlseek: - int 3 movb ah, 0x42 - mov bx, sp - mov dx, 4(bx) - mov cx, 6(bx) - movb al, 8(bx) - mov bx, 2(bx) + mov ebx, esp + mov edx, 8(bx) + mov ecx, 12(bx) + movb al, 16(bx) + mov ebx, 4(bx) int 0x21 jmp .sys_dxaxret diff --git a/plat/msdos386/libsys/sys_rawopen.s b/plat/msdos386/libsys/sys_rawopen.s index 5fae1bba4..bb4ff5acb 100644 --- a/plat/msdos386/libsys/sys_rawopen.s +++ b/plat/msdos386/libsys/sys_rawopen.s @@ -16,10 +16,30 @@ .define __sys_rawopen __sys_rawopen: - int 3 + ! Copy filename to transfer buffer. + + mov ebx, esp + push esi + push edi + + mov esi, 4(ebx) + movzx edi, (transfer_buffer_ptr) + mov es, (pmode_ds) + cld +1: + lodsb + stosb + testb al, al + jnz 1b + + ! Make the DOS call. + movb ah, 0x3d - mov bx, sp - mov dx, 2(bx) - movb al, 4(bx) - int 0x21 + o16 mov dx, (transfer_buffer_ptr) + movb al, 8(ebx) + or ebx, 0x210000 + callf (interrupt_ptr) + + pop edi + pop esi jmp .sys_axret diff --git a/plat/msdos386/libsys/sys_rawread.s b/plat/msdos386/libsys/sys_rawread.s index c54410347..f5b0c1a35 100644 --- a/plat/msdos386/libsys/sys_rawread.s +++ b/plat/msdos386/libsys/sys_rawread.s @@ -12,12 +12,6 @@ .sect .text -.extern pmode_ds -.extern pmode_cs -.extern rmode -.extern transfer_buffer_ptr -.extern interrupt_ptr - ! Read bytes from a file descriptor. These routines do not do any ! translation between CRLF and LF line endings. ! @@ -27,6 +21,8 @@ .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 @@ -43,7 +39,6 @@ amount_to_read = 4*4 movb ah, 0x3f o16 mov dx, (transfer_buffer_ptr) o16 mov bx, file_handle(ebp) - mov ecx, 0x80 or ebx, 0x210000 callf (interrupt_ptr) jnc success @@ -52,8 +47,8 @@ amount_to_read = 4*4 push eax call __sys_seterrno - leave - ret + pop ecx + jmp exit success: ! Copy eax bytes out of the transfer buffer. @@ -71,6 +66,9 @@ success: loop 1b pop eax +exit: + pop edi + pop esi leave ret diff --git a/plat/msdos386/libsys/sys_rawwrite.s b/plat/msdos386/libsys/sys_rawwrite.s index 5451670fe..3ac3a7e16 100644 --- a/plat/msdos386/libsys/sys_rawwrite.s +++ b/plat/msdos386/libsys/sys_rawwrite.s @@ -12,12 +12,6 @@ .sect .text -.extern pmode_ds -.extern pmode_cs -.extern rmode -.extern transfer_buffer_ptr -.extern interrupt_ptr - ! Write bytes to/to a file descriptor. These routines do not do any ! translation between CRLF and LF line endings. ! @@ -27,6 +21,8 @@ .define __sys_rawwrite __sys_rawwrite: enter 0, 0 + push esi + push edi file_handle = 2*4 read_buffer = 3*4 amount_to_write = 4*4 @@ -59,7 +55,10 @@ amount_to_write = 4*4 push eax call __sys_seterrno + pop ecx exit: + pop edi + pop esi leave ret diff --git a/plat/msdos386/libsys/unlink.s b/plat/msdos386/libsys/unlink.s index 912f6958d..7d023ad48 100644 --- a/plat/msdos386/libsys/unlink.s +++ b/plat/msdos386/libsys/unlink.s @@ -16,8 +16,29 @@ .define _unlink _unlink: - mov bx, sp - mov dx, 2(bx) + ! Copy filename to transfer buffer. + + mov ebx, esp + push esi + push edi + + mov esi, 4(ebx) + movzx edi, (transfer_buffer_ptr) + mov es, (pmode_ds) + cld +1: + lodsb + stosb + testb al, al + jnz 1b + + ! Make the DOS call. + + movzx edi, (transfer_buffer_ptr) movb ah, 0x41 - int 0x21 + or ebx, 0x210000 + callf (interrupt_ptr) + + pop edi + pop esi jmp .sys_zret diff --git a/plat/msdos386/stub.s b/plat/msdos386/stub.s index 35b9e8e40..219d66470 100644 --- a/plat/msdos386/stub.s +++ b/plat/msdos386/stub.s @@ -321,24 +321,21 @@ interrupt: mov (dpmi_ds), ax mov (dpmi_ss), ax push es - push ds - mov ax, dosstack ! auto stack is too small - mov (dpmi_sp), ax + mov (dpmi_sp), dosstack ! auto stack is too small push ds pop es - mov di, dpmi_edi + o32 mov edi, dpmi_edi mov ax, 0x300 o32 shr ebx, 16 int 0x31 ! simulate DOS interrupt - pop ds pop es - pushf o32 movzx eax, (dpmi_eax) o32 movzx ebx, (dpmi_ebx) o32 movzx ecx, (dpmi_ecx) o32 movzx edx, (dpmi_edx) o32 movzx esi, (dpmi_esi) o32 movzx edi, (dpmi_edi) + push (dpmi_flags) popf ret