0

Hey guys,

I'm fairly new to assembly & i'm having trouble iterating through an array; i.e. increasing the index as I loop.

I'm working under x86-64 in Linux using NASM.
There doesn't seem to be much documentation on the 64-bit architecture.
Also, the book i'm using seems to code all the examples in C, then disassembles the code into AT&T syntax assembly. Doesn't really help.

Description of my code:
After taking in the first input & moving it into slot 0 of the array, I ask if there's more input.
If there is, I move into the loop.
I think each slot in the array is 8 bits, so I tried this to increment the index:

mov qword [r14+8], rsi

However, I then realized this will always input into slot 1 of the array as I loop....
How can I increase the index of the array as I loop so that my data is not overwritten?

Thanks a lot, any help is appreciated.

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by jdelgado08
0

Hi,

Please, forgive me if I am wrong, but if you use another register instead of 8, you can increment it adding it 8.

mov r13, 0 
mylabel:
mov qword [r14+r13], rsi
add r13, 8
cmp r13, YourArrayLimitMultipliedBy8
jb mylabel

But you must realize that in this loop rsi never changes.

Cheers.

0

Hello untio, thanks for the prompt reply.
I'll try that & see if it works.

But you must realize that in this loop rsi never changes.

Yes, of course. I have a different section in my loop where I take in input & store it in rsi.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.