Carlos Frank
Carlos Frank

Reputation: 167

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

Upvotes: 0

Views: 390

Answers (1)

Scott Hunter
Scott Hunter

Reputation: 49921

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

Upvotes: 1

Related Questions