Assembler Project Revision

Loads (LW, LH, LB):

InstructionFirst
Operand
Second
Operand
Third
Operand
ExampleAction taken
Load ByteDest Reg Src RegVariable Name LB R1, R2, XR1 <- MEM[(contents of R2)+Address Offset]
Load HalfwordDest Reg Src RegVariable Name LH R1, R2, XR1 <- MEM[(contents of R2)+Address Offset]
Load WordDest Reg Src RegVariable Name LW R1, R2, XR1 <- MEM[(contents of R2)+Address Offset]

Note: Address Offset refers to the result of calculating the distance between the current location and the specified data variable.

Example:

   LW  R6, R7, X  ; assume that the offset for X is 2A

The opcode for this instruction is 05, the source register is R7 and the destination register is R6.

opcode source
register
destination
register
immediate value
000101 00111 00110 0000000000101010

Regrouped, this produces:

0001 0100 1110 0110 0000 0000 0010 1010

or,   14E6002A   in hexadecimal

 

Stores (SW, SH, SB):

InstructionFirst
Operand
Second
Operand
Third
Operand
ExampleAction taken
Store ByteDest Reg Variable NameSrc Reg SB R1, X, R2MEM[(contents of R1)+Address Offset] <- R2
Store HalfwordDest Reg Variable NameSrc Reg SH R1, X, R2MEM[(contents of R1)+Address Offset] <- R2
Store WordDest Reg Variable NameSrc Reg SW R1, X, R2MEM[(contents of R1)+Address Offset] <- R2

Note: Address Offset refers to the result of calculating the distance between the current location and the specified data variable.

Example:

   SH  R4, X, R5  ; assume that the offset for X is 32

The opcode for this instruction is 07, the source register is R5 and the destination register is R4.

opcode source
register
destination
register
immediate value
000111 00101 00100 0000000000110010

Regrouped, this produces:

0001 1100 1010 0100 0000 0000 0011 0010

or,   1CA40032   in hexadecimal

 

Jump Absolute (JA, JAL):

InstructionFirst
Operand
ExampleAction taken
Jump AbsoluteDest Reg (Address Register) JA R1PC <- (contents of R1)
Jump Absolute and LinkDest Reg (Address Register) JAL R1R31 <- PC, PC <- (contents of R1)

Example:

   JA  R9

The opcode for this instruction is 0C and the destination register is R9. There is no source register and no immediate value.

opcode source
register
destination
register
immediate value
001100 00000 01001 0000000000000000

Regrouped, this produces:

0011 0000 0000 1001 0000 0000 0000 0000

or,   30090000   in hexadecimal