Metropoli BBS
VIEWER: dos.s MODE: TEXT (ASCII)
#
# DOS.S   (c) Rainer Schnitker
#
# Provide syscalls for Win32 and MSDOS
#
# History:
#
#  6/95 : first code
#  7/95 : modify import address to call dummy code if RSXNT is not imported
#

.data
        __win32_app:
        .long   1

        __init_address:
        .long   __emx_init

        __call_address:
        .long   __emx_syscall

.text

        .align  2, 0x90
__emx_init:
        ret     $4                      # dummy init

        .align  2, 0x90
__emx_syscall:                          # code for dll that will
        movl    $-1, %eax               # not use RSXNT.DLL
        movl    $-1, %ecx               # return like syscall fail
        ret

        .align  2, 0x90
        .globl  __dos_init
__dos_init:
        movl    $__text, %eax           # if DOS, eax = 0x10000
        subl    $0x10000, %eax          # compare to dos text addr
        movl    %eax, __win32_app
        jz      1f
__rsxnt_init:
        jmp     *__init_address         # win32 : import-address
1:      ret     $4                      # dos

        .align  2, 0x90
        .globl  __dos_syscall
__dos_syscall:
        cmpl    $0, __win32_app
        je      1f
__rsxnt_call:
        jmp     *__call_address         # win32 : import-address
1:      int     $0x21                   # dos
        ret

        call    _force_reloc_call

# add syscall import entries for RSXNT.DLL

.stabs "__ImpNT_RSXNT_Call=RSXNT.dll", 36, 0, 1, __rsxnt_call+2
.stabs "__ImpNT_RSXNT_Init=RSXNT.dll", 36, 0, 2, __rsxnt_init+2
[ RETURN TO DIRECTORY ]