Assembly addq clarification

The addq a,b instruction adds the contents of a to b. So if rcx = 0x1rax = 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.

Leave a Comment