mmm@gssc.UUCP (01/25/87)
=-=-=-=-=-=-=-=-=-= DISCLAIMER: As I have been reading this newsgroup for only a month, it is entirely possible that mention of the following bug has appeared previously, and, if so, I apologize for the long-winded repetition. =-=-=-=-=-=-=-=-=-= I have discovered what appears to me to be a bug in the Microsoft Macro Assembler, which I haven't seen mention of in any of the trade rags nor on the network, so here it is. Note that this is *not* the infamous bug for which Dr. Dobbs published a patch last year, dealing with the assembler's inability to handle include files with (or was it *without*) a terminating CTRL-Z. What I've found is that MASM 4.00 mishandles INCLUDE pseudo-ops that are imbedded in MACRO definitions. Consider the following example files (Note that they do nothing. They are for demonstration purposes only): ---------- test.asm: -------------------- DOIT Macro Include ifile2.mac Include ifile3.mac Endm Code Segment Assume Cs:Code Main Proc Far DOIT Main Endp Code Ends End ---------- ifile2.mac: -------------------- %OUT This is ifile2.mac XY Struc XY_x Dw ? XY_y Dw ? XY Ends Jmp Start3 ---------- ifile3.mac: -------------------- %OUT This is ifile3.mac Start3: Mov Ax,Es:[0].XY_y -------------------- I assembled test.asm with IBM MASM version 2.00 (similar, if not the same as Microsoft MASM 3.00) and with Microsoft MASM 4.00 , producing a listing with each: masm test,,test; Here is what IBM MASM version 2.00 produced: ---------- IBM Personal Computer MACRO Assembler Version 2.00 Page 1-1 01-25-87 DOIT Macro Include ifile2.mac Include ifile3.mac Endm 0000 Code Segment Assume Cs:Code 0000 Main Proc Far DOIT C+ XY Struc 0000 ???? C+ XY_x Dw ? 0002 ???? C+ XY_y Dw ? 0004 C+ XY Ends 0000 EB 01 90 C+ Jmp Start3 0003 C+ Start3: 0003 26: A1 0002 C+ Mov Ax,Es:[0].XY_y 0007 Main Endp 0007 Code Ends End [I've removed the symbol table for brevity] 49900 Bytes free Warning Severe Errors Errors 0 0 ---------- And here's what Microsoft MASM 4.00 produced: ---------- Microsoft (R) Macro Assembler Version 4.00 1/25/87 11:13:47 Page 1-1 DOIT Macro Include ifile2.mac Include ifile3.mac Endm 0000 Code Segment Assume Cs:Code 0000 Main Proc Far DOIT C %OUT This is ifile3.mac 0000 C Start3: 0000 26: A1 0002 C Mov Ax,Es:[0].XY_y C C %OUT This is ifile2.mac C XY Struc 0000 ???? C XY_x Dw ? 0002 ???? C XY_y Dw ? 0004 C XY Ends C 0004 EB FA C Jmp Start3 C Main Endp 0006 Code Ends End [Again, symbol table removed for brevity] 50260 Bytes symbol space free 0 Warning Errors 0 Severe Errors ---------- Notice the different order in which the INCLUDE directives are processed by the two assemblers. It appears that MASM 4.00 delays handling of INCLUDEs inside macros until the macro is processed, and then it processes the INCLUDEs in the reverse order of their appearance in the macro. This produces exactly the opposite of the desired effect by inverting code ordering and invalidating any order dependencies. According to all documentation that I have read, MASM 4.00 is in error. INCLUDE pseudo-ops are supposed to be handled immediately, suspending assembly of the surrounding code while the include file is processed. No mention is made of there being a different method for handling INCLUDEs inside MACRO expansions. Now, the main reason for posting this: Is there a patch for this bug? (Yes, I know this is a naive question, but you never know...) I would like to upgrade to MASM 4.00, but doing so would mean major architectural changes to my existing code that assembles with IBM MASM 2.00. I would rather stick with IBM MASM 2.00 or patch MASM 4.00 than modify my code. In any case, I am sending a copy of this posting to Microsoft Technical Support in hopes that future assemblers won't have this problem. I'll let you know what they say. -- Mitchell McLain ...hplabs!tektronix!sequent!gssc!mmm Opinions are my own, not those of GSS (they're happy about that).