Professional Documents
Culture Documents
Contents
Introduction
General Register Organization Stack Organization
Instruction Formats
Addressing Mode Data Transfer and Manipulation
Program Control
Reduced Instruction Set Computer (RISC)
2
Introduction
Register set
R1
Input
R2
R3 R4 R5 R6 R7 Load (7 lines) SELA
MUX
MUX
SELB
A bus
Arithmetic logic unit (ALU)
B bus
3X8 decoder
SELD
OPR
Output
Microoperation
Control word
R2 R4 R6 R1 R2 Input R4 R5
R3 R5 R5
R1 R4 R6 R7 None None R4 R5
Stack Organization
10
11
12
13
Conversion RPN
Infix expression
(A+B)*[C*(D+E)+F] First perform the arithmetic inside the parenthesis. Next calculate the expression between the square brackets. The Multiplication must be done before in this C*(D+E)+F ,since multiplication has higher precedence over addition
RPN= AB+ DE+C*F+*
14
Instruction Formats
15
Instruction Format
16
17
18
Addressing Mode
19
ADDRESSING MODES
20
Implied Addressing mode: In this mode the operands are specified implicitly in the definition of
the instruction.
E.g. CMA ,CME because the operand in the accumulator register is
Opcode
Mode
Address
21
Immediate Addressing
Operand is part of instruction Operand = address field e.g. ADD 5
Add 5 to contents of accumulator 5 is operand
Direct Addressing
Address field contains address of operand Effective address (EA) = address field (A) e.g. ADD A
Add contents of cell A to accumulator Look in memory at address A for operand
Single memory reference to access data No additional calculations to work out effective address
Operand
Indirect Addressing
Memory cell pointed to by address field contains the address of
(pointer to) the operand . EA = (A) Look in A, find address (A) and look there for operand e.g. ADD (A) Add contents of cell pointed to by contents of A to accumulator Multiple memory accesses to find operand Hence slower
Memory
Pointer to operand
Operand
Register Addressing
Operand is held in register named in address filed
EA = R
Limited number of registers Very small address field needed
Shorter instructions
Operand
uses fewer bit to select the register then would have been required to specify the memory address directly.
Registers
Pointer to Operand
Operand
This mode is similar to register indirect mode except the register is incremented or decremented after (or before)its vale is accessed from the memory.
31
part of the instruction in order to obtain the effective Address. E.g. Assume the PC=825 Address part of the Instruction contain 24 Then the instruction location 825 is read from memory during fetch phase and PC is incremented by 1. PC=825+1=826 Effective address=826+24=850 This mode is largely used in branch type instructions. It result in shorter address field in the instruction format since the relative address can be specified with the smaller no. of bits as compare to entire memory address.
32
address part of the instruction to obtain the effective Address. Index register is a CPU register contain the index value. The address field of the instruction defines the beginning address of the data array in the memory. Each operand in the array is stored in the memory relative to the beginning address.
33
Base Register Address Mode: The content of a base register is added to the address part of the instruction to obtain the effective address. This is similar to index register mode except the register is base register.
34
35
PROGRAM CONTROL
Instruction are stored in successive memory locations. When processed in
the CPU, the instructions are fetched from the memory place .
Program control types of instructions , when executed, may change the
address value of the program counter and causes the flow of instruction altered.
This change in program counter value result in execution of a program
36
Program Control
37
stored for further analysis. Status bits are also called condition code bit or flag bit. Common flags in PSW C, Carry is set to 1 if carry out of ALU is 1 S, Sign set to 1 if MSB bit is 1 Z ,zero is set to 1,if all the bits of output are 0s. V, Overflow set to 1,XOR of last two bits is equals to 1.
38
B
8
C7
C8
8-bit ALU
C F7
F7~F0
Output F
39
40
41
Introduction
The trend into computer hardware complexity was
into machine language programs Striving to develop machines that move functions from software implementation into hardware implementation
classified as a complex instruction set computer (CISC). A computer use fewer instructions with simple constructs so they can be executed much faster within the CPU without having to use memory as often. It is classified as a reduced instruction set computer (RISC).
42
Introduction(cont.)
One reason for the trend to provide a complex instruction
set is the desire to simplify the compilation and improve the overall computer performance. The essential goal of a CISC architecture is to attempt to provide a single machine insruction for each statement that is written in a high-level language. Example of CISC architecture are the DEC VAX computer and the IBM 37 0computer.
43
CISC characteristics
The major characteristics of CISC architecture are:
A large number of instructions typically from 100 to 250 instructions Some instructions that perform specialized tasks and are used
infrequently A large variety of addressing modestypically from 5 to 20 different modes Variable-length instruction formats Instructions that manipulate operands in memory
44
RISC characteristics
The major characteristics of a RISC processor are:
Relatively few instructions Relatively few addressing modes Memory access limited to load and store instructions
45
RISC characteristics(cont.)
Other characteristics attributed to RISC architecture are:
A relatively large number of registers in the processor unit
Use of overlapped register windows to speed-up procedure call and return Efficient instruction pipeline Compiler support for efficient translation of high-level language programs
architecture do not differentiate between the effects of the reduced instruction set and the effects of a large register file.
A large number of registers in the processing unit are sometimes associated
46
is allocated its own bank of registers. This eliminates the need for saving and restoring register values. Some computers use the memory stack to store the parameters that are needed by the procedure, but this required a memory access every time the stack is accessed. A characteristics of some RISC processors is their use of overlapped register windows to provide the passing of parameters and avoid the need for saving and restoring register values. The concept of overlapped register windows is illustrated in Fig. 8-9.
47
calculated as followed:
window size = L + 2C + G
Common to D and A
Local to D
R63 R58 R57 R48
Proc D
Common to B and C
R41 R32
Proc C
R9 R0
Local to B
R31 R26
Common to A and B
R25 R16 R15
Proc B
Global registers
Proc A
R10
Berkeley RISC I
The Berkeley RISC I is a 32-bit integrated circuit CPU.
It supports 32-bit address and either 8-, 16-, or 32-bit data. It has a 32-bit instruction format and a total of 31 instructions. There are three basic addressing modes:
Register addressing, immediate operand, and relative to PC addressing for branch instructions. 10 global register and 8 windows of 32registers in each
50
register-to-register instructions and memory access instructions. Seven of the bits in the operation code specify an operation, and the eighth bit indicates whether to update the status bits after an ALU operation. For register-to-register instructions :
The 5-bit Rd field select one of the 32 rgisters as a destination for the
result of the operation The operation is performed with the data specified in fields Rs and S2. Thus the instruction has a three-address format, but the second source may be either a register or an immediate operand.
51
quantity
to form a 19-bit relative address Y and is used primarily with the jump and call instructions.
The COND field replaces the Rd field for jump instructions and is used to
52
31
Opcode 8
24 23
19 18
COND 5 (c) PC relative mode: Y 19
53
Perform arithmetic, logic, and shift operations. An immediate operand is symbolized by the number sign #. ADD ADD ADD ADD ADD R22, R21, R23 R22, #150, R23 R0, R21, R22 R0, #150, R22 R22, #1, R22 R23 R22 + R21 R23 R22 + 150 R22 R21 (Move) R22 150 (Load immediate) R22 R22 + 1 (Increment)
54
Consist of six load instructions, three store instructions, and two instructions that transfer the program status word PSW. PSW contains the status of the CPU and includes the program counter, the status bits from the ALU, pointers used in conjunction with the register windows, and other info. That determine the state of the CPU.
LDL (R22)#150, R5 LDL (R22)#0, R5 LDL (R0)#500, R5 R5 M[R22] + 150 R5 M[R22] R5 M[500]
Operate with the program counter PC to control the program sequence One uses an index plus displacement addressing The second uses a relative to PC mode with the 19-bit Y value as the relative address
55
56
57
Operands
COND,S2(Rs) COND,Y Rd,S2(Rs) Rd,Y Rd,S2 Rd Rd,S2 Rd
Register transfer
PC Rs + S2 PC PC + Y Rd PC PC Rs + S2 CWP CWP 1 Rd PC PC PC + Y CWP CWP 1 PC Rd + S2 CWP CWP + 1 Rd PC CWP CWP 1 PC Rd + S2 CWP CWP + 1 Rd PC
Description
Conditional jump Jump relative Call subroutine and change window Call relative and change window Return and change window Disable interrupts Enable interrupt Get last PC
58
Homework # 4
Q8-36, Q8-37, Q8-39
59
60
61
62
Increment Decrement Add Subtract Multiply Divide Add with carry ADDC Subtract with borrow Negate (2s complement)
63
64
65