对不起,如果这个问题真的很简单,但我尝试了所有我知道的但无法弄清楚。
我正在尝试制作一个简单的程序,该程序从控制台获取一个字符串和一个 Count,并打印由 Count 指定的字符串次数。
一切都很好,但是当我将 Count 移动到 eax 循环时,值变得混乱,我最终得到了一个无限循环的打印。
我尝试使用 atodw 将 Count 更改为 DWORD,但没有成功。
这是代码:
PrintString PROTO :DWORD, :DWORD
.data
String db 100 DUP(0)
Count db 10 DUP(0)
.code
start:
;1- get user input
invoke StdIn, addr String, 99
invoke StdIn, addr Count, 10
;2- Remove the CRLF from count
invoke StripLF, addr Count
;3- Convert the count to DWORD
invoke atodw, addr InputCount
mov Counter, eax
;4- Call the Printer function
invoke Printer, addr String, addr Count
Printer PROC StringToPrint:DWORD, count:DWORD
mov eax,count ;;;;;; This is the problem I think
Looppp:
push eax
invoke StdOut, StringToPrint
pop eax
dec eax
jnz Looppp
ret
Printer endp