1 / 12

ENGR 330: Today’s Class

ENGR 330: Today’s Class. Questions/issues? In-class Exam next week – more on Wed. Cliffhanger on procedure calls MIPS Simulator Memory and register use Principles and Pitfalls IF time: what is floating point? (Chapter 3). Cliffhanger. The scene: We’ve called a subroutine from Main.

donagh
Download Presentation

ENGR 330: Today’s Class

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ENGR 330: Today’s Class • Questions/issues? • In-class Exam next week – more on Wed. • Cliffhanger on procedure calls • MIPS Simulator • Memory and register use • Principles and Pitfalls • IF time: what is floating point? (Chapter 3) R. Smith - University of St Thomas - Minnesota

  2. Cliffhanger • The scene: • We’ve called a subroutine from Main. • The return address was stored in $ra • Now we’re calling ANOTHER subroutine • How are we ever getting back to Main?? R. Smith - University of St Thomas - Minnesota

  3. Words that are interchangeable • (more or less, at this architectural level) • Procedure • Function • Subroutine • Method R. Smith - University of St Thomas - Minnesota

  4. MIPS Simulator • Don’t Panic • Dr. Jalkio assures me you’ve suffered enough • No more ASM assignments (well, this semester anyway) • Except maybe when we do C (I’ll look into it) • There are many simulators • They’re all lame in one way or another • But interesting features worth looking at here • PCSPIM • Blurs the line between ASM and machine language • Already a problem with the MIPS R. Smith - University of St Thomas - Minnesota

  5. Memory map elements • Code/text • Global variables • Dynamic allocation space • Stack space R. Smith - University of St Thomas - Minnesota

  6. Weird MIPS stuff that matters • .data versus .text • Stack space, local variables, global variables • Dedicated general registers • See above: stack, fp, global pointer • Reserved for the OS kernel – contents may change at any time • Procedure temporary variables – trashed by subroutine calls • Saved temporary variables • If you use it, you save it first and restore it before returning • You can assume other subroutines won’t trash it • Arguments passed to subroutines • Procedure results returned from subroutines • ASM temporary variables R. Smith - University of St Thomas - Minnesota

  7. Mapping it to C or Java • Globals – defined outside of methods • Point $gp at the start of the global area • Int add2(arg1, arg2) • { • Int local1, local2; • } • Add2 is a function • Collect arg1, arg2 into $a1, $a2 • Save current $rp on the stack • Save $s registers on the stack • Make stack space for local1, local2 (“automatic variables”) • Point $fp at the stack space for local1, local2 • Put result of add2 in $v0 • Restore saved registers and $rp • Return by jr $rp R. Smith - University of St Thomas - Minnesota

  8. Loading and Relocating • Loading a single program to the same spot • Loading in unpredictable spots • PC relative – great, but not enough • Relocation via patching – ‘object’ format R. Smith - University of St Thomas - Minnesota

  9. Instruction set design principles • From P & H, Chapter 2 • Simplicity favors regularity – 1 instruction size, arithmetic on registers, register spec in same instruction location • Smaller is faster – 32 registers instead of 64, instruction size • Make the common case fast – PC relative on conditional branches, branch on equal, constants in immediate instrs. • Good design demands good compromises – how to handle larger addresses and offsets while keeping instructions a single size R. Smith - University of St Thomas - Minnesota

  10. Fallacies and Pitfalls • More powerful instructions = higher performance • ASM programming achieves highest performance • Sequential word addresses on byte addressable machines: not by 1 • Pointers to automatic variables outside of the defining procedure R. Smith - University of St Thomas - Minnesota

  11. What is Floating Point? • Double vs Float • Parts • Matissa • Exponent • Signs • Overflow • Underflow • Loss of precision R. Smith - University of St Thomas - Minnesota

  12. R. Smith - University of St Thomas - Minnesota

More Related