【问题标题】:Nasm x86 modified char in arrayNasm x86 修改数组中的字符
【发布时间】:2016-08-11 03:14:40
【问题描述】:

我已经定义了一个像这样的 SECTION .bss 数组:

TextLenght EQU 1024 ; Define length of a line of  text data
Text resb TextLenght ; Define array to hold text

然后我使用 getchar 将字符从使用标准输入的文件中放入,如下所示:

all getchar ; call getchar to get input from stdin, char is save in eax 
cmp eax, -1
jle Done     ; if return -1, we at EOF
mov [Text+esi], eax; put char from eax into array
add esi, 4    ; increase array index
jmp read   ; loop back this function

那么我将如何将 Text 中的字符向上移动一个字母,以使 'a' 变为 'b' ?

谢谢

【问题讨论】:

    标签: arrays assembly char x86 nasm


    【解决方案1】:

    move 之前将 1 添加到 eax 到数组中。或者,如果你已经把它放在数组中,并且寄存器 X 是索引的 4 倍,你可以这样做

    add [Text+X], 1
    

    【讨论】:

    • 有没有办法直接修改数组的内容?
    猜你喜欢
    • 2017-09-26
    • 1970-01-01
    • 2017-09-16
    • 2014-02-21
    • 2020-03-21
    • 2015-01-12
    • 2017-03-31
    • 1970-01-01
    • 2013-01-02
    相关资源
    最近更新 更多