1 / 18

CS 300 – Lecture 19

CS 300 – Lecture 19. Intro to Computer Architecture / Assembly Language C Coding & The Simulator Caches. A Test. We'll have a test on Thursday. 45 minutes. Open book / notes but no computing allowed. You'll need to understand MIPS programming and C. Also numeric stuff.

louie
Download Presentation

CS 300 – Lecture 19

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. CS 300 – Lecture 19 Intro to Computer Architecture / Assembly Language C Coding & The Simulator Caches

  2. A Test We'll have a test on Thursday. 45 minutes. Open book / notes but no computing allowed. You'll need to understand MIPS programming and C. Also numeric stuff. We'll review the worksheet and Quicksort before the test. You WILL be writing code!

  3. Assembly Language Coding Why is assembly language so hard? The instructions are so far removed from what's really going on. It's up to you to place GOOD comments in your code so that others can read it. And so you can understand it too. Remember this on the test!

  4. Good / Bad Comments The bad: (from an anonymous student) j done # Jump to done addi $s2, $s1, 1 # increment $s1 into $s2 The good: addi $s2, $zero, 1 # set flag to say a swap happened noswap: addi $s0, $s0, 4 # bump pointer to next element of arr ($s0) addi $s1, $s1, -1 # number of remaining compares

  5. What's The Problem? * Registers don't have names that make sense – if you increment $s1, what's really in $s1? * Control flow is hard to understand: refer back to C code, use good labels, state what condition the program is in at a code point * Data structures are implicit: relate your code to C level structures to make it more readable.

  6. Optimizing Quicksort How fast can we make quicksort run? As assembly language programmers we have a lot of control over this … What are some concrete ideas? How do these ideas translate into compiler optimizations?

  7. Next Homework This is a C project that will last two weeks – I'll collect it on the 21st. There will be a turnin next week to demonstrate progress – I will get the details in the wiki. Will anyone be gone Thanksgiving week?

  8. A Mini Homework This will be due Thursday. It's mainly to help you with the test – I won't grade it in detail but you do have to turn it in. Let's do a few problems in class.

  9. My Little Buddy

  10. Writing Your Own SPIM Need to decode and execute NOVA instructions. We'll skip the IO instructions except for a few special ones. Two basic instructions: arithmetic (add, subtract, …) memory reference (LDA, STA, JMP, JSR, ISZ, DSZ)

  11. Machine Layout 16 Bit Architecture 4 Registers: 0,1,2,3 1 "Carry bit" PC (15 bits) Memory: 15 bit address (max is 32K words), 16 bits per word.

  12. Arithmetics Instruction layout: Op code (1 bit) (topmost bit = 1) Source AC (2 bits) (AC number) Destination AC (2 bits) (AC Number) Arithmetic function (3 bits) (ADD, SUB, ADC, MOV, INC, COM, NEG) Initial carry (2 bits) (O, Z, C) Shift (2 bits) (L, R, S) Skip condition (3 bits) (SZR, SNR, SZC, SNC, SEZ, SBN, SKP) No Load (1 bit) (#)

  13. Memory References Address: 8 bit unsigned (page 0) or 8 bit signed + PC / AC2 / AC3 Indirect addressing (@) uses top bit of an address

  14. Functionality * Load programs into memory * Start at a given address * Inspect processor state * Set a breakpoint (one will be enough) * Simple IO (just printing a character) * Statistics (# of instructions executed) * Performance of your C code is important!

  15. The Memory Hierarchy This is an essential part of the course … How do we manage storage? Where is the storage? * Network (the entire WWW!) * Disk (may cache network) * Memory (may cache disk) * On chip / off chip caches * Registers Each is smaller / faster than the one above.

  16. Prediction Storage strategies often need to predict what will happen next: * If a program opens a file, it usually needs to read it starting at the beginning * If a program reads a memory address, it will likely use adjacent addresses too * If a program writes a memory address it will usually read the value again soon Hardware / software often has to take a guess at what will happen next.

  17. Locations We address data using locations (pointers). These may refer to url, disk, memory word, or register number. Locations have to work "correctly" when a value is shared in any way. The operation of the storage device requires that readers see what the most recent writer has written.

  18. Cache A cache replicates a portion of a larger memory. It makes use of the fact that most references are to a relatively small number of locations.

More Related