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.

Recommended Answers

All 2 Replies


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 
mov qword [r14+r13], rsi
add r13, 8
cmp r13, YourArrayLimitMultipliedBy8
jb mylabel

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


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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.