0% found this document useful (0 votes)
36 views

Lecture 6

The document discusses machine instruction characteristics and functions. It describes how instructions contain information like operation codes, source and result operand references, and next instruction references. Instructions operate on different data types like numbers, characters, and logical data. The instruction set defines the operations and functions of the processor by specifying instruction formats and addressing modes.

Uploaded by

Hafza Raza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Lecture 6

The document discusses machine instruction characteristics and functions. It describes how instructions contain information like operation codes, source and result operand references, and next instruction references. Instructions operate on different data types like numbers, characters, and logical data. The instruction set defines the operations and functions of the processor by specifying instruction formats and addressing modes.

Uploaded by

Hafza Raza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 37

1

Instruction Sets:
Characteristics and
Functions
+
+ 2

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
+ 3

Example

Instruction Format

Partial List of Opcodes


+ 4

Example of
Program
Execution
Elements of a Machine Instruction
5

Operation code Source operand


(opcode) reference
• Specifies the operation to • The operation may
be performed. The involve one or more
operation is specified by source operands, that is,
a binary code, known as operands that are inputs
the operation code, or for the operation
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
6
Source and result operands can be in
7

one of four areas:


3) Processor register
 A processor contains one or
1) Main or virtual memory
more registers that may be
 As with next instruction references, referenced by machine
the main or virtual memory address
instructions.
must be supplied
 If more than one register exists
each register is assigned a
unique name or number and the
instruction must contain the
2) I/O device
number of the desired register
 The instruction must specify the
I/O module and device for the
operation. 4) Immediate
 The value of the operand is
contained in a field in the
instruction being executed
+ 8

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
+ 9

Instruction Representation
 Opcodes are represented by abbreviations
called mnemonics

 Examples include:
 ADD Add
 SUB Subtract
 MUL Multiply
 DIV Divide
 LOAD Load data from memory
 STOR Store data to memory

 Operands are also represented symbolically

 Each symbolic opcode has a fixed binary representation


 The programmer specifies the location of each symbolic operand
+ 10

Instruction - Example
• Consider a high-level language instruction:

X = X + Y;

Assume the variables X and Y correspond to locations 513 and 514

1. Load a register with the contents of memory location 513

2. Add the contents of memory location 514 to the register

3. Store the contents of the register in memory location 513

• Any program written in a high-level language must be translated into machine


language to be executed.

• The set of machine instructions must be sufficient to express any of the instruction
from a high-level language
Instruction Types 11

• Arithmetic instructions provide computational • Movement of data into


capabilities for processing numeric data or out of register and or
• Logic (Boolean) instructions operate on the bits of a memory locations
word as bits rather than as numbers, thus they provide
capabilities for processing any other type of data the
user may wish to employ

Data
Data storage
processing

Data
Control
movement

• Test instructions are used to test the value of a data • I/O instructions are
word or the status of a computation needed to transfer
• Branch instructions are used to branch to a different programs and data into
set of instructions depending on the decision made memory and the results
of computations back out
to the user
12
13

Table 12.1  
Utilization of Instruction Addresses
(Non-branching Instructions)
Instruction Set Design 14

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:

Operation Range Data Types Instruction Format Registers Addressing


• How many and which • The various types of data • Instruction length in bits, • Number of processor • The mode or modes by which
operations to provide and upon which operations are number of addresses, size of registers that can be the address of an operand is
how complex operations performed various fields, etc. referenced by instructions specified
should be and their use
15

Types of Operands

e sses
Ad d r
Num
be rs

Chara
cters
a l Da t a
Lo gi c
+ Numbers 16

 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
 To form numbers 4-bit codes are strung together, usually in multiples of 8
bits
+ 17

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
+ 18

Logical Data

 An n-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
 E.g. we need to be able to shift significant bits in some operations
19

Table 12.2 

x86
Data Types
20

Table 12.3  
Common
Instruction Set
Operations
(page 1 of 2)

(Table can be found on page


426 in textbook.)
21

Table 12.3  
Common
Instruction Set
Operations
(page 2 of 2)

(Table can be found on page


426 in textbook.)
Table 12.4   22

Processor Actions for Various Types of Operations

(Table can be found on page 427 in textbook.)


Data Transfer
23

Must specify:
• Location of the source and destination
operands
Most fundamental type of • The length of data to be transferred
machine instruction must be indicated
• The mode of addressing for each
operand must be specified
+
24

 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
25

Table 12.6  
Basic Logical Operations
26
27

Table 12.7

Examples of Shift and Rotate Operations


28

Instructions that
change the format
or operate on the Conversion
format of data

An example of a
more complex
editing instruction
is the EAS/390
An example is Translate (TR)
converting instruction
from decimal
to binary
+ 29

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
30
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 Access to process control


An instruction to read or modify
may read or alter a control blocks in a multiprogramming
a storage protection key
register system
+ 31

Transfer of Control

 Reasons why 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
32
Skip Instructions 33

Typically implies that one


instruction be skipped, thus
the implied address equals
Includes an implied address
the address of the next
instruction plus one
instruction length

Because the skip instruction


Example is the increment-
does not require a destination
and-skip-if-zero (ISZ)
address field it is free to do
instruction
other things
+ 34

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
35
36
+ 37

References

“Computer Organization and Architecture – Designing for


Performance, 10th edition” by William Stallings

• Chapter 10: Instruction Sets: Characteristics and Functions

You might also like