[comp.sys.ibm.pc] help me with assembly program linked to C

johnl@ima.ima.isc.com (John R. Levine) (01/28/89)

In article <3161@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes:
>DGROUP	GROUP	_DATA
>_DATA	SEGMENT	WORD PUBLIC	'DATA'
>	assume		ds:dgroup
>	tstmsg		db	"This is a test.",13,10,"$"
>...
>[		mov	dx,offset tstmsg ]

Welcome to the amazing world of 8086 programming.  When you refer to
"offset tstmsg" the assembler gives you the offset from the beginning of
the segment in which tstmsg is defined.  Unfortunately, the DS register
points to the beginning of DGROUP, not the beginning of your segment, so
the offset is not what you want.  Try this to get the offset you want:

	mov	dx,offset dgroup:tstmsg

-- 
John R. Levine, Segue Software, POB 349, Cambridge MA 02238, +1 617 492 3869
{ bbn | spdcc | decvax | harvard | yale }!ima!johnl, Levine@YALE.something
You're never too old to have a happy childhood.