views:

80

answers:

2

Hi,

I have a problem with the MASM32 assembler

The following code is a Hello World example that I copied from the MASM32 tutorial:

.model small
.stack
.data
    message   db "Hello world!", "$"
.code

_main   proc

    mov   ax,seg message
    mov   ds,ax

    mov   ah,09
    lea   dx,message
    int   21h

    mov   ax,4c00h
    int   21h

_main   endp
end _main

On attempt to assemble, MASM32 throws A2004 error with the following comment:

C:\masm32\console.asm(11) : error A2004: symbol type conflict

Can anyone help me with that? This code worked perfectly fine with the TASM assembler, but now I have to use MASM32 and I am having this A2004 error for any assembly code that I've earlier proven to work with TASM.

In case this is relevant, I am have a 32bit CPU running Win7 OS.

Thanks.

A: 

It's been a while since I used MASM - but isn't 'message' a reserved word? try '_message'.

Joe Wood
I've tried _message. Still throws A2004 error at line 11.
udushu
+1  A: 

I'm pretty certain that .model small and seg are artefacts of an earlier age when the x86 architecture was truly segmented (into 64K chunks).

The masm32 IDE doesn't like them very much at all (not unexpected since it's far more common nowadays to be doing 32-bit flat model code).

The problem lies in the fact that the bin\assmbl.bat file is being used by the editor to assemble the file and it contains the line:

\masm32\bin\ml /c /coff %1.asm > \masm32\bin\asmbl.txt

(with the /coff option). This is what's making the assembler complain.

You can get it to work by reverting to the command line. Assuming your file is tst.asm, use the following commands:

c:\masm32\bin\ml.exe /c tst.asm
c:\masm32\bin\link16 tst.obj.tst.exe,,,,

and you'll have a tst.exe that works fine.


The following transcript shows that this works:

C:\masm32> type tst.asm
.model small
.stack
.data
    message   db "Hello world!", "$"
.code

_main   proc

    mov   ax,seg message
    mov   ds,ax

    mov   ah,09
    lea   dx,message
    int   21h

    mov   ax,4c00h
    int   21h

_main   endp
end _main

 

C:\masm32> bin\ml.exe /c tst.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

 Assembling: tst.asm

 

C:\masm32> bin\link16 tst.obj,tst.exe,,,,

Microsoft (R) Segmented Executable Linker  Version 5.60.339 Dec  5 1994
Copyright (C) Microsoft Corp 1984-1993.  All rights reserved.

 

C:\masm32> tst.exe
Hello world!

Alternatively, the editor is very configurable. If you open up the menus.ini file for editing (back it up first, I shouldn't need to tell you that) and change:

&Assemble ASM file,\MASM32\BIN\Assmbl.bat "{b}"

to:

&Assemble ASM file,\MASM32\BIN\Assmbl.bat "{b}"
Assemble ASM file (no COFF),\MASM32\BIN\Assmbl2.bat "{b}"

you can get your new menu item added on IDE restart.

You also need to copy bin\assmbl.bat to bin\assmbl2.bat and remove the /coff from the latter.

Then you can compile fine from within the IDE with the new menu option.

Of course, you'll have to do the same thing for the link and assemble/link menu items as well. But, now that you know how it's done, that shouldn't present a problem.

paxdiablo
Huh! That does work. Thanks a lot!
udushu
I've eventially came up with a script to do the assemble/link commands. but thanks for the IDE tip, I didn't know that it is that flexible.
udushu