我尝试在论坛中搜索答案,但我得到的只是 16 位或 nasm 的输入。我尝试使用
push ecx
push edx
mov edx, offset myVar
mov ecx, sizeof myVar
call readstring
但它没有按我的预期工作。我正在尝试将字符串/字符作为输入并递增它(例如从 A 到 B)并将其打印在屏幕上。我的代码:
include irvine32.inc
.data
myVar BYTE ?
myVar2 BYTE ?
shifts DWORD 3
.code
main proc
push ecx
push edx
mov edx, offset myVar
mov ecx, sizeof myVar
call readstring
mov esi, offset [myVar]
mov al,[esi]
mov myVar2, al
mov eax, DWORD PTR myVar2
add eax, shifts
mov DWORD PTR myVar2,eax
mov edx, offset myVar2
call writestring
exit
main endp
end main
如果我用一个字符初始化 myVar 并递增它,代码就可以正常工作,但是(也向结果添加一个垃圾 ascii 字符,我不知道为什么)所以我知道问题出在接受输入上。
最佳答案
抱歉,Book 已经给出了答案。
.data
buffer BYTE 21 DUP(0) ; input buffer
byteCount DWORD ? ; holds counter
.code
mov edx,OFFSET buffer ; point to the buffer
mov ecx,SIZEOF buffer ; specify max characters
call ReadString ; input the string
mov byteCount,eax ; number of characters
关于assembly - 如何在Assembly中获取字符串输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51137948/