6th Edition - Chapter2-Instruction Set Architecture
6th Edition - Chapter2-Instruction Set Architecture
Machine
Instructions and
Programs
Objectives
Machine instructions and program execution,
including branching and subroutine call and return
operations.
Number representation and addition/subtraction in
the 2’s-complement system.
Addressing modes for accessing register and
memory operands.
Assembly language for representing machine
instructions, data, and programs.
Program-controlled Input/Output operations.
Memory Locations,
Addresses, and
Operations
Memory is organized as a large array of bytes or
words
b 31 b 30 b1 b0
•
•
•
Sign bit: b 31= 0 for positive numbers
b 31= 1 for negative numbers
0 0 1 2 3 0 3 2 1 0
4 4 5 6 7 4 7 6 5 4
• •
• •
• •
k k k k k k k k k k
2 -4 2 -4 2 -3 2- 2 2 - 1 2 - 4 2- 1 2 - 2 2 -3 2 -4
To initiate write:
The processor sends the address of desired location to
the memory along with the data to be written into the
location.
Memory uses the address and data perform a write
Store (or Write)
Overwrite the content in memory
RISC and CISC Instruction Sets
RISC Characteristics:
Relatively few instructions
Relatively few addressing modes.
More accesses are limited to load and store
instructions.
All operations are done with the registers of the CPU.
It is designed to reduce the execution time by
simplifying the instruction set computer.
Each instruction requires only one clock cycle.
Two key characteristics of RISC instruction sets
are:
• Each instruction fits in a single word.
• A load/store architecture is used, in which
– Memory operands are accessed only using Load and
Store instructions.
– All operands involved in an arithmetic or logic operation
must either be in processor registers, or one of the
operands may be given explicitly within the instruction
word.
Introduction to RISC Instruction SETs
C=A+B:
Load R2,A
Load R3,B
Add R4,R2,R3
Store R4,C
Load destination, source
MAR MDR
Control
PC R0
R1
Processor
IR
ALU
Rn - 1
n general purpose
registers
Branch_if_[R2]>0 LOOP
Branching
One way of implementing conditional branch instructions
is to compare the contents of two registers and then
branch to the target instruction if the comparison meets
the specified.
Def: The term addressing modes refers to the way in which the
operand of an instruction is specified.
Basic Addressing Modes
Immediate Mode: Actual data is specified as part
of the instruction. i.e. instruction as an operand field
rather than as address field. The operand field
contains the actual operand.
Register Mode:
Register name is specified as part of the instruction,
i.e. register contains actual data i.e operands i.e
operands are in registers.
ADD R4,R2,R3
Absolute mode (or) Direct Addressing mode:
Need of subroutines.
Some space is allocated for subroutines
When a subroutine is called, PC is jumped to the
starting address of the subroutine.
Before it jumps the present PC value is stored in a link
register.
After execution of subroutine, when a return statement
appears the link register’s value is placed in PC.
Subroutine Call and Return
The way in which a computer makes it possible to call
and return from subroutines is referred to as its subroutine
linkage method.
Alternate method:
The processor stack provides a convenient and flexible
mechanism for passing an arbitrary number of parameters.
before: 0 0 1 1 1 0 . . . 0 1 1
after: 1 1 1 0 . . . 0 1 1 0 0
0 R0 C
before: 0 1 1 1 0 . . . 0 1 1 0
after: 0 0 0 1 1 1 0 . . . 0 1
R0 C
before: 1 0 0 1 1 . . . 0 1 0 0
after: 1 1 1 0 0 1 1 . . . 0 1
. . .
Rotate
before: 0 0 1 1 1 0 0 1 1
after: 1 1 1 0 . . . 0 1 1 0 1
C R0
before: 0 0 1 1 1 0 . . . 0 1 1
after: 1 1 1 0 . . . 0 1 1 0 0
R0 C
before: 0 1 1 1 0 . . . 0 1 1 0
after: 1 1 0 1 1 1 0 . . . 0 1
R0 C
before: 0 1 1 1 0 . . . 0 1 1 0
after: 1 0 0 1 1 1 0 . . . 0 1