如何用Windows CE(x86)的汇编语言编写程序? 现在我使用VS2008 winth Windows CE 5.0 SDK,我的C++程序运行良好。 我试图创建一个ASM文件,我的代码,并把它列入到项目:用于Windows CE的汇编语言
#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的
我添加包括与Windows CE SDK库为MASM路径:
C:\ Program Files文件\ Windows CE Tools \ wce500 \ STANDARDSDK_500 \ Lib \ x86
和试图包括coredll.lib,但没有什么效果
includelib coredll.lib
所以主要问题是: 哪里是我的错?我可以使用winapi函数编写asm代码吗?
Thaks为您解答!
-------------------------------------------- ---
UPD: 谢谢大家。 我设法通过编写的函数原型defenition建设项目:
MessageBoxW PROTO HWND:DWORD,lpText:DWORD,lpCaption:DWORD, UTYPE:DWORD
如何避免写出这样我将使用每个功能的原型? 据我了解,我需要.inc文件与功能proto defenitions? 或以某种方式使用.h文件中的函数定义?
也许MessageBoxA?也就是说,MessageBox的ASCII变体实际上是在c头文件中定义的:#define MessageBox MessageBoxW用于定义UNICODE,否则用#define MessageBox MessageBoxA。 – Aneri
感谢您的回复! – eimc