I have some assembly code which I'm trying to understand:
0x0000000000401024 <+55>: mov $0x0,%ecx
0x0000000000401029 <+60>: mov $0x0,%edx
0x000000000040102e <+65>: add $0x1,%edx
0x0000000000401031 <+68>: cltq
0x0000000000401033 <+70>: mov 0x402360(,%rax,4),%eax
But I'm having a hard time really understanding this code. I read that cltq converts a 4 byte word to a 8 byte word. Is this always for eax and rax? So essentially rax gets filled with eax taking the sign into account, and the other information in rax gets lost. Is this correct?
Furthermore, what is then the consequence of the next line of code? I think the value in %rax gets multiplied by 4 and added to 0x402360, after which the value corresponding to that address gets put in eax.
What am I thinking wrong and what right? Thanks!