pointr: .word pointr
mov #pointr,r0
mov pointr,r1
Can someone please explain the difference between the values r0 and r1?
pointr: .word pointr
mov #pointr,r0
mov pointr,r1
Can someone please explain the difference between the values r0 and r1?
TL;DR - r0 and r1 will hold the same value, but just because of the initialization in the first line
Let's break this down, instruction by instruction:
pointr: .word pointr
This means "define a label named 'pointer' in address X, and put the value of the label (in this case, X) in that address". So in address X there's a word holding the value X.
mov #pointr,r0
This means "move the value of label 'pointr' (in this case, the address X) to r0". So r0 will hold the value X because 'pointr' is the label for this address.
mov pointr,r1
This means "move the value that sits in the address of label 'pointr' (in this case, also X) to r1". So r1 will hold the value X because of the ".word pointr" part of the first line in code.
To clarify, if we were to replace the first line of code to get:
pointr: .word pointr+2
mov #pointr,r0
mov pointr,r1
the value of r0 will not change (in comparison to the original code), but the value of r1 will.