;actually segments.inc ... but who cares?

iscom           equ     1               ;COMMENT IT IF IT'S NOT A COM FILE!!!
@codesize       equ     0               ;0=near,1=far
@datasize       equ     0               ;0=near,1=far,2=huge
;stackfar        equ     1

macro   startcode
  segment _text dword public 'code' use16
        assume  es:nothing,cs:@code,ss:@stack,ds:@data,fs:nothing,gs:nothing
endm    startcode
macro   endcode
        align   dword   ;pad it with nops instead of 0's
        ends
endm    endcode

macro   startcodeend
  segment textend para public 'textend' use16 ;MUST BE PARA ALIGNED (dis.asm depends on it)
endm    startcodeend
macro   endcodeend
        ends
endm    endcodeend

macro   startdata
  segment _data dword public 'data' use16
endm    startdata
macro   enddata
        ends
endm    enddata
macro   startconst
  segment const dword public 'const' use16
endm    startconst
macro   endconst
        ends
endm    endconst
macro   startbss
  segment _bss dword public 'bss' use16
endm    startbss
macro   endbss
        ends
endm    endbss
macro   startbssend
  segment bssend para public 'bss' use16        ;PARA aligned!
endm    startbssend
macro   endbssend
        ends
endm    endbssend

ifndef iscom
macro   startstack
  segment stack para stack 'stack' use16        ;PARA ALIGNED!
endm    startstack
macro   endstack
        ends
endm    endstack
endif

;stack for .com files
macro   startlastseg
  segment lastseg para public 'lastseg' use16   ;PARA ALIGNED!
endm    startlastseg
macro   endlastseg
        ends
endm    endlastseg

ifdef iscom
  group dgroup _text,textend,_data,const,_bss,bssend,lastseg
  @code         equ     dgroup
  @data         equ     dgroup
else
  group dgroup _data,const,_bss,bssend,stack,lastseg
  @code         equ     _text
  @data         equ     dgroup
endif
@stack          equ     % @data
@codeend        equ     textend

        startcode
        endcode
        startcodeend
        endcodeend
        startdata
        enddata
        startconst
        endconst
        startbss
        endbss
        startbssend
        endbssend
ifndef iscom
        startstack
        endstack
endif
        startlastseg
        endlastseg

if @codesize
  procptr       equ     far
else
  procptr       equ     near
endif

if @datasize
  _es           equ     es
else
  _es           equ     ds
endif
