0

I am currently solving some problems out of "Microcontrollers Second Edition" and the question is asking:
mov [ W1],W0
The initial register memory contents of

W0 = 0x1004
W1 = 0x1006
W3 = 0xF0A2
0x1000 = 0x382A
0x1002 = 0xFB80
0x1004 = 0x80FF

The answer is:

W0 = 0x80FF
W1 = 0x0804

once the command is executed. The problem I am facing is the fact that there is no operation before the [ W1] register such as "--" or "++" which is why I do not understand how they came to this answer. If anyone could clarify I would greatly appreciate it.

mov [ W1],W0 ;Intentional space left before "W1" register. 

W0 = 0x80FF
W1 = 0x0804

is the answer

Mike
  • 4,041
  • 6
  • 20
  • 37
Frio
  • 1
  • What architecture is this? Some custom example ISA for that textbook? How does one `mov` instruction change both `W0` and `W1` to totally different values? `++` or `--` wouldn't explain anything. So yeah, could well be an error in the book. – Peter Cordes Feb 18 '19 at 22:53
  • That is exactly what I was thinking! From my past experience brackets around a register serve sorta like a pointer in C but the initial register or its memory contents do not get modified. In this book however, it says both register's memory contents are being modified leading me to believe is an error. – Frio Feb 18 '19 at 23:05
  • Yes, exactly. `[reg + offset]` in x86, ARM and others, or `offset(reg)` in many RISC ISAs, just reference memory at that address without changing the register. PowerPC and ARM have ways to update `reg` to `reg+offset`, but you're not using an offset. Updating the pointer register based on the result loaded from memory would be *super* weird, and often less useful. – Peter Cordes Feb 19 '19 at 03:17

1 Answers1

1

I believe there is a mistake in this book. The "[]" means the data saved at the address written in the register inside the brackets. The only data changed in the line above is [W1] neither W1 or W0 changed.

tomer zeitune
  • 1,080
  • 1
  • 12
  • 14