[comp.sys.ibm.pc] MASM "GROUP" is weird

kiely@lownlab.harvard.edu (James P. Kiely) (12/01/88)

I am trying to use the "GROUP" directive with MASM 5.1
and I am having no end of trouble.
In the MASM 5.0 Programmers' Guide on page 106 Section 5.3
it states: "... use a group if you want several types of
data to be organized in separate segments in your source
code, but want them all to be accessible from a single,
common segment register at run time.
Below is a little test program to illustrate my problem.
BTW: the linker is v3.65
=============================================================================

	page	66, 132
	title	group_test
;
; test the GROUP directive

FIRST_GROUP	GROUP	FIRST_TEXT, FIRST_DATA, FIRST_STACK

FIRST_TEXT	SEGMENT	byte public 'CODE'
	ASSUME	nothing
	ASSUME	cs:FIRST_GROUP, ds:FIRST_GROUP, ss:FIRST_GROUP

main	PROC FAR

	mov	ax, SEG FIRST_GROUP
	mov	ax, cs
	mov	ax, SEG FIRST_TEXT
	mov	ax, ds
	mov	ax, SEG FIRST_DATA
	mov	ax, ss
	mov	ax, SEG FIRST_STACK
	mov	ax, OFFSET FIRST_GROUP:rcs_id
	mov	ax, OFFSET FIRST_DATA:rcs_id
	mov	ax, 4C00h		; \ exit
	int	21h			; /

main	ENDP

FIRST_TEXT	ENDS


FIRST_DATA	SEGMENT word public 'DATA'
rcs_id	db "$Header$"
FIRST_DATA	ENDS


FIRST_STACK	SEGMENT	word stack 'STACK'
fstack	db	100h DUP (?)
FIRST_STACK	ENDS

	END	main

=============================================================================
Below here is the codeview output of the above program.
Note that the SEG operator says that FIRST_TEXT, FIRST_DATA,
and FIRST_STACK are all in different segments.
Why?
I thought that they were all in the same segment because they
were in the group FIRST_GROUP.

Interestingly enough, the data at FIRST_GROUP:rcsid and FIRST_DATA:rcsid
appear to be identical.  Is this *always* true?
And when I push something on to the stack, does it get put at
SS:SP or at FIRST_GROUP:SP or am I supposed to initialize SS
at the start of the program?
=============================================================================
>u 0 1b
MAIN:
15:		mov	ax, SEG FIRST_GROUP
46A8:0000 B8A846         MOV       AX,46A8
16:		mov	ax, cs
46A8:0003 8CC8           MOV       AX,CS
17:		mov	ax, SEG FIRST_TEXT
46A8:0005 B8A846         MOV       AX,46A8
18:		mov	ax, ds
46A8:0008 8CD8           MOV       AX,DS
19:		mov	ax, SEG FIRST_DATA
46A8:000A B8A946         MOV       AX,46A9
20:		mov	ax, ss
46A8:000D 8CD0           MOV       AX,SS
21:		mov	ax, SEG FIRST_STACK
46A8:000F B8AB46         MOV       AX,46AB
22:		mov	ax, OFFSET FIRST_GROUP:rcs_id
46A8:0012 B81E00         MOV       AX,001E
23:		mov	ax, OFFSET FIRST_DATA:rcs_id
46A8:0015 B80E00         MOV       AX,000E
24:		mov	ax, 4C00h		; \ exit
46A8:0018 B8004C         MOV       AX,4C00
25:		int	21h			; /
46A8:001B CD21           INT       21
>db 46a8:1e					( <--- FIRST_GROUP:rcs_id)
46A8:0010                         -                  24 48                $H
46A8:0020  65 61 64 65 72 24 4E 42-30 30 8A 00 00 00 00 00  eader$NB00......
46A8:0030  00 00 1D 00 00 00 00 00-00 00 09 47 52 4F 55 50  ...........GROUP
46A8:0040  2E 4F 42 4A 01 03 00 72-80 74 01 03 00 72 80 73  .OBJ...r.t...r.s
46A8:0050  0E 05 0E 00 01 00 94 00-06 52 43 53 5F 49 44 09  .........RCS_ID.
46A8:0060  0B 00 00 04 04 4D 41 49-4E 0E 05 00 00 03 00 84  .....MAIN.......
46A8:0070  00 06 46 53 54 41 43 4B-09 67 72 6F 75 70 2E 41  ..FSTACK.group.A
46A8:0080  53 4D 0B 00 0F 00 00 00-10 00 03 00 11 00 05 00  SM..............
46A8:0090  12 00 08 00 13 00 0A 00-14 00 0D 00 15 00        ..............
>db 46a9:e					( <--- FIRST_DATA:rcs_id )
46A9:0000                         -                  24 48                $H
46A9:0010  65 61 64 65 72 24 4E 42-30 30 8A 00 00 00 00 00  eader$NB00......
46A9:0020  00 00 1D 00 00 00 00 00-00 00 09 47 52 4F 55 50  ...........GROUP
46A9:0030  2E 4F 42 4A 01 03 00 72-80 74 01 03 00 72 80 73  .OBJ...r.t...r.s
46A9:0040  0E 05 0E 00 01 00 94 00-06 52 43 53 5F 49 44 09  .........RCS_ID.
46A9:0050  0B 00 00 04 04 4D 41 49-4E 0E 05 00 00 03 00 84  .....MAIN.......
46A9:0060  00 06 46 53 54 41 43 4B-09 67 72 6F 75 70 2E 41  ..FSTACK.group.A
46A9:0070  53 4D 0B 00 0F 00 00 00-10 00 03 00 11 00 05 00  SM..............
46A9:0080  12 00 08 00 13 00 0A 00-14 00 0D 00 15 00        ..............
>t
16:		mov	ax, cs
>s&
mixed
>t
AX=46A8  BX=0000  CX=0000  DX=0000  SP=0100  BP=0000  SI=0000  DI=0000  
DS=4698  ES=4698  SS=46AB  CS=46A8  IP=0005  NV UP EI PL NZ NA PO NC 
17:		mov	ax, SEG FIRST_TEXT
46A8:0005 B8A846         MOV       AX,46A8
>q

=============================================================================
So am I doing something wrong with the "GROUP" directive
or am I just thinking about it incorrectly?

Please respond via email.
Thanks.

=============================================================================
NAME:     James P. Kiely                USPS:   Kiely Laboratories
USENET:   ...!harvard!lownlab!kiely             P.O. Box 624
DOMAIN:   kiely@lownlab.harvard.edu             Allston, MA 02134-0624
PHONE:    +1 617 782 4136                       USA

everett@hpcvlx.HP.COM (Everett Kaser) (12/06/88)

First of all, you'll need to straighten out your assembly language syntax.
The 'mov' instruction specifies the destination as the first argument and
the source as the second argument.  So, the following...

>	mov	ax, SEG FIRST_GROUP
>	mov	ax, cs
>	mov	ax, SEG FIRST_TEXT
>	mov	ax, ds
>	mov	ax, SEG FIRST_DATA
>	mov	ax, ss
>	mov	ax, SEG FIRST_STACK
>	mov	ax, OFFSET FIRST_GROUP:rcs_id

should be written as:

	mov	ax,FIRST_GROUP
	mov	ds,ax

etc.
You do NOT want to try loading the CS register.  It has to be right all ready
or you wouldn't be executing the code.

Remember, it's 'mov' INTO 'first_arg' FROM 'second arg'.  All of the lines of
code in your example are just re-loading the AX register with different values.

Everett Kaser
!hplabs!hp-pcd!everett

everett@knkvlx.HP.COM (Everett Kaser) (12/06/88)

First of all, you'll need to straighten out your assembly langaage syntax.
The 'mov' instruction specifies the destination as the first argument and
the source as the second argument.  So, the following...

>	mov	ax, SEG FIRST_GROUP
>	mov	ax, cs
>	mov	ax, SEG FIRST_TEXT
>	mov	ax, ds
>	mov	ax, SEG FIRST_DATA
>	mov	ax, ss
>	mov	ax, SEG FIRST_STACK
>	mov	ax, OFFSET FIRST_GROUP:rcs_id

should be written as:

	mov	ax,FIRST_GROUP
	mov	ds,ax

etc.
You do NOT want to try loading the CS register.  It has to be right all ready
or you wouldn't be executing the code.

Remembercode in your example are just re-loading the AX register with different values.

Everett Kaser
!hplaDs!hp-pcd!everett
#! rnews 1050.T.!a