240-334 by Wannarat 240-334 Computer System Design Lecture 2 Instruction Set Architecture.

Slides:



Advertisements
Similar presentations
Chapter 2: Data Manipulation
Advertisements

Machine cycle.
Chapter 2 Instruction Set Principles. Computer Architecture’s Changing Definition 1950s to 1960s: Computer Architecture Course = Computer Arithmetic 1970s.
Chapter 1. Basic Structure of Computers
Instruction Set Design
ISA Issues; Performance Considerations. Testing / System Verilog: ECE385.
The Microprocessor and its Architecture
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 4.
Microprocessor.  The CPU of Microcomputer is called microprocessor.  It is a CPU on a single chip (microchip).  It is called brain or heart of the.
Computer Systems. Computer System Components Computer Networks.
CHAPTER 4 COMPUTER SYSTEM – Von Neumann Model
Midterm Wednesday Chapter 1-3: Number /character representation and conversion Number arithmetic Combinational logic elements and design (DeMorgan’s Law)
Computer Organization and Architecture Tutorial 2 Kenneth Lee.
Chapter 2.2 Machine Language.
Overview The von Neumann Machine - the programmable digital computer Introducing the LC-3 Computer - A “toy” computer for us to learn from Computer machine.
Basic Computer Organization, CPU L1 Prof. Sin-Min Lee Department of Computer Science.
1 Sec (2.3) Program Execution. 2 In the CPU we have CU and ALU, in CU there are two special purpose registers: 1. Instruction Register 2. Program Counter.
Overview von Neumann Model Components of a Computer Some Computer Organization Models The Computer Bus An Example Organization: The LC-3.
Design and Synthesis of a RISC Stored-Program Machine
Basic Microcomputer Design. Inside the CPU Registers – storage locations Control Unit (CU) – coordinates the sequencing of steps involved in executing.
CS 1308 Computer Literacy and the Internet Computer Systems Organization.
CMP 301A Computer Architecture 1 Lecture 4. 2 Outline zISA Introduction zISA Classes yStack yAccumulator yRegister memory yRegister register/load store.
Computer Systems Organization CS 1428 Foundations of Computer Science.
The Central Processing Unit (CPU) and the Machine Cycle.
COMPUTER ARCHITECURE INSTRUCTION SET ARCHITECTURE.
Chapter 2 Data Manipulation Yonsei University 1 st Semester, 2015 Sanghyun Park.
Important Concepts  Parts of the CPU  Arithmetic/Logic Unit  Control Unit  Registers  Program Counter  Instruction Register  Fetch/Decode/Execute.
Computer Organization & Programming Chapter 6 Single Datapath CPU Architecture.
Lecture 11: 10/1/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Computer Structure & Architecture 7b - CPU & Buses.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Information Representation: Machine Instructions.
W.S Computer System Design Lecture 4 Wannarat Suntiamorntut.
Represents different voltage levels High: 5 Volts Low: 0 Volts At this raw level a digital computer is instructed to carry out instructions.
CS 1308 Computer Literacy and the Internet. Objectives In this chapter, you will learn about:  The components of a computer system  Putting all the.
Dale & Lewis Chapter 5 Computing components
Lecture 5 Computer Hardware. von Neumann Architecture.
EEL5708/Bölöni Lec 3.1 Fall 2006 Sept 1, 2006 Lotzi Bölöni EEL 5708 High Performance Computer Architecture Lecture 3 Review: Instruction Sets.
Question What technology differentiates the different stages a computer had gone through from generation 1 to present?
By Wannarat Computer System Design Lecture 4 Wannarat Suntiamorntut.
Chapter 2 Data Manipulation © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter 2 Data Manipulation © 2007 Pearson Addison-Wesley. All rights reserved.
Central Processing Unit Decode Cycle. Central Processing Unit Current Instruction Register (CIR) I1 The fetch cycle has transferred an instruction from.
Chapter 20 Computer Operations Computer Studies Today Chapter 20.
ARM7 Architecture What We Have Learned up to Now.
1 Classification of instructions 4-address instructions 3-address instructions 2-address instructions 1-address instructions 0-address instructions.
Immediate Addressing Mode
CPU Organisation & Operation
Computer Science 210 Computer Organization
Computer Architecture
פרק 2: חיווט, זיכרונות בנקים זוגיים ואי-זוגיים
The fetch-execute cycle
The Processor and Machine Language
Figure 8.1 Architecture of a Simple Computer System.
Functional Units.
CS149D Elements of Computer Science
Intro to Architecture & Organization
Processor Organization and Architecture
Figure 8.1 Architecture of a Simple Computer System.
Computer System Design Lecture 5
The Little Man Computer
Classification of instructions
MARIE: An Introduction to a Simple Computer
October 29 Review for 2nd Exam Ask Questions! 4/26/2019
Computer System Design Lecture 5
William Stallings Computer Organization and Architecture 8 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.
Information Representation: Machine Instructions
Computer Architecture
Sec (2.3) Program Execution.
Little Man Computer.
Presentation transcript:

by Wannarat Computer System Design Lecture 2 Instruction Set Architecture

by Wannarat What’re the component of ISA? Machine Instruction Set Instruction format Nature of the fetch through execute wannarat: machine instruction set :make use of storage cells, formats, and result of fetch/execute, register transfer instruction format : size and meaning of field within instruction the nature of the fetch-execute cycle : things that are done before the operation code is known. wannarat: machine instruction set :make use of storage cells, formats, and result of fetch/execute, register transfer instruction format : size and meaning of field within instruction the nature of the fetch-execute cycle : things that are done before the operation code is known.

by Wannarat Varies Programming Model

by Wannarat What must an instruction specify? Which Operation is perform? ADDr1,r2,r3 Where to find the operands ADDr1,r2,r3 Place to store the result ADDr1,r2,r3 Location of next instruction

by Wannarat Basic ISA Class Accumulator (1 register) 1 addressadd A; acc <= acc + mem[A] 1 + x addressaddxA; acc <= acc + mem[A+x] Stack : 0 addressaddtos <= tos + next General Purpose Register 2 addressaddA, B 3 addressaddA, B, C wannarat: add A, B; A = A + B add A B C; A = B + C wannarat: add A, B; A = A + B add A B C; A = B + C

by Wannarat Basic ISA Classes(con’t) Load/Store load Ra, RbRa <= mem[Rb] Store Ra, Rbmem[Rb] <= Ra

by Wannarat Compare number of instruction Code Sequence for C = A + B StackAccumulator RegisterRegister (reg. - mem) (load/store) Push ALoad ALoad R1,ALoad R1,A Push BAdd BAdd R1,BLoad R2,B AddStore CStore C, R1Add R3,R1,R2 Pop CStore C,R3

by Wannarat CPU Register Stack RegisterArithmetic Register & Address Register

by Wannarat General Purpose Register all machines use general purpose registers. Advanced of Registers - faster than memory - easier for compiler to use - hold variables wannarat: easier for compiler to use : (A*B) - (C*D) - (E*F) can do multiplies in any order vs. stack hold variables: memory traffic is reduced (program speed up), code density improves ( register named with fewer bits than memory location) wannarat: easier for compiler to use : (A*B) - (C*D) - (E*F) can do multiplies in any order vs. stack hold variables: memory traffic is reduced (program speed up), code density improves ( register named with fewer bits than memory location)

by Wannarat Summary Instruction Set Class Data Movement Instructions - Load - Store Arithmetic and Logic (ALU) Instruction - Add, Sub, Shift … Branch Instructions - Br, Brz, …

by Wannarat 3-Address Machine and ISA wannarat: Address of next instruction kept in Processor state register (PC) wannarat: Address of next instruction kept in Processor state register (PC)

by Wannarat 2-Address Machine ISA

by Wannarat 1-Address Machine and ISA

by Wannarat 0-Address Machine and ISA wannarat: Push-down stack in CPU, Arithmetic uses stack for both operands and result, Computer must have 1-address instruction to push and pop operands to and from the stack wannarat: Push-down stack in CPU, Arithmetic uses stack for both operands and result, Computer must have 1-address instruction to push and pop operands to and from the stack

by Wannarat Examples a = (b+c)*d - e 3-address 2-address1-address stack add a,b,c load a,bload b push b mpy a,a,d add a,cadd c push c sub a,a,e mpy a,dmpy d add sub a,esub e push d store a mpy push e sub pop a

by Wannarat Real Machine Have mixture of 3, 2, 1 or 0 address instructions if ALU instructions only use registers for operands and result, machine type is load-store mix of register-memory and memory-memory

by Wannarat Break 5 Minutes

by Wannarat Addressing Mode

by Wannarat Addressing Mode Addressing ModeExamplesMeaning RegisterAdd r4,r3r4 <= r4 + r3 ImmediateAdd r4,#3r4 <= r4 + 3 Displacement Add r4,100(r1)r4 <= r4 + mem[100+r1] indirect(r)Add r4,(r1)r4 <= r4 + mem[r1] index+base Add r3,(r1+r2)r3 <= r3 + mem[r1+r2] DirectAdd r1,(1001)r1 <= r1 + mem[1001] indirect(m) Add <= r1 + mem[mem[r3]] auto-increAdd r1,(r2)+r1 <= r1+mem[r2];r2=r2+d auto-decreAdd r1,-(r2)r2 <=r2-d,r1<=r1+mem[r2] scaledAdd r1,100(r2)[r3] r1 <=r1+mem[100+r2+r3*d]

by Wannarat MIPS Registers 31 x 32-bit GPR (R0 = 0) 32 x 32-bit FP register PC lo hi-multiplier output register R0 R1 R31 PC lo hi

by Wannarat Memory Addressing Since 1980, Most machine uses address to level of 8-bits (byte) How do byte address map onto words? Can a word be placed on any byte boundary?

by Wannarat Endianess and Alignment Big Endian : 68k, SPARC, MIPS, HP PA Little Endian : 80x86,DEC(Vax, Alpha)

by Wannarat Generic of Instruction format width Variable : Fixed: Hybrid :...

by Wannarat Summary ISA Variable length instructions, if code size is very important. Fixed length instructions, if performance is most important. Embedded Machine (ARM, MIPS) have optional mode to execute 16-bitwide. (decide performance or density)

by Wannarat To be Continuous

by Wannarat Part II : Lecture 2

by Wannarat MIPS ISA Target Embedded System used by NEC, Nintendo, Silicon Graphics, Sony

by Wannarat MIPS ISA

by Wannarat MIPS Addressing Modes All instructions have 32-bit wide.

by Wannarat MIPS Arithmetic Instruction InstructionExampleMeaning 1.addadd $1,$2,$3$1 = $2 + $3 2.subtractsub $1,$2,$ add immeaddi $1,$2, add unsignaddu $1,$2,$ subu $1,$2,$ addiu $1,$2, multiplymult$2,$3Hi,Lo = $2x$3 8.multu $2,$

by Wannarat MIPS Arithmetic Instruction InstructionExampleMeaning 9.dividediv $2,$3Lo=$2/$3, Hi=$2mod$3, 10.Divu $2,$3 11.movmfhi $1 12.mflo $1

by Wannarat MIPS Logical Instruction InstructionExampleMeaning 13.ANDand 14.ORor 15.XORxor 16.NORnor 17.andi 18.ori 19.xori 20.shift left logical sll $1,$2,10 21.Srl $1,$2,10

by Wannarat MIPS Logical Instruction InstructionExampleMeaning 22.shift right arithm sra $,$2,10 (sign extend) 23.sllv 24.srlv 25.srav

by Wannarat MIPS data transfer instructions 26. sw 500(r4),r3Store word 27.sh 502(r4),r3store half word 28. sb 41(r4,r3store byte 29.lw r1,30(r2)load word 30.Lh r1,40(r2)load half word 31.Lb r1,40(r2)load byte 32lui r1,40load upper immediate (16 bits shifted left by 16)

by Wannarat Testing Condition Condition Code addr1,r2,r3 bzlabel Condition Register cmpr1,r2,r3 bgtr1,label Compare and Branch bgtr1,r2,label

by Wannarat MIPS Compare and Branch Compare and Branch BEQrs,rt,offset BNErs,rt,offset compare to zero and Branch BLEZrs, offset BGTZrs, offset BLT< BGEZ>= BLTZALif R[rs] < 0 then branch and link(to R31) BGEZAL>=

by Wannarat MIPS Jump, Branch Compare

by Wannarat Software conventions for Register

by Wannarat Note for MIPS Instruction Set R0 always = “0” (even if u try to write) Branch/jump and link PC+4 ->R31 Imme arith and logical are extended - logical imme op are zero extend to 32 bits - arith imme op are sign extend to 32 bits data loaded by lb, lh extended - lbu, lhu are zero extended - lb, lh are sign extedned Overflow occur in ADD, SUB, ADDI Don’t occur in ADDU, SUBU, ADDIU, AND, OR, XOR, NOR, SHIFT, MULT, MULTU, DIV, DIVU

by Wannarat MIPS arithmetic Instruction has 3 operands Operand order is fixed Pascal Code : a := b + c; MIPS Code :add $s0, $s1, $s2

by Wannarat MIPS Arithmetic Pascal Code : a := b + c + d; e := f - a; MIPS Code :add $t0, $s1, $s2 add $s0, $t0, $s3 sub $s4, $s5, $s0

by Wannarat Register & Memory Registers were used in Arithmetic Instructions - 32 registers

by Wannarat Memory Organization Memory is an index into the array Byte Addressing = points to a byte of memory 1 8 bits of Data

by Wannarat Memory Organization For MIPS, a word is 32-bit or 4 bytes 2 32 bytes with byte addresses from 0 to words with byte address from 0, 4, 6, …, bits of Data

by Wannarat MIPS Load/Store Instruction Code : A[8] = h + A[8]; A[8] ==> 8 x 4 = 32 (word alignment) MIPS Code :lw $t0, 32($s3); add $t0,$s2,$t0; sw $t0, 32($s3); Arithmetic Operand is Register, not Memory!!

by Wannarat Example : Swap (int v[], int k); { Int temp; temp = v[k];swap:muli $2, $5, 4 v[k] = v[k+1];add $2,$4,$2 v[k+1]=temp;lw $15, 0[$2] }lw $16, 4[$2] sw $16, 0[$2] sw $15, 4[$2] jr $31

by Wannarat Meaning add$2, $4, $2$2 = $4 + $2; lw$16, 0[$2]$16 = Memory[0 + $2] sw$15, 4[$2]Memory[4+$2] = $15

by Wannarat Machine Language Instructions, like register & words of data are 32 bits long. - add $t0, $s1, $s2 - register : $t0 = 9, $s1 = 17, $s2 = 18 Instruction Format

by Wannarat Machine Language I-type for Data transfer instruction Example : lw $t0, 32($s2)

by Wannarat Control Decision Making instructions MIPS conditional branch instructions: - bne $t0, $t1, label - beq $t0, $t1, label Example : if (i=j) h= i +j; bne$s0, $s1, Label add$s3, $s0, $s1 Label :...

by Wannarat Control MIPS unconditional Branch Example : if ( i != j)beq$s4, $s5, label; h=i+j;add$s3, $s4, $s5; elsej lab2 h=i-j;lab1: sub $s3, $s4, $s5 lab2: …

by Wannarat Summarize :

by Wannarat

Homework Use MIPS Assembly to write program. 1. “Factorial Program” n is input, Example : if n=3, result = 3! = 3 x 2 x 1 = 6

by Wannarat Homework Use MIPS Assembly to write program. 2. Write program that use Most of the MIPS instructions

by Wannarat MIPS Instruction Encoding Please see more detail in the Figure 3.18 Page 153,