Exceptions, MIPS-Style
|
|
- Juniper Beasley
- 6 years ago
- Views:
Transcription
1 Exceptions, MIPS-Style Reminder: MIPS CPU deals with exceptions. Interrupts are just a special case of exceptions. The MIPS Architecture has no interrupt-vector table! All exceptions trigger a jump to the same location, demultiplexing happens in the exception hler, after looking up the reason for the exception in the CAUSE register. exception exception hler specific service routine Exception Hling MIPS-Style (I): Data Structures /* /* DATA STRUCTURES /* typedef enum {Int = 0, Mod = 1, TLBL = 2, TLBS = 3, AdEL = 4, AdES = 5, IBE = 6, DBE = 7, Syscall = 8, Bp = 9, RI = 10, CpU = 11, Ov = 12, TRAP = 13, VCEI = 14, FPE = 15, C2E = 16, Watch = 23, VCED = 31 EXCEPTION_CODE; typedef unsigned int reg_t; typedef struct xcptcontext { /* This is the exception context frame that is passed to the exception hlers. It gets filled in by the low-level exception hler in "machine.s". An assembler version of this structure can be found at the bottom of "machine.h". reg_t ; /* Status Register reg_t cr; /* Cause Register reg_t epc; /* PC at time of exception. reg_t vaddr; reg_t regs[32]; /* Copy of all general purpose registers reg_t mdlo; /* HI/LO registers (used for memory management) reg_t mdhi; reg_t count; /* Timer registers reg_t compare; struct xcptcontext * prev; /* To link exceptions. (unused for now) unsigned xcss; /* Priority css of this exception. (unused for now). EXCEPTION_CONTEXT; 1
2 Exception Hling MIPS-Style (II): Set-up Frame LEAF().set noreorder.set noat /* Note: exceptions do not save k0 k1. * on entry, k1 = exception css. /* save exception css in memory k0, css sw k1, 0(k0) # had better not trap! move k0, zero # now boot exception will abort. /* allocate excepti frame (on 8-byte boundary) subu k1, sp, XCP_SIZE l k1, 3 /* shift right/left -> alligned on boundary sll k1, 3 Exception Hling MIPS-Style (III): Save Registers /* AT, XCP_AT(k1) v0, XCP_V0(k1) v1, XCP_V1(k1) a0, XCP_A0(k1) a1, XCP_A1(k1) a2, XCP_A2(k1) a3, XCP_A3(k1) sp, XCP_SP(k1) ra, XCP_RA(k1) /* get coprocessor 0 exception state mfc0 a0, CPU0_CR mfc0 a1, CPU0_SR mfc0 a2, CPU0_VADDR mfc0 a3, CPU0_EPC /* we can safely use AT now.set at /* switch to using sp to point at exception frame move sp, k1 /* we skip saving of watchpoint registers /* stash exception css lw v0, css /* nothing sensible to store for k0/k1, store zero zero, XCP_K0(sp) zero, XCP_K1(sp) 2
3 Exception Hling MIPS-Style (IV): Save More Registers /* we have finished with the uninterruptible code. * (using k0/k1, saving exception state), so * we can permit nested exceptions ; however, we cannot * permit device interrupts until the interrupt hler * does its prioritization sets SR_IMASK. k0, # restore rom boot exception hook v0, a1, ~(SR_IMASK SR_EXL SR_KSU_MASK) mtc0 v0, CPU0_SR.set reorder /* we are now interruptible: dump all remaining state * into the excepti frame. /* coprocessor exception state a0, XCP_CR(sp) a1, XCP_SR(sp) a2, XCP_VADDR(sp) a3, XCP_EPC(sp) /* timer data mfc0 a0, CPU0_COUNT mfc0 a1, CPU0_COMPARE a0, XCP_COUNT(sp) a1, XCP_COMPARE(sp) /* mdhi mdlo mfhi v0 mflo v1 v0, XCP_MDHI(sp) v1, XCP_MDLO(sp) Exception Hling MIPS-Style (V) /* Save all the other general registers. * We save zero, s0-s7 s8 as well, as instruction emutors (e.g. FP * operations) debuggers rely on all registers stored together in * well-defined structure. zero, XCP_ZERO(sp) t0, XCP_T0(sp) t7, XCP_T7(sp) s0, XCP_S0(sp) s7, XCP_S7(sp) t8, XCP_T8(sp) t9, XCP_T9(sp) gp, XCP_GP(sp) s8, XCP_S8(sp) /* I don't know what the following does. [rb] /* load our _gp pointer gp, _gp 3
4 Exception Hling MIPS-Style (VI) /* call the C exception hler move a0, sp # arg1 = &xcp subu sp, 16 # (arg save area) move ra, zero # fake return address b _xcptcall /* This strange call to _xcptcall with zero return address is to * help exception-aware debuggers to trace back over the exception event. * We are basically interposing a bogus stackframe (with a zero return * address) between the C exception hler the actual machine * exception. xcptrest:.set noat add AT, sp, 16 /* at points to exception frame LEAF(_xcptcall) /* on entry: a0 == &xcp subu sp, 24 ra, 16(sp) /* punt out to _xcpt_deliver jal _xcpt_deliver ra, 16(sp) addu sp, 24 beqz ra, xcptrest j ra END(_xcptcall) /* This function gets called by the low-level exception hler. ::dispatch(_xcp); /* end of _xcpt_deliver Exception Hling MIPS-Style (VII): Restore Registers xcptrestother: /* restore all state /* restore most general registers t0, XCP_T0(AT) t7, XCP_T7(AT) s0, XCP_S0(AT) s7, XCP_S7(AT) t8, XCP_T8(AT) t9, XCP_T9(AT) gp, XCP_GP(AT) s8, XCP_S8(AT) /* mdhi mdlo v0, XCP_MDHI(AT) v1, XCP_MDLO(AT) mthi v0 mtlo v1 /* remaining general registers a0, XCP_A0(AT) a1, XCP_A1(AT) a2, XCP_A2(AT) a3, XCP_A3(AT) ra, XCP_RA(AT) /* restore the exception-time status register, which has the * side effect of disabling interrupts..set noreorder v0, XCP_SR(AT) 4
5 Exception Hling MIPS-Style (VIII): Return /* in the following we do some magic address pipeline effects when updating the control register. #clear SR_IMASK before setting SR_EXL (nasty window) li v1, ~(SR_IMASK SR_EXL) v1, v0 mtc0 v1, CPU0_SR or v0, SR_EXL v1, XCP_V1(AT) mtc0 v0, CPU0_SR v0, XCP_V0(AT) sp, XCP_SP(AT) /* we are not uninterruptible can use k1 safely k1, XCP_EPC(AT) AT, XCP_AT(AT) mtc0 k1, CPU0_EPC eret.set reorder.set at END() Initialize MIPS Low-Level Exception Hler /* Macro to copy exception hler to unchached low memory #define XCPTCOPY(offs, start, end) \ li t0, KSEG1_BASE+offs ; \ t1, start ; \ t2, end ; \ 1: lw t3, 0(t1) ; \ addu t1, 4 ; \ sw t3, 0(t0) ; \ addu t0, 4 ; \ bne t1, t2, 1b LEAF(_xcptlow_init) /* disable all interrupts mfc0 t4, CPU0_SR t4, ~SR_IE mtc0 t4, CPU0_SR _xcptlowstart: j _xcptlowend:.text.set noat.set noreorder.set reorder.set at k1, k1 XCPTCOPY(0x180, _xcptlowstart, _xcptlowend) lw beqz t0, _ram_based t0, 1f /* using RAM-based hlers, so switch off boot exceptions t4, ~SR_BEV mtc0 t4, CPU0_SR 1: k0, j ra END(_xcptlow_init) 5
6 High-Level Exception Hling /* This function gets called by the low-level exception hler. ::dispatch(_xcp); /* end of _xcpt_deliver Default Memory InterruptDispatcher Default Clock High-Level Exception Hling /* This function gets called by the low-level exception hler. ::dispatch(_xcp); /* end of _xcpt_deliver int ::dispatch(exception_context * _xcp) { /* -- RETRIEVE EXCEPTION CODE int xcp_code; xcp_code = (_xcp->cr & CR_EXCCODE) >> 2; Default Console::putstr("EXCEPTION DISPATCHER: xcp_code = "); Console::putint((int)xcp_code); Console::putstr("\n"); Memory assert(xcp_code >= InterruptDispatcher 0 && xcp_code < EXCEPTION_TABLE_SIZE); /* -- HAS A HANDLER BEEN REGISTERED FOR THIS CODE? * hler = hler_table[xcp_code]; /* -- IF SO, CALL THE HANDLER; OTHERWISE, CALL DEFAULT HANDLER. if (hler) { hler->hle_exception(_xcp); else { Default Clock /* --- NO DEFAULT HANDLER HAS BEEN REGISTERED. SIMPLY RETURN AN ERROR. Console::putstr("NO DEFAULT EXCEPTION HANDLER REGISTERED\n"); return -1; 6
7 High-Level Exception Hling int InterruptDispatcher::hle_exception(EXCEPTION_CONTEXT * _xcp) { /* This function gets called by the low-level exception hler. /* -- THE EXCEPTION IS IN RESPONSE TO AN INTERRUPT. ::dispatch(_xcp); /* --- DETERMINE THE PENDING INTERRUPTS /* end of _xcpt_deliver int interrupt_no = (_xcp->cr & CR_IP) >> 8; Console::putstr("InterruptDispatcher::hle_exception : interrupt_stat = "); Console::putint(interrupt_no); Console::putstr("\n"); /* --- DISPATCH THE INTERRUPT WITH THE HIGHEST NUMBER for (int i = 7 + MAX_INTERRUPTS; i > 7; i--) { if (_xcp->cr & (1 << i)) { Console::putstr("Interrupt No "); Console::putint(i-8); Console::putstr(" set.\n"); * interrupt_hler = interrupt_dispatch_table[i-8]; Default if (interrupt_hler) Memory { InterruptDispatcher Console::putstr("calling IDT->hle\n"); interrupt_hler->hle_exception(_xcp); else { if (default_interrupt_hler) { default_interrupt_hler->hle_exception(_xcp); else { /* ---- THERE IS NO HANDLER FOR THIS Default INTERRUPT Console::putstr("UNCAUGHT INTERRUPT\n"); /* InterruptDispatcher::hle_exception Clock 7
Exceptions and Interrupts
Exceptions and Interrupts Unexpected events (asynchronous interrupt) requiring change in flow of control (different ISAs use the terms differently) exception Arises within the CPU e.g., undefined opcode,
More informationCompiling Techniques
Lecture 10: An Introduction to MIPS assembly 18 October 2016 Table of contents 1 Overview 2 3 Assembly program template.data Data segment: constant and variable definitions go here (including statically
More informationLearning Outcomes. Understanding of the existence of compiler function calling conventions Including details of the MIPS C compiler calling convention
System Calls 1 Learning Outcomes Exposure architectural details of the MIPS R3000 Detailed understanding of the of exception handling mechanism From Hardware Guide on class web site Understanding of the
More informationECE 2035 Programming HW/SW Systems Fall problems, 7 pages Exam Two 23 October 2013
Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate
More informationLearning Outcomes. A high-level understanding of System Calls Mostly from the user s perspective From textbook (section 1.6)
System Calls 1 Learning Outcomes A high-level understanding of System Calls Mostly from the user s perspective From textbook (section 1.6) Exposure architectural details of the MIPS R3000 Detailed understanding
More informationTraps, Exceptions, System Calls, & Privileged Mode
Traps, Exceptions, System Calls, & Privileged Mode Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University P&H Chapter 4.9, pages 509 515, appendix B.7 Operating Systems 2 Control Transfers
More informationLearning Outcomes. System Calls. System Calls. The System Call Interface: A Brief Overview. System Calls. The Structure of a Computer System
Learning Outcomes System Calls Interface and Implementation A high-level understanding of System Call interface Mostly from the user s perspective From textbook (section.6) Understanding of how the application-kernel
More informationSystem Calls. Interface and Implementation
System Calls Interface and Implementation 1 Learning Outcomes A high-level understanding of System Call interface Mostly from the user s perspective From textbook (section 1.6) Understanding of how the
More informationEEC 483 Computer Organization
EEC 483 Computer Organization Chapter 3. Arithmetic for Computers Chansu Yu Table of Contents Ch.1 Introduction Ch. 2 Instruction: Machine Language Ch. 3-4 CPU Implementation Ch. 5 Cache and VM Ch. 6-7
More informationKernel Registers 0 1. Global Data Pointer. Stack Pointer. Frame Pointer. Return Address.
The MIPS Register Set The MIPS R2000 CPU has 32 registers. 31 of these are general-purpose registers that can be used in any of the instructions. The last one, denoted register zero, is defined to contain
More informationECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Two 11 March Your Name (please print) total
Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate
More informationMIPS Reference Guide
MIPS Reference Guide Free at PushingButtons.net 2 Table of Contents I. Data Registers 3 II. Instruction Register Formats 4 III. MIPS Instruction Set 5 IV. MIPS Instruction Set (Extended) 6 V. SPIM Programming
More informationQuestion 0. Do not turn this page until you have received the signal to start. (Please fill out the identification section above) Good Luck!
CSC B58 Winter 2017 Final Examination Duration 2 hours and 50 minutes Aids allowed: none Last Name: Student Number: UTORid: First Name: Question 0. [1 mark] Read and follow all instructions on this page,
More informationLearning Outcomes. Understanding of the existence of compiler function calling conventions Including details of the MIPS C compiler calling convention
System Calls 1 Learning Outcomes A high-level understanding of System Calls Mostly from the user s perspective From textbook (section 1.6) Exposure architectural details of the MIPS R3000 Detailed understanding
More informationLecture 11: Interrupt and Exception. James C. Hoe Department of ECE Carnegie Mellon University
18 447 Lecture 11: Interrupt and Exception James C. Hoe Department of ECE Carnegie Mellon University 18 447 S18 L11 S1, James C. Hoe, CMU/ECE/CALCM, 2018 Your goal today Housekeeping first peek outside
More informationSystem Calls. COMP s1
System Calls 1 Contents A high-level view of System Calls Mostly from the user s perspective From textbook (section 1.6) A look at the R3000 A brief overview Mostly focused on exception handling From Hardware
More informationSPIM Instruction Set
SPIM Instruction Set This document gives an overview of the more common instructions used in the SPIM simulator. Overview The SPIM simulator implements the full MIPS instruction set, as well as a large
More informationMIPS Instruction Set
MIPS Instruction Set Prof. James L. Frankel Harvard University Version of 7:12 PM 3-Apr-2018 Copyright 2018, 2017, 2016, 201 James L. Frankel. All rights reserved. CPU Overview CPU is an acronym for Central
More informationInstruction Set Architecture part 1 (Introduction) Mehran Rezaei
Instruction Set Architecture part 1 (Introduction) Mehran Rezaei Overview Last Lecture s Review Execution Cycle Levels of Computer Languages Stored Program Computer/Instruction Execution Cycle SPIM, a
More informationECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 23 October Your Name (please print clearly) Signed.
Your Name (please print clearly) This exam will be conducted according to the Georgia Tech Honor Code. I pledge to neither give nor receive unauthorized assistance on this exam and to abide by all provisions
More informationCSc 256 Midterm (green) Fall 2018
CSc 256 Midterm (green) Fall 2018 NAME: Problem 1 (5 points): Suppose we are tracing a C/C++ program using a debugger such as gdb. The code showing all function calls looks like this: main() { bat(5);
More informationThe Operating System (OS) MicroComputer Engineering OperatingSystem slide 1!
The Operating System (OS) MicroComputer Engineering OperatingSystem slide 1! The Operating System (OS) P1:! Editor! P2: Compiler! P3:! Quake! Arena! Operating System! MIPS! At any one time the processor
More informationReduced Instruction Set Computer (RISC)
Reduced Instruction Set Computer (RISC) Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of instructions of the machine. Reduced number of cycles needed per instruction.
More informationECE 2035 A Programming Hw/Sw Systems Fall problems, 8 pages Final Exam 8 December 2014
Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate
More informationMIPS Instruction Format
MIPS Instruction Format MIPS uses a 32-bit fixed-length instruction format. only three different instruction word formats: There are Register format Op-code Rs Rt Rd Function code 000000 sssss ttttt ddddd
More informationECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 21 October 2016
Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate
More informationECE232: Hardware Organization and Design. Computer Organization - Previously covered
ECE232: Hardware Organization and Design Part 6: MIPS Instructions II http://www.ecs.umass.edu/ece/ece232/ Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Computer Organization
More informationChapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont )
Chapter 2 Computer Abstractions and Technology Lesson 4: MIPS (cont ) Logical Operations Instructions for bitwise manipulation Operation C Java MIPS Shift left >>> srl Bitwise
More informationReduced Instruction Set Computer (RISC)
Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of instructions of the ISA. RISC Goals RISC: Simplify ISA Simplify CPU Design Better CPU Performance Motivated by simplifying
More informationMemory Usage 0x7fffffff. stack. dynamic data. static data 0x Code Reserved 0x x A software convention
Subroutines Why we use subroutines more modular program (small routines, outside data passed in) more readable, easier to debug code reuse i.e. smaller code space Memory Usage A software convention stack
More informationComputer Architecture Instruction Set Architecture part 2. Mehran Rezaei
Computer Architecture Instruction Set Architecture part 2 Mehran Rezaei Review Execution Cycle Levels of Computer Languages Stored Program Computer/Instruction Execution Cycle SPIM, a MIPS Interpreter
More informationComputer Architecture. The Language of the Machine
Computer Architecture The Language of the Machine Instruction Sets Basic ISA Classes, Addressing, Format Administrative Matters Operations, Branching, Calling conventions Break Organization All computers
More informationTraps, Exceptions, System Calls, & Privileged Mode!
Traps, Exceptions, System Calls, & Privileged Mode! Hakim Weatherspoon CS 3410, Spring 2011 Computer Science Cornell University P&H Chapter 4.9, pages 509 515, appendix B.7 OperaGng Systems 2 Control Transfers!
More informationCPS104 Computer Organization and Programming Lecture 17: Interrupts and Exceptions. Interrupts Exceptions and Traps. Visualizing an Interrupt
CPS104 Computer Organization and Programming Lecture 17: Interrupts and Exceptions Robert Wagner cps 104 Int.1 RW Fall 2000 Interrupts Exceptions and Traps Interrupts, Exceptions and Traps are asynchronous
More informationECE/CS 314 Fall 2003 Homework 2 Solutions. Question 1
ECE/CS 314 Fall 2003 Homework 2 Solutions Question 1 /* Equivalent C code with no loops (goto instead) char* strchr(char* pcstring, char csearchchr) strchr_loop: if (!*pcstring) return 0; if (*pcstring
More informationRecap from Last Time. CSE 2021: Computer Organization. Levels of Programming. The RISC Philosophy 5/19/2011
CSE 2021: Computer Organization Recap from Last Time load from disk High-Level Program Lecture-3 Code Translation-1 Registers, Arithmetic, logical, jump, and branch instructions MIPS to machine language
More informationCSc 256 Midterm 2 Spring 2012
CSc 256 Midterm 2 Spring 2012 NAME: 1a) You are given this MIPS assembly language instruction (i.e., pseudo- instruction): ble $12, 0x20004880, there Translate this MIPS instruction to an efficient sequence
More informationa) Do exercise (5th Edition Patterson & Hennessy). Note: Branches are calculated in the execution stage.
CS3410 Spring 2015 Problem Set 2 (version 3) Due Saturday, April 25, 11:59 PM (Due date for Problem-5 is April 20, 11:59 PM) NetID: Name: 200 points total. Start early! This is a big problem set. Problem
More informationMIPS Assembly Language. Today s Lecture
MIPS Assembly Language Computer Science 104 Lecture 6 Homework #2 Midterm I Feb 22 (in class closed book) Outline Assembly Programming Reading Chapter 2, Appendix B Today s Lecture 2 Review: A Program
More informationCSc 256 Final Fall 2016
CSc 256 Final Fall 2016 NAME: Problem 1 (25 points) Translate the C/C++ function func() into MIPS assembly language. The prototype is: void func(int arg0, int *arg1); arg0-arg1 are in $a0- $a1 respectively.
More informationToday s Lecture. MIPS Assembly Language. Review: What Must be Specified? Review: A Program. Review: MIPS Instruction Formats
Today s Lecture Homework #2 Midterm I Feb 22 (in class closed book) MIPS Assembly Language Computer Science 14 Lecture 6 Outline Assembly Programming Reading Chapter 2, Appendix B 2 Review: A Program Review:
More information5/17/2012. Recap from Last Time. CSE 2021: Computer Organization. The RISC Philosophy. Levels of Programming. Stored Program Computers
CSE 2021: Computer Organization Recap from Last Time load from disk High-Level Program Lecture-2 Code Translation-1 Registers, Arithmetic, logical, jump, and branch instructions MIPS to machine language
More informationMIPS ISA and MIPS Assembly. CS301 Prof. Szajda
MIPS ISA and MIPS Assembly CS301 Prof. Szajda Administrative HW #2 due Wednesday (9/11) at 5pm Lab #2 due Friday (9/13) 1:30pm Read Appendix B5, B6, B.9 and Chapter 2.5-2.9 (if you have not already done
More informationENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5
ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5 MIPS/SPIM General Purpose Registers Powers of Two 0 $zero all bits are zero 16 $s0 local variable 1 $at assembler temporary 17 $s1 local
More informationCSc 256 Midterm 2 Fall 2011
CSc 256 Midterm 2 Fall 2011 NAME: 1a) You are given a MIPS branch instruction: x: beq $12, $0, y The address of the label "y" is 0x400468. The memory location at "x" contains: address contents 0x40049c
More informationECE 2035 A Programming Hw/Sw Systems Spring problems, 8 pages Final Exam 29 April 2015
Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate
More informationOverview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2)
Introduction to the MIPS ISA Overview Remember that the machine only understands very basic instructions (machine instructions) It is the compiler s job to translate your high-level (e.g. C program) into
More informationECE Exam I February 19 th, :00 pm 4:25pm
ECE 3056 Exam I February 19 th, 2015 3:00 pm 4:25pm 1. The exam is closed, notes, closed text, and no calculators. 2. The Georgia Tech Honor Code governs this examination. 3. There are 4 questions and
More informationMIPS Datapath. MIPS Registers (and the conventions associated with them) MIPS Instruction Types
1 Lecture 08 Introduction to the MIPS ISA + Procedure Calls in MIPS Longer instructions = more bits to address registers MIPS Datapath 6 bit opcodes... 2 MIPS Instructions are 32 bits More ways to address
More informationCOMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture
COMP 303 Computer Architecture Lecture 3 Comp 303 Computer Architecture 1 Supporting procedures in computer hardware The execution of a procedure Place parameters in a place where the procedure can access
More informationMIPS R2000 Assembly Language (Procedure Call, Interrupt, IO, Syscall) CS 230
MIPS R2000 Assembly Language (Procedure Call, Interrupt, IO, Syscall) CS 230 이준원 1 Procedure Call Why do we need it? structured programming reuse frequently used routine Who takes care of it? compiler
More informationEEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture
EEM 486: Computer Architecture Lecture 2 MIPS Instruction Set Architecture EEM 486 Overview Instruction Representation Big idea: stored program consequences of stored program Instructions as numbers Instruction
More informationMIPS Procedure Calls. Lecture 6 CS301
MIPS Procedure Calls Lecture 6 CS301 Function Call Steps Place parameters in accessible location Transfer control to function Acquire storage for procedure variables Perform calculations in function Place
More informationOrange Coast College. Business Division. Computer Science Department CS 116- Computer Architecture. The Instructions
Orange Coast College Business Division Computer Science Department CS 116- Computer Architecture The Instructions 1 1 Topics: Assembly language, assemblers MIPS R2000 Assembly language Instruction set
More informationLecture 5: Procedure Calls
Lecture 5: Procedure Calls Today s topics: Procedure calls and register saving conventions 1 Example Convert to assembly: while (save[i] == k) i += 1; i and k are in $s3 and $s5 and base of array save[]
More informationIntroduction to MIPS Processor
Introduction to MIPS Processor The processor we will be considering in this tutorial is the MIPS processor. The MIPS processor, designed in 1984 by researchers at Stanford University, is a RISC (Reduced
More informationMIPS Programming. A basic rule is: try to be mechanical (that is, don't be "tricky") when you translate high-level code into assembler code.
MIPS Programming This is your crash course in assembler programming; you will teach yourself how to program in assembler for the MIPS processor. You will learn how to use the instruction set summary to
More informationMark Redekopp, All rights reserved. EE 357 Unit 11 MIPS ISA
EE 357 Unit 11 MIPS ISA Components of an ISA 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support SUBtract instruc. vs. NEGate + ADD instrucs. 3. Registers accessible
More informationMIPS Instruction Reference
Page 1 of 9 MIPS Instruction Reference This is a description of the MIPS instruction set, their meanings, syntax, semantics, and bit encodings. The syntax given for each instruction refers to the assembly
More informationMIPS function continued
MIPS function continued Review Functions Series of related instructions one after another in memory Called through the jal instruction Pointed to by a label like any other Returns by calling Stack Top
More informationECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Three 10 April 2013
Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate
More informationCSc 256 Midterm 1 Fall 2011
CSc 256 Midterm 1 Fall 2011 NAME: Problem 1a: Given the C++ function prototype and variable declarations: int func(int arg0, int *arg1, int *arg2); int *ptr, n, arr[10]; which of the following statements
More informationMIPS ISA. 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support
Components of an ISA EE 357 Unit 11 MIPS ISA 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support SUBtract instruc. vs. NEGate + ADD instrucs. 3. Registers accessible
More informationEE 457 Unit 8. Exceptions What Happens When Things Go Wrong
1 EE 457 Unit 8 Exceptions What Happens When Things Go Wrong 2 What are Exceptions? Exceptions are rare events triggered by the hardware and forcing the processor to execute a software handler HW Interrupts
More informationQ1: /30 Q2: /25 Q3: /45. Total: /100
ECE 2035(A) Programming for Hardware/Software Systems Fall 2013 Exam One September 19 th 2013 This is a closed book, closed note texam. Calculators are not permitted. Please work the exam in pencil and
More informationECE 2035 Programming Hw/Sw Systems Fall problems, 10 pages Final Exam 9 December 2013
Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate
More informationControl Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary
Control Instructions Computer Organization Architectures for Embedded Computing Thursday, 26 September 2013 Many slides adapted from: Computer Organization and Design, Patterson & Hennessy 4th Edition,
More informationControl Instructions
Control Instructions Tuesday 22 September 15 Many slides adapted from: and Design, Patterson & Hennessy 5th Edition, 2014, MK and from Prof. Mary Jane Irwin, PSU Summary Previous Class Instruction Set
More informationCS 61c: Great Ideas in Computer Architecture
MIPS Functions July 1, 2014 Review I RISC Design Principles Smaller is faster: 32 registers, fewer instructions Keep it simple: rigid syntax, fixed instruction length MIPS Registers: $s0-$s7,$t0-$t9, $0
More informationBranch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015
Branch Addressing Branch instructions specify Opcode, two registers, target address Most branch targets are near branch Forward or backward op rs rt constant or address 6 bits 5 bits 5 bits 16 bits PC-relative
More informationLecture 5: Procedure Calls
Lecture 5: Procedure Calls Today s topics: Memory layout, numbers, control instructions Procedure calls 1 Memory Organization The space allocated on stack by a procedure is termed the activation record
More informationWhat are Exceptions? EE 457 Unit 8. Exception Processing. Exception Examples 1. Exceptions What Happens When Things Go Wrong
8. 8.2 What are Exceptions? EE 457 Unit 8 Exceptions What Happens When Things Go Wrong Exceptions are rare events triggered by the hardware and forcing the processor to execute a software handler Similar
More informationWeek 10: Assembly Programming
Week 10: Assembly Programming Arithmetic instructions Instruction Opcode/Function Syntax Operation add 100000 $d, $s, $t $d = $s + $t addu 100001 $d, $s, $t $d = $s + $t addi 001000 $t, $s, i $t = $s +
More informationUniversity of California at Santa Barbara. ECE 154A Introduction to Computer Architecture. Quiz #1. October 30 th, Name (Last, First)
University of California at Santa Barbara ECE 154A Introduction to Computer Architecture Quiz #1 October 30 th, 2012 Name (Last, First) All grades will be posted on the website as a single spreadsheet
More informationICS DEPARTMENT ICS 233 COMPUTER ARCHITECTURE & ASSEMBLY LANGUAGE. Midterm Exam. First Semester (141) Time: 1:00-3:30 PM. Student Name : _KEY
Page 1 of 14 Nov. 22, 2014 ICS DEPARTMENT ICS 233 COMPUTER ARCHITECTURE & ASSEMBLY LANGUAGE Midterm Exam First Semester (141) Time: 1:00-3:30 PM Student Name : _KEY Student ID. : Question Max Points Score
More informationInstruction Set Architecture of. MIPS Processor. MIPS Processor. MIPS Registers (continued) MIPS Registers
CSE 675.02: Introduction to Computer Architecture MIPS Processor Memory Instruction Set Architecture of MIPS Processor CPU Arithmetic Logic unit Registers $0 $31 Multiply divide Coprocessor 1 (FPU) Registers
More informationMIPS Functions and the Runtime Stack
MIPS Functions and the Runtime Stack COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals Presentation Outline
More informationExamples of branch instructions
Examples of branch instructions Beq rs,rt,target #go to target if rs = rt Beqz rs, target #go to target if rs = 0 Bne rs,rt,target #go to target if rs!= rt Bltz rs, target #go to target if rs < 0 etc.
More informationComputer Organization MIPS Architecture. Department of Computer Science Missouri University of Science & Technology
Computer Organization MIPS Architecture Department of Computer Science Missouri University of Science & Technology hurson@mst.edu Computer Organization Note, this unit will be covered in three lectures.
More informationECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 19 September 2012
Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate
More informationWe will study the MIPS assembly language as an exemplar of the concept.
MIPS Assembly Language 1 We will study the MIPS assembly language as an exemplar of the concept. MIPS assembly instructions each consist of a single token specifying the command to be carried out, and
More informationFlow of Control -- Conditional branch instructions
Flow of Control -- Conditional branch instructions You can compare directly Equality or inequality of two registers One register with 0 (>,
More informationCMSC 611: Advanced Computer Architecture
CMSC 611: Advanced Computer Architecture Compilers Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted from Hennessy & Patterson / 2003 Elsevier Science
More informationNAME: 1. (2) What is a transistor?
NAME: CS3411 Test #1, 6 September 2007. You have 1h15min (one css period). Answer all questions. The number of points (out of 100) each problem is worth is shown in (parentheses). Be as concise as you
More informationECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam One 4 February Your Name (please print clearly)
Your Name (please print clearly) This exam will be conducted according to the Georgia Tech Honor Code. I pledge to neither give nor receive unauthorized assistance on this exam and to abide by all provisions
More informationECE 15B Computer Organization Spring 2010
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 7: Procedures I Partially adapted from Computer Organization and Design, 4 th edition, Patterson and Hennessy, and classes taught by and
More informationECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture
ECE468 Computer Organization & Architecture MIPS Instruction Set Architecture ECE468 Lec4.1 MIPS R2000 / R3000 Registers 32-bit machine --> Programmable storage 2^32 x bytes 31 x 32-bit GPRs (R0 = 0) 32
More informationReview of Activation Frames. FP of caller Y X Return value A B C
Review of Activation Frames In general, activation frames are organized like this: HI LO Bookkeeping/preserved registers I/O parameters Locals and temps RA of caller FP of caller Y X Return value A B C
More informationThreads and Concurrency
Threads and Concurrency 1 Threads and Concurrency key concepts threads, concurrent execution, timesharing, context switch, interrupts, preemption reading Three Easy Pieces: Chapter 26 (Concurrency and
More informationLec 10: Assembler. Announcements
Lec 10: Assembler Kavita Bala CS 3410, Fall 2008 Computer Science Cornell University Announcements HW 2 is out Due Wed after Fall Break Robot-wide paths PA 1 is due next Wed Don t use incrementor 4 times
More informationECE 2035 A Programming Hw/Sw Systems Fall problems, 8 pages Final Exam 9 December 2015
Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate
More informationEE 109 Unit 17 - Exceptions
EE 109 Unit 17 - Exceptions 1 2 What are Exceptions? Any event that causes a break in normal execution Error Conditions Invalid address, Arithmetic/FP overflow/error Hardware Interrupts / Events Handling
More informationAnne Bracy CS 3410 Computer Science Cornell University
Anne Bracy CS 3410 Computer Science Cornell University The slides were originally created by Deniz ALTINBUKEN. P&H Chapter 4.9, pages 445 452, appendix A.7 Manages all of the software and hardware on the
More informationMIPS Architecture and Assembly Language Overview
MIPS Architecture and Assembly Language Overview Adapted from: http://edge.mcs.dre.g.el.edu/gicl/people/sevy/architecture/mipsref(spim).html [Register Description] [I/O Description] Data Types and Literals
More informationFormat. 10 multiple choice 8 points each. 1 short answer 20 points. Same basic principals as the midterm
Final Review Format 10 multiple choice 8 points each Make sure to show your work Can write a description to the side as to why you think your answer is correct for possible partial credit 1 short answer
More informationCOMP2421 COMPUTER ORGANZATION. Lab 3
Lab 3 Objectives: This lab shows you some basic techniques and syntax to write a MIPS program. Syntax includes system calls, load address instruction, load integer instruction, and arithmetic instructions
More informationM2 Instruction Set Architecture
M2 Instruction Set Architecture Module Outline Addressing modes. Instruction classes. MIPS-I ISA. High level languages, Assembly languages and object code. Translating and starting a program. Subroutine
More informationDiscussion 4 Richard Guo SLAB, Buddy, Garbage Collection, and Intro to MIPS 01/30/09
Discussion 4 Richard Guo SLAB, Buddy, Garbage Collection, and Intro to MIPS 01/30/09 1. Answers to Last Time's Problems #include #include struct node int value; // or char or whatever
More informationCSE Lecture In Class Example Handout
CSE 30321 Lecture 07-09 In Class Example Handout Part A: A Simple, MIPS-based Procedure: Swap Procedure Example: Let s write the MIPS code for the following statement (and function call): if (A[i] > A
More informationECE 2035 A Programming Hw/Sw Systems Fall problems, 10 pages Final Exam 14 December 2016
Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate
More information