A Closer Look at Instruction Set Architectures: Expanding Opcodes

Slides:



Advertisements
Similar presentations
Instruction Set Design
Advertisements

INSTRUCTION SET ARCHITECTURES
There are two types of addressing schemes:
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson slides3.ppt Modification date: March 16, Addressing Modes The methods used in machine instructions.
Instruction Set Architecture
Instruction Set Architecture & Design
TK 2633 Microprocessor & Interfacing
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
What is an instruction set?
Part II: Addressing Modes
Lecture 18 Last Lecture Today’s Topic Instruction formats
Lecture 17 Today’s Lecture –Instruction formats Little versus big endian Internal storage in the CPU: stacks vs. registers Number of operands and instruction.
Instruction Set Design by Kip R. Irvine (c) Kip Irvine, All rights reserved. You may modify and copy this slide show for your personal use,
Machine Instruction Characteristics
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CS-334: Computer.
Chapter 4 MARIE: An Introduction to a Simple Computer.
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 7.
Chapter 5 A Closer Look at Instruction Set Architectures.
Chapter 5 A Closer Look at Instruction Set Architectures.
Computer Architecture and Organization
A summary of TOY. 4 Main Components Data Processor Control Processor Memory Input/Output Device.
Computer Architecture EKT 422
Chapter 10 Instruction Sets: Characteristics and Functions Felipe Navarro Luis Gomez Collin Brown.
EEL5708/Bölöni Lec 8.1 9/19/03 September, 2003 Lotzi Bölöni Fall 2003 EEL 5708 High Performance Computer Architecture Lecture 5 Intel 80x86.
Instruction Sets: Addressing modes and Formats Group #4  Eloy Reyes  Rafael Arevalo  Julio Hernandez  Humood Aljassar Computer Design EEL 4709c Prof:
Lecture 5 A Closer Look at Instruction Set Architectures Lecture Duration: 2 Hours.
The Instruction Set Architecture. Hardware – Software boundary Java Program C Program Ada Program Compiler Instruction Set Architecture Microcode Hardware.
What is a program? A sequence of steps
Ass. Prof. Dr Masri Ayob TK 2123 Lecture 14: Instruction Set Architecture Level (Level 2)
Chapter 5 A Closer Look at Instruction Set Architectures.
Instruction Sets: Characteristics and Functions  Software and Hardware interface Machine Instruction Characteristics Types of Operands Types of Operations.
CSC 221 Computer Organization and Assembly Language Lecture 06: Machine Instruction Characteristics.
Instruction Set Architectures Continued. Expanding Opcodes & Instructions.
Computer Architecture. Instruction Set “The collection of different instructions that the processor can execute it”. Usually represented by assembly codes,
Displacement (Indexed) Stack
Instruction sets : Addressing modes and Formats
A Closer Look at Instruction Set Architectures
Control Unit Lecture 6.
A Closer Look at Instruction Set Architectures
A Closer Look at Instruction Set Architectures
COMP2121: Microprocessors and Interfacing
A Closer Look at Instruction Set Architectures
Computer Organization and Design
Microcomputer Programming
William Stallings Computer Organization and Architecture 8th Edition
Computer Organization and Design
Processor Organization and Architecture
Chapter 5 The LC-3.
BIC 10503: COMPUTER ARCHITECTURE
CS170 Computer Organization and Architecture I
Central Processing Unit
Chapter 8 Central Processing Unit
Processor Organization and Architecture
MARIE: An Introduction to a Simple Computer
ECEG-3202 Computer Architecture and Organization
Instruction Set Architectures Continued
ECEG-3202 Computer Architecture and Organization
Chapter 9 Instruction Sets: Characteristics and Functions
Classification of instructions
A Closer Look at Instruction Set Architectures Chapter 5
Other ISAs Next, we’ll first we look at a longer example program, starting with some C code and translating it into our assembly language. Then we discuss.
Other ISAs Next, we’ll first we look at a longer example program, starting with some C code and translating it into our assembly language. Then we discuss.
ECEG-3202 Computer Architecture and Organization
Addressing mode summary
COMPUTER ORGANIZATION AND ARCHITECTURE
Computer Organization
Chapter 10 Instruction Sets: Characteristics and Functions
Presentation transcript:

A Closer Look at Instruction Set Architectures: Expanding Opcodes

Lecture Overview Instruction formats Instruction types Addressing Expanding Opcodes Instruction types Addressing

One way to recover some of this space is to use expanding opcodes. Instruction formats Expanding Opcodes We have seen how instruction length is affected by the number of operands supported by the ISA. In any instruction set, not all instructions require the same number of operands. Operations that require no operands, such as HALT, necessarily waste some space when fixed-length instructions are used. One way to recover some of this space is to use expanding opcodes.

When the opcode is short, a lot of bits are left to hold operands Instruction formats Expanding Opcodes The idea of expanding opcodes is to make some opcodes short, but have a means to provide longer ones when needed. When the opcode is short, a lot of bits are left to hold operands So, we could have two or three operands per instruction If an instruction has no operands (such as Halt), all the bits can be used for the opcode Many unique instructions are hence available In between, there are longer opcodes with fewer operands as well as shorter opcodes with more operands.

Instruction formats Expanding Opcodes Example 1: Consider a machine with 16-bit instructions and 16 registers. The instruction format can have several structures: Opcode + Memory address (such as MARIE): If we have 4KB byte addressable memory we need 12 bits to specify an address location The remaining 4 bits are used for the opcode: 16 instruction are hence available Opcode + Registers Addresses we need 4 bits to select one of the 16 available registers Suppose we have 4 bits opcode, we could encode 16 different instructions with three operands each (3 x 4 bits = 12 bits).

Can we encode this instruction set in 16 bits? Instruction formats Expanding Opcodes Example 2: Consider a machine with 16-bit instructions and 16 registers. And we wish to encode the following instructions: 15 instructions with 3 addresses 14 instructions with 2 addresses 31 instructions with 1 address 16 instructions with 0 addresses Can we encode this instruction set in 16 bits? Answer: Yes if we use expanding opcodes

One possible encoding is as follows: Instruction formats Expanding Opcodes One possible encoding is as follows: Is there something missing from this instruction set?

Instruction formats Expanding Opcodes How do we know if the instruction set we want is possible when using expanding opcodes? We must determine if we have enough bits to create the desired number of bits patterns

Going back to Example 2 (Slide 6): Instruction formats Expanding Opcodes Going back to Example 2 (Slide 6): The first 15 instructions account for: 15x24x24x24 = 15 x 212 = 61440 bit patterns The next 14 instructions account for: 14 x 24 x 24 = 15 x 28 = 3584 bit patterns The next 31 instructions account for: 31 x 24 = 496 bit patterns The last 16 instructions account for 16 bit patterns In total we need 61440 + 3584 + 496 + 16 = 65536 different bit patterns Having a total of 16 bits we can create 216 = 65536 bit patterns We have an exact match with no wasted patterns. So our instruction set is possible.

Instruction formats Expanding Opcodes Example 3: Is it possible to design an expanding opcode to allow the following to be encoded with a 12-bit instruction? Assume a register operand requires 3 bits. 4 instructions with 3 registers 255 instructions with 1 register 16 instructions with 0 register

Solution: The first 4 instructions account for: Instruction formats Expanding Opcodes Solution: The first 4 instructions account for: 4x23x23x23 = 4 x 29 = 2048 bit patterns The next 255 instructions account for: 255 x 23= 2040 bit patterns The last 16 instructions account for 16 bit patterns In total we need 2048 + 2040 + 16 = 4104 bit patterns With 12 bit instruction we can only have 212 = 4096 bit patterns Required bit patterns (4104) is more than what we have (4096), so this instruction set is not possible with only 12 bits.

Lecture Overview Instruction formats Instruction types Addressing Expanding Opcodes Instruction types Addressing

Instructions fall into several broad categories: Instruction types Instruction types Instructions fall into several broad categories: Data movement instructions The most frequently used instructions Data is moved from memory into registers, from registers to registers, and from registers to memory Examples: Load, Store, Move, Push, Pop, etc. Arithmetic instructions Include those instructions that use integers and floating point numbers. As with the data movement instructions, there are sometimes different instructions for providing various combinations of register and memory accesses in different addressing modes. Examples: Add, Subtract, Multiply, Increment, Decrement, etc.

Instructions fall into several broad categories: Instruction types Instruction types Instructions fall into several broad categories: Boolean Instructions Perform Boolean expressions. Commonly used to control I/O devices. Examples: Not, Or, Xor, Test, compare, etc. Bit manipulation instructions Used for setting and resetting individual bits (or sometimes groups of bits) within a given data word. Examples: Shift left, shift right, rotate left, rotate right

Instructions fall into several broad categories: Instruction types Instruction types Instructions fall into several broad categories: I/O instructions Used to communicate with input/output devices Examples: Input, Output. Control transfer Instructions Include branches, skips and procedure calls. Examples: For MARIE we have Jump, skipcond and JnS. Special purpose Instructions Include those used for string processing, high-level language support, protection, flag control, and cache management.

Instruction types Instruction types When designing an instruction set for a given architecture, we must respect the following: Create a complete instruction set. Be carful not to add redundant instructions We should respect instructions orthogonality Each instruction should perform a unique function without duplicating any other instruction

Lecture Overview Instruction formats Addressing Introduction Expanding Opcodes Addressing Introduction Addressing Modes

Addressing - Introduction Addressing modes specify where an operand is located. They can specify a constant, a register, or a memory location. The actual location of an operand is its effective address. Certain addressing modes allow us to determine the address of an operand dynamically.

Immediate addressing Direct addressing Register addressing Addressing Modes Immediate addressing The data is part of the instruction. Example: Load 008 The numeric value 8 is loaded into the AC Direct addressing The address of the data is given in the instruction. The data value found at memory address 008 is loaded into the AC Register addressing The data is located in a register. Example: Load R1. The contents of R1 register is used as the operand.

Addressing Addressing Modes Indirect addressing Gives the address of the address of the data in the instruction. Example Load 008 The data value found at memory address 008 is actually the effective address of the desired operand. Suppose we find the value 2A0 stored in location 008. 2A0 is the “real” address of he value we want. The value found at location 2A0 is then loaded into the AC

Register indirect addressing Addressing Modes Register indirect addressing Uses a register to store the effective address of the data. Works exactly the same way as indirect addressing mode, except it uses a register instead of a memory address to point to the data. Example: Load R1 The effective address of the desired operand is found in R1.

Addressing Addressing Modes Indexed addressing uses a register (implicitly or explicitly) as an offset, which is added to the address in the operand to determine the effective address of the data. Example: Load X, where the index register holds the value 1. The effective address of the operand in actually X + 1

Based addressing Stack addressing Addressing Modes Based addressing Similar to indexed addressing except that a base register is used instead of an index register. An index register holds an offset relative to the address given in the instruction, but a base register holds a base address where the address field represents a displacement from this base. Example: Load 3, where the base register holds the address value X. The effective address of the operand is actually X +3 Stack addressing The operand is assumed to be on top of the stack.

Addressing Addressing Modes Example: For the instruction shown, what value is loaded into the accumulator for each addressing mode? 800

Addressing Addressing Modes Example: For the instruction shown, what value is loaded into the accumulator for each addressing mode? 800 900

Addressing Addressing Modes Example: For the instruction shown, what value is loaded into the accumulator for each addressing mode? 800 900 1000

Addressing Addressing Modes Example: For the instruction shown, what value is loaded into the accumulator for each addressing mode? 800 + 800 = 1600 800 900 1000 700