CS计算机代考程序代写 python mips compiler case study assembly PowerPoint Presentation

PowerPoint Presentation

Slide #1 of 49

Computer Systems
Week 2 (part 1)

Instructions, Assembly Language, and
Machine Code

Slide #2 of 49

Lecture Objectives

To develop fundamental understanding of computer

architecture & organization, instruction sets and

assembly language programming.

Slide #3 of 49

Lecture Outline

◆Computer anatomy

◆How a program is executed

◆The von

◆ CPU Cycles and Instruction Pipelining

◆ The Harvard Architecture

◆ Case Study – MIPS R4000

◼Structure

◼Key Features

◼Assembly Languages

◼Instruction Sets

◼MIPS Instruction Types

Slide #4 of 49

Before we start …
What is a computer ?

Some of the following slides are based on:

Resources: Chapter 9 – Principles of Computer Operations

Slide #5 of 49

A computer is a complex system (machine) that

can be instructed to carry out sequences of

arithmetic or logical operations automatically via

computer programming…

Slide #6 of 49

So…
How Computers Execute Programs?

Slide #7 of 49

Requirements of a Computing Device

◆Load the program from some external device/memory

◆– interface to the outside world

◆Process instructions in the correct order – mechanism to keep
track of progress, local storage and decoding of instructions

◆Access pieces of data in accordance with the program’s

instructions – local storage of data

◆Perform computations – a calculation “engine”

◆Take decisions according to the results of the

computations – mechanism for control

◆Send the results of the computations to some external

device – interface to the outside world

Slide #8 of 49

Anatomy of a Computer System

All computers, regardless of their implementing technology,

have five basic parts or subsystems:

1) Memory,

2) Control unit,

3) Arithmetic/logic unit (ALU),

4) Input unit, and

5) Output unit

Slide #9 of 49

1) Memory

Memory stores both the program while it is running and the

data on which the program operates:

Properties of memory:

◆ Discrete locations

◆ Memory is organized as a sequence of discrete locations

◆ In modern memory, each location is composed of 1 byte (8

bits)

◆ Addresses

◆ Every memory location has an address, whole numbers

starting at 0

◆ Values

◆ Memory locations record / store values

Slide #10 of 49

1) Memory

◆ Finite Capacity

◆ Memory locations have a finite capacity (limited size),

◆ Data may not “fit” in the memory location

Address of location is displayed above the box and the

contents of location is shown in the box

Blocks of four/eight bytes are used as a unit so often

that they are called memory words

Slide #11 of 49

Random Access Memory (RAM)

◆ Computer memory is called Random Access Memory

(RAM)

◼“Random access” is out-of-date and simply means that

the computer can refer to the memory locations in any

order

◆ RAM is measured in megabytes (MB) or gigabytes (GB)

◆ Lots of memory is needed to handle the space required

of programs and data

Slide #12 of 49

2) Control Unit

◆ The control unit of a computer is where the Fetch/

Execute Cycle occurs

◼ Its circuitry fetches an instruction from memory and

performs the other operations of the Fetch/Execute

Cycle on it

◼ A typical machine instruction has the form

ADD 4000, 2000, 2080

◼ Looks like those three numbers should be added together

◆ What it really means is that whatever numbers are

stored in memory locations 2000 and 2080 be added

together, and the result be stored in location 4000

Slide #13 of 49

Illustration of a Single Instruction

Slide #14 of 49

3) Arithmetic/Logic Unit (ALU)

◆“Does the math”

◆A circuit in the ALU can add/subtract two numbers

◆The circuit uses logic gates or simpler circuits that

implement operations like AND and OR

◆There are also circuits for multiplying, for comparing two

numbers, etc.

◆The ALU carries out each machine instruction with a

separate circuit

Slide #15 of 49

4 & 5) Input / Output Units

◆These two components are the wires and circuits through

which information moves into and out of a computer

◆A computer without input or output is useless

Slide #16 of 49

The Peripherals

◆Peripherals connect to the computer input/output (I/O)

ports

◆They provide input or receiving its output

◆They are not considered part of the computer:

◼They are only specialized gadgets that encode or decode

information between the computer and the physical world.

◼Some examples are Keyboard, Mouse, Monitor, USB, Hard

Disks, Network Cards etc.

Slide #17 of 49

Anatomy of a Computer System

All computers, regardless of their implementing technology,

have five basic parts or subsystems:

1) Memory,

2) Control unit,

3) Arithmetic/logic unit (ALU),

4) Input unit, and

5) Output unit

Slide #18 of 49

How Computers Execute Programs?

Here is a simple computer program:

What is the program computing ?

Online Python compiler – https://www.online-python.com/

Slide #19 of 49

Executing Programmes

A program is loaded into memory and address of first

instruction is placed in PC (Program Counter)

The following Fetch / Execute cycle is then followed:

1) Instruction Fetch (IF)

2) Instruction Decode (ID)

3) Data / Operand Fetch (DF/OF)

4) Instruction Execution (EX)

5) Result Return / Store (RR/ST)

Slide #20 of 49

ADD 800, 428, 884

ADD the values found in memory locations 428 and

884 and store the result in location 800

Slide #21 of 49

Instruction Fetch (IF)

◆Execution begins by

moving the instruction at

the address given by the

PC (PC 2200) from

memory to the control

unit

◆Bits of instruction are

placed into the decoder

circuit of the Control Unit

◆Once instruction is

fetched, the PC can be

readied for fetching the

next instruction

Slide #22 of 49

Instruction Decode (ID)

◆Decoder determines what operation the ALU will

perform (ADD), and sets up the ALU

◆Decoder finds the memory

address of the instruction’s

data (source operands)

◆Decoder finds the

destination address for the

Result Return step and

places the address in the

RR circuit

Slide #23 of 49

Data Fetch (DF)

◆The data values to be

operated on are

retrieved from memory

◆Bits at specified memory

locations are copied into

locations in the ALU

circuitry

◆Data values remain in

memory (they are not

destroyed)

Slide #24 of 49

Instruction Execution (EX)

◆For this ADD instruction,

the addition circuit adds

the two source operands

together to produce their

sum

◆Sum is held in the ALU

circuitry

◆This is the actual

computation

Slide #25 of 49

Result Return (RR)

◆RR returns the result of

EX to the memory

location specified by the

destination address.

◆Once the result is

stored, the cycle begins

again

Slide #26 of 49

Many Simple Operations

◆Computers “know” very few instructions

◆The decoder hardware in the controller recognizes, and

the ALU performs, only about 100 or so different

instructions (with a lot of duplication)

◆Everything that computers do must be reduced to some

combination of these primitive, hardwired instructions

◆ADD is representative of the complexity of computer

instructions…some are slightly simpler, some slightly

more complex.

◆Computers achieve success at what they can do with

speed i.e. millions of instructions per second (Clock

Speed in MHz or even GHz)

Slide #27 of 49

Computer’s View of Software

◆A computer “sees” software as a long sequence of 4-

byte groups of bits (0’s and 1’s)

This binary object file can be hundreds of thousands to

millions of words long

◆Once installed, the computer runs the software by:

◆ copying the binary instructions into the RAM

◆ interpreting them using the Fetch/Execute Cycle.

◆It does whatever the instructions tell it to do!

Slide #28 of 49

Summary

◆All computers, regardless of their implementing

technology, have five basic parts or subsystems:

▪ The memory, a very long sequence of bytes, each with an

address, stores the program and data while the program is

running.

▪ The ALU does the actual computing.

▪ The Control Unit controls the activity of all other units in the

computer system, giving them directions.

▪ The input and output units are the interfaces for the peripheral

devices connected to the computer.

◆A program is executed according to the Fetch/Execute

Cycle:

▪ The repeating process fetches each instruction (indicated by

the PC), decodes the operation, retrieves the data, performs

the operation, and stores the result back into the memory.