The Instruction Set Architecture

Download Report

Transcript The Instruction Set Architecture

The Instruction Set
Architecture
September 27th, 2007
By: Corbin Johnson
CS 146
1
What is the Instruction Set
Architecture?

It contains instructions to use and manipulate
programmer-accessible hardware in a computer.
in terms of
place in a
computer
2
What is the relationship between
the Instruction Set Architecture and
Assembly / Machine language?

An assembly / machine program is made
up of the instructions in the ISA and makes
use of registries in the ISA.
3
Here’s how it works
Higher level languages (Java, C++, etc…)
are translated into assembly / machine
language by compilers.
 When a user calls the program, the
compiled program is loaded into RAM.
 The program then executes, line by line,
until the Operating System takes back
control of the computer.

4
A Sample Computer: ARC
The ARC has an ISA that is a subset of the
ISA of the SPARC, or Scalable Processor
Architecture processor developed by Sun
in the mid 80’s.
 Has most important features of SPARC
but has left out most complex portions.
 ARC is considered a RISC or “Reduced
Instruction Set Computer.”

5
Goal: Program the ARC

A program can be written for the ARC
using the ISA of the ARC.

Discuss three main parts of ARC:
RAM
 Processor (CPU)
 Instruction Set

6

Discuss three main parts of ARC:
 RAM
 Processor (CPU)
 Instruction Set
32 bit memory
 Byte Addressable
 Memory-mapped I/O

7


Discuss three main parts of ARC:
 RAM
 Processor (CPU)
 Instruction Set
The OS
211 bits of memory
 Only OS uses this
area

8


Discuss three main parts of ARC:
 RAM
 Processor (CPU)
 Instruction Set
The User Space
Undefined amount
 User’s program fills
Into unused space
 Designed to work well
If stack small and
Program large or
Vice versa.

9


Discuss three main parts of ARC:
 RAM
 Processor (CPU)
 Instruction Set
The System Stack
Undefined amount
 Program’s execution
Uses stack for storage
 Grows towards lower
Memory as user’s
Space grows towards
Higher memory.

10


Discuss three main parts of ARC:
 RAM
 Processor (CPU)
 Instruction Set
Memory-Mapped I/O
Static slots
 Data talks with input
And output devices

11


Discuss three main parts of ARC:
 RAM
 Processor (CPU)
 Instruction Set
The CPU
Executes programs
In main memory
 Contains Registries
Holding data
 Four-Step cycle to
Execute program

12


Discuss three main parts of ARC:
 RAM
 Processor (CPU)
 Instruction Set
The Four Step
Cycle
1)
2)
3)
4)
Fetch next instruction
Decode the instruction
Read operand in main
memory if any
Execute instruction
and store results, if
any.
13


Discuss three main parts of ARC:
 RAM
 Processor (CPU)
 Instruction Set
The registers


Positions in CPU that
hold data during
calculation
Special Registries:
%r0, %sp, %link,
%psr, % pc
14


Discuss three main parts of ARC:
 RAM
 Processor (CPU)
 Instruction Set
The Arithmetic and
Logic Unit


Takes care of
calculations that need
to be executed
Fed instructions by
the Control Unit
15


Discuss three main parts of ARC:
 RAM
 Processor (CPU)
 Instruction Set
Some Features of the ISA:



All of the instructions in the Instruction Set
are 32 bit
ARC is load-store: all operands must be
either loaded to use or stored in memory to
be stored
ARC is two’s compliment
16


Discuss three main parts of ARC:
 RAM
 Processor (CPU)
 Instruction Set
Three different classes of instructions:



Arithmetic and Logic
Memory Access
Transfer of Control
17


Three different classes of instructions:

Arithmetic and Logic

Memory Access

Transfer of Control
Arithmetic and Logic
Includes instructions
like Add and Subtract
Also includes
instructions like AND,
OR and NOT.
18


Three different classes of instructions:

Arithmetic and Logic

Memory Access

Transfer of Control
Memory Access
Includes instructions
load and store
Loads into registers
and stores into
memory slots in RAM
19


Three different classes of instructions:

Arithmetic and Logic

Memory Access

Transfer of Control
Transfer of Control
Instructions help get
to different places in
program
Place in ISA where
conditionals first are
seen (if statement,
loops, etc…)
Essentially changes
program counter
register
20
The Syntax of the ARC Assembly
Language

The Mnemonic is a way for the programmer
to remember the instruction’s name.

A Compiler will take a written assembly
language code and convert it to machine
code.
21
What’s that cc after addcc?

CC stands for Condition Code and they are set in the
PSR (it is a 32 bit registry)

There are 4:

Z: if the result of the instruction is zero, this flag is set.

N: if the most significant bit is 1, this bit is set

C: if there is a carry out of the MSB or a borrow into it,
this flag is set.

V: Overflow. The result cannot be represented in 32
22
bits.
THE PSR
(Processor Status Register)
23
More on The Syntax of the ARC
Assembly Language

Brackets [ ] around an operand means to load
(or store) from (or in) the memory which is
addressed by the operand within the brackets.
24
A few of the 35 instructions
The ARC ISA has more than 35
instructions.
 Memory: ld [%r5 + 2064] , %r1
 Arithmetic: addcc %r1, 129, %r1
 Control: call sub_r

25
From Assembly Language to
Machine Code

Each Assembly
Language
instruction is
translated one
line for one line
(one to one).
rd: destination registry
Cond: based on the PSR, this
executes differently
Simm13: a user defined
constant in 2’s compliment
in 13 bits.
Rs1: registry 1 in the CPU
Disp30/Disp 22: 30/22 bit number is
shifted to the left to achieve 32 bit
destination of it’s function.
26
Summary
Although not explicitly shown, this method
will take an upper level program and
convert it into actual things the computer
can do.
 Involves translation from the higher level
into assembly language into machine code
using the ARC ISA.

27