【问题标题】:How to take string input in Assembly如何在汇编中获取字符串输入
【发布时间】:2018-12-10 18:52:23
【问题描述】:

我尝试在论坛中搜索答案,但我得到的只是 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 字符我也不知道为什么)所以我知道问题在于输入。

【问题讨论】:

    标签: assembly x86 masm 32-bit irvine32


    【解决方案1】:

    抱歉,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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-10
      • 1970-01-01
      • 1970-01-01
      • 2021-06-18
      • 1970-01-01
      相关资源
      最近更新 更多