;       SCCSID = @(#)debseg.inc	6.1 90/11/17
;      SCCSID = @(#)debseg.inc	13.4 89/08/11
;***	DEBSEG.INC
;
;	This is where the debugger's data and code segments 
;	are defined. There are macros and equates that are
;	used to allow the code and data segments to be easly
;	changed.
;
;

; These equates should be used instead of directly using the segment name.

codeOFFSET	equ	offset DBGCODE:
dataOFFSET	equ	offset DBGDATA:

DCODE	segment	dword public 'DCODE'
DCODE	ends

DFIRST	segment	word public 'DDATA'
DFIRST	ends

DDATA	segment	word public 'DDATA'
DDATA	ends

DCONST	segment word public 'DDATA'
DCONST	ends

DBSS	segment	word public 'DDATA'
DBSS	ends

ifndef DBGCODE
DBGCODE group DCODE
endif

ifndef DBGDATA
DBGDATA group DFIRST, DDATA, DCONST, DBSS
endif

; Use these macros to assume a segment register to data or code

assumeDATA	macro	reglist
		irp	x,<reglist>
			assume x:DBGDATA
		endm
		endm

assumeCODE	macro	reglist
		irp	x,<reglist>
			assume x:DBGCODE
		endm
		endm

; Use these macros at the begin and end of the DCODE segment

CodeSegmentStart macro
DCODE		segment
		assumeCODE <cs>
		assumeDATA <ds,es,ss>
		endm

CodeSegmentEnd	macro
DCODE		ends
		endm

; Use these macros at the begin and end of the DCODE segment

DataSegmentStart macro segname,noassume
		ifb	<segname>
DDATA		segment
		assumeCODE <cs>
		ifb	<noassume>
		assumeDATA <ds,es,ss>
		endif
		else
DFIRST		segment
		assumeCODE <cs>
		endif
		endm

DataSegmentEnd	macro segname
		ifb	<segname>
DDATA		ends
		else
DFIRST		ends
		endif
		endm

; Use this macro to set a register to the debugger's data segment

DataContext	macro	reglist, trashreg
		ifnb <trashreg>
			mov	trashreg,ss
		endif
		irp	reg,<reglist>
			ifb <trashreg>
				push	ss
				pop	reg
			else
				mov	reg,trashreg
			endif
			irp	x,<es,ds,ss,eS,dS,sS,Es,Ds,Ss,ES,DS,SS>
				ifidn	<reg>,<x>
					assumeDATA <reg>
				endif
			endm
		endm
		endm

; Defined for use with CALL32 macro

?ASSUMECS	macro
		assumeCODE	<cs>
		endm
