Understanding Assembly basic code
Understanding Assembly basic code
pointr: .word pointr
mov #pointr,r0
mov pointr,r1
Can someone please explain the difference between the values r0 and r1?
#pointr
pointr
mov
pointr: .word pointr creates a label for a word value containing the actual absolute address of pointr. mov #pointr,r0 uses immediate mode to move the value of the pointr label directly to r0. mov pointr,r1 uses relative mode to move the word value at pointr into r1. Since the word value stored at pointr is the address of pointr itself it has the effect of moving the address of pointr to r1. The values in r0 and r1 should be the same.– Michael Petch
Jul 1 at 19:45
pointr: .word pointr
pointr
mov #pointr,r0
pointr
mov pointr,r1
pointr
r1
pointr
pointr
pointr
1 Answer
1
r0 and r1 are two different CPU registers.
They're being written by similar instructions. I think you're missing the point of the question. (PDP-11 was the inspiration for x86 AT&T syntax, where the destination operand is last).
– Peter Cordes
Jul 1 at 2:52
Sorry you feel that way. I was simply answering the question as I understood it. His question clearly says "explain the difference between the values r0 and r1". Those are not values, they're registers.
– STLDeveloper
Jul 1 at 2:57
Oh, I didn't notice the missing word. I was reading it as "difference between the values in r0 and r1". I'm still pretty confident that's the intended meaning. Using variable names or register names as a value is pretty common usage, even if it's a bit sloppy.
– Peter Cordes
Jul 1 at 3:08
But anyway, now I see why you thought this answered the question, even though I still think it doesn't. It's up to the OP to clarify now.
– Peter Cordes
Jul 1 at 3:10
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
From experience with asm syntax for other machines, likely
#pointris an immediate operand (the address of the label), whilepointris a memory source operand, so the 2ndmovis a load instruction.– Peter Cordes
Jul 1 at 2:42