-2

Beginner at assembly code but I'm a bit confused between the usage of move and load, being:

move ra rd
load ra rd
load ra (rd)

from what I've read, move ra rd copies the value from RD to RA, load ra rd copies the value in RD from memory to RA, while load ra (rd) does the same thing as load ra rd. Am I mistaken or are the last two the same?

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
  • 2
    What architecture and assembler are you using where `load ra rd` and `load ra (rd)` are both valid syntax? The answer totally depends on how the assembler (software) interprets the text syntax of your program to turn it into machine code. (If the CPU manuals define different forms of a `load` instruction or say anything about asm syntax, an assembler will normally follow that unless it makes up its own syntax.) – Peter Cordes Aug 09 '22 at 09:23
  • 1
    assembly is specific to the tool and target, so we need to not only know the target but also the tool, assembler. – old_timer Aug 09 '22 at 10:13
  • I don't know any assembly language instruction set that does `load ra rd`. Some allow something like `move ra (rd)`. – Erik Eidt Aug 09 '22 at 19:39
  • 1
    I’m using Xilinx 64bit project manager coding onto a FPGA board, the reference sheet for it includes explanations for both move and load but though “load ra rd” is not included while “load ra (rd)” is, both work. – rabbitfufu Aug 10 '22 at 12:50
  • Assemble it, then use a disassembler to see what instructions it actually created. Also, put that detail about `load ra rd` being undocumented into the question. – Peter Cordes Nov 14 '22 at 07:12

2 Answers2

1

In mov ra rd the contents of RD (be it a register or a memory location or any constant value) are copied into the register RA.

In ldr ra rd the contents from the specified memory location (RD) are loaded into the specified register (RA).

You have more flexibility with mov instruction.

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
  • 1
    If this is something like MIPS, `move` is only available between two registers, not with a memory source. You're using ARM mnemonics where `move` is spelled `mov` and load is `ldr`, but in ARM you can't `mov` from memory, only a register or immediate constant: like `mov r0, r1` or `mov r0, #123`, but not `mov r0, [r1]`. And ARM's `ldr` requires the source operand to be memory, opposite of `mov` which requires it to be non-memory. Or are you talking about some other architecture? x86 only has `mov`, no separate mnemonics for load or store, so not that. – Peter Cordes Aug 09 '22 at 09:27
0

In ARM architecture, the LOAD instruction is used to load data from memory locations into a destination register. The MOV instruction can be used to move an immediate value or a value stored in a register into a destination register. So, MOV instruction has no permission to access memory. Only Load instruction.