You are on page 1of 17

The University of Adelaide, School of Computer Science 12 August 2021

COMPUTER ORGANIZATION AND DESIGN 5th


Edition
The Hardware/Software Interface

Chapter 2
Instructions: Language
of the Computer

Contents

Chapter 2 — Instructions: Language of the Computer — 2

Chapter 2 — Instructions: Language of the Computer 1


The University of Adelaide, School of Computer Science 12 August 2021

Executing programs on a computer

Chapter 2 — Instructions: Language of the Computer — 3

Computer system

Chapter 2 — Instructions: Language of the Computer — 4

Chapter 2 — Instructions: Language of the Computer 2


The University of Adelaide, School of Computer Science 12 August 2021

Inside a processor

Chapter 2 — Instructions: Language of the Computer — 5

Programming a processor

Chapter 2 — Instructions: Language of the Computer — 6

Chapter 2 — Instructions: Language of the Computer 3


The University of Adelaide, School of Computer Science 12 August 2021

Walk through the program execution


• What will the processor do?
– 1. Load the instruction
– 2. Figure out what operation to do
– 3. Figure out what data to use
– 4. Do the computation
– 5. Figure out next instruction

Chapter 2 — Instructions: Language of the Computer — 7

1:Load r0 (i) from memory (location 7)

Chapter 2 — Instructions: Language of the Computer — 8

Chapter 2 — Instructions: Language of the Computer 4


The University of Adelaide, School of Computer Science 12 August 2021

2:Subtract 2 from r0 (i) to see if it is 2

Chapter 2 — Instructions: Language of the Computer — 9

3:Check if r1 is zero, and jump to done if it is

Chapter 2 — Instructions: Language of the Computer — 10

Chapter 2 — Instructions: Language of the Computer 5


The University of Adelaide, School of Computer Science 12 August 2021

4: Increment r0 (i)

Chapter 2 — Instructions: Language of the Computer — 11

5: Continue the loop

Chapter 2 — Instructions: Language of the Computer — 12

Chapter 2 — Instructions: Language of the Computer 6


The University of Adelaide, School of Computer Science 12 August 2021

6:Subtract 2 from r0 (i) to see if it is 2

Chapter 2 — Instructions: Language of the Computer — 13

7:Check if r1 is zero, and jump to done if it is

Chapter 2 — Instructions: Language of the Computer — 14

Chapter 2 — Instructions: Language of the Computer 7


The University of Adelaide, School of Computer Science 12 August 2021

8: Increment r0 (i)

Chapter 2 — Instructions: Language of the Computer — 15

9: Continue the loop

Chapter 2 — Instructions: Language of the Computer — 16

Chapter 2 — Instructions: Language of the Computer 8


The University of Adelaide, School of Computer Science 12 August 2021

10:Subtract 2 from r0 (i) to see if it is 2

Chapter 2 — Instructions: Language of the Computer — 17

11:Check if r1 is zero, and jump to done if it is

Chapter 2 — Instructions: Language of the Computer — 18

Chapter 2 — Instructions: Language of the Computer 9


The University of Adelaide, School of Computer Science 12 August 2021

12: Crash because instruction 5 is invalid!

Chapter 2 — Instructions: Language of the Computer — 19

Walk through the program execution

Chapter 2 — Instructions: Language of the Computer — 20

Chapter 2 — Instructions: Language of the Computer 10


The University of Adelaide, School of Computer Science 12 August 2021

Introduction to instructions
• Simpler commands/operations eventually lead to
instructions
• Instructions represent something the processor HW can
actually do.
• Instructions inherently suggest a sequence of 1s and 0s
that the processor can understand
• Example: Common DSP function is a multiply-accumulate
operation: x = x + (y*z)
• Some DSP processors have HW that can do this directly
• Others may require two separate steps:
• temp = y * z
• x = x + temp, thus, there would not be a multiply-accumulate instruction

MIPS instructions

Chapter 2 — Instructions: Language of the Computer — 22

Chapter 2 — Instructions: Language of the Computer 11


The University of Adelaide, School of Computer Science 12 August 2021

Question:2 or 3 registers per instruction

Chapter 2 — Instructions: Language of the Computer — 23

Types of instructions

Chapter 2 — Instructions: Language of the Computer — 24

Chapter 2 — Instructions: Language of the Computer 12


The University of Adelaide, School of Computer Science 12 August 2021

Registers in MIPS

Chapter 2 — Instructions: Language of the Computer — 25

Register order

Chapter 2 — Instructions: Language of the Computer — 26

Chapter 2 — Instructions: Language of the Computer 13


The University of Adelaide, School of Computer Science 12 August 2021

Complex functions

Chapter 2 — Instructions: Language of the Computer — 27

MIPS memory organization


 Register file and main memory

Chapter 2 — Instructions: Language of the Computer — 28

Chapter 2 — Instructions: Language of the Computer 14


The University of Adelaide, School of Computer Science 12 August 2021

Memory vs. registers

Read/write
data

Chapter 2 — Instructions: Language of the Computer — 29

Memory organization

Chapter 2 — Instructions: Language of the Computer — 30

Chapter 2 — Instructions: Language of the Computer 15


The University of Adelaide, School of Computer Science 12 August 2021

Memory and register file

1 word

1 8word
bits
8 bits
8 bits
8 bits

Viewing memory as bytes or words

• Most data in MIPS is handled in words not bytes


– A word is 32 bits or 4 bytes
– A word is the size of a register

Chapter 2 — Instructions: Language of the Computer 16


The University of Adelaide, School of Computer Science 12 August 2021

Access alignment

Chapter 2 — Instructions: Language of the Computer — 33

Question

Chapter 2 — Instructions: Language of the Computer — 34

Chapter 2 — Instructions: Language of the Computer 17

You might also like