The GROUP directive associates a group Name with one or more segments, and causes all labels and variables defined in the given segments to have addresses relative to the beginning of the group, rather than to the segments where they are defined.
Syntax
Name GROUP Segment-Name [,...]Remarks
Each Segment-Name entry must be a unique segment name assigned by the SEGMENT directive. A Segment-Name entry may be a forward reference to a subsequently declared segment name.
An additional occurrence of a given group Name in a subsequent GROUP directive does not constitute a redefinition, but instead the effect is cumulative. The group Name itself is declared the first time it appears in a GROUP directive, but the group definition is not complete until the end of the source module is reached. The final group definition is the cumulative list of all unique segments named in all occurrences of a GROUP directive for that group Name.
Segments in a group need not be contiguous. Segments that do not belong to the group can be loaded between segments that do belong to the group. The only restriction is that for USE16 segments the distance (in bytes) between the first byte in the first segment of the group and the last byte in the last segment must not exceed 65535 bytes.
Group names can be used with the ASSUME directive and as an operand prefix with the segment override operation (:).
The following example shows how to use the GROUP directive to combine segments:
In Module A:
CGROUP GROUP XXX,YYY XXX SEGMENT ASSUME CS:CGROUP . . . XXX ENDS YYY SEGMENT ASSUME CS:CGROUP . . . YYY ENDS
In Module B:
CGROUP GROUP ZZZ ZZZ SEGMENT ASSUME CS:CGROUP . . . ZZZ ENDS
The next example shows how to set DS with the paragraph number of the group called DGROUP.
As immediate:
MOV AX,DGROUP MOV DS,AX
In assume:
ASSUME DS:DGROUP
As an operand prefix:
MOV BX,OFFSET DGROUP:FOO DW FOO DW DGROUP:FOO
Note:
PAGE ,132 TITLE GRPCOM - Use GROUP to create a DOS .COM file ;Use the DOS EXE2BIN utility to convert GRPCOM.EXE to GRPCOM.COM. CG GROUP CSEG,DSEG ;ALL SEGS IN ONE GROUP DISPLAY MACRO TEXT LOCAL MSG DSEG SEGMENT BYTE PUBLIC 'DATA' MSG DB TEXT,13,10,"$" DSEG ENDS ;;Macro produces partly in DSEG, ;;partly in CSEG MOV AH,9 MOV DX,OFFSET CG: MSG ;;Note use of group name ;;in producing offset INT 21H ENDM DSEG SEGMENT BYTE PUBLIC 'DATA' ;Insert local constants and work areas here DSEG ENDS CSEG SEGMENT BYTE PUBLIC 'CODE' ASSUME CS:CG,DS:CG,SS:CG,ES:CG ;SET BY LOADER ORG 100H ;Skip to end of the PSP ENTPT PROC NEAR ;COM file entry at 0100H DISPLAY "USING MORE THAN ONE SEGMENT" DISPLAY "YET STILL OBEYING .COM RULES" RET ;Near return to DOS ENTPT ENDP CSEG ENDS END ENTPT