0

Suppose we have:

MOV #NUM, R0

I understand that the hashtag represents an immediate addressing mode. However, what I don't understand what exactly gets stored in R0 in this case. Is it the actual address of NUM?

Dimitri
  • 1,906
  • 3
  • 25
  • 49
  • Typically parentheses or square brackets are used to indicate indirection to memory and there is no instruction for loading the address of the immediate portion of the instruction itself (which need not even be byte aligned or contiguous). (Perhaps somewhat confusingly, base values are so bracketed but offsets are not.) `MOV #NUM, R0` would put the value NUM in R0; `MOV [#NUM], R0` would put the value at the address NUM in R0. –  Apr 06 '15 at 17:57
  • That is so confusing. So why do they use this type of notation to iterate through an array of numbers? If NUM is at 1000 and NUM1 is at 1001, then they would use MOV #NUM, R0 and then do MOV (R0), R1 followed by ADD #1, R0 It would seem that the address 1000 would be stored in this case. – Dimitri Apr 06 '15 at 18:19
  • 1
    `MOV R0, R1` copies the value in R0 to R1 without indirection through memory. One can look at the `()` sort of like the `*` in C. Without the decoration, one gets the value in the register/variable (which may or may not be an address); with the decoration, one gets the value referenced by the value when treated as a pointer. Since direct references are more common, it makes some sense for them not to use special decoration (though one *might* consider the "R" a decoration indicating indirection of the number into the register file, but that is probably not helpful). –  Apr 06 '15 at 18:35
  • Another way of looking at this would be to consider there being an implicit "Memory" designation and the brackets or parentheses are using an array notation. I.e., `MOV [R0], R1` could be read as `MOV Memory[R0], R1` –  Apr 06 '15 at 18:37
  • Gotcha! Thanks so much or the help! – Dimitri Apr 06 '15 at 19:32

0 Answers0