Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!floyd!harpo!seismo!hao!hplabs!sri-unix!XA.W51%STANFORD.BITNET@Berkeley From: XA.W51%STANFORD.BITNET%Berkeley@sri-unix.UUCP Newsgroups: net.micro.pc Subject: Accessing External STRUC in 8086 MS-DOS Assembler Message-ID: <16662@sri-arpa.UUCP> Date: Sun, 12-Feb-84 18:10:00 EST Article-I.D.: sri-arpa.16662 Posted: Sun Feb 12 18:10:00 1984 Date-Received: Sat, 18-Feb-84 04:16:13 EST Lines: 79 From: Robert & Carol LercheIn order to get addressability to data, the assembler must know the SEGMENT the data are defined in. Define a COMMON SEGMENT as follows: (FOODEFN.INC) ; FIRST, THE STRUCTURE DEFINITION FOO STRUC A DW ? B DW ? FOO ENDS ; NEXT, THE ACTUAL ALLOCATION OF A FOO DATA SEGMENT COMMON FOOBAR FOO <0,0> DATA ENDS Then simply include the definition in all referencing modules. The linker will overlay the definitions due to the COMMON combine type. (FOO1.ASM) PAGE 59,120 INCLUDE FOODEFN.INC ; DATA2 SEGMENT 'DATA' STUFF DB 'PRIVATE DATA FOR BLAH (NOT BLAH2)' DATA2 ENDS ; DGROUP GROUP DATA,DATA2 CODE SEGMENT PUBLIC BYTE 'CODE' ASSUME CS:CODE EXTRN BLAH2:FAR BLAH PROC FAR MOV AX,DGROUP MOV DS,AX ASSUME DS:DGROUP CALL BLAH2 MOV AX,FOOBAR.A MOV BX,FOOBAR.B MOV CX,OFFSET(DGROUP:STUFF) BLAH ENDP CODE ENDS ; END BLAH (FOO2.ASM) PAGE 59,120 INCLUDE FOODEFN.INC CODE SEGMENT PUBLIC BYTE 'CODE' DGROUP GROUP DATA ASSUME CS:CODE ASSUME DS:DGROUP PUBLIC BLAH2 BLAH2 PROC FAR MOV CX,FOOBAR.A MOV DX,FOOBAR.B RET BLAH2 ENDP CODE ENDS END NOTES: 1. This is a "work around." In principle, there is no reason why you can't just have a STRUC with an external name. In practice, *sigh*. 2. Note use of OFFSET(DGROUP:STUFF) in FOO1. If you forget the DGROUP, you will just get the offset from the start of the DATA2 segment, which will probably not be what you want.