What is an Instruction Set?

advertisement
GROUP #4
CHAPTER 10
JOEL FRAGA
JAIME J.OCON
DEISY HERNANDEZ
What is an Instruction Set?




Also called a command set, the basic set
of commands, or instructions, that a
microprocessor understands
Machine Code
Binary
Usually represented by assembly codes
Elements of an Instruction




Operation code: Specifies the operation to be
performed (e.g.. ADD, I/O). The operation is
specified by a binary code, known as the
operation code, or opcode.
Source operand reference: The operation may
involve one or more source operands, that is,
operands that are inputs for the operation.
Result operand reference: The operation may
produce a result.
Next instruction reference: This tells the CPU
where to fetch the next instruction after the
execution of this instruction is complete.
Instruction Cycle State Diagram
Instruction Cycle State Diagram
steps.







Instruction address calculation (iac): Determine the address of the next
instruction to be executed. Usually, this involves adding a fixed number to
the address of the previous instruction. For example, if each instruction is
16 bits long and memory is organized into 16-bit words, then add 1 to the
previous address. If, instead, memory is organized as individually
addressable 8-bit bytes, then add 2 to the previous address.
Instruction fetch (if): Read instruction from its memory location into the
processor.
Instruction operation decoding (iod): Analyze instruction to determine type
of operation to he performed and operand(s) to be used.
Operand address calculation (oac): If the operation involves reference to an
operand in memory or available via I/O. then determine the address of the
operand.
Operand fetch (of): Fetch the operand from memory or read it in from I/O,
Data operation (do): Perform the operation indicated in the instruction.
Operand store (os): Write the result into memory or out to I/O
Instruction Types
Data processing: Arithmetic and logic
instructions
 Data storage: Memory instructions
 Data movement: I/O instructions
 Control: Test and branch instructions

Simple Instruction Format
Number of Addresses (a)

3 addresses


Operand 1, Operand 2, Result
a = b + c;
 Three-address instruction formats are not
common, because they require a relatively
long instruction format to hold the three
address references
Number of Addresses (b)

2 addresses


One address doubles as operand and result
a=a+b
The two-address formal reduces the space
requirement but also introduces some
awkwardness. To avoid altering the value of an
operand, a MOVE instruction is used to move
one of the values to a result or temporary
location before performing the operation.

Number of Addresses (c)


1 address
a second address must be implicit. This
was common in earlier machines, with the
implied address being a CPU register
known as the accumulator. or AC. The
accumulator contains one of the operands
and is used to store the result.
Number of Addresses (d)

0 (zero) addresses


Zero-address instructions are applicable to a
special memory organization, called a Stack. A
stack is a last-in-first-out set of locations.
c=a+b
How Many Addresses






Fewer addresses:
Fewer addresses per instruction result in more primitive instructions,
which requires a less complex CPU.
It also results in instructions of shorter length. On the other hand,
programs contain more total instructions, which in general results in
longer execution times and longer, more complex programs
Multiple-address instructions:
With multiple-address instructions, it is common to have multiple
general-purpose registers. This allows some operations to be
performed solely on registers.
Because register references are faster than memory references, this
speeds up execution.
Number of Address


One of the ways of describing the processor architecture is by the number of
addresses contained in each instruction.
The number of address can be from zero to four addresses, depending on the
number of operations required.
Number of Addresses
Symbolic
Representation
3
OP A, B, C
2
OP A, B
1
OP A
0
OP
Interpretation
A f
A
B OP C
f A OP B
AC f AC OP A
T
f (T-1) OP T
Instruction Sets Design




Instruction sets is the most interesting and analyzed aspect of a computer design.
The Instruction sets define the functions performed by the CPU and has significant
effect on the implementation of the CPU.
The design of Instruction Sets is complex because it affects many aspects of the
computer
The Instruction Sets are the programmer's means of controlling the CPU.
Instruction Sets Design

The most fundamental Instructions Sets design issues are:





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 FORMATS:

Instruction length, number of addresses, size of various fields.
REGISTERS:

Number of CPU registers that can be referenced by instructions, and their sizes.
ADDRESSING:

The mode or modes by which the address of an operant is specified.
Types of Operands

Operands are the part of a machine instruction that reference data or device.

In the general instruction: ADD B to A
A and B are the Operands
ADD is the Operation code
Types of Operands



The most important or general categories Operand data references are described as
follows:
ADDRESSES: They are a form of data that is used for calculations in a instruction to
determine the main or virtual memory address.
NUMBERS: Numeric data types act as counters and other functions that require
nonnumeric data processing.

Three types of numerical data common on computers:



Integers or fixed point
Floating points
decimal
Types of Operands


CHARACTERS: A unique 7 bit data representation of characters used by computers.
The most commonly used characters codes is the IRA (International
Reference Alphabet) or the ASCII Code (American Standard Code for
Information Interchange)
LOGICAL DATA: Is a n-bit unit of a word or other addressable selected for data
information. The selected unit consist of a 1-bit items of data. It
can be used for storing an array of a Boolean or binary information
in which each item can only take the values of 1 (true) and 0 (false).
Pentium Data Types



The Pentium Processors is capable of dealing with data types of 8 (byte), 16 (word),
32(doubleword), and 64 (quadword) bits in lenghts.
The byte, word, doubleword, and quadword are refered to as general data types.
The pentium processor also support an impressive array of specific data types that
are recognized and operated on by particular instructions.
Pentium Data Types

Pentium Data types:

General: Byte word(16 bits), doubleworld(32 bits), and quadword(64 bits) locations with arbitrary binary contents .

Intergers: A signed binary value contained in a byte, word, or doubleword, using two complement representation.

Ordinal: An unsigned integer contained in a byte, word, or doubleword.

Umpacked Binary Code: A representation of a BCD digit in the range 0 through 9, with one digit in each byte.

Packed Binary Code: Packed byte representation of two BCD digits, value range 0 to 99.

Near Pointer: A 32 bit effective address that represent the offset within a segment. Used for all pointers in a nonsegmented
memory and for references within segment in a segmented memory.

Bit Field: A continuous sequence of bits in which the position of each bit is considered as an independent unit.

Byte String: A continuous sequence of bytes, words, or doublewords, containing form zero to 32 bytes.

Floating Point: A set of data types that are used by the floating point unit and operated on by floating point instructions
Pentium Data Types
Pentium Numeric Data Format:
Power PC Data Types



The Power PC can support data types of 8 (byte), 16 (halfword), 32 (word) and 64
(doubleword) bits in length.
The byte, halfword, word, and doubleword are general data types.
The Power Pc can use either little endian or big endian style. That is, the last
significant byte is stored in the lowest or highest address.
Power PC Data Types

The Power PC Processor support the following data:

UNSIGNED BYTE: Can be used for logical or interger arithmetic operations. It is loaded from the

UNSIGNED HALFWORD: Used for 16 bit quantities of unsigned byte.

SIGNED HALFWORD: Used for arithmetic operations. It is loaded into the memory by sign extending

UNSIGNED WORD: Used for logical operations and as an address pointer.

SIGNED WORD: Used for arithmetic operations.

UNSIGNED DOUBLEWORD: Used as an address pointer.

BYTE STRING: Byte string extending from zero to 128 bytes in length.
memory into a general register by zero extending on the left to the full register size.
on the left to full register size.
Types of Operations

The number of opcodes varies widely from machine to machine.

The same general types of operations are found on all machines.

General Types of Operations:







Data Transfer
Arithmetic
Logical
Conversion
I/O
System Control
Transfer of Control
Types of Operations

DATA TRANSFER:

It is the most fundamental type of machine instruction.

The Data Transfer Instructions must specify the following:

Specify the location of the source and destination of the operands.

Indicate the length of data to be transferred.

Specify the mode of the of the addressing for each operand.
Types of Operations

ARITHMETIC:

Provides the basic operations for addition, multiplication, and division.

Other possible arithmetic operations include a variety of single operands instructions:

ABSOLUTELY: Takes the absolute value of the operand.

NEGATE: Negates the operand. (-a)

INCREMENT: Add 1 to the operand. (a++)

DECREMENT: Subtract 1 from the operand. (a--)
Types of Operations

LOGICAL:


Logical operations provides a means of manipulating individual bits of a word or other addressable units.
Often call “Bit Twiddling”.
The logical data manipulation is based upon Boolean operations or binary data as shown in the following
table:
P
Q
NOT P
P AND Q
P OR Q
P XOR Q
P=Q
0
0
1
0
0
0
1
0
1
1
0
1
1
0
1
0
0
0
1
1
0
1
1
0
1
1
0
1
Types of Operations

In addition to Logical operations, most machines provides a variety of shifting and
rotating functions, the most common ones are illustrated:





The logical right shift moves the bits of words
to the right. The last bit of data is lost.
The Logical left shift moves the bits of words
to the left. The last bit of data is lost.
The arithmetic right shift treats the data
assigned integers. The sign bit is replicated
into the bit position to its right.
The arithmetic left shift treats the data
assigned integers. The sign bit is replicated
into the bit position to its left.
The rotate or cyclic changes the format or
operate on the format of data. Converting
from decimal to binary.
Types of Operations

Example of Shifting and Rotating
Operations:
INPUT
OPERATION
RESULT
10100110
LOGICAL RIGHT SHIFT (3 Bits)
00010100
10100110
Logical left shift (3 Bits)
00110000
10100110
Arithmetic right shift (3 Bits)
11110100
10100110
Arithmetic left shift (3 Bits)
10110000
10100110
Right Rotate (3 Bits)
11010100
10100110
Left rotate (3 Bits)
00110101
Types of Operations

CONVERSIONS:

Conversion instructions are those that change the format or operate on the format of data.

An example is to convert from decimal to binary.
Instructions to transfer data
between an Input/Output and the
CPU or memory.
It can be done by:

Specific Instructions (I/O commands): A transfer in which only one byte or
word of information is moved by a given computer command (i.e. Control,
Test, Read, Write) A terminal is an example of a device that is normally
capable of only this type of transfer.

Using data movement instructions (memory mapped). A computer that uses
memory-mapped I/O, accesses hardware by reading and writing to specific
memory locations, using the same assembler language instructions that
computer would normally use to access memory.

By a separate controller (DMA module: Direct Memory access). It is capable
of mimicking the processor and takes over control of the system from the
processor. DMA module in effects steals a bus cycle. A disk is an example of
a device that uses DMA.
Systems Control Instructions:
control some basic element of the system or
processor state.
Most simple version of privilege states: Two states, “user” and “administrator” states.
Some processors have more than two privilege states, allowing different levels of
freedom to increasingly trusted operations.


Privileged Instructions: Typically are reserved for the use of the operating system
as a form of protection.
CPU needs to be in specific state
Ring 0: Is the level with the most privileges and interacts with the physical hardware
such as the CPU and memory.
Kernel mode (Supervisor or administrator mode): A program in supervisor mode is
trusted never to fail. A failure may cause the whole computer system to crash.
Example of privilege ring usage in a
typical operating system.
Transfer of Control Instructions


Branch Instruction: Also called a jump instruction. Has as one of its operands the
address of the next instruction to be executed.
e.g. go to x if result is zero. (conditional Branch)
If a branch is always taken is an unconditional branch.
Skip Instruction: implies that one instruction be skipped; thus, the implied address
equals the address of the next instruction plus one instruction length.
e.g. increment and skip if zero
ADD A
Branch xxxx
Subroutine call: these type of instructions typically modified the program code,
modifying the address of a branch at a standard location so that it behaved like an
explicit return instruction.
e.g. interrupt call
Branch Instruction
Nested Procedure Calls
Use of Stack:
is an ordered set of
elements, only one of which can be
accessed at a time. Items may only be
added or deleted from the top of the stack.
Byte Order

In computing, endianness is the byte (and sometimes bit) ordering used
to represent some kind of data. Typical cases are the order in which integer
values are stored as bytes in computer memory (relative to a given memory
addressing scheme) and the transmission order over a network or other
medium. When specifically talking about bytes, endianness is also referred
to simply as byte order.
Byte Order (example)
12345678 can be stored in 4x8bit locations
as follows ;






Address
184
185
186
186
Value (1)
Value(2)
12
78
34
56
56
34
78
12
Big endian
Little endian
i.e. read top down or bottom up?
Review Questions?
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
What is an Instruction Set?
Explain each steps of the instruction set cycle?
How many general data types does processor support?
How many general data type the power PC processor support?
What are the types of general operations found on majority of
computers?
How are instruction types categorize?
What is the maximum number of addresses one might need in an
instruction?
Which ways you can transfer data between I/O and the CPU?
What is the importance of the Kernel mode?
Explain the concept of Byte Order?
Download