Professional Documents
Culture Documents
Notes Unza23 Ict1110 Lecture 17
Notes Unza23 Ict1110 Lecture 17
● Introduction
● MIPS Instruction Formats
● R-Format Instructions
● I-Format Instructions
● J-Format Instructions
● Addition and Subtraction
● Multiplication
● Division
● MIPS System Calls
● Summary
October 4, 2023 ICT 1110 (2022/23) L17 - 2
Introduction (1/3)
http://rivoire.cs.sonoma.edu/cs351/wemips
rd Destination register
rs Source register #1
rt Source register #2
rd Destination register
rs Source register #1
rt Source register #2
rt Target register
rs Source register
rd Destination register
rs Source register
opcode rs rt IMM
6 bits 5 bits 5 bits 16 bits
addi $8 $9 -2019
0x08 $8 $9 -2019
001000 01000 01001 1111100000011101
opcode rs rt IMM
6 bits 5 bits 5 bits 16 bits
addi $8 $9 -2019
0x08 $8 $9 -2019
001000 01000 01001 1111100000011101
opcode rs rt IMM
6 bits 5 bits 5 bits 16 bits
addi $zero $t0 -2019
addi $8 $0 -2019
0x08 $8 $0 -2019
$zero = $0 $8 = $8
001000 01000 00000 1111100000011101
opcode rs rt IMM
6 bits 5 bits 5 bits 16 bits
addi $zero $t0 -2019
addi $0 $8 -2019
0x08 $8 $0 -2019
001000 01000 00000 1111100000011101
opcode rs rt IMM
6 bits 5 bits 5 bits 16 bits
addi $t0 $zero -2019
addi $0 $8 -2019
0x08 $8 $0 -2019
addi 001000
= 0x08 01000 00000 1111100000011101
opcode rs rt IMM
6 bits 5 bits 5 bits 16 bits
addi $t0 $zero -2019
addi $0 $8 -2019
0x08 $0 $8 -2019
001000 01000 00000 1111100000011101
opcode rs rt IMM
6 bits 5 bits 5 bits 16 bits
addi $t0 $zero -2019
addi $0 $8 -2019
0x08 $0 $8 -2019
001000 01000 00000 1111100000011101
-2019 in 2’s complement using 16 bit representation
● 0000011111100011 (2019 in binary)
● 1111100000011100 (1’s complement)
● 1111100000011101 (add 1 to get 2’s complement)
opcode rs rt IMM
6 bits 5 bits 5 bits 16 bits
addi $t0 $zero -2019
addi $0 $8 -2019
0x08 $0 $8 -2019
001000 00000 01000 1111100000011101
opcode rs rt IMM
6 bits 5 bits 5 bits 16 bits
addi $zero $t0 -2019
addi $0 $8 -2019
0x08 $0 $8 -2019
001000 00000 01000 1111100000011101
addi $t0, $zero, -2019 = 001000 00000 01000 1111100000011101
○ Example
j loop1
○ Example
j loop1
● Operands must be
registers.
● Complex expressions need
to be broken down.
● Multiplying two
number using a HLL
involves initialising
variables with
number and
performing
mathematical
operation using ‘*’.
● Syscalls are typically used to print data, read user input and
exiting programs.
10 Exit — —
.text
## STEP 1: Prompt first integer
# Print string for printing number 1
li $v0, 4
la $a0, var_number1
syscall
li $v0, 4
la $a0, var_result
syscall
10 Exit — —