Monash University >
School
of Computer Science and Software Engineering >
CSE1303 >
Part B >
Lectures > Lecture B09 notes
CSE1303 Computer Science
Semester 3 (summer), 2003
Part B
Lecture B09 notes: MIPS instructions
In this lecture
- MIPS instruction set
- All instructions that MIPS computer is capable of performing
- Arithmetic
- add (addition)
- sub (subtraction)
- mul (multiplication)
- div (division)
- rem (modulus)
- neg (negate)
- Logic
- and (bitwise AND)
- or (bitwise OR)
- xor (bitwise exclusive OR (XOR))
- nor (bitwise not-OR (NOR))
- not (bitwise NOT)
- sll (shift left (logical))
- srl (shift right (logical))
- sra (shift right (arithmetic))
- Data movement instructions
- li (load immediate)
- move (register-to-register copy)
- Load/store instructions
- lb (load byte from memory to register)
- lh (load halfword from memory to register)
- lw (load word from memory to register)
- sb (store byte from register to memory)
- sh (store halfword from register to memory)
- sw (store word from register to memory)
- la (compute address of location in memory)
- Control transfer instructions
- j (jump unconditionally)
- jal (jump unconditionlly, remember return address)
- jr (jump to address found in register)
- jalr (jump to address found in register, remember
return address)
- beq (branch if equal)
- bne (branch if not equal)
- blt (branch if less than)
- ble (branch if less than or equal)
- bgt (branch if greater than)
- bge (branch if greater than or equal)
- Miscellaneous instructions
- Immediate instructions
- addi, andi, ori, xori
- Others synthesized as pseudoinstructions
- Pseudoinstructions
- Also known as macro instructions
- Instructions which are in fact implemented using other
instructions instead
- li, la, move, blt,
ble, bgt, bge
- Unsigned instructions
- addu, subu, mulu, divu,
bltu, bleu, bgtu, bgeu lbu, lhu
- Instruction formats
- 32 bits
- Encoding
- R-format (usually 3 registers)
- I-format (usually 2 registers and one immediate value)
- J-format (one label)
- Extension
- Zero extension: always fill with zero bits
- Sign extension: always fill with copies of MSB
Listings
Slide 31
# Program to convert inches to millimetres.
# Integer approximation, multiply by 254/10.
# Data used by the program
.data
inch: .word 42 # Allocate word, store value 42
mm: .space 4 # Allocate word, value unimportant
# Program starts from label main.
.text
main: lw $t0, inch # get inches into $t0
mulu $t1, $t0, 254 # multiply...
divu $t2, $t1, 10 # ...and divide
sw $t2, mm # store result in mm
li $v0, 10 # system call 10...
syscall # ...exits simulation
[ Top |
Home ]
Last modified 2002-12-05