0

I have some assembly code that uses movq with the destination operand having the triple-argument parentheses:

movq %rax, a(, %rax, 8).

From my understanding, a(, %rax, 8) = a + 8 * %rax, but I think it has something to do with a matrix also, (I just don't understand how, since there is no first argument in ().

Any help you greatly be appreciated!

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • 2
    Your understanding is correct. A missing part of a SIB operand has value zero. – fuz Oct 01 '21 at 16:08
  • 2
    @NalinRanjan No, it's called the *base register.* The offset (or *displacement*) is the part before the parentheses. It is present. – fuz Oct 01 '21 at 16:15
  • 1
    Yeah.. Even I am thinking... – Nalin Ranjan Oct 01 '21 at 16:31
  • 1
    It's nothing to do with matrices (though conceivably it could appear in some code that processes matrices). And the syntax is just an arbitrary choice of notation, in which the first argument is allowed to be omitted. Don't overthink it. – Nate Eldredge Oct 01 '21 at 17:43
  • @NateEldredge Gotcha, thank you! I think I meant to say 'array' rather than matrix, but I think I understand the reason behind now! – Satan Lucifer Oct 01 '21 at 19:47

0 Answers0