-7

What is the difference between these instructions:

-Add   (R0), R3
-Add    R0, (R3)

And why has the place of () been changed?

too honest for this site
  • 12,050
  • 4
  • 30
  • 52
  • 5
    Is this assembly? You might want to add the specific architecture in your tags. – Stephen Newell Mar 16 '18 at 05:34
  • 5
    You don't tell us what processor architecture this is for but usually parentheses around a register mean that the register contains a memory address and that operand will retrieve data from that address to complete the instruction. `Add (R0), R3` probably is "add contents of register R3 to the memory address pointed to by R0 storing the result to the memory address pointed to by R0". .`Add R0, (R3)` is probably "add contents pointed to by register R3 and add them to register R0 storing the result in register R0". I'm taking a guess at syntax and which side is src and destination. – Michael Petch Mar 16 '18 at 06:12
  • 3
    What does the `-` at the start of the `Add` mnemonic mean? Is that part of the instruction, or is that a bullet point? – Peter Cordes Mar 16 '18 at 08:42

1 Answers1

0

You don't indicate the processor architecture, which can make a really big difference.

That said, your question can easily be answered by reading the documentation for your assembler. Based on how every other assembler I've used works, my expectation would be one of the following:

  1. They are not different; the parentheses have no actual impact.

  2. The parentheses are being used much like square brackets are typically used in an assembler to dereference the register to a memory address(also known as indirect addressing). This would mean that one instruction dereferences R0 while the other dereferences R3.

You should be able to determine which of these is the case by assembling this code in memory and stepping through it while watching the register values.

David Hoelzer
  • 15,862
  • 4
  • 48
  • 67