??MASM32??

???

????????Hello World??,??MASM32????:

.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

?????,MASM32??A2004???????:

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

??????? ??????????TASM??,????????MASM32,????A2004????????,????????????,TASM?

?????????,??????32?CPU Win7?????

???

有帮助吗?

解决方案

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.

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top