Unit 4 Instruction Sets Instruction Characteristics Types of

  • Slides: 46
Download presentation
Unit 4 Instruction Sets Instruction Characteristics Types of Operands Data Types Operators

Unit 4 Instruction Sets Instruction Characteristics Types of Operands Data Types Operators

Machine Instruction Characteristics

Machine Instruction Characteristics

Machine Instruction Characteristics Machine Instructions- are instructions executed by the processor. Instruction set- a

Machine Instruction Characteristics Machine Instructions- are instructions executed by the processor. Instruction set- a collection of instructions that the processor can execute Opcode Operand Reference 2

Elements of a machine instruction Opcode- uses a binary code which specifies the operation

Elements of a machine instruction Opcode- uses a binary code which specifies the operation to be preformed. Source operand reference- the input for the operation Result operand reference- the result produced by the operation Next instruction reference- tells the processor where to get the next instruction

Source and result operands can be found in Main or virtual memory Processor register-

Source and result operands can be found in Main or virtual memory Processor register- contains registers that can be used by machine instructions Immediate- the operand value is being contained when the instruction is being executed I/O devices- instruction specifies I/O module and device but if memory mapped then just another main or virtual memory address

Instruction Representation Are represented by a sequence of bits It is common to use

Instruction Representation Are represented by a sequence of bits It is common to use “symbolic representation” of machine instructions Op codes and operands are represented by abbreviations called “mnemonics”

Mnemonics ADD add SUB subtract MUL multiply DIV divide LOAD load data from memory

Mnemonics ADD add SUB subtract MUL multiply DIV divide LOAD load data from memory STOR store data to memory

Instruction types Data processing- arithmetic and logic instructions Data storage- moving data into or

Instruction types Data processing- arithmetic and logic instructions Data storage- moving data into or out of register or memory locations Data movement- I/O instructions Control- test and branch instructions

Number of Addresses • A traditional way of describing processor architecture • What is

Number of Addresses • A traditional way of describing processor architecture • What is the maximum number of addresses one might need in an instruction? • An instruction could be required to contain four addresses

Number of Addresses • 3 addresses instructions • Operand 1, Operand 2, Result •

Number of Addresses • 3 addresses instructions • Operand 1, Operand 2, Result • a = b + c; • May be a forth - next instruction (usually implicit) • Not common • Needs very long words to hold everything

Number of Addresses • 2 addresses instructions • One address doubles as operand result

Number of Addresses • 2 addresses instructions • One address doubles as operand result • a = a + b; • Reduces length of instruction • Requires some extra work • Temporary storage to hold some results

Number of Addresses • 1 address instructions • Implicit second address • Usually a

Number of Addresses • 1 address instructions • Implicit second address • Usually a register (accumulator) • Common on early machines

Number of Addresses • 0 address instruction: • Special memory organization • Last in

Number of Addresses • 0 address instruction: • Special memory organization • Last in first out • Stack is a known location

Number of Addresses Utilization of Instruction Addresses (Nonbranching Instructions)

Number of Addresses Utilization of Instruction Addresses (Nonbranching Instructions)

Number of Addresses 1 address instructions • One general purpose register 2 Or 3

Number of Addresses 1 address instructions • One general purpose register 2 Or 3 address instructions Multiple general purpose registers

Instruction Set Design Operation Repertoire- How many and which operations to provide, and how

Instruction Set Design Operation Repertoire- How many and which operations to provide, and how complex the operations should be. Data Types- The various types of data upon which operations are performed. Instruction Format- Instruction length (in bits), number of addresses and size of fields.

Instruction Set Design Registers- Number of processor registers that can be referenced by instructions,

Instruction Set Design Registers- Number of processor registers that can be referenced by instructions, and their use Addressing- The mode or modes by which the address of an operand is specified.

10. 2 Types of operands

10. 2 Types of operands

TYPES OF OPERANDS Addresses Numbers Characters Logical Data Specialized Data Types Data Structures

TYPES OF OPERANDS Addresses Numbers Characters Logical Data Specialized Data Types Data Structures

Addresses Main or Virtual memory address Unsigned Integers

Addresses Main or Virtual memory address Unsigned Integers

Numbers All machine languages include numeric types Non-numeric processing: counters, field widths, etc Numbers

Numbers All machine languages include numeric types Non-numeric processing: counters, field widths, etc Numbers in a machine are limited by magnitude and precision Consequences: rounding, overflow, underflow

Numerical Data Binary integer or Binary fixed point Binary floating point Decimal

Numerical Data Binary integer or Binary fixed point Binary floating point Decimal

Decimal Majority of users deal with decimals Necessity to convert from decimal to binary

Decimal Majority of users deal with decimals Necessity to convert from decimal to binary on input and binary to decimal on output Packed decimal

Packed Decimal Used when there is a great deal of I/O and simple computation

Packed Decimal Used when there is a great deal of I/O and simple computation Each decimal digit is represented by a 4 -bit code. Ex: 0 = 0000, 1 = 0001 Numbers are formed by a string of 4 -bit codes usually in multiples of 8 -bit 246 = 0000 0010 0100 0110 Positive: 1100 Negative: 1101

Characters Text or character strings Represented by a sequence of bits Morse Code International

Characters Text or character strings Represented by a sequence of bits Morse Code International Reference Alphabet (IRA) American Standard Code for Information Interchange (ASCII) Extended Binary Coded Decimal Interchange Code (EBCDIC)

Logical Data Consider n-bit unit as consisting of n 1 -bit items of data,

Logical Data Consider n-bit unit as consisting of n 1 -bit items of data, each having a value of 0 or 1 Advantages: Store array of Boolean or Binary data items Manipulating bits of data items

10. 3 data types

10. 3 data types

Intel x 86 and ARM data types Ø are instruction set architecture. Ø change

Intel x 86 and ARM data types Ø are instruction set architecture. Ø change code into instructions a processor can understand execute. Ø determines which operating systems and apps to run.

x 86 data types Ø The x 86 can deal with data types of

x 86 data types Ø The x 86 can deal with data types of 8 (byte), 16 (word), 32 (doubleword), 64 (quadword), and 128 (double quadword) bits in length. Ø are referred to as general data types. Ø To allow maximum flexibility in data structures and efficient memory utilization, words do not need be aligned at even numbered addresses and doublewords do not need to aligned at addresses evenly divisible by 4. Ø x 86 also supports specific data types that are recognized and operated on by particular instructions.

10. 4 operators

10. 4 operators

Types of Operations Data Transfer Arithmetic Logical Conversion Input/output System Control Transfer of Control

Types of Operations Data Transfer Arithmetic Logical Conversion Input/output System Control Transfer of Control

Data Transfer Operation Name Description Move(Transfer) Transfer word from source to destination Store From

Data Transfer Operation Name Description Move(Transfer) Transfer word from source to destination Store From processor to memory Load (Fetch) From memory to processor Exchange Swap contents of source and destination Clear ( Reset) Transfer 0 s to destination Set Transfer 1 s to destination Push Word from source to top of stack Pop From top of stack to destination

Arithmetic Operation Name Description Compute sum of two operands Difference of two operands Product

Arithmetic Operation Name Description Compute sum of two operands Difference of two operands Product of two operands Divide Quotient of two operands Absolute Negate Replace by its absolute value Change sign Add 1 to operand Subtract 1 to operand Add Subtract Multiply Increment Decrement

Logical Operation Name Description AND; OR; NOT; OR Perform the specified logical operation bitwise

Logical Operation Name Description AND; OR; NOT; OR Perform the specified logical operation bitwise Test Compare Test specified condition; set flags based on outcome Make logical and arithmetic comparison of two operands Class of instructions to set controls for protection purposes, interrupt handling, timer control. Left/right operand introducing constants at end. Left/right with wraparound end Set Control Variables Shift Variables

Conversion Operation Name Translate Convert Description Translate values in a section of memory based

Conversion Operation Name Translate Convert Description Translate values in a section of memory based on a table of correspondences Convert the contents of a word from one form to another. E. g(packed decimal to binary

I/O Operation Name Input (Read) Output ( Write) Start I/O End I/O Description Transfer

I/O Operation Name Input (Read) Output ( Write) Start I/O End I/O Description Transfer data from specified I/O port or device to destination From specified source to I/O port or device Transfer instructions to I/O processor to initiate I/O operation Transfer status info from I/O system to specified destination

System Of Control Can be executed only while the processor is in a certain

System Of Control Can be executed only while the processor is in a certain privileged state or is executing a program in a special privileged area of memory. These instructions, are reserved for the use of the operating system. Examples: A system control instruction may read or alter a control register An instruction to read or modify a storage protection key Access to process control blocks in multiprogramming system

Transfer Of Control Description Operation Name Jump (Branch) Jump Conditional Jump to Subroutine Return

Transfer Of Control Description Operation Name Jump (Branch) Jump Conditional Jump to Subroutine Return Unconditional Transfer: load PC with specified address Test condition: either load PC with specified address or do nothing Place current program control info in known location; jump to specified address Replace contents of PC and other register from known location Fetch operand from location and execute as instructed Execute Skip conditional Increment PC to skip next instruction Halt Either skip or do nothing based on condition Wait (Hold) Stop program execution No Operation Test specified repeatedly and resume condition No operation is performed; but program execution is continued.

Addressing Modes: The different ways in which the location of an operand is specified

Addressing Modes: The different ways in which the location of an operand is specified in an instruction are referred to as addressing modes. Types of Addressing Modes Immediate Mode: In this mode the operand is specified in the instruction itself or we can say that, an immediate mode instruction has an operand rather than an address. Example –MOVE Ro, 3100

 Direct Address Mode: It this mode, the address of the memory location that

Direct Address Mode: It this mode, the address of the memory location that holds the operand is included in the instruction. The effective address is the address part of the instruction. Example – MOVE R 1, x

 Indirect Address Mode: In this mode the address field of the instruction gives

Indirect Address Mode: In this mode the address field of the instruction gives the address where the effective address is stored in memory. Example MOV Ro, (p)

 Register Mode: In this mode, the operands are in registers. Example Mov R

Register Mode: In this mode, the operands are in registers. Example Mov R 1, x

 Register Indirect –sometime the address of the memory location which contain data or

Register Indirect –sometime the address of the memory location which contain data or operand is determined in an indirect way using a pointer register. Example -MOV DL, [SI]

 Displacement Addressing -it is very powerful -it is combination of both direct and

Displacement Addressing -it is very powerful -it is combination of both direct and register indirect -If the register R is being used for indirection and the content of operand field is A then effective address EA is given by EA=A+(R). -Based on use and implementation this Addressing scheme known as Relative, Base, Indexing

 Stack Addressing – -A stack is LIFO structure -A stack is associated with

Stack Addressing – -A stack is LIFO structure -A stack is associated with a pointer which points to top of stack. -two operation associated ie PUSH and POP -Stack pointer is maintain in CPU register.