Upload
preetamn
View
214
Download
0
Embed Size (px)
Citation preview
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
1/24
Schaums Outline of Theory and Problems of Computer ArchitectureCopyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
1
Chapter 04: Instruction Sets and the
Processor organizations
Lesson 09:
Processor Instructions - Part 2
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
2/24
Schaums Outline of Theory and Problems of Computer ArchitectureCopyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
2
Objective
Learn Instructions
Subroutine Call and Return Logic Instructions
Add, subtract, Test and Comparison
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
3/24
Schaums Outline of Theory and Problems of Computer ArchitectureCopyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
3
Subroutine call and return
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
4/24
Schaums Outline of Theory and Problems of Computer ArchitectureCopyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
4
Subroutine
A subroutine is also called routine
Called function in c or C++
Called method in Java
A set of instructions or sub-program
For a specific purpose At last instruction in subroutine, there is RET
instruction for return to the calling program
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
5/24
Schaums Outline of Theory and Problems of Computer ArchitectureCopyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
5
Examples of Subroutine call
1. Delay according to some parameter andthe parameter passed as input to the routine
2. Cube of a parameter and the parameterpassed as input to the routine
3. Sum of N- numbers in a table with thevalues of N and table start address passed asinputs to the routine
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
6/24
Schaums Outline of Theory and Problems of Computer ArchitectureCopyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
6
CALL
Subroutine call CALL Save the next
instruction PC (IP) on to stack-top or on to a
register called link register (LR) and set thePC equal to the value of its input operand
for the called routine address
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
7/24
Schaums Outline of Theory and Problems of Computer ArchitectureCopyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
7
RET
Return from the subroutine RET Retrieve
the next instruction PC (IP) from stack-
top or from the LR (link register) and set
the PC equal to the next instruction
address of the routine calling program
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
8/24
Schaums Outline of Theory and Problems of Computer ArchitectureCopyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
8
Example
StepK: (instruction k);
(instruction k + 1);
(instruction k + 2); CALL SBR_X;
StepL:
.....
SBR_X: (instruction l).... .
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
9/24
Schaums Outline of Theory and Problems of Computer ArchitectureCopyright The McGraw-Hill Companies Inc. Indian Special Edition 2009 9
Operation
PC for StepL saves at stack-top or at LR
PC gets the address of SBR_X after the
CALL instruction
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
10/24
Schaums Outline of Theory and Problems of Computer ArchitectureCopyright The McGraw-Hill Companies Inc. Indian Special Edition 2009 10
Subroutine SBR_X
SBR_X: (instruction l)
.
.
RET
PC for gets the address of StepL from thestack-top or from the LR after the RET
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
11/24
Schaums Outline of Theory and Problems of Computer ArchitectureCopyright The McGraw-Hill Companies Inc. Indian Special Edition 2009 11
Addition and Subtraction
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
12/24
Schaums Outline of Theory and Problems of Computer ArchitectureCopyright The McGraw-Hill Companies Inc. Indian Special Edition 2009 12
Addition and Subtraction Instructions
Simple arithmetic operations are addition andsubtraction, which are provided in all
processors
They generally take one or two inputs, andgenerate one output
In general, arithmetic operations read theirinput operands from and write their outputs tothe register file
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
13/24
Schaums Outline of Theory and Problems of Computer ArchitectureCopyright The McGraw-Hill Companies Inc. Indian Special Edition 2009 13
Add, FADD and ADC
AdditionAdd Add its second integer
operand to its first
Floating Point Add
FAdd Add its
second floating point operand to its first
Addition with carry
ADC Addprevious carry and its second integer
operand to its first
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
14/24
Schaums Outline of Theory and Problems of Computer ArchitectureCopyright The McGraw-Hill Companies Inc. Indian Special Edition 2009 14
SUB, FSUB
SubtractionSUB Subtract its second
integer operand from its first
Floating Point subtraction
FSUBSubtract its second floating point operand
from its first
Subtract with borrow
SUBB Subtract
previous borrow (in carry flag) and its
second integer operand from its first
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
15/24
Schaums Outline of Theory and Problems of Computer ArchitectureCopyright The McGraw-Hill Companies Inc. Indian Special Edition 2009 15
INC, DEC
IncrementINC Increment the operand
input by 1
Decrement
DEC Decrement the operandinput by 1
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
16/24
Schaums Outline of Theory and Problems of Computer ArchitectureCopyright The McGraw-Hill Companies Inc. Indian Special Edition 2009 16
Logic, test and comparison Instructions
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
17/24
Schaums Outline of Theory and Problems of Computer ArchitectureCopyright The McGraw-Hill Companies Inc. Indian Special Edition 2009 17
Complement, OR, AND and XOR
Logical NOTCPL Complement itsoperand
Logical OR
OR OR its second operandto its first
Logical ANDAND AND its second
operand to its first Logical XORXOR XOR its second
operand to its first
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
18/24
Schaums Outline of Theory and Problems of Computer Architecture
Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009 18
Test and Compare for Equality
TestTest Test its two operands whether
they are equal by a hypothetical logical AND
Equality
EQ Test its two integer operands
whether they are equal by a hypothetical
subtraction
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
19/24
Schaums Outline of Theory and Problems of Computer Architecture
Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009 19
Compare GT and NEQ
GreaterGT Test its two integer operands
or whether first is greater by a hypothetical
subtraction Not EqualityNEQ Test its two integer
operands whether they are not equal by a
hypothetical subtraction
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
20/24
Schaums Outline of Theory and Problems of Computer Architecture
Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009 20
Compare LT and GEQ
LesserLT Test its two integer operands
or whether first is lesser by a hypothetical
subtraction Greater or EqualityGEQ Test its two
integer operands whether first is greater by
a hypothetical subtraction or whether they
are equal by a hypothetical subtraction
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
21/24
Schaums Outline of Theory and Problems of Computer Architecture
Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009 21
Compare LEQ
Lesser or EqualityLEQ Test its two
integer operands whether first is lesser by a
hypothetical subtraction or whether they areequal by a hypothetical subtraction
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
22/24
Schaums Outline of Theory and Problems of Computer Architecture
Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009 22
Summary
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
23/24
Schaums Outline of Theory and Problems of Computer Architecture
Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009 23
Instructions for Subroutine Call and RET
Logical AND, OR, XOR, NOT Add
Subtract
Test Comparison Instructions
We learntWe learnt
7/28/2019 CompArchCh04L09ProcessorInstructionsPart2
24/24
Schaums Outline of Theory and Problems of Computer Architecture
Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009 24
End of Lesson 09 on
Processor Instructions - Part 2