[comp.sys.ibm.pc] GROUP trouble in Assembler

andrews@hpcupt1.HP.COM (Edward E. Andrews) (01/06/90)

	I am trying to write an assembler program that will be able to access
the initialized DATA segment using the stack segment register.  I am trying to
do this by using the simplified segment directives in TURBO ASSEMBLER.

	On p. 464 of the TURBO ASSEMBLER manual it states that "...the group
DGROUP is used by high-level languages to allow the stack, initialized near
data, uninitialized near data, and constant segments to be accessed relative
to a single segment register."  The simplified segment directives put .DATA,
.?DATA, .BSS, and .STACK into one group (DGROUP).

	So, I wrote this program:

	DOSSEG
	.MODEL	MEDIUM
	.STACK	100h
	.CODE
Start:	mov	ax,DGROUP
	mov	ds,ax
	ASSUME	DS:DGROUP
	mov	ax,Var
	.DATA
Var	dw	0
	End	Start


	Which produced this MAP file:

 Start  Stop   Length Name               Class

 00000H 00007H 00008H SEG_TEXT           CODE
 00008H 00009H 00002H _DATA              DATA
 00010H 0010FH 00100H STACK              STACK

Detailed map of segments

0000:0000 0008 C=CODE S=SEG_TEXT G=(none) M=SEG.ASM ACBP=48
0000:0008 0002 C=DATA S=_DATA G=DGROUP M=SEG.ASM ACBP=48
0001:0000 0100 C=STACK S=STACK G=DGROUP M=SEG.ASM ACBP=74

  Address         Publics by Name


  Address         Publics by Value


Program entry point at 0000:0000


	Note that the segment of the stack and data are different!  And
when I use a debugger to examine the actual values that are loaded, DS
and SS are different.  This will happen with other .MODELs also.

	What am I doing wrong?