Lecture 5: MIPS Instruction Set

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
MIPS assembly. Review  Lat lecture, we learnt  addi,  and, andi, or, ori, xor, xori, nor,  beq, j, bne  An array is stored sequentially in the memory.
CS/COE0447 Computer Organization & Assembly Language
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /15/2013 Lecture 11: MIPS-Conditional Instructions Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER.
Lecture 6: MIPS Instruction Set Today’s topic –Control instructions –Procedure call/return 1.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 5 MIPS ISA & Assembly Language Programming.
ELEN 468 Advanced Logic Design
Chapter 2 Instructions: Language of the Computer
ENEE350 Spring07 1 Ankur Srivastava University of Maryland, College Park Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005.”
Computer Architecture CPSC 321 E. J. Kim. Overview Logical Instructions Shifts.
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.
CS 300 – Lecture 6 Intro to Computer Architecture / Assembly Language Instructions.
MIPS Instruction Set Advantages
ISA-2 CSCE430/830 MIPS: Case Study of Instruction Set Architecture CSCE430/830 Computer Architecture Instructor: Hong Jiang Courtesy of Prof. Yifeng Zhu.
Lecture 7: MIPS Instruction Set Today’s topic –Procedure call/return –Large constants Reminders –Homework #2 posted, due 9/17/
Computer Architecture Instruction Set Architecture Lynn Choi Korea University.
Lecture 15: 10/24/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Lecture 4: MIPS Instruction Set Reminders: –Homework #1 posted: due next Wed. –Midterm #1 scheduled Friday September 26 th, 2014 Location: TODD 430 –Midterm.
COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer Science York University Handout # 3: MIPS Instruction Set I Topics: 1.
1 Branches and Procedure Calls Lecture 14 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
Lecture 4: MIPS Instruction Set
Computer Architecture CSE 3322 Lecture 2 NO CLASS MON Sept 1 Course WEB SITE crystal.uta.edu/~jpatters.
IFT 201: Unit 1 Lecture 1.3: Processor Architecture-3
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /08/2013 Lecture 10: MIPS Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL STATE.
MIPS coding. Review Shifting – Shift Left Logical (sll) – Shift Right Logical (srl) – Moves all of the bits to the left/right and fills in gap with 0’s.
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
9/29: Lecture Topics Conditional branch instructions
Chapter 2 CSF 2009 The MIPS Assembly Language. Stored Program Computers Instructions represented in binary, just like data Instructions and data stored.
MS108 Computer System I Lecture 3 ISA Prof. Xiaoyao Liang 2015/3/13 1.
Computer Organization CS224 Fall 2012 Lessons 7 and 8.
EET 4250 Instruction Representation & Formats Acknowledgements: Some slides and lecture notes for this course adapted from Prof. Mary Jane Penn.
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 9 Binary Representation and Logical Operations.
CDA 3101 Spring 2016 Introduction to Computer Organization
Computer Organization Instructions Language of The Computer (MIPS) 2.
CS Computer Organization Numbers and Instructions Dr. Stephen P. Carl.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Yaohang Li.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
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.
Computer Architecture Instruction Set Architecture
MIPS Instruction Set Advantages
COMPUTER ARCHITECTURE & OPERATIONS I
Computer Architecture Instruction Set Architecture
Morgan Kaufmann Publishers
MIPS Coding Continued.
Lecture 4: MIPS Instruction Set
ELEN 468 Advanced Logic Design
Computer Architecture & Operations I
CS170 Computer Organization and Architecture I
The University of Adelaide, School of Computer Science
MIPS coding.
Instructions - Type and Format
Lecture 4: MIPS Instruction Set
Computer Architecture & Operations I
MIPS Instruction Encoding
ECE232: Hardware Organization and Design
MIPS Instruction Encoding
Instruction encoding The ISA defines Format = Encoding
Lecture 5: Procedure Calls
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Computer Architecture
COMS 361 Computer Organization
COMS 361 Computer Organization
MIPS Assembly.
MIPS Coding Continued.
MIPS coding.
MIPS assembly.
MIPS instructions.
Presentation transcript:

Lecture 5: MIPS Instruction Set Morgan Kaufmann Publishers April 10, 2017 Lecture 5: MIPS Instruction Set Today’s topic More MIPS Instructions Procedure call/return Reminder Homework #1 posted: due 9/10 Course website http://eecs.wsu.edu/~hassan/cs260/ http://eecs.wsu.edu/~hassan/ Click on courses Chapter 1 — Computer Abstractions and Technology

Memory Operands Values must be fetched from memory before (add and sub) instructions can operate on them Load word lw $t0, memory-address Store word sw $t0, memory-address How is memory-address determined? Memory Register Memory Register

… Memory Address The compiler organizes data in memory… it knows the location of every variable (saved in a table)… it can fill in the appropriate mem-address for load-store instructions int a, b, c, d[10] … Memory Base address

Immediate Operands An instruction may require a constant as input An immediate instruction uses a constant number as one of the inputs (instead of a register operand) addi $s0, $zero, 1000 # the program has base address # 1000 and this is saved in $s0 # $zero is a register that always # equals zero addi $s1, $s0, 0 # this is the address of variable a addi $s2, $s0, 4 # this is the address of variable b addi $s3, $s0, 8 # this is the address of variable c addi $s4, $s0, 12 # this is the address of variable d[0]

Memory Instruction Format The format of a load instruction: destination register source address lw $t0, 8($t3) any register a constant that is added to the register in brackets

Example Convert to assembly: C code: d[3] = d[2] + a; Assembly: # addi instructions as before lw $t0, 8($s4) # d[2] is brought into $t0 lw $t1, 0($s1) # a is brought into $t1 add $t0, $t0, $t1 # the sum is in $t0 sw $t0, 12($s4) # $t0 is stored into d[3] Assembly version of the code continues to expand!

Recap – Numeric Representations Decimal 3510 = 3 x 101 + 5 x 100 Binary 001000112 = 1 x 25 + 1 x 21 + 1 x 20 Hexadecimal (compact representation) 0x23 or 23hex = 2 x 161 + 3 x 160 0-15 (decimal)  0-9, a-f (hex) Dec Binary Hex 0 0000 00 1 0001 01 2 0010 02 3 0011 03 Dec Binary Hex 4 0100 04 5 0101 05 6 0110 06 7 0111 07 Dec Binary Hex 8 1000 08 9 1001 09 10 1010 0a 11 1011 0b Dec Binary Hex 12 1100 0c 13 1101 0d 14 1110 0e 15 1111 0f

Instruction Formats Instructions are represented as 32-bit numbers (one word), broken into 6 fields R-type instruction add $t0, $s1, $s2 000000 10001 10010 01000 00000 100000 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits op rs rt rd shamt funct opcode source source dest shift amt function I-type instruction lw $t0, 32($s3) 6 bits 5 bits 5 bits 16 bits opcode rs rt constant

Logical Operations Logical ops C operators Java operators MIPS instr Shift Left << << sll Shift Right >> >>> srl Bit-by-bit AND & & and, andi Bit-by-bit OR | | or, ori Bit-by-bit NOT ~ ~ nor

Control Instructions Conditional branch: Jump to instruction L1 if register1 equals register2: beq register1, register2, L1 Similarly, bne and slt (set-on-less-than) Unconditional branch: j L1 jr $s0 (useful for large case statements and big jumps) Convert to assembly: if (i == j) f = g+h; else f = g-h;

Control Instructions Conditional branch: Jump to instruction L1 if register1 equals register2: beq register1, register2, L1 Similarly, bne and slt (set-on-less-than) Unconditional branch: j L1 jr $s0 (useful for large case statements and big jumps) Convert to assembly: if (i == j) bne $s3, $s4, Else f = g+h; add $s0, $s1, $s2 else j Exit f = g-h; Else: sub $s0, $s1, $s2 Exit:

Example Convert to assembly: while (save[i] == k) i += 1; i and k are in $s3 and $s5 and base of array save[] is in $s6

Example Convert to assembly: while (save[i] == k) i and k are in $s3 and $s5 and base of array save[] is in $s6 Loop: sll $t1, $s3, 2 add $t1, $t1, $s6 lw $t0, 0($t1) bne $t0, $s5, Exit addi $s3, $s3, 1 j Loop Exit: