Chapter 04: Instruction Sets and the Processor organizations
Lesson 09: Processor Instructions - Part 2
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
Objective
Learn Instructions Subroutine Call and Return Logic Instructions Add, subtract, Test and Comparison
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
Subroutine call and return
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
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
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
Examples of Subroutine call
1. Delay according to some parameter and the parameter passed as input to the routine 2. Cube of a parameter and the parameter passed as input to the routine 3. Sum of N- numbers in a table with the values of N and table start address passed as inputs to the routine
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
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 the PC equal to the value of its input operand for the called routine address
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
RET Return from the subroutine RET Retrieve the next instruction PC (IP) from stacktop or from the LR (link register) and set the PC equal to the next instruction address of the routine calling program
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
Example
StepK: (instruction k); (instruction k + 1); (instruction k + 2); CALL SBR_X; StepL: ..... SBR_X: (instruction l)....
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
Operation
PC for StepL saves at stack-top or at LR PC gets the address of SBR_X after the CALL instruction
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
Subroutine SBR_X SBR_X: (instruction l) . . RET PC for gets the address of StepL from the stack-top or from the LR after the RET
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
10
Addition and Subtraction
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
11
Addition and Subtraction Instructions
Simple arithmetic operations are addition and subtraction, which are provided in all processors They generally take one or two inputs, and generate one output In general, arithmetic operations read their input operands from and write their outputs to the register file
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
12
Add, FADD and ADC
Addition Add 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 Add previous carry and its second integer operand to its first
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
13
SUB, FSUB
Subtraction SUB Subtract its second integer operand from its first Floating Point subtraction FSUB Subtract 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
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
14
INC, DEC Increment INC Increment the operand input by 1 Decrement DEC Decrement the operand input by 1
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
15
Logic, test and comparison Instructions
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
16
Complement, OR, AND and XOR
Logical NOT CPL Complement its operand Logical OR OR OR its second operand to its first Logical AND AND AND its second operand to its first Logical XOR XOR XOR its second operand to its first
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
17
Test and Compare for Equality
Test Test 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
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
18
Compare GT and NEQ
Greater GT Test its two integer operands or whether first is greater by a hypothetical subtraction Not Equality NEQ Test its two integer operands whether they are not equal by a hypothetical subtraction
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
19
Compare LT and GEQ
Lesser LT Test its two integer operands or whether first is lesser by a hypothetical subtraction Greater or Equality GEQ Test its two integer operands whether first is greater by a hypothetical subtraction or whether they are equal by a hypothetical subtraction
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
20
Compare LEQ
Lesser or Equality LEQ Test its two integer operands whether first is lesser by a hypothetical subtraction or whether they are equal by a hypothetical subtraction
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
21
Summary
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
22
We learnt
Instructions for Subroutine Call and RET Logical AND, OR, XOR, NOT Add Subtract Test Comparison Instructions
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
23
End of Lesson 09 on Processor Instructions - Part 2
Schaums Outline of Theory and Problems of Computer Architecture Copyright The McGraw-Hill Companies Inc. Indian Special Edition 2009
24