assembly - 如何在Assembly中获取字符串输入

标签 assembly x86 masm 32-bit irvine32

我尝试在论坛中搜索答案,但我得到的只是 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/

相关文章:

math - x86上三角指令的误差是多少?

windows - 全局描述符表

c# - NGEN x86 与 x64 与 .NET 可执行文件

assembly - 在 MASM x86 中使用文本宏 @date 或 @time

assembly - MASM32循环

visual-studio - Visual Studio 中的外部程序集文件

windows - NASM ReadConsoleA 或 WriteConsoleA 缓冲区调试问题

assembly - addi和add之间的汇编语言(MIPS)区别

assembly - 从 CD 加载扇区

assembly - 是否可以修改或访问程序计数器?