我尝试使用以下 masm 代码在 cmd 屏幕中输出 hello 的字符串长度。我创建了一个调用strlo
来计算字符串长度的函数。
.486
.Model flat,Stdcall
option casemap :none ; case sensitive
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\masm32.inc
includelib \masm32\lib\masm32.lib
strlo PROTO :DWORD
.data
msg db "Hello",0
.data?
pr dd ?
.code
start:
invoke strlo,addr msg
strlo proc parm:DWORD
xor eax,eax
mov edi,parm
l1:
cmp byte ptr [edi] ,0
je l2
inc edi
inc eax
jmp l1
l2:
ret
strlo endp
invoke StdOut,eax
invoke ExitProcess,0
end start
当我运行它时,我没有得到任何输出。
F:\masm32>len.exe
F:\masm32>