1

9(%rax, %rdx): What happens here? Is 9 the offset? and do you add the two registers together?

I'm reading Randal E. Bryant and David R. O'Hallaran's "Computer Systems - A programmer's Persepctive"

At page 209 we are presented with a table (Operand forms):

enter image description here


It's then possible to do a little assignment where I have to fill the empty table with values. I tried my best but am stuck as you can see:

enter image description here

9(%rax, %rdx). Is the 9 the offset? And do you add the two registers here? Not quite sure what to add. I would really appreciate if someone could walk me through the last empty values I need to fill.


Below is the solutions:

enter image description here

1

Welcome to the wonderful world of AT&T assembly! The 9 in 9(%rax, %rdx) is commonly called displacement or sometimes base, and you should indeed just add all three values:

9+rax+rdx = 9+0x100+0x3 = 0x10C

This address is then dereferenced so the value 0x11 is loaded from the address 0x10C.

I would recommend reading the Solaris x86 Assembly Language Reference Manual if you plan to stick with AT&T, or just switch to Intel syntax since it's much more widely used (especially in processor documentation).

| improve this answer | |
  • Thank you, Igor. Makes sense now! – user10829235 Sep 13 '19 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.