Reputation: 121
I'm reviewing a worksheet for a machine architecture exam and I wanted a clarification on the answer my instructor provided. He's had a couple typos on previous worksheets so I wanted to make sure he was correct here. Take a look at the above picture and notice that he says the destination after the instruction would be 0x100 and the value would be 0x100, but wouldn't the correct answer be destination: 0x100 (value of %rax because of parentheses) and 0x1 (value of %rcx)? Thanks in advance.
EDIT: fixing the picture
Upvotes: 2
Views: 12066
Reputation: 93014
The addq a,b
instruction adds the contents of a
to b
. So if rcx = 0x1
, rax = 0x100
and we have 0xff
at address 0x100
, then add %rcx,(%rax)
adds 0x1
in rcx
to 0xff
at address 0x100
, yielding 0x100
at address 0x100
as the worksheet correctly indicates.
Your intuition would be correct if the instruction was movq
instead of addq
as movq
just overwrites a memory location or register instead of adding to it.
Upvotes: 4