Instruction Set Architecture

Similar documents
Instruction Sets: Characteristics and Functions

Instruction Sets: Characteristics and Functions Addressing Modes

BIG AND LITTLE ENDIAN

CHAPTER 5 A Closer Look at Instruction Set Architectures

17. Instruction Sets: Characteristics and Functions

COMPUTER ORGANIZATION & ARCHITECTURE

CHAPTER 5 A Closer Look at Instruction Set Architectures

Computer Organization CS 206 T Lec# 2: Instruction Sets

CHAPTER 5 A Closer Look at Instruction Set Architectures

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 10 Instruction Sets: Characteristics and Functions

Instruction Set II. COMP 212 Computer Organization & Architecture. COMP 212 Fall Lecture 7. Instruction Set. Quiz. What is an Instruction Set?

Topics Power tends to corrupt; absolute power corrupts absolutely. Computer Organization CS Data Representation

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1

Typical Processor Execution Cycle

Lecture 4: Instruction Set Architecture

Addressing Modes. Immediate Direct Indirect Register Register Indirect Displacement (Indexed) Stack

When an instruction is initially read from memory it goes to the Instruction register.

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 11 Instruction Sets: Addressing Modes and Formats

COS 140: Foundations of Computer Science

Page 1. Structure of von Nuemann machine. Instruction Set - the type of Instructions

CS4617 Computer Architecture

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

Assembly Language Programming of 8085

Assembly Language Design

Chapter 2A Instructions: Language of the Computer

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

Computer Organization

Computer Architecture

CS3350B Computer Architecture MIPS Instruction Representation

Instruction Set Architecture

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation

Assembly Language Programming of 8085

Run time environment of a MIPS program

55:132/22C:160, HPCA Spring 2011

SEN361 Computer Organization. Prof. Dr. Hasan Hüseyin BALIK (8 th Week)

Instruction Sets Ch 9-10

Instruction Sets Ch 9-10

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation

Practical Malware Analysis

EC 413 Computer Organization

Instruction Set Design

Instruction Set. Instruction Sets Ch Instruction Representation. Machine Instruction. Instruction Set Design (5) Operation types

Instruction content (2/2) Instruction content (1/2) The Instruction Set. Chapter 9. Each instruction must contain 4 basic pieces of information

UNIT 2 PROCESSORS ORGANIZATION CONT.

CSEE 3827: Fundamentals of Computer Systems

Bits and Bytes. Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions

CSCI 402: Computer Architectures. Instructions: Language of the Computer (1) Fengguang Song Department of Computer & Information Science IUPUI

ECE232: Hardware Organization and Design

Announcements HW1 is due on this Friday (Sept 12th) Appendix A is very helpful to HW1. Check out system calls

COMP3221: Microprocessors and. and Embedded Systems. Instruction Set Architecture (ISA) What makes an ISA? #1: Memory Models. What makes an ISA?

COMP2121: Microprocessors and Interfacing. Instruction Set Architecture (ISA)

Evolution of ISAs. Instruction set architectures have changed over computer generations with changes in the

Byte Ordering. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

CSCE 5610: Computer Architecture

Instruction Set Architecture (ISA)

8051 Overview and Instruction Set

COMPUTER HARDWARE. Instruction Set Architecture

Chapter 2: Instructions How we talk to the computer

EITF20: Computer Architecture Part2.1.1: Instruction Set Architecture

Instruction Set Principles and Examples. Appendix B

Computer Architecture and Organization. Instruction Sets: Addressing Modes and Formats

Overview. EE 4504 Computer Organization. Much of the computer s architecture / organization is hidden from a HLL programmer

Lecture Topics. Announcements. Today: The MIPS ISA (P&H ) Next: continued. Milestone #1 (due 1/26) Milestone #2 (due 2/2)

UNIT-II. Part-2: CENTRAL PROCESSING UNIT

The CPU and Memory. How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram:

Computer Organization MIPS ISA

Microcontrollers. Microcontroller

Byte Ordering. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

Chapter 11. Instruction Sets: Addressing Modes and Formats. Yonsei University

EC-801 Advanced Computer Architecture

Architectures. CHAPTER 5 Instruction Set 5.1 INTRODUCTION 5.2 INSTRUCTION FORMATS

Review of instruction set architectures

CS 61C: Great Ideas in Computer Architecture Intro to Assembly Language, MIPS Intro

Microcontroller Intel [Instruction Set]

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C

Programming of 8085 microprocessor and 8051 micro controller Study material

Understand the factors involved in instruction set

3.1 DATA MOVEMENT INSTRUCTIONS 45

Instructions: Language of the Computer

ECE232: Hardware Organization and Design

CPE300: Digital System Architecture and Design

The von Neumann Architecture. IT 3123 Hardware and Software Concepts. The Instruction Cycle. Registers. LMC Executes a Store.

RISC, CISC, and ISA Variations

EE 3170 Microcontroller Applications

Computer Organization and Technology Processor and System Structures

Instructions: Language of the Computer

Instruction Set Architectures. CS301 Prof. Szajda

Chapter 2. Instruction Set. RISC vs. CISC Instruction set. The University of Adelaide, School of Computer Science 18 September 2017

INSTRUCTION SET ARCHITECTURE

Hakim Weatherspoon CS 3410 Computer Science Cornell University

EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University

Page 1. Where Have We Been? Chapter 2 Representing and Manipulating Information. Why Don t Computers Use Base 10?

CENG3420 Lecture 03 Review

We briefly explain an instruction cycle now, before proceeding with the details of addressing modes.

Chapter 13 Reduced Instruction Set Computers

Lecture 5-6: Bits, Bytes, and Integers

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

General Purpose Processors

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Transcription:

C Fortran Ada etc. Basic Java Instruction Set Architecture Compiler Assembly Language Compiler Byte Code Nizamettin AYDIN naydin@yildiz.edu.tr http://www.yildiz.edu.tr/~naydin http://akademik.bahcesehir.edu.tr/~naydin Assembler Interpreter Executable Instruction Set Architecture HW Implementation 1 HW Implementation 2 HW Implementation N Instruction Set Instruction: Language of the machine Instruction set: Vocabulary of the language (Collection of instructions that are understood by a CPU) lda, sta, brp, jmp, nop,... (VVM) Machine Code machine readable Binary(example: 10111010) Usually represented by assembly codes Human readable Example: VVM code adding a number entered from keyboard and a number in memory location 40 0 in 1 sta 30 2 add 40 3 sta 50 4 hlt Instruction Types Data processing ADD, SUB Data storage (main memory) STA Data movement (I/O) IN, OUT, LDA Program flow control BRZ Elements of an Instruction Operation code (Op-code) Do this Example: ADD 30 (VVM code) Source Operand reference To this Example: LDA 50 (VVM code) Result Operand reference Put the result here Example: STA 60 (VVM code) Next Instruction Reference When you have done that, do this... PC points to the next instruction Source and Result Operands Source and Result Operands can be in one of the following areas: Main memory Virtual memory Cache CPU register I/O device 1

Instruction Representation In machine code each instruction has a unique bit pattern For human consumption a symbolic representation is used (assembly language) Opcodes are represented by abbreviations, called mnemonics indicating the operation ADD, SUB, LDA, BRP,... In an assembly language, operands can also be represented as following ADD A,B (add contents of B and A and save the result into A) Simple Instruction Format Following is a 16 bit instruction format So... What is the maximum number of instructions in this processor? What is the maximum directly addressable memory size? Instruction Set Classification One way Number of operands for typical arithmetic instruction add $s1, $s2, $s3 3 Zero Address Machine a.k.a. Stack Machines What are the possibilities? Will use this C statement as an example: a = b + c; Assume a, b and c are in memory PUSH b PUSH c ADD POP a # Push b onto stack # Push c onto stack # Add top two items # on stack and replace # with sum # Remove top of stack # and store in a One Address Machine a.k.a. Accumulator Machine One operand is implicitly the accumulator LOAD b # ACC b ADD c # ACC ACC + c STORE a # a ACC A good example for such a machine is... VVM Two Address Machine (1) a.k.a. Register-Memory Instruction Set One operand may be a value from memory Machine has n general purpose registers $0 through $n-1 LOAD $1, b # $1 M[b] ADD $1, c # $1 $1 + M[c] STORE $1, a # M[a] $1 2

Two Address Machine (2) a.k.a. Memory-Memory Machine Another possibility do stuff in memory! These machines have registers used to compute memory addresses 2 addresses (One address doubles as operand and result) MOVE a, b # M[a] M[b] ADD a, c # M[a] M[a] + M[c] Two Address Machine (3) a.k.a. Load-Store Instruction Set or Register-Register Instruction Set Typically can only access memory using load/store instructions LOAD $1, b # $1 M[b] LOAD $2, c # $2 M[c] ADD $1, $2 # $1 $1 + $2 STORE $1, a # M[a] $1 Three Address Machine a.k.a. Load-Store Instruction Set or Register- Register Instruction Set Typically can only access memory using load/store instructions 3 addresses (Operand 1, Operand 2, Result) May be a forth - next instruction (usually implicit) Needs very long words to hold everything Utilization of Instruction Addresses (Nonbranching Instructions) LOAD $1, b # $1 M[b] LOAD $2, c # $2 M[c] ADD $3, $1, $2 # $3 $1 + $2 STORE $3, a # M[a] $3 History Hardware Expensive Memory Expensive Accumulators EDSAC IBM 701 Hardware Less Expensive Memory Expensive Register Oriented Machines (2 address) Register-Memory IBM 360 DEC PDP-11 Also Fringe Element Stack Machines Burroughs B-50 (Banks) Hardware and Memory Cheap Microprocessors Compilers getting good CISC VAX Motorola 680 Intel 80x86 RISC Berkley RISC Sparc Dave Patterson Stanford MIPS SGI John Hennessy IBM 801 Performans (which one is better?) 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 1940 1950 1960 1970 1980 1990 3

Types of Operand Addresses Operand is in the address Numbers (actual operand) Integer or fixed point floating point decimal Characters (actual operand) ASCII etc. Logical Data (actual operand) Bits or flags Pentium Data Types 8 bit (byte), 16 bit (word), 32 bit (double word), 64 bit (quad word) Addressing in Pentium is by 8 bit units A 32 bit double word is read at addresses divisible by 4: 01 1A 22 F1 77 +0 +1 +2 +3 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 Pentium Numeric Data Formats PowerPC Data Types 8 (byte), 16 (halfword), 32 (word) and 64 (doubleword) length data types Fixed point processor recognises: Unsigned byte, unsigned halfword, signed halfword, unsigned word, signed word, unsigned doubleword, byte string (<128 bytes) Floating point IEEE 754 Single or double precision Types of Operation Data Transfer Arithmetic Logical Conversion I/O System Control Transfer of Control 4

Data Transfer Need to specify Source Destination Amount of data May be different instructions for different movements Or one instruction and different addresses Arithmetic Basic arithmetic operations are... Add Subtract Multiply Divide Increment (a++) Decrement (a--) Negate (-a) Absolute Arithmetic operations are provided for... Signed Integer Floating point? Packed decimal numbers? Logical Bitwise operations AND, OR, NOT Example1: bit masking using AND operation (R1) = 101101 (R2) = 1111 (R1) AND (R2) = 0101 Basic Logical Operations Example2: taking ones coplement using XOR operation (R1) = 101101 (R2) = 11111111 (R1) XOR (R2) = 01011010 Shift and Rotate Operations Examples of Shift and Rotate Operations 5

An example To send the two characters in a word Suppose we wish to transmit characters of data to an I/O device 1 character at a time. If each memory word is 16 bits in length and contains two characters, we must unpack the characters before they can be sent. Load the word into a register AND with the value 11111111 This masks out the character on the right Shift to the right eight times This shifts the remaining character to the right half of the register Perform I/O The I/O module reads the lower-order 8 bits from the data bus. To send the two characters in a word Conversion The preceding steps result in sending the left-hand character. To send the right-hand character: Load the word again into the register AND with 11111111 Perform I/O Conversion instructions are those that change the format or operate on the format of data. For example: Binary to Decimal conversion Input/Output Systems Control May be specific instructions IN, OUT May be done using data movement instructions (memory mapped) May be done by a separate controller (DMA) Privileged instructions CPU needs to be in specific state For operating systems use 6

Transfer of Control Branch For example: brz 10 (branch to 10 if result is zero) Branch Instruction Skip e.g. increment and skip if zero ISZ Register1 Branch xxxx ADD A Subroutine call c.f. interrupt call Nested Procedure Calls Use of Stack Types of Operation Types of Operation 7

CPU Actions for Various Types of Operations Pentium Operation Types Pentium Condition Codes Pentium Conditions for Conditional Jump and SETcc Instructions MMX Instruction Set 8

PowerPC Operation Types PowerPC Operation Types Byte Ordering How should bytes within multi-byte word be ordered in memory? Some conventions Sun s, Mac s are Big Endian machines Least significant byte has highest address Alphas, PC s are Little Endian machines Least significant byte has lowest address Byte Ordering Example Big Endian Least significant byte has highest address Little Endian Least significant byte has lowest address Example Variable x has 4-byte representation 0x01234567 Address given by &x is 0x1 Big Endian Little Endian 0x1 0x101 0x102 0x103 01 23 45 67 0x1 0x101 0x102 0x103 67 45 23 01 Representing Integers int A = 15213; int B = -15213; long int C = 15213; Linux/Alpha A 3B Linux/Alpha B 93 C4 Sun A 3B Sun B C4 93 Decimal: 15213 Binary: 11 1011 0110 1101 Hex: 3 B 6 D Linux C 3B Alpha C 3B Two s complement representation (Covered next lecture) Sun C 3B Representing Pointers int B = -15213; int *P = &B; Alpha Address Hex: 1 F F F F F C A 0 Binary: 01 1111 1111 1111 1111 1111 11 1010 Sun P EF FB 2C Sun Address Hex: E F F F F B 2 C Binary: 1110 1111 1111 1111 1111 1011 10 11 Linux Address Hex: B F F F F 8 D 4 Binary: 1011 1111 1111 1111 1111 10 1101 01 Different compilers & machines assign different locations to objects Alpha P A0 FC 01 Linux P D4 F8 BF 9

Representing Floats Float F = 15213.0; Linux/Alpha F B4 46 IEEE Single Precision Floating Point Representation Hex: 4 6 6 D B 4 0 0 Binary: 01 0110 0110 1101 1011 01 15213: 1110 1101 1011 01 Sun F 46 B4 Not same as integer representation, but consistent across machines Can see some relation to integer representation, but not obvious Representing Strings Strings in C char S[6] = "15213"; Represented by array of characters Each character encoded in ASCII format Standard 7-bit encoding of character set Character 0 has code 0x30 +Digit i has code 0x30+i Linux/Alpha S Sun S String should be null-terminated 31 31 Final character = 0 35 35 Compatibility 32 32 31 31 Byte ordering is not an issue 33 33 Data are single byte quantities Text files generally platform independent Except for different conventions of line termination character(s)! Example of C Data Structure Common file formats and their endian order are as follows: Adobe Photoshop -- Big Endian BMP (Windows and OS/2 Bitmaps) -- Little Endian DXF (AutoCad) -- Variable GIF -- Little Endian IMG (GEM Raster) -- Big Endian JPEG -- Big Endian FLI (Autodesk Animator) -- Little Endian MacPaint -- Big Endian PCX (PC Paintbrush) -- Little Endian PostScript -- Not Applicable (text!) POV (Persistence of Vision ray-tracer) -- Not Applicable (text!) QTM (Quicktime Movies) -- Little Endian (on a Mac!) Microsoft RI (.WAV &.AVI) -- Both Microsoft RTF (Rich Text Format) -- Little Endian SGI (Silicon Graphics) -- Big Endian Sun Raster -- Big Endian TGA (Targa) -- Little Endian TI -- Both, Endian identifier encoded into file WPG (WordPerfect Graphics Metafile) -- Big Endian (on a PC!) XWD (X Window Dump) -- Both, Endian identifier encoded into file 10