Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!ut-sally!husc6!mit-eddie!ll-xn!ames!sdcsvax!ucsdhub!jack!man!crash!gryphon!greg From: greg@gryphon.CTS.COM (Greg Laskin) Newsgroups: comp.sys.ibm.pc Subject: Re: Please explain this MASM/LINK behavior... Message-ID: <1423@gryphon.CTS.COM> Date: Thu, 3-Sep-87 17:32:55 EDT Article-I.D.: gryphon.1423 Posted: Thu Sep 3 17:32:55 1987 Date-Received: Sat, 5-Sep-87 17:23:17 EDT References: <88@wjh12.HARVARD.EDU> <2474@bnrmtv.UUCP> Reply-To: greg@gryphon.CTS.COM (Greg Laskin) Organization: Trailing Edge Technology, Redondo Beach, CA Lines: 81 Keywords: MASM LINK bug? In article <2474@bnrmtv.UUCP> perkins@bnrmtv.UUCP (Henry Perkins) writes: >In article <88@wjh12.HARVARD.EDU>, lotto@wjh12.HARVARD.EDU (Jerry Lotto) writes: >> Code_Seg Segment Para 'CODE' > >> Assume CS:Code_Seg >> Org 100H > >> Begin: mov ax, Code_Seg:[2ch] > >> Code_Seg Ends >> End Begin > >> assembles fine, but generates a link error (invalid object module). >The problem is with MASM not complaining about the > > mov ax, Code_Seg:[2ch] > >line. This SHOULD be written as > > mov ax, cs:[2ch] > >if you want to make use of the ASSUME directive and specify the >code segment. There's no 8086 addressing mode that allows a >segment to be specified as immediate data for a MOV instruction. The assembler documentation asserts that the assembler will resolve Code_Seg:[2ch] to CS:[2ch]. (see below) >Of course, since you're making a .COM file, you can make use of >the fact that CS and DS both already point to your one and only >segment, and omit the segment override, which then defaults to >using DS. That's what you're doing in the example that works. Accurate. >If you had any data declarations in this segment, you'd also >want to put in an > > Assume DS:Code_Seg > provided that you had assured that DS would contain the value of Code_Seg at run-time. The Assume directive is a cue to the assembler about what segment addresses will be in the segment registers at run-time. This directive is a "guarantee" to the assembler. If DS is not actually pointing at Code_Seg, the assembler will (and can not) do anything about it. Ther MASM 4.0 reference manual says, in section 5.3.7, Segment-Override Operator: SYNTAX segmentregister:expression segmentname:expression groupname:expression ... if either sementname or groupname is given, the name must have been assigned to a segment register with a previous ASSUME directive and defined using a SEGMENT or GROUP directive. The expression can be an absolute symbol or relocatable operand. The segmentregister must be CS, DS, SS or ES. ---- end of quotation --- Code_Seg is a segmentname and a relocatable operand. CS is a segmentregister and is an absolute operand. It would seem that one could reasonably expect to generate the code for the sample correctly. In fact, the code in the assembly listing IS correct. Once the assembler had resolved the relocatable Code_Seg to the absolute CS, it should have stopped (while it was ahead). It doesn't seem unfair to expect the assembler to correctly generate the sample code. That said, it doesn't work. Specify CS explicitly as a work-around. -- Greg Laskin "When everybody's talking and nobody's listening, how can we decide?" INTERNET: greg@gryphon.CTS.COM UUCP: {hplabs!hp-sdd, sdcsvax, ihnp4}!crash!gryphon!greg UUCP: {philabs, scgvaxd}!cadovax!gryphon!greg