我嘗試使用以下masm代碼輸出cmd屏幕中hello的字符串長度。 我創建了一個名爲strlo
的函數來計算字符串長度。masm中的字符串長度
.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>