我尝试在论坛上搜索答案,但我得到的只是输入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 字符,我不知道为什么(所以我知道问题出在接受输入上。
对不起,书有答案。
.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