+
Lec08 - Instruction Sets:
Characteristics and
Functions
+
Contents
Machine instruction characteristics
Types of operands
Intel x86 data types
Types of operations
Intel x86 operation type
+
Machine Instruction
Characteristics
The operation of the processor is determined by
the instructions it executes, referred to as machine
instructions or computer instructions
Thecollection of different instructions that the
processor can execute is referred to as the
processor’s instruction set
Eachinstruction must contain the information
required by the processor for execution
Elements of a Machine Instruction
Operation code Source operand
(opcode) reference
• Specifies the operation • The operation may
to be performed. The involve one or more
operation is specified source operands, that is,
by a binary code, known operands that are inputs
as the operation code, for the operation
or opcode
Result operand Next instruction
reference reference
• The operation may • This tells the processor
produce a result where to fetch the next
instruction after the
execution of this
instruction is complete
Instruction Cycle State Diagram
Source and result operands can be
in one of four areas:
3) Processor register
A processor contains one or
1) Main or virtual more registers that may be
memory referenced by machine
As with next instruction instructions.
references, the main or virtual
If more than one register
memory address must be
exists each register is
supplied
assigned a unique name or
number and the instruction
2) I/O device must contain the number of
The instruction must specify the desired register
the I/O module and device for 4) Immediate
the operation. If memory-
mapped I/O is used, this is The value of the operand is
just another main or virtual contained in a field in the
memory address instruction being executed
+
Instruction Representation
Within the computer each instruction is represented by a
sequence of bits
The instruction is divided into fields, corresponding to the
constituent elements of the instruction
Instruction Types
• Arithmetic instructions
provide computational • Movement of data into
capabilities for or out of register and or
processing numeric data memory locations
• Logic (Boolean)
instructions operate on
the bits of a word as bits
rather than as numbers,
thus they provide
capabilities for Data Data
processing any other processing storage
type of data the user
may wish to employ
Data
Control
movement
• Test instructions are used to • I/O instructions are
test the value of a data word needed to transfer
or the status of a programs and data into
computation memory and the results
• Branch instructions are of computations back
used to branch to a out to the user
different set of instructions
depending on the decision
made
+
Number of Addresses
+
Number of Addresses
Three addresses (OP A, B, C)
Not common - because require a relatively long instruction format to hold
the three address references.
Each instruction specifies two source operand locations and a destination
operand location.
Two addresses (OP A, B)
Reduces the space requirement but also introduces some awkwardness.
One address must do double duty as both an operand and a result.
One address (OP A)
A second address must be implicit (normally accumulator (AC)).
Zero address (OP)
Applicable to a special memory organization called a stack.
A stack is a last-in-first-out set of locations.
Instructions would reference the top stack elements.
+
Table 12.1
Utilization of Instruction Addresses
(Nonbranching Instructions)
Instruction Set Design
Very complex because it affects so many aspects of
the computer system
Defines many of the functions performed by the
processor
Programmer’s means of controlling the processor
Fundamental design issues:
Instruction Set Design
Fundamental design issues:
Operation Data types Instruction Registers Addressing
repertoire • The various format • Number of • The mode or
• How many types of data • Instruction processor modes by
and which upon which length in registers that which the
operations to operations bits, number can be address of an
provide and are of addresses, referenced operand is
how complex performed size of by specified
operations various instructions
should be fields, etc. and their use
Types of Operands
+
Numbers
All machine languages include numeric data types
Numbers stored in a computer are limited:
Limit to the magnitude of numbers representable on a machine
In the case of floating-point numbers, a limit to their precision
Three types of numerical data are common in computers:
Binary integer or binary fixed point
Binary floating point
Decimal
Packed decimal
Each decimal digit is represented by a 4-bit code with two digits
stored per byte (0 = 0000, 1 = 0001, …, 9 = 1001)
To form numbers 4-bit codes are strung together, usually in
multiples of 8 bits (246 = 0000 0010 0100 0110)
+
Characters
A common form of data is text or character strings
Textual data in character form cannot be easily stored or
transmitted by data processing and communications systems
because they are designed for binary data
Most commonly used character code is the International
Reference Alphabet (IRA)
Referred to in the United States as the American Standard Code
for Information Interchange (ASCII)
Another code used to encode characters is the Extended
Binary Coded Decimal Interchange Code (EBCDIC)
EBCDIC is used on IBM mainframes
+ ASCII Table
+
Logical Data
Ann-bit unit consisting of n 1-bit items of data,
each item having the value 0 or 1
Two advantages to bit-oriented view:
Memory can be used most efficiently for storing an array of
Boolean or binary data items in which each item can take
on only the values 1 (true) and 0 (false)
To manipulate the bits of a data item
If floating-point operations are implemented in software,
we need to be able to shift significant bits in some
operations
To convert from IRA (International Reference Alphabet)
to packed decimal, we need to extract the rightmost 4
bits of each byte
Table
12.2
+
x86 Data
x86 Data Types Types
+
x86 Numeric Data
Formats
+
Types of Operations
Typical categorization:
Data transfer
Arithmetic
Logical
Conversion
I/O
System control
Transfer of control
Data Transfer
Must specify:
• Location of the source and
destination operands
Most fundamental type of • The length of data to be
machine instruction transferred must be indicated
• The mode of addressing for each
operand must be specified
Table 12.5
Examples of IBM EAS/390 Data Transfer Operations
Most machines provide the basic arithmetic
+
operations of add, subtract, multiply, and
divide
These are provided for signed integer
(fixed-point) numbers
Often they are also provided for floating-
point and packed decimal numbers
Other possible operations include a variety
of single-operand instructions:
Absolute Arithmetic
Take the absolute value of the operand
Negate
Negate the operand
Increment
Add 1 to the operand
Decrement
Subtract 1 from the operand
Logical
Table 12.6 Basic Logical Operations
+
Shift and Rotate
Operations
+
Table 12.7
Examples of Shift and Rotate
Operations
Instructions that
change the
format or
operate on the
format of data
Conversion
An example of a
An example more complex
is converting editing
from instruction is
decimal to the EAS/390
binary Translate (TR)
instruction
+
Input/Output
Variety of approaches taken:
Isolated programmed I/O
Memory-mapped programmed I/O
DMA
Use of an I/O processor
Many implementations provide only a few I/O
instructions, with the specific actions specified by
parameters, codes, or command words
System Control
Instructions that 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
Typically these instructions are reserved for the use of the
operating system
Examples of system control operations:
A system control instruction An instruction to read or Access to process control
may read or alter a control modify a storage protection blocks in a
register key multiprogramming system
+
Transfer of Control
Reasonswhy transfer-of-control operations are
required:
It is essential to be able to execute each instruction more
than once
Virtually all programs involve some decision making
It helps if there are mechanisms for breaking the task up
into smaller pieces that can be worked on one at a time
Most common transfer-of-control operations found
in instruction sets:
Branch
Skip
Procedure call
+
Branch
Instruction
Skip Instructions
Typically implies that one
instruction be skipped,
Includes an implied thus the implied address
address equals the address of the
next instruction plus one
instruction length
Because the skip
instruction does not Example is the
require a destination increment-and-skip-if-
address field it is free to zero (ISZ) instruction
do other things
+
Procedure Call Instructions
Self-contained computer program that is incorporated into a
larger program
At any point in the program the procedure may be invoked, or
called
Processor is instructed to go and execute the entire procedure
and then return to the point from which the call took place
Two principal reasons for use of procedures:
Economy
A procedure allows the same piece of code to be used many
times
Modularity
Involves two basic instructions:
A call instruction that branches from the present location to the
procedure
Return instruction that returns from the procedure to the place
from which it was called
+
Nested
Procedures
Use of Stack to Implement Nested
Procedures
+
Table 12.3
Common
Instruction Set
Operations
(page 1 of 2)
+
Table 12.3
Common
Instruction
Set
Operations
(page 2 of 2)
Table 12.4
Processor Actions for Various Types of Operations
Table 12.8
x86
Operation
Types (With
Examples of
+ Typical
Operations)
(page 1 of 2)
Table 12.8
x86
Operation
Types (With
Examples of
Typical
Operations)
(page 2 of 2)
+
Call/Return Instructions
The x86 provides four instructions to support procedure call/return:
CALL
ENTER
LEAVE
RETURN
Common means of implementing the procedure is via the use of stack
frames
The CALL instruction pushes the current instruction pointer value onto
the stack and causes a jump to the entry point of the procedure by
placing the address of the entry point in the instruction pointer
The ENTER instruction was added to the instruction set to provide direct
support for the compiler
x86 Status Flags
+ Summary Instruction Sets:
Characteristics and
Functions
Lec08
Intel x86 data types
Machine instruction
Types of operations
characteristics
Data transfer
Elements of a machine
instruction Arithmetic
Instruction representation Logical
Instruction types Conversion
Number of addresses Input/output
Instruction set design System control
Types of operands Transfer of control
Numbers
Intel x86 operation types
Characters
Logical data