What is the difference between
ldw r8,0(r4)
and
mov r8, r4
Load word says "copy from memory" but when load word copies from r4, it is copying from register and not from memory right?
A load operation copies data from main memory into a register. A store operation copies data from a register into main memory . When a word (4 bytes) is loaded or stored the memory address must be a multiple of four.
LOAD is used to load data from memory to accumulator. STORE is used to store the accumulator result in memory. Both LOAD and STORE are 1-address instructions. MOV is a 2-address instruction.
1 : something lifted up and carried : burden. 2 : the quantity of material put into a device at one time He washed a load of clothes. 3 : a large number or amount They collected loads of candy on Halloween. 4 : a mass or weight supported by something. 5 : something that causes worry or sadness That's a load off my mind ...
Loads a word of data from a specified location in memory into a general-purpose register. The lwz and l instructions load a word in storage from a specified location in memory addressed by the effective address (EA) into the target general-purpose register (GPR) RT.
lw loads the value which is stored at a certain address. So lw $a1, input_sz will load the value 80 into the register a1 because the value 80 is stored at the address that is specified by the label input_sz . la loads the address of the label itself into the register.
The mov instruction copies the data item referred to by its second operand (i.e. register contents, memory contents, or a constant value) into the location referred to by its first operand (i.e. a register or memory).
The lw instruction (I assume that's what you meant since ldw isn't a standard MIPS instruction, though all the loads will be similar in the context of this answer) loads a word from the memory address specified by 0 + r4, while move1 simply transfers the value of r4 into r8.
For example, let's say r4 is currently 1234 and the word stored at 1234 in memory is 5678.
The difference is thus:
move r8, r4 ; r8 is now 1234
lw r8, 0(r4) ; r8 is now 5678
1 The move instruction" is actually a pseudo-instruction where move $rt, $rs is encoded as addi $rt, $rs, 0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With