The MASM Forum Archive 2004 to 2012

Specialised Projects => Assembler/Compiler Technology => Topic started by: japheth on June 17, 2008, 12:59:28 PM

Title: Interesting Masm bug
Post by: japheth on June 17, 2008, 12:59:28 PM

Hi,

during the JWasm tests I found an interesting Masm bug. This bug was new to me, it was revealed by JWasm feeded with some of my old Masm projects. It's here:



    .386
    .model flat
    option casemap:none

GUID STRUCT
    Data1 dd ?
    Data2 dw ?
    Data3 dw ?
    Data4 db 8 dup(?)
GUID ENDS

.data
   
IID_IUnknown      GUID {00000000,0000,0000,{0C0,00,00,00,00,00,00,46h}}
IID_IClassFactory GUID <00000001,0000,0000,<0C0,00,00,00,00,00,00,46h>>

END



Masm doesn't warn about the missing 'h' after 0C0 and generates number 78h instead.
Title: Re: Interesting Masm bug
Post by: PBrennick on June 17, 2008, 03:10:58 PM
Definitely a strange error, for some reason it parses the value of 'C' which is 12 and then the '0' making 120 which is 78h. Errors like that can lead to a long bout of drinking! :green

-- Paul
Title: Re: Interesting Masm bug
Post by: japheth on June 18, 2008, 05:53:14 AM

Hi Paul,

Quote from: PBrennick on June 17, 2008, 03:10:58 PM
Definitely a strange error, for some reason it parses the value of 'C' which is 12 and then the '0' making 120 which is 78h. Errors like that can lead to a long bout of drinking! :green

I successfully verified your theory by trying other values. Fortunately it only occurs if an initialization string is embedded in another initialization string. And it doesn't matter if it is a string for an array or a struct.

Title: Re: Interesting Masm bug
Post by: PBrennick on June 18, 2008, 06:14:43 AM
Japheth,

QuoteFortunately it only occurs if an initialization string is embedded in another initialization string

Yeah, I tend to avoid code like that, myself. You are doing some nice work with your assembler. I wrote an assembler/disassembler for the 6809e a long time ago and it 'was' a headache (and that was a very simplistic microprocessor).
Paul
Title: Re: Interesting Masm bug
Post by: Jimg on June 18, 2008, 11:48:07 AM
Quote from: japheth on June 18, 2008, 05:53:14 AM
Fortunately it only occurs if an initialization string is embedded in another initialization string. And it doesn't matter if it is a string for an array or a struct.
This simple example does the same thing for me.
tsty struct
  tyx dd ?
tsty ends
ytst tsty <0c0>

00000004 tsty struct
00000000  00000000 tyx dd ?
tsty ends
00000010 00000078 ytst tsty <0c0>
Title: Re: Interesting Masm bug
Post by: japheth on June 19, 2008, 04:18:40 AM
Quote from: Jimg on June 18, 2008, 11:48:07 AM
Quote from: japheth on June 18, 2008, 05:53:14 AM
Fortunately it only occurs if an initialization string is embedded in another initialization string. And it doesn't matter if it is a string for an array or a struct.
This simple example does the same thing for me.

Jimg, you're right of course. I was talking nonsense.

QuoteYou are doing some nice work with your assembler.

thanks! It's more work than I did assume before starting. I had hoped that the goal can be achieved by rewriting about 20-30% of the code, but this has turned out to be too optimistic.