简体   繁体   中英

Nasm x86 modified char in array

I have defined an array is SECTION .bss like this :

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

Then i use getchar to put the char from a file using stdin like this :

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

So how would i go about shifting the char in Text up one letter so that 'a' become 'b' ?

Thank you

Add 1 to eax before you move it into the array. Or, if you have already put it in the array, and register X is 4 times the index, you can just do

add [Text+X], 1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM