DOC PREVIEW
Berkeley COMPSCI 61C - Lecture Notes

This preview shows page 1-2-24-25 out of 25 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

PowerPoint PresentationOverviewLanguage ContinuumInterpretation vs TranslationInterpretationTranslationSlide 7Interpretation vs. Translation?Steps to Starting a ProgramCompilerUpcoming CalendarAdministrivia…Midterm in 1 week!Administrivia…Other stuffWhere Are We Now?AssemblerAssembler Directives (p. A-51 to A-53)Pseudoinstruction ReplacementProducing Machine Language (1/2)Producing Machine Language (2/2)Symbol TableRelocation TableObject File FormatPeer InstructionPeer Instruction AnswerAnd in conclusion…CS 61C L18 Running a Program aka Compiling, Assembling, Loading, Linking (CALL) I (1)Garcia, Fall 2004 © UCBLecturer PSOE Dan Garciawww.cs.berkeley.edu/~ddgarciainst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 18 – Running a Program Iaka Compiling, Assembling, Linking, Loading (CALL) 2004-10-11Finally, Tivo for the radio! Griffin Technologies releasedtheir new “radioSHARK” for $70 that allows you to pause live radio and “timeshift”your radio shows. Easily download them easily to your iPod…cool! griffintechnology.com/products/radioshark/CS 61C L18 Running a Program aka Compiling, Assembling, Loading, Linking (CALL) I (2)Garcia, Fall 2004 © UCBOverview•Interpretation vs Translation•Translating C Programs•Compiler•Assembler•Linker (next time)•Loader (next time)•An Example (next time)CS 61C L18 Running a Program aka Compiling, Assembling, Loading, Linking (CALL) I (3)Garcia, Fall 2004 © UCBLanguage Continuum•In general, we interpret a high level language if efficiency is not critical or translated to a lower level language to improve performanceEasy to programInefficient to interpretEfficientDifficult to programSchemeJavaC++ C Assembly machine languageJava bytecodeCS 61C L18 Running a Program aka Compiling, Assembling, Loading, Linking (CALL) I (4)Garcia, Fall 2004 © UCBInterpretation vs Translation•How do we run a program written in a source language?•Interpreter: Directly executes a program in the source language•Translator: Converts a program from the source language to an equivalent program in another language•For example, consider a Scheme program foo.scmCS 61C L18 Running a Program aka Compiling, Assembling, Loading, Linking (CALL) I (5)Garcia, Fall 2004 © UCBInterpretationScheme program: foo.scmScheme InterpreterCS 61C L18 Running a Program aka Compiling, Assembling, Loading, Linking (CALL) I (6)Garcia, Fall 2004 © UCBTranslationScheme program: foo.scmHardwareScheme CompilerExecutable(mach lang pgm): a.out°Scheme Compiler is a translator from Scheme to machine language.CS 61C L18 Running a Program aka Compiling, Assembling, Loading, Linking (CALL) I (7)Garcia, Fall 2004 © UCBInterpretation•Any good reason to interpret machine language in software?•SPIM – useful for learning / debugging•Apple Macintosh conversion•Switched from Motorola 680x0 instruction architecture to PowerPC.•Could require all programs to be re-translated from high level language•Instead, let executables contain old and/or new machine code, interpret old code in software if necessaryCS 61C L18 Running a Program aka Compiling, Assembling, Loading, Linking (CALL) I (8)Garcia, Fall 2004 © UCBInterpretation vs. Translation?•Easier to write interpreter•Interpreter closer to high-level, so gives better error messages (e.g., SPIM)•Translator reaction: add extra information to help debugging (line numbers, names)•Interpreter slower (10x?) but code is smaller (1.5X to 2X?)•Interpreter provides instruction set independence: run on any machine•Apple switched to PowerPC. Instead of retranslating all SW, let executables contain old and/or new machine code, interpret old code in software if necessaryCS 61C L18 Running a Program aka Compiling, Assembling, Loading, Linking (CALL) I (9)Garcia, Fall 2004 © UCBSteps to Starting a ProgramC program: foo.cCompilerAssembly program: foo.sAssemblerLinkerExecutable(mach lang pgm): a.outLoaderMemoryObject(mach lang module): foo.olib.oCS 61C L18 Running a Program aka Compiling, Assembling, Loading, Linking (CALL) I (10)Garcia, Fall 2004 © UCBCompiler•Input: High-Level Language Code (e.g., C, Java such as foo.c)•Output: Assembly Language Code(e.g., foo.s for MIPS)•Note: Output m ay contain pseudoinstructions•Pseudoinstructions: instructions that assembler understands but not in machine (last lecture) For example:• mov $s1,$s2  or $s1,$s2,$zeroCS 61C L18 Running a Program aka Compiling, Assembling, Loading, Linking (CALL) I (11)Garcia, Fall 2004 © UCBUpcoming CalendarWeek # Mon Wed Thurs Lab Fri#7This weekRunning Program IRunning Program IIRunning ProgramCaches#8Midterm weekCachesMidterm @ 7pm1 PimintelCaches Caches Caches Midterm grades outCS 61C L18 Running a Program aka Compiling, Assembling, Loading, Linking (CALL) I (12)Garcia, Fall 2004 © UCBAdministrivia…Midterm in 1 week!•2004-10-18 @ 7-10pm in 1 Piminitel•Covers labs,hw,proj,lec up to Caches•Last sem midterm + answers on www•Bring…•NO backpacks, cells, calculators, pagers, PDAs•2 Pens (we’ll provide write-in exam booklets)•One handwritten (both sides) 8.5”x11” paper•One green sheet (corrections below to bugs from “Core Instruction Set”)1) Opcode wrong for Load Word. It should say 23hex, not 0 / 23hex. 2) sll and srl should shift values in R[rt], not R[rs]i.e. sll/srl: R[rd] = R[rt] << shamtCS 61C L18 Running a Program aka Compiling, Assembling, Loading, Linking (CALL) I (13)Garcia, Fall 2004 © UCBAdministrivia…Other stuf•Bug in Friday’s slides (slide 19)•WAS: ori $at,$zero,lower 16 bits•SHOULD BE: ori $at,$at,lower 16 bits•Grades in for Homework XX, Proj YY•You have one week to request official ‘regrade’ from reader – specify reason. •Reader will then regrade entire HW/Proj (grade may go down). In exceptional cases, can appeal to TA to intervene.•If no appeal generated within a week, grade frozen, no way to change after that. (Regrade could still be pending, tho)CS 61C L18 Running a Program aka Compiling, Assembling, Loading, Linking (CALL) I (14)Garcia, Fall 2004 © UCBWhere Are We Now?C program: foo.cAssembly program: foo.sExecutable(mach lang pgm): a.outCompilerAssemblerLinkerLoaderMemoryObject(mach lang module): foo.olib.oCS 61C L18 Running a Program aka Compiling, Assembling, Loading, Linking (CALL) I (15)Garcia, Fall 2004 ©


View Full Document

Berkeley COMPSCI 61C - Lecture Notes

Documents in this Course
SIMD II

SIMD II

8 pages

Midterm

Midterm

7 pages

Lecture 7

Lecture 7

31 pages

Caches

Caches

7 pages

Lecture 9

Lecture 9

24 pages

Lecture 1

Lecture 1

28 pages

Lecture 2

Lecture 2

25 pages

VM II

VM II

4 pages

Midterm

Midterm

10 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?