Metropoli BBS
VIEWER: startup.inc MODE: TEXT (ASCII)
;Modified QLIB.INC for startup code

.386
.387

option language:c
option dotname
option nokeyword:<.code .data .data? .stack>

_QLIB_CFG_ segment dword public use32 'CODE' ;the 1st segment!!!
_QLIB_CFG_ ends
_TEXT segment dword public use32 'CODE'
_TEXT ends
.text segment dword public use32 'CODE'
.text ends
_DATA segment dword public use32 'DATA'
_DATA ends
_INIT_ segment word public use32 'INITDATA'
_INIT_ ends
_INITEND_ segment word public use32 'INITDATA'
_INITEND_ ends
_EXIT_ segment word public use32 'EXITDATA'
_EXIT_ ends
_EXITEND_ segment word public use32 'EXITDATA'
_EXITEND_ ends
XIB segment word public use32 'DATA'
XIB ends
XI segment word public use32 'DATA'
XI ends
XIE segment word public use32 'DATA'
XIE ends
CONST  SEGMENT word PUBLIC USE32 'CONST'
CONST  ends
CONST2  SEGMENT word PUBLIC USE32 'DATA'
CONST2  ends
CONST2END  SEGMENT word PUBLIC USE32 'DATA'
CONST2END  ends
.CRT$XCU        SEGMENT DWORD PUBLIC USE32 'DATA'
.CRT$XCU        ENDS
.CRT$XCUEND     SEGMENT DWORD PUBLIC USE32 'DATA'
.CRT$XCUEND     ENDS
_BSS segment dword public use32 'BSS'
_BSS ends

dgroup group _QLIB_CFG_,_TEXT,_DATA,.text,STACK,_INIT_,_INITEND_,_EXIT_,_EXITEND_,XIB,XI,XIE,CONST,CONST2,CONST2END,.CRT$XCU,.CRT$XCUEND,_BSS

assume ds:dgroup,es:dgroup,ss:dgroup,fs:dgroup,gs:dgroup

endseg macro
  ifnb @CurSeg
  @CurSeg ends
  endif
endm
.code macro
  endseg
  _TEXT segment dword public use32 'CODE'
endm
.data macro
  endseg
  _DATA segment dword public use32 'DATA'
endm
.stack macro
  endseg
  STACK segment dword public use32 'STACK'
endm
.data? macro
  endseg
  _BSS segment dword public use32 'BSS'
endm
.bss macro
  .data?
endm

#include _str_.tmp

.data
externdef _os_typ:byte
externdef _os_ver_major:byte
externdef _os_ver_minor:byte
externdef _dos_ver_major:byte
externdef _dos_ver_minor:byte
externdef _dosXver:word   ;version (BCD coded)
externdef _dosXtyp:byte   ;DOS extender type (0=PMODEW 1=DOS/4GW 2=DOS32)
  DOSX_PMODEW equ 0
  DOSX_DOS4GW equ 1
  DOSX_DOS32 equ 2        ;not implemented any more
  DOSX_UNKNOWN equ 255
externdef errno:word
externdef selcode:word
externdef seldata:word
externdef selzero:word
externdef _environ:dword    ;relative addr
externdef _psp:dword        ;relative addr to PSP
externdef _dta:dword        ;relative addr to DTA  (it's not in your PSP)
externdef _base:dword       ;base of program
externdef _fpu:byte         ;80387?
externdef _8087:byte        ;WATCOM support
externdef _argstr:byte ;129 dup (?)
externdef _argv:dword ;64 dup (?)
externdef _argc:byte
externdef _pmmode:byte
  SRV_UNKNOWN equ 0ffh
  SRV_DPMI equ 3
  SRV_VCPI equ 2
  SRV_XMS equ 1
  SRV_RAW equ 0
externdef _filename:dword
externdef _ds_:word
externdef _es_:word
externdef _8kbufferseg:word
externdef _8kbuffer:dword
externdef _processor:byte  ; processor type : 3=386 4=486 5=586
externdef _cpu:byte        ; processor type : same
externdef _ansi_sys:byte

NULL equ 0
ERROR equ -1
NULLPROC proto

callstruct struct   ;50 bytes  (32h)
  _edi dd ?     ;0
  _esi dd ?     ;4
  _ebp dd ?     ;8
  _res dd ?     ;0ch reserved
  _ebx dd ?     ;10h
  _edx dd ?     ;14h
  _ecx dd ?     ;18h
  _eax dd ?     ;1ch
  _flg dw ?     ;20h flags
  _es dw ?      ;22h segments (NOT selectors)
  _ds dw ?      ;24h "
  _fs dw ?      ;26h "
  _gs dw ?      ;28h "
  _ip dw ?      ;2ah ignored in some calls
  _cs dw ?      ;2ch "
  _sp dw ?      ;2eh must be 0 to use system stacks
  _ss dw ?      ;30h "
callstruct ends

qptr equ qword ptr
dptr equ dword ptr
wptr equ word ptr
bptr equ byte ptr

.code
dos4gwint3 macro
  .if _dosXtyp==DOSX_DOS4GW
    int 3  ;call debugger if loaded
  .endif
endm

[ RETURN TO DIRECTORY ]