Lecture 13: 10/8/2002CS170 Fall 20021 CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.

Slides:



Advertisements
Similar presentations
Goal: Write Programs in Assembly
Advertisements

Review of the MIPS Instruction Set Architecture. RISC Instruction Set Basics All operations on data apply to data in registers and typically change the.
Instruction Set-Intro
Lecture 20: 11/12/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
1 ECE462/562 ISA and Datapath Review Ali Akoglu. 2 Instruction Set Architecture A very important abstraction –interface between hardware and low-level.
1 ECE369 ECE369 Chapter 2. 2 ECE369 Instruction Set Architecture A very important abstraction –interface between hardware and low-level software –standardizes.
ECE 232 L6.Assemb.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 6 MIPS Assembly.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 5: Data Transfer Instructions / Control Flow Instructions Partially adapted from Computer.
SPIM and MIPS programming
Systems Architecture Lecture 5: MIPS Instruction Set
Chapter 2 Instructions: Language of the Computer
Chapter 2.
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson slides3.ppt Modification date: March 16, Addressing Modes The methods used in machine instructions.
Inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 6 – Introduction to MIPS Data Transfer & Decisions I Pieter Abbeel’s recent.
Chap.2: Instructions: Language of the computer Jen-Chang Liu, Spring 2006 Adapted from
CS61C L09 Introduction to MIPS: Data Transfer & Decisions I (1) Garcia © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
CS 61C L09 Introduction to MIPS: Data Transfer & Decisions I (1) Garcia, Fall 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
Elec2041 lec-11-mem-I.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 11: Memory Access - I
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 4: Arithmetic / Data Transfer Instructions Partially adapted from Computer Organization.
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
CS61C L09 Introduction to MIPS : Data Transfer and Decisions (1) Garcia, Spring 2007 © UCB Lecturer SOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
CS 300 – Lecture 6 Intro to Computer Architecture / Assembly Language Instructions.
9/29: Lecture Topics Memory –Addressing (naming) –Address space sizing Data transfer instructions –load/store on arrays on arrays with variable indices.
Topic 8: Data Transfer Instructions CSE 30: Computer Organization and Systems Programming Winter 2010 Prof. Ryan Kastner Dept. of Computer Science and.
MIPS assembly. Computer What’s in a computer? Processor, memory, I/O devices (keyboard, mouse, LCD, video camera, speaker), disk, CD drive, …
CDA 3101 Fall 2012 Introduction to Computer Organization Instruction Set Architecture MIPS Instruction Format 04 Sept 2013.
CSE331 W02.1Irwin Fall 2001 PSU Computer Architecture Discussion Lecture # 2 MIPS Programming.
Lecture 18: 11/5/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Lecture 15: 10/24/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Lecture 19: 11/7/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Computer Organization and Architecture Instructions: Language of the Machine Hennessy Patterson 2/E chapter 3. Notes are available with photocopier 24.
CWRU EECS 3221 Language of the Machine EECS 322 Computer Architecture Instructor: Francis G. Wolff Case Western Reserve University.
Computer Architecture CSE 3322 Lecture 2 NO CLASS MON Sept 1 Course WEB SITE crystal.uta.edu/~jpatters.
Chapter 2 — Instructions: Language of the Computer — 1 Memory Operands Main memory used for composite data – Arrays, structures, dynamic data To apply.
Arrays in MIPS Assembly Computer Organization and Assembly Language: Module 6.
Lecture 2: Instruction Set Architecture part 1 (Introduction) Mehran Rezaei.
Computer Organization Instructions Language of The Computer (MIPS) 2.
MIPS assembly. Computer  What’s in a computer?  Processor, memory, I/O devices (keyboard, mouse, LCD, video camera, speaker), disk, CD drive, …
Lecture 16: 10/29/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Assembly Variables: Registers Unlike HLL like C or Java, assembly cannot use variables – Why not? Keep Hardware Simple Assembly Operands are registers.
May 22, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 14: A Simple Implementation of MIPS * Jeremy R. Johnson Mon. May 17, 2000.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Lecture 17: 10/31/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Computer Architecture & Operations I
Computer Architecture & Operations I
CS2100 Computer Organisation
Instruction Set Architecture
Morgan Kaufmann Publishers
MIPS Assembly.
CS170 Computer Organization and Architecture I
Instructions - Type and Format
CS170 Computer Organization and Architecture I
Computer Programming Machine and Assembly.
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
CS149D Elements of Computer Science
The University of Adelaide, School of Computer Science
Systems Architecture Lecture 5: MIPS Instruction Set
MIPS assembly.
Systems Architecture I
Computer Instructions
Computer Architecture
3.
CS170 Computer Organization and Architecture I
COMS 361 Computer Organization
COMS 361 Computer Organization
COMS 361 Computer Organization
Review In last lecture, done with unsigned and signed number representation. Introduced how to represent real numbers in float format.
CPU Structure CPU must:
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
9/27: Lecture Topics Memory Data transfer instructions
Presentation transcript:

Lecture 13: 10/8/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture 13: 10/8/2002

CS170 Fall Outline MIPS introduction with simple examples Should cover sections 3.1 – 3.3

Lecture 13: 10/8/2002CS170 Fall MIPS General-purpose registers ISA Load/Store ISA operands of arithmetic instructions must be in registers Register size is 32 bits In MIPS, 32 bits are called a word Uses two characters following a dollar sign to represent a register $s0, $s1,..: registers that correspond to variables in high-level language program $t0, $t1,..: temporary registers used to hold any intermediate results Will see some more notations and special purpose registers

Lecture 13: 10/8/2002CS170 Fall C Assignment using Registers C Assignment statement f = (g + h) – (i +j); Compiler associates program variables with registers Variables f, g, h, i, and j can be assigned to registers $s0, $s1, $s2, $s3, and $s4 What is the compiled MIPS assembly code? add $t0, $s1, $s2# register $t0 contains g+h add $t1, $s3, $s4# register $t1 contains I+j sub $s0, $t0, $t1# f gets $t0 - $t1 Comments Operation with 3 operands

Lecture 13: 10/8/2002CS170 Fall Complex Structures: Arrays Contains a number of elements instead of a single element Can be 1-dimensional or 2-dimensional Arrays are kept in memory due to register size limitations. Array stored starting at base address Arithmetic operation on an array element load array element into register Data transfer instructions  access a word in memory  Need to supply memory address COPYRIGHT 1998 MORGAN KAUFMANN PUBLISHERS, INC. ALL RIGHTS RESERVED Address of third data element is 2 Contents of Memory[2] is 10

Lecture 13: 10/8/2002CS170 Fall Data from Memory to Register Data transfer instruction: load Formatlw register to be loaded, constant(register used to access memory) Memory address formed by adding constant portion and contents of second register Examplelw $t0, 8($s3)# $t0  Mem[8+$s3] Compiling an assignment when an operand is in memory Assume A is an array of 100 words. Compiler associated variables g and h with registers $s1 and $s2 Base address of array is in $s3. The statement g = h + A[8]; MIPS assembly code? lw $t0, 32($s3)# $t0  A[8], Why constant is 32? add $s1, $s2, $t0# g = h + A[8]

Lecture 13: 10/8/2002CS170 Fall Byte Addressing Most architectures address individual bytes Address of a word matches address of one of the 4 bytes within the word Words start at addresses that are multiple of 4 in MIPS (alignment restriction) MIPS uses Big Endian (address of leftmost byte is word address) COPYRIGHT 1998 MORGAN KAUFMANN PUBLISHERS, INC. ALL RIGHTS RESERVED Actual MIPS addresses are shown in figure Byte address of third word is 8 A[8] is 9 th element in array, with each element 4 bytes Leftmost byte of A[8] is located 32 bytes away from base address ( 8 *4) lw $t0, 32($s3)

Lecture 13: 10/8/2002CS170 Fall Data from Register to Memory Data transfer instruction: store Formatsw register to be stored, offset(base register) Memory address formed by adding offset and contents of base register Examplesw $t0, 48($s3)# $t0  Mem[48+$s3] Compiling using Load and Store Assume A is an array of 100 words. Compiler associated variables h with register $s2 Base address of array is in $s3. The statement A[12] = h + A[8]; MIPS assembly code? lw $t0, 32($s3)# $t0  A[8] add $t0, $s2, $t0# $t0  h + A[8] sw $t0,48($s3)# $t0  Mem[48+$s3]

Lecture 13: 10/8/2002CS170 Fall Another example: Variable Array Index Assume A is an array of 100 words. Compiler associated variables g, h, and i with register $s1, $s2, and $s4 Base address of array is in $s3. The statement g = h + A[i]; MIPS assembly code? add $t1, $s4, $s4# $t1  2*i add $t1, $t1, $t1# $t1  4*i add $t1, $t1, $s3# $t1  base + offset lw $t0,0($t1)# $t0  Mem[0+$t1] add $s1, $s2, $t0# g = h + A[i] Need to load A[i] into register, need its address To get address, need to multiply i by 4 to get offset of element i from base address (byte addressing issues) 4* i = 2i + 2i

Lecture 13: 10/8/2002CS170 Fall Spilling Registers Programs have more variables than machines have registers Compiler tries to  keep most frequently used variables in registers  place rest in memory  use loads and stores to move variables between registers and memory Spilling variables process of putting less commonly used variables (or those needed later) into memory

Lecture 13: 10/8/2002CS170 Fall MIPS Instruction Set so far Fig. 3.4 page 116 Why 2 30 memory words? A word is 32 bits. Memory address is 32 bits Number of bytes that can be addressed is 2 32 (byte 0, byte 1, …., byte 2 32 –1) bytes = 4 GB (How?) 4 bytes per word Number of words = 2 32 /4 = 2 30 words