lw $8, B
moves a word from location B in RAM to register $8. The instruction
sw $10, Amoves a word from register $10 to memory location A.
To execute the SAL instruction
add A, B, C
requires the MAL instructions
lw $8, B # load B into $8 lw $9, C # load C into $9 add $10, $8, $9 # $10 = $8 + $9 sw $10, A # store $10 in A
The general form of the load and store instructions is:
lw R, Address sw R, Addresswhere R is a general register and Address is either a label or a base displacement address, as described in the next section. In the lw and sw instructions, Address must be a word address (a multiple of 4 bytes).
There are separate load and store instructions to manipulate bytes of data. The lb (load byte), lbu (load byte unsigned) and sb (store byte) instructions operate on single bytes. The form of these instructions is:
lb R, Address lbu R, Address sb R, Addresswhere R is a general register and Address is a label or base displacement address. The Address in this case is a byte address. The lb and lbu instructions move a byte from Address to the least-significant byte of register R.
The lb instruction extends the sign bit of the byte to fill the register. The lbu instruction fills bits 8-31 of the register with 0's.
The half-word load and store instructions operate on two bytes of data. The general form of these instructions is:
lh R, Address lhu R, Address sh R, Addresswhere R is a general register and Address is a byte address. These instructions are identical with the byte instructions, except that two bytes of data are moved.
Two additional load instructions do not move data from RAM. The li (load immediate) instruction is used to load a constant into a register. The general form is:
li R, Constant
The la (load address) instruction is similar to the SAL la instruction. In MAL, la is used to place the address of a label into a register:
la R, Label
The MAL load and store instructions are shown below:
Notes: