程序: 书上的例程(文件名P10.asm)
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kerne132.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
.date
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
我用MASM32 V10编译
C:\masm32\bin>ml.exe /c /coff p10.ASM
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.
Assembling: p10.ASM
p10.ASM(5) : fatal error A1000: cannot open file : \masm32\include\kerne132.inc
因为上面提示的是 不能打开那个文件,其实文件是存在的 所以换了个程序
; p227.asm
;
.model flat,c
PUBLIC power2
_TEXT SEGMENT WORD PUBLIC 'CODE'
_power2 PROC
push ebp
mov ebp,esp
mov eax,[ebp+4]
mov ecx,[ebp+6]
mov eax,cl
pop ebp
ret
_power2 ENDP
_TEXT ENDS
END
执行结果:
C:\masm32\bin>ml.exe /c /coff p227.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.
Assembling: p227.asm
p227.asm(3) : error A2085: instruction or register not accepted in current CPU m
ode
p227.asm(8) : error A2085: instruction or register not accepted in current CPU m
ode
p227.asm(9) : error A2085: instruction or register not accepted in current CPU m
ode
p227.asm(10) : error A2085: instruction or register not accepted in current CPU
mode
p227.asm(11) : error A2085: instruction or register not accepted in current CPU
mode
p227.asm(12) : error A2085: instruction or register not accepted in current CPU
mode
p227.asm(13) : error A2085: instruction or register not accepted in current CPU
mode
p227.asm(4) : error A2006: undefined symbol : power2