小弟初学,初级问题
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \ masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
.data
MsgCaption db "hi,Masm32!",0
MsgBoxText db "Win32 Assembly is Great!",0
.code
start:
invoke MessageBox,NULL,addr MsgBoxText,addr MsgCaption,MB_OK
invoke ExitProcess,NULL
end start
当我build的时候,为什么编译器显示
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.
Assembling: C:\masm32\11\test.asm
C:\masm32\11\test.asm(16) : error A2137: too few arguments to INVOKE
C:\masm32\11\test.asm(16) : error A2206: missing operator in expression
C:\masm32\11\test.asm(16) : error A2114: INVOKE argument type mismatch : argumen
t : 1
_
Assembly Error
请按任意键继续. . .
我用的是sasm32v8
问题点数:20、回复次数:3Top
1 楼zhongxin81(Que~sera)回复于 2004-05-03 19:48:25 得分 0
怎么没人回答?分太少了?Top
2 楼zhongxin81(Que~sera)回复于 2004-05-03 19:59:34 得分 0
我在另外一个教材上看到
addr 操作符用来把标号的地址传递给被调用的函数,它只能用在 invoke 语句中,譬如您不能用它来把标号的地址赋给寄存器或变量,如果想这样做则要用 offset 操作符。在 offset 和 addr 之间有如下区别:
addr不可以处理向前引用,offset则能。所谓向前引用是指:标号的定义是在invoke 语句之后,譬如在如下的例子:
invoke MessageBox,NULL, addr MsgBoxText,addr MsgBoxCaption,MB_OK
......
MsgBoxCaption db "Iczelion Tutorial No.2",0
MsgBoxText db "Win32 Assembly is Great!",0
如果您是用 addr 而不是 offset 的话,那 MASM 就会报错。
那为什么我把标号的定义是在invoke 语句前面了还是会报错?而只有当我把addr 改为offset才能通过编译
为什么?????Top
3 楼dunkel(内心和夜 哪个黑)回复于 2004-05-03 20:40:11 得分 20
>> ...
>> includelib \ masm32\lib\user32.lib
>> ...
只是上面的那一行多了个空格啊, 在 masm32 之前. 其他应该正常的, 我的 ml 也是 6.14.8444
E:\MASM32>ml /c /coff zhongxin.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.
Assembling: zhongxin.asm
E:\MASM32>link /subsystem:windows zhongxin.obj
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
E:\MASM32>zhongxin
出现一个显示 "Win32..." 的对话框, "确定" 后结束!Top




