Nasm x86 修改数组中的字符
Nasm x86 modified char in array
我定义了一个数组是 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' ?
谢谢
在 move
将其放入数组之前,将 eax
加 1。或者,如果你已经把它放在数组中,并且注册 X 是索引的 4 倍,你可以这样做
add [Text+X], 1
我定义了一个数组是 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' ?
谢谢
在 move
将其放入数组之前,将 eax
加 1。或者,如果你已经把它放在数组中,并且注册 X 是索引的 4 倍,你可以这样做
add [Text+X], 1