1 Lecture 3a: Supplemental Notes for Chapter 3 CS 447 Jason Bakos.

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

The University of Adelaide, School of Computer Science
Lecture 4. MIPS Instructions #3 Branch Instructions Prof. Taeweon Suh Computer Science Education Korea University ECM534 Advanced Computer Architecture.
1 Lecture 4: Procedure Calls Today’s topics:  Procedure calls  Large constants  The compilation process Reminder: Assignment 1 is due on Thursday.
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.
Computer Architecture CSCE 350
1 Nested Procedures Procedures that don't call others are called leaf procedures, procedures that call others are called nested procedures. Problems may.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /17/2013 Lecture 12: Procedures Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.
The University of Adelaide, School of Computer Science
Apr. 12, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 6: Branching and Procedures in MIPS* Jeremy R. Johnson Wed. Apr. 12, 2000.
MIPS Assembly Language
Comp Sci instruction encoding 1 Instruction Encoding MIPS machine language Binary encoding of instructions MIPS instruction = 32 bits Three instruction.
Chapter 3: Instructions
Computer Structure - The Instruction Set (2) Goal: Implement Functions in Assembly  When executing a procedure (function in C) the program must follow.
S. Barua – CPSC 440 CHAPTER 2 INSTRUCTIONS: LANGUAGE OF THE COMPUTER Goals – To get familiar with.
RISC Concepts, MIPS ISA and the Mini–MIPS project
Fall 2003SYCS-401 Operating Systems Instruction Set Architecture An overview of MIPS R3000 assembly language.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
Lecture 5: Procedures. Function call book-keeping in C main() { int i,j,k,m;... i = mult(j,k);... m = mult(i,i);... } /* really dumb mult function */
Lecture 7: MIPS Instruction Set Today’s topic –Procedure call/return –Large constants Reminders –Homework #2 posted, due 9/17/
CS224 Fall 2011 Chapter 2b Computer Organization CS224 Fall 2011 Chapter 2 b With thanks to M.J. Irwin, D. Patterson, and J. Hennessy for some lecture.
13/02/2009CA&O Lecture 04 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
Lecture 8. MIPS Instructions #3 – Branch Instructions #1 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System Education.
Adapted from Computer Organization and Design, Patterson & Hennessy, UCB ECE232: Hardware Organization and Design Part 7: MIPS Instructions III
Lecture 19: 11/7/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
11/02/2009CA&O Lecture 03 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
6.S078 - Computer Architecture: A Constructive Approach Introduction to SMIPS Li-Shiuan Peh Computer Science & Artificial Intelligence Lab. Massachusetts.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
Procedure (Method) Calls Ellen Spertus MCS 111 September 25, 2003.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
Lecture 4: MIPS Instruction Set
Computer Architecture CSE 3322 Lecture 4 crystal.uta.edu/~jpatters/cse3322 Assignments due 9/15: 3.7, 3.9, 3.11.
Chapter 2 CSF 2009 The MIPS Assembly Language. Stored Program Computers Instructions represented in binary, just like data Instructions and data stored.
Computer Organization CS224 Fall 2012 Lessons 7 and 8.
Computer Architecture CSE 3322 Lecture 4 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/10/09
MIPS Assembly Language Chapter 13 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
Chapter 2 — Instructions: Language of the Computer — 1 Conditional Operations Branch to a labeled instruction if a condition is true – Otherwise, continue.
MIPS Assembly Language Chapter 15 S. Dandamudi To be used with S. Dandamudi, “Fundamentals of Computer Organization and Design,” Springer, 2003.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 11 Conditional Operations.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 12 Procedure Calling.
Control Flow and Arrays COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum.
Lecture 4. MIPS Instructions #3 Branch Instructions Prof. Taeweon Suh Computer Science & Engineering Korea University COSE222, COMP212 Computer Architecture.
Computer Architecture & Operations I
Rocky K. C. Chang Version 0.1, 25 September 2017
Computer Science 210 Computer Organization
Prof. Hsien-Hsin Sean Lee
Computer Organization and Design Assembly & Simulation
CSCI206 - Computer Organization & Programming
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Adventures in Assembly Land
Pick up the handout on your way in!!
CSCI206 - Computer Organization & Programming
Control Flow and Arrays
MIPS Instructions.
CSCI206 - Computer Organization & Programming
The University of Adelaide, School of Computer Science
Computer Organization and Design Assembly & Simulation
Instruction encoding The ISA defines Format = Encoding
Lecture 5: Procedure Calls
Chapter 2 Instructions: Language of the Computer part 2
The University of Adelaide, School of Computer Science
Flow of Control -- Conditional branch instructions
Lecture 6: Assembly Programs
Assembly and Simulation
Flow of Control -- Conditional branch instructions
Computer Architecture
Adventures in Assembly Land
Adventures in Assembly Land
Control Flow and Arrays
Presentation transcript:

1 Lecture 3a: Supplemental Notes for Chapter 3 CS 447 Jason Bakos

2 Review of Branch Instructions b –Unconditional branch –Pseudoinstruction beq,, –Branch if equal bgez, label –Branch if greater than or equal 0 bgezal, label –Branch if greater than or equal 0 and link 4r1r2offset r11offset r10x11offset 65516

3 Review of Branch Instructions bgtz, –Branch if greater than zero blez, –Branch if less than or equal 0 bltzal, label –Branch if less than 0 and link bltz, label –Branch if less than 0 7r10offset r10offset r10x10offset r10offset 65516

4 Review of Branch Instructions bne,, –Branch if not equal beqz, –Branch if equal 0 –Pseudoinstruction bge,, label –Branch if greater than or equal –Pseudoinstruction bgeu,, label –Branch if greater than or equal unsigned –Pseudoinstruction 5r1r2offset 65516

5 Review of Branch Instructions bgt,, –Branch if greater than –Pseudoinstruction bgtu,, –Branch if greater than unsigned –Pseudoinstruction blte,, label –Branch if less than or equal –Pseudoinstruction blteu,, label –Branch if less than or equal unsigned –Pseudoinstruction

6 Review of Branch Instructions blt,, –Branch if less than –Pseudoinstruction bltu,, –Branch if less than unsigned –Pseudoinstruction bnez, label –Branch if not equal zero –Pseudoinstruction

7 Notes on Branch Instructions Offset field represents offset in instruction words (bytes/4) –starting from the next instruction next instruction would be offset 0 can be negative (as can offset in load/store) Branch pseudoinstructions assemble into the equivalent comparison instruction followed by a bgtz And-link instructions load the address of the next instruction into $31 ($ra) if the branch is taken

8 Notes on Comparison Instructions There is a comparison instruction for every conditional branch instruction –They work just like the conditional branch instructions, but instead, if the comparison is evaluated true, the destination register is set to the value 1, and 0 otherwise slt and sltu follow the R-type format Comparison instructions aren’t really useful, except for slti and sltiu (unsigned), which are immediate comparison instructions –They follow the I-type format –Immediates are sign-extended!!! –Use these, followed by a bltz to compare a register and immediate and branch based on result seq, sge, sgeu, sgt, sgtu, sle, sleu, sne are pseudoinstructions

9 Jump Instructions j –Unconditional jump (used when b instruction is used) jal –Jump and link (used for procedure call) jalr, –Jump and link register (same as above, but links into r2) jr –Jump register (used to return from a procedure) 2target 626 3target 626 0r10r r100x

10 Notes on Pseudodirect Addressing j and jal use pseudodirect addressing –To compute the effective branch target address, the MS 6 bits of the PC are added to the address in the instruction

11 A More Robust Procedure Calling Convention We’ll use $a0-$a3 to pass parameters to a procedure We’ll use $v0 and $v1 for procedure returns We want to save $s0-$s7 across procedure calls We want to be able to have multiple levels of procedure calls and we want to be able to call procedures recursively –This means we need to somehow save arguments, state registers, and return addresses for each procedure call

12 A More Robust Procedure Calling Convention Solution: Use a stack! When each procedure is called, push arguments, return address, and saved registers onto a stack NOTE: The stack frames can be FIXED size using this convention To create a better procedure calling convention, we would also allow for variable numbers of arguments and local variable storage on the stack, but we will make this simpler

13 A More Robust Procedure Calling Convention For calling procedures: –Caller must move arguments into argument registers and jal to procedure –Callee must save arguments, return address, and machine state (registers) on stack, and decrement $sp by 13*4=52 $sp always points to next stack position stack grows down –Upon completion, callee must set the return value register(s), restore the $s registers, restore $ra, increment $sp by 52, and jump back to the caller $sp is already initialized when you start your program

14 More Notes You can use whatever procedure calling convention you want in your programs, but I recommend using this one Your programs’ procedures will share a static memory space (no scope) –In order to implement scope, we’d have to allocate local space on the stack