chapter 10 instruction sets: characteristics and functions

48
Chapter 10 Instruction Sets: Characteristics and Functions

Upload: sibyl-jones

Post on 23-Dec-2015

231 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 10 Instruction Sets: Characteristics and Functions

Chapter 10

Instruction Sets:

Characteristics and Functions

Page 2: Chapter 10 Instruction Sets: Characteristics and Functions

What is an Instruction Set?

• The complete collection of instructions that are understood by a CPU

• Machine Code• Binary• Usually represented by assembly

codes

Page 3: Chapter 10 Instruction Sets: Characteristics and Functions

Elements of an Instruction

• Operation code (Op code)– Do this

• Source Operand reference– To this

• Result Operand reference– Put the answer here

• Next Instruction Reference– When you have done that, do this...

Page 4: Chapter 10 Instruction Sets: Characteristics and Functions

Where have all the Operands Gone?• Long time passing….• (If you don’t understand, you’re too

young!)• Main memory (or virtual memory or

cache)• CPU register• I/O device

Page 5: Chapter 10 Instruction Sets: Characteristics and Functions

Instruction Representation

• In machine code each instruction has a unique bit pattern

• For human consumption (well, programmers anyway) a symbolic representation is used– e.g. ADD, SUB, LOAD

• Operands can also be represented in this way– ADD A,B

Page 6: Chapter 10 Instruction Sets: Characteristics and Functions

Simple Instruction Format

Page 7: Chapter 10 Instruction Sets: Characteristics and Functions

Instruction Types

• Data processing– Arithmetic & Logic Instructions

• Data storage (main memory)– Memory Instructions

• Data movement (I/O)– I/O Instructions

• Program flow control – Test & Branch Instructions

Page 8: Chapter 10 Instruction Sets: Characteristics and Functions

Number of Addresses (a)

• 3 addresses– 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

Page 9: Chapter 10 Instruction Sets: Characteristics and Functions

Number of Addresses (b)

• 2 addresses– One address doubles as operand and

result– a = a + b– Reduces length of instruction– Requires some extra work

• Temporary storage to hold some results

Page 10: Chapter 10 Instruction Sets: Characteristics and Functions

Number of Addresses (c)

• 1 address– Implicit second address– Usually a register (accumulator)– Common on early machines

Page 11: Chapter 10 Instruction Sets: Characteristics and Functions

Number of Addresses (d)

• 0 (zero) addresses– All addresses implicit– Uses a stack– e.g. push a– push b– add– pop c

– c = a + b

Page 12: Chapter 10 Instruction Sets: Characteristics and Functions

How Many Addresses

• More addresses– More complex (powerful?) instructions– More registers

• Inter-register operations are quicker

– Fewer instructions per program• Fewer addresses

– Less complex (powerful?) instructions– More instructions per program– Faster fetch/execution of instructions

Page 13: Chapter 10 Instruction Sets: Characteristics and Functions

Design Decisions (1)

• Operation repertoire– How many ops?– What can they do?– How complex are they?

• Data types• Instruction formats

– Length of op code field– Number of addresses

Page 14: Chapter 10 Instruction Sets: Characteristics and Functions

Design Decisions (2)

• Registers– Number of CPU registers available– Which operations can be performed on

which registers?• Addressing modes (later…)

• RISC v CISC

Page 15: Chapter 10 Instruction Sets: Characteristics and Functions

Types of Operand

• Addresses• Numbers

– Integer/floating point• Characters

– ASCII etc.• Logical Data

– Bits or flags• (Aside: Is there any difference between numbers and

characters? Ask a C programmer!)

Page 16: Chapter 10 Instruction Sets: Characteristics and Functions

Addresses

• Addresses are a form of data.• Sometimes, calculations must be performed on the

operand reference in an instruction to determine the memory address.

• The various addressing modes that are defined in a given instruction set architecture define how machine language instructions in that architecture identify the operand (or operands) of each instruction.

• Addresses can be considered as unsigned integers.

Page 17: Chapter 10 Instruction Sets: Characteristics and Functions

Addressing Modes

• Different computer architectures vary greatly as to the number of addressing modes they provide.

• When there are only a few addressing modes, the particular addressing mode required is usually encoded within the instruction code.

• Examples of common addressing modes: Immediate Indexed Memory deferred Auto-increment Scaled Displacement

Page 18: Chapter 10 Instruction Sets: Characteristics and Functions

68HC11 Addressing Modes

68C11 Addressing Modes: Immediate Indexed InherentRelativeDirectExtended

Page 19: Chapter 10 Instruction Sets: Characteristics and Functions

6502 Addressing Modes

The 6502 processor provides several ways in which memory locations can be addressed. Some instructions support several different modes while others may only support one. In addition the two index registers can not always be used interchangeably. This makes the 6502 trickier to program well.

Page 20: Chapter 10 Instruction Sets: Characteristics and Functions

Numbers

• All machine languages include numeric data types.• There is a limited latter between ordinary math

numbers and stored computer numbers.• There is a limit on the number of numbers

represented on a machine and a limit on the precision of floating-point numbers.

• The programmer faces the consequences of rounding, overflow, and underflow.

Page 21: Chapter 10 Instruction Sets: Characteristics and Functions

Numerical Data

Three types of numerical data: Integer or fixed point Floating point Decimal There is a necessity to convert from decimal to binary on

input and vice versa on output. Packed decimal is often referred as BCD code. Each decimal

is represented by a 4-bit code. Ex: 0=0000 1=0001 5=0101 8=1000

Page 22: Chapter 10 Instruction Sets: Characteristics and Functions

Inefficiency

• This coding is sometimes rather inefficient because only 10 of 16 possible 4-bit values are used. To form numbers, 4-bit codes are put together usually in multiples of 8 bits.

• Ex: 246 = 0000 0010 0100 0110• Negative numbers can be represented by

including a 4-bit sign digit at either the left or right end of a string of packed decimal digits.

Page 23: Chapter 10 Instruction Sets: Characteristics and Functions

Characters

A common form of data is text or character strings. Many codes have been devised by which characters are

represented by a sequence of bits. The most common character code used today is the

American Standard Code for Information Interchange known as ASCII also referred to as the International Reference Alphabet (IRA).

Each character in this code is represented by a unique 7-bit pattern which creates 128 different characters.

Some characters are called “control” characters which control the printing of the characters on a page. Others are used for communication procedures.

IRA codes are almost always stored and transmitted using 8 bits per character. The 8th can be a parity bit (odd or even) used for error detection.

Page 24: Chapter 10 Instruction Sets: Characteristics and Functions

ASCII Table

• This code conversions between 7-bit IRA and 4-bit packed decimal representation is the same as code as BCD code which facilitates conversions.

Page 25: Chapter 10 Instruction Sets: Characteristics and Functions

EBCDIC Table

• This code is used on IBM mainframes.

• It is an 8-bit code compatible with packed decimal.

• The codes 11110000 through 11111001 represent the digits 0 through 9.

Page 26: Chapter 10 Instruction Sets: Characteristics and Functions

Logical Data

• Logical Data can be seen as a word or address unit that can be considered to be an n-bit unit consisting of n 1-bit items of data having the value of 1 or 0.

• With this type of data, memory can be used most efficiently for storing an array of Boolean or binary data items.

• The “type” of a unit of data is determined by the operation being performed on it.

Boolean Logic

Page 27: Chapter 10 Instruction Sets: Characteristics and Functions

Pentium and PowerPC Data Types

Page 28: Chapter 10 Instruction Sets: Characteristics and Functions

Pentium Data Types• Pentium refers to Intel's single-core x86 microprocessor

based on the P5 fifth-generation micro architecture. The name Pentium was derived from the Greek “pente” which means 'five‘.

• The Pentium can deal with data types of 8 (byte),16(word),32(double-word), and 64(quad-word) bits in length.

• The least significant byte is stored in the lowest address.• The Pentium supports an impressive array of specific data

types that are recognized and operated on by particular instructions.

• Addressing is by 8 bit unit.• A 32 bit double word is read at addresses divisible by 4.

Page 29: Chapter 10 Instruction Sets: Characteristics and Functions

Specific Data Types:

• General - arbitrary binary contents• Integer - single binary value• Ordinal - unsigned integer• Unpacked BCD - One digit per byte• Packed BCD - 2 BCD digits per byte• Near Pointer - 32 bit offset within segment• Bit field• Byte String• Floating Point

Page 30: Chapter 10 Instruction Sets: Characteristics and Functions

Power PC Data Types

• PowerPC is a RISC instruction set architecture created by the 1991 Apple–IBM–Motorola alliance, known as AIM. Originally intended for personal computers, PowerPC CPUs have since become popular embedded and high-performance processors.

• The PowerPC can deal with data types of 8 (byte), 16 (half-word), 32(word), and 64 (double-word) bits in length.

• The significant difference in the two processors are the fact that PowerPC can operate on big and little-endian, while the Pentium can only perform on little-endian. This means that the least significant byte is stored in the lowest or highest address.

Page 31: Chapter 10 Instruction Sets: Characteristics and Functions

Fixed-Point Processor Data Types

• Unsigned byte: Can be used for logical or integer arithmetic operations.

• Unsigned half-word: As for unsigned byte, but for 16-bit quantities.

• Signed half-word: Used for arithmetic operations.• Unsigned word: Used for logical operations and as address

pointer.• Signed word: Used for arithmetic operations.• Unsigned double-word: Used as an address pointer.• Byte String: From 0 to 128 bytes in length.

Page 32: Chapter 10 Instruction Sets: Characteristics and Functions

Pentium Numeric Data Formats

Page 33: Chapter 10 Instruction Sets: Characteristics and Functions

• RISC: or Reduced Instruction Set Computer. is a type of microprocessor architecture that utilizes a small, highly-optimized set of instructions, rather than a more specialized set of instructions often found in other types of architectures.

• There were two stages in history for the microprocessor. One using CISC or complex instruction set computer and the other is RISC.

• The latter architecture uses a smaller set of instructions. A simpler instruction set may offer the potential for higher speeds, reduced processor size, and reduced power consumption; a more complex one may optimize common operations, improve memory/cache efficiency.

Page 34: Chapter 10 Instruction Sets: Characteristics and Functions

Endian Type

• Endian: is the convention that two parties that wish to exchange information will use to send and receive this information when they need to cut the information down to pieces. In simple terms is the byte ordering to represent some of data.

• The most significant byte (MSB) value, which is 0x0A in our example, is stored at the memory location with the lowest address, the next byte value in significance, 0x0B, is stored at the following memory location and so on. This is akin to Left-to-Right reading order in hexadecimal.

Page 35: Chapter 10 Instruction Sets: Characteristics and Functions

The Data Types

• In computing, "word" is a term for the natural unit of data used by a particular computer design. A word is simply a fixed-sized group of bits that are handled together by the machine. The number of bits in a word (the word size or word length) is an important characteristic of a computer architecture.

• The size of a word is reflected in many aspects of a computer's structure and operation.

Page 36: Chapter 10 Instruction Sets: Characteristics and Functions

Types of Operation

• Data Transfer• Arithmetic• Logical• Conversion• I/O• System Control• Transfer of Control

Page 37: Chapter 10 Instruction Sets: Characteristics and Functions

Data Transfer

• Specify– Source– Destination– Amount of data

• May be different instructions for different movements– e.g. IBM 370

• Or one instruction and different addresses

Page 38: Chapter 10 Instruction Sets: Characteristics and Functions

Arithmetic

• Add, Subtract, Multiply, Divide• Signed Integer• Floating point ?• May include

– Increment (a++)– Decrement (a--)– Negate (-a)

Page 39: Chapter 10 Instruction Sets: Characteristics and Functions

Shift and Rotate 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 0Right rotate (3 bits)

11010100

10100110 Left rotate (3 bits) 00110101

• 1. Load the word into a register. • 2. AND with the value 1111111100000000. This masks out the

character on the right. • 3. Shift to the right eight times. This shifts the remaining character to

the right half of the register. • 4. Perform I/O. The I/O module reads the lower-order 8 bits from the

data bus.

Page 40: Chapter 10 Instruction Sets: Characteristics and Functions

Logical

• Bitwise operations• AND, OR, NOT• Bitwise operators• NOT for example• The bitwise NOT, or complement, is a unary operation

which performs logical negation on each bit, forming the ones' complement of the given binary value. Digits which were 0 become 1, and vice versa. For example:

• NOT 0111 = 1000

Conversion• E.g. Binary to Decimal

Page 41: Chapter 10 Instruction Sets: Characteristics and Functions

Input/Output

• May be specific instructions• May be done using data movement

instructions (memory mapped)• May be done by a separate controller

(DMA)

Page 42: Chapter 10 Instruction Sets: Characteristics and Functions

Systems Control

• Privileged instructions• CPU needs to be in specific state

– Ring 0 on 80386+– Kernel mode

• For operating systems use

Page 43: Chapter 10 Instruction Sets: Characteristics and Functions

Transfer of Control

• Branch– e.g. branch to x if result is zero

• Skip– e.g. increment and skip if zero– ISZ Register1– Branch xxxx– ADD A

• Subroutine call

Page 44: Chapter 10 Instruction Sets: Characteristics and Functions

Questions?• What is an Address? o Any form of data.• Is Indexed an addressing mode?o Yes.• Do all microprocessors have the same addressing modes?o No.• What is the inefficiency of BCD coding?o Only 10 of 16 possible 4-bit values are used• Where is EBCDIC coding used? o It is used on IBM mainframes.• What is Endianness? o Byte ordering that represent some kind of data.

Page 45: Chapter 10 Instruction Sets: Characteristics and Functions

• Which three manufactures united to create the PowerPC processor?

o Apple, IBM, and Motorola.• What does the acronym is RISC stand for?o Reduced Instruction Set Computers• What year did the AIM alliance occur?o 1991• What is a bitwise operation?o The operation of one or two bit patterns at the level of their

individual bits• Aside of the common arithmetic operations ( Add, Sub, Multiply,

Div) what are four other possibilities?o Absolute, Negate, Increment, Decrement

Page 46: Chapter 10 Instruction Sets: Characteristics and Functions

• What is the common practice name for the representation of machine instructions?• Symbolic Representation

• The source and result operands can be in the areas of main/virtual memory, I/O device and what other area?• CPU Register

• In one-address instructions, a second address is implicit which is a process register. What is the name of this register?• Accumulator

Page 47: Chapter 10 Instruction Sets: Characteristics and Functions

References

• Wikipedia• Wiki-Answers• Computer Organization and Architecture: Designing for

Performance, 7/E

William Stallings

Page 48: Chapter 10 Instruction Sets: Characteristics and Functions

The Cast and CrewThis has been a production of < Dr. Herman Watson > class

from <FIU>.

Ken Berry

Jean Paul Larach

Hugo Blanco