ECE 4436ECE 5367 ISA II Microprocessor without Interlocked Piped Stages Million Instructions Per Second Meaningless indicator of Performance.

Slides:



Advertisements
Similar presentations
1 Lecture 3: MIPS Instruction Set Today’s topic:  More MIPS instructions  Procedure call/return Reminder: Assignment 1 is on the class web-page (due.
Advertisements

Goal: Write Programs in Assembly
Review of the MIPS Instruction Set Architecture. RISC Instruction Set Basics All operations on data apply to data in registers and typically change the.
Lecture 5: MIPS Instruction Set
CS/COE0447 Computer Organization & Assembly Language
INSTRUCTION SET ARCHITECTURES
1 ECE462/562 ISA and Datapath Review Ali Akoglu. 2 Instruction Set Architecture A very important abstraction –interface between hardware and low-level.
Deeper Assembly: Addressing, Conditions, Branching, and Loops
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 5: Data Transfer Instructions / Control Flow Instructions Partially adapted from Computer.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 5 MIPS ISA & Assembly Language Programming.
The University of Adelaide, School of Computer Science
Assembly Process. Machine Code Generation Assembling a program entails translating the assembly language into binary machine code This requires more than.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 4: Arithmetic / Data Transfer Instructions Partially adapted from Computer Organization.
331 W02.1Spring 05 Announcements  HW1 is due on this Friday  Appendix A (on CD) is very helpful to HW1.
Instruction Representation II (1) Fall 2007 Lecture 10: Instruction Representation II.
1 Lecture 2: MIPS Instruction Set Today’s topic:  MIPS instructions Reminder: sign up for the mailing list cs3810 Reminder: set up your CADE accounts.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
ECE 4436ECE 5367 ISA I. ECE 4436ECE 5367 CPU = Seconds= Instructions x Cycles x Seconds Time Program Program Instruction Cycle CPU = Seconds= Instructions.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
9/29: Lecture Topics Memory –Addressing (naming) –Address space sizing Data transfer instructions –load/store on arrays on arrays with variable indices.
ISA-2 CSCE430/830 MIPS: Case Study of Instruction Set Architecture CSCE430/830 Computer Architecture Instructor: Hong Jiang Courtesy of Prof. Yifeng Zhu.
Some material taken from Assembly Language for x86 Processors by Kip Irvine © Pearson Education, 2010 Slides revised 2/2/2014 by Patrick Kelley.
83 Assembly Language Readings: Chapter 2 ( , 2.8, 2.9, 2.13, 2.15), Appendix A.10 Assembly language Simple, regular instructions – building blocks.
CSE378 Instr. encoding.1 Instruction encoding The ISA defines –The format of an instruction (syntax) –The meaning of the instruction (semantics) Format.
Character Data and 32-bit Constants (Lecture #20) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying.
Lecture 4. MIPS Instructions #2 Memory Access (Load/Store) Instructions Prof. Taeweon Suh Computer Science Education Korea University ECM534 Advanced Computer.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
Lecture 4: MIPS Instruction Set
Computer Architecture and Organization
CWRU EECS 3221 Language of the Machine EECS 322 Computer Architecture Instructor: Francis G. Wolff Case Western Reserve University.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /08/2013 Lecture 10: MIPS Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL STATE.
 1998 Morgan Kaufmann Publishers MIPS arithmetic All instructions have 3 operands Operand order is fixed (destination first) Example: C code: A = B +
MIPS Instructions Instructions: Language of the Machine
1 CS/COE0447 Computer Organization & Assembly Language Chapter 2 Part 2.
COMPUTER ORGANISATION Sri.S.A.Hariprasad Sr.Lecturer R.V.C.E Bangalore.
EE472 – Spring 2007P. Chiang, with Slide Help from C. Kozyrakis (Stanford) ECE472 Computer Architecture Lecture #3—Oct. 2, 2007 Patrick Chiang TA: Kang-Min.
MIPS Instructions Instructions: Language of the Machine
Chapter 2 — Instructions: Language of the Computer — 1 Memory Operands Main memory used for composite data – Arrays, structures, dynamic data To apply.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 7, 8 Instruction Set Architecture.
Arrays in MIPS Assembly Computer Organization and Assembly Language: Module 6.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Memory Access Instructions Load and Store Addressing Modes Memory Addressing. Base addressing mode. Load byte and store byte: lb, lbu, sb Address alignment.
Computer Architecture & Operations I
Computer Architecture & Operations I
Memory Access Instructions
MIPS Instruction Set Advantages
Morgan Kaufmann Publishers
Lecture 4: MIPS Instruction Set
ELEN 468 Advanced Logic Design
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Computer Architecture (CS 207 D) Instruction Set Architecture ISA
Lecture 4: MIPS Instruction Set
MPIS Instructions Functionalities of instructions Instruction format
CSCI206 - Computer Organization & Programming
The University of Adelaide, School of Computer Science
Computer Architecture & Operations I
Chapter 2 Instructions: Language of the Computer
Instruction encoding The ISA defines Format = Encoding
Computer Instructions
Computer Architecture
3.
Instruction encoding The ISA defines Format = Encoding
COMS 361 Computer Organization
COMS 361 Computer Organization
Instruction encoding The ISA defines Format = Encoding
Instruction encoding The ISA defines Format = Encoding
CS352H Computer Systems Architecture
9/27: Lecture Topics Memory Data transfer instructions
Chapter 10 Instruction Sets: Characteristics and Functions
Presentation transcript:

ECE 4436ECE 5367 ISA II Microprocessor without Interlocked Piped Stages Million Instructions Per Second Meaningless indicator of Performance

ECE 4436ECE 5367 Addressing Objects: Endianess and Alignment Big Endian: address of most significant byte = word address (xx00 = Big End of word) IBM 360/370, Motorola 68k, MIPS, Sparc, HP PA Little Endian: address of least significant byte = word address (xx00 = Little End of word) Intel 80x86, DEC Vax, DEC Alpha (Windows NT) msb lsb little endian byte big endian byte 0 Alignment: require that objects fall on address that is multiple of their size Aligned Not Aligned

ECE 4436ECE 5367 MIPS Assembly Language: Instruction Set 3 different instruction formats I-type, R-type,

ECE 4436ECE 5367 R-type instructions R-type Three register operands Arithmetic & logical opcodes Format: Rd = destination operand (output) Rs = source operand (input) Rt = source operand (input) 6 bits5 bits 6 bits OpcodeRsRtRdshamtfunction

ECE 4436ECE 5367 I-type instructions. I-type Two registers and an immediate Format: Rt = destination operand Rs = source operand Immediate = a constant, also a source operand Note: immediate operand must fit into 16 bits! (Why?) 6 bits5 bits 6 bits OpcodeRsRtaddress

ECE 4436ECE 5367 I-type instructions contd… I-type: 4 fields I-type at work ADDI$2,$1,32 LUI $7,OxABCD 6 bits5 bits 6 bits OpcodeRsRtaddress

ECE 4436ECE 5367 Flow control instructions

ECE 4436ECE 5367 Unconditional Branch

ECE 4436ECE 5367 Unconditional jump

ECE 4436ECE 5367 example

ECE 4436ECE 5367 Branch formats

ECE 4436ECE 5367 Unconditional Branch Jlabel transfer control unconditionally to instruction following label Ex. loop:add$t1,$s3,$s3 sw$t1,8($s4) jloop Why is the above code segment poor programming?

ECE 4436ECE 5367 Conditional Branches Ex 1: Ex 2: $s0==$s1? No Yes label23 c < 7? No Yes label17

ECE 4436ECE 5367 Conditional Branches Ex 3: if (i==j) f=f-i; else f=g+h;

ECE 4436ECE 5367 Branching far away…. 26 bit field in jump instructions is a word address It represents a word address Due to the fact that instructions are located at multiples of 4, the 2 LSbits are always 00 !!!!!! Implicit and can be dropped CPU appends the 2bits back on the instruction when instruction is fetched and decoded.

ECE 4436ECE 5367 For & While Loops Using Arrays Ex.clear an uninitialized array intarrayA[100]; for(i=0; i<100; i++) arrayA[i] = 0; Let i = $S3 base addr. of A = $S4 100 = $t1

ECE 4436ECE 5367 For & While Loops Using Arrays.data arrayA:.space 400….text LI$t1,100# load count MOVE$s3,$zero# i = 0 LA$s4,arrayA# load base addr. of A LOOP:BGE$s3,$t1,DONE# done? ADD$t2,$s3,$s3# i  2 * i ADD$t2,$t2,$t2# double again ADD$t2,$t2,$s4# ArrayA[i] SW$zero,0($t2)# ArrayA[i] ADDi$s3,$s3,1# i++ JLOOP DONE: Int: mult By 4

ECE 4436ECE 5367 Addressing Mode

ECE 4436ECE 5367

ECE 4436ECE 5367

ECE 4436ECE 5367

ECE 4436ECE 5367

ECE 4436ECE 5367

ECE 4436ECE 5367

ECE 4436ECE 5367 Variable Declarations Memory is a linear array of bytes Used to store programs and data Memory is numbered in bytes MIPS can access up to 2 32 bytes i.e. from to FFFFFFFF 16 range of _______ to _______(??Bytes) Note: addresses are always unsigned

ECE 4436ECE 5367 Variable Declarations Every memory cell has two attributes address (location) contents Note: Recall registers are accessed by name Note: We may give a location a name for convenience 5F89025C B94 16 sum

ECE 4436ECE 5367 Variable Declarations In MIPS, two types of memory accesses are supported 1. Load Register with contents of a memory cell 2. Store Register into a memory cell Reg Memory Reg

ECE 4436ECE 5367 Variable Declarations In MIPS, 3 cell sizes can be accessed: bytelb halfword (2 bytes)sh word (4 bytes)lw All accesses must be aligned addresses of words must be divisible by 4 addresses of halfwords must be divisible by 2 bytes are always aligned

ECE 4436ECE 5367 Data Allocation In assembly language, we need to allocate memory for use by program assign names to memory locations (declare variables) initialize memory.data # start of data declarations

ECE 4436ECE 5367 Data Allocation To allocate uninitialized memory, use.space To allocate initialized memory, use.byte,.half,.word,.ascii,.asciiz To assign names to locations, prepend allocation directive with a label

ECE 4436ECE 5367 Data Allocation Examples. byte7# allocate byte and put a 7 in it.half15# allocate halfword and put a 15 in it.word9# allocate word and put a 9 in it

ECE 4436ECE 5367 Data Allocation Ex. (assume we start at address 0 after.data directive) a:.word0xab b:.word0x1234 c:.word 0x Symbol Table: a = b = c =

ECE 4436ECE 5367 Data Allocation Can also draw memory in words a: 0 b: 4 c: 8 a:.word0xab b:.word0x1234 c:.word0x

ECE 4436ECE 5367 Data Allocation Multiple numeric values separated by commas indicate repeat of directive Useful for small initialized arrays Ex.: a:.word1,2,3 b:.word4,5 a:.word1.word 2.word3 b:.word4.word5

ECE 4436ECE 5367 Data Allocation Memory Map a: 0 b: 12 a:word1,2,3 b:word4,5

ECE 4436ECE 5367 Data Allocation Ex..data datanums:.byte1,2,3,4 datanums: 0

ECE 4436ECE 5367 Alignment in MIPS Words are said to be aligned if they begin on a 4 byte boundary. Halfwords are said to be aligned if they begin on a 2 byte boundary Bytes are always aligned!

ECE 4436ECE 5367 Alignment in MIPS Default in MIPS is ALIGNED memory allocation i.e. .word means allocate at next quad address (divisible by 4) .half means allocate at next even address (divisible by 2) When you skip locations, they are uninitialized

ECE 4436ECE 5367 Alignment in MIPS Ex..data a:.word 1 b:.byte2 c:.half3 d:.byte4 e:.word0x Symbol 0 Location

ECE 4436ECE 5367 Alignment in MIPS Q: Why bother aligning data? A: Because the databus is 32 bits wide. (i.e. memory is accessed on word boundaries.) An unaligned access cannot be done in a single transfer sum

ECE 4436ECE 5367 Uninitialized Allocation:.space.spacen# allocate n bytes Ex..data a:.space4 b:.word4 c:.space4 d:.ascii“4” a: 0

ECE 4436ECE 5367 Allocating Memory for ASCII Strings Ex..data string1:.ascii“abcdef” string2:.asciiz“abcdef” number1:.word0x1234 string1: Symbol Table:

ECE 4436ECE 5367 Allocating Memory: C example Convert the C code to MIPS machine language int a,b=5,c[3]={7,8,9}; char string1 = “abcd”; char array1[10]; short int array2[7]; int d=0xAB.data a:.word 0 b:.word 5 c:.word 7.word 8.word 9 string1:.asciiz “abcd” array1:.space 10.space 1 array2:.space 14 d:.word 0xAB align manually auto align

ECE 4436ECE 5367 Allocating Memory: C example

ECE 4436ECE 5367 Allocating Memory: C example Symbol Table a b c string1 array1 array2 d

ECE 4436ECE 5367 Loading from Memory to Register Storing from Register to Memory To get stuff into and out of registers, must use load & store instructions Only way to access memory Memory access => Read or write from or to memory

ECE 4436ECE 5367 Loading from Memory to Register Storing from Register to Memory LoadsLxxRt, memory_address e.g.LW $S1,100($S2) Memory[$S2+100]  $S1 Load word from memory location to register StoresSxxRt, memory_address e.g.SB$S1,100($S2) $S1  Memory[$S2+100] Store byte from register to memory location

ECE 4436ECE 5367 Loading from Memory to Register Load  get contents of appropriate # of bytes from memory starting at address memadd and put into register Rt starting with low order.  if # of bytes < 4, then fill high order with 0’s or sign as indicated by instruction Note: loads always affect the entire register! (=> sign extension)

ECE 4436ECE 5367 Loading from Memory to Register List of load instructions LW load word (4 bytes) LH load half word (2bytes) -- fill high order with sign LHU load half word (2bytes) -- fill high order with 0’s LB load byte (1 byte) -- fill high order with sign LBU load byte (1 byte) -- fill high order with 0’s

ECE 4436ECE 5367 Storing from Register to Memory Store  List of store instructions SWstore word (4 bytes) SHstore half word (2bytes) SBstore byte (1 byte) Store appropriate # of bytes from Rt, (starting with low order) into memory starting at address memadd

ECE 4436ECE 5367 Sign Extension for Value Preservation Sign extension is required to preserve value when moving a 2’s complement number from a smaller cell to larger cell. Why? Given: 16 bit register (for simplicity) Want to store -7 in the register What is -7 in 4-bit 2’s complement binary? How do we store it in 16 bits?

ECE 4436ECE 5367 Sign Extension for Value Preservation Some examples: Ex. 1: -1 in 8 bits= -1 in 32 bits = Ex. 2: -7 in 8 bits = -7 in 32 bits =

ECE 4436ECE 5367 Sign Extension for Value Preservation Example 3: in 8 bits = in 32 bits =

ECE 4436ECE 5367 Sign Extension for Value Preservation When moving a 2’s complement # from an m- bit cell to an n-bit cell where n>m, the value is preserved if bits x n-1...x m are set to all 0’s if x is positive (x m-1 =0) all 1’s if x is negative (x m-1 =1) Another way to say: 2’s complement #’s preserve value when the sign is extended. (i.e. Copy bit x m-1 into x n-1...x m )

ECE 4436ECE 5367 Loading and Storing using Direct Mode Address known at load time (before execution) Ex:.data a:.wordOx1 b:.wordOxFFFFFFFF c:.halfOx7890 d:.halfOxABCD e:.byteOx10 f:.byteOxEE g:.word0 Addr.ValueAddr.Value 0D 1E 2F A17 B18 C19

ECE 4436ECE 5367 Loading and Storing using Direct Mode LW$t0,a SW$t0,g LH$t1,d LHU$t2,d LH$t3,c SB$t1,e LB$t4,f SW$t4,b

ECE 4436ECE 5367 Loading and Storing using Direct Mode Legal LB $t0,a SH $t0,e LW $t0,e (Not good programming) Illegal LW $t0,f SW $t0,d SH $t0,f Note: Assembly language does not care about declarations, only alignment

ECE 4436ECE 5367 Quick Review Part 1 Memory Allocation/Initialization.data a:.wordOx56 c:.halfOx7623 e:.byteOx10 g:.word0