如何用Windows CE(x86)的汇编语言编写程序?现在我正在使用VS2008 winth Windows CE 5.0 SDK,我的C程序运行正常 . 我尝试使用我的代码创建一个asm文件并将其包含在项目中:
#include "stdafx.h"
#include "windows.h"
extern "C" void clear();
int _tmain(int argc, _TCHAR* argv[])
{
clear();
return 0;
}
clear.asm:
.586 ;Target processor. Use instructions for Pentium class machines
.MODEL FLAT, C ;Use the flat memory model. Use C calling conventions
.STACK ;Define a stack segment of 1KB (Not required for this example)
.DATA ;Create a near data segment. Local variables are declared after
;this directive (Not required for this example)
.CODE ;Indicates the start of a code segment.
clear PROC
xor eax, eax
xor ebx, ebx
ret
clear ENDP
END
一切顺利,直到我想调用WinApi函数(MessageBox)形式的asm代码 .
.DATA ;Create a near data segment. Local variables are declared after
szMessageText DB "Hello world text", 0
szMessageCaption DB "HWorld capt, 0
.CODE ;Indicates the start of a code segment.
clear PROC
Invoke MessageBox, NULL, ADDR szMessageText, ADDR szMessageCaption, MB_OK
clear ENDP
END
它给
错误A2006:未定义的符号:MessageBox
我为MASM添加了包含Windows CE SDK库的包含路径:
C:\ Program Files \ Windows CE Tools \ wce500 \ STANDARDSDK_500 \ Lib \ x86
并试图包括coredll.lib,但没有效果
includelib coredll.lib
所以主要问题是: Where is my mistake? Can I write asm code with winapi functions?
Thaks for your answers!
-----------------------------------------------
UPD: 谢谢大家 . 我设法通过编写一个函数的proto defenition来构建项目:
MessageBoxW PROTO hwnd:DWORD,lpText:DWORD,lpCaption:DWORD,uType:DWORD
我怎样才能避免为我将要使用的每个函数编写这样的原型?据我所知,我需要.inc文件与proto defenitions的功能?或者以某种方式使用.h文件中的函数定义?