如何用汇编语言为 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;
}
清除.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 工具\wce500\STANDARDSDK_500\Lib\x86
并尝试包含coredll.lib,但没有效果
includelib coredll.lib
所以主要问题是: 我的错误在哪里?我可以用winapi函数编写asm代码吗?
谢谢你的回答!
-----------------------------------------------------------
UPD: 谢谢大家。我设法通过编写函数的原型定义来构建项目:
MessageBoxW PROTO hwnd:DWORD, lpText:DWORD, lpCaption:DWORD, uType:DWORD
如何避免为我将使用的每个函数编写这样的原型?据我了解,我需要带有原始功能定义的 .inc 文件吗?或者以某种方式使用 .h 文件中的函数定义?