DOC PREVIEW
Berkeley COMPSCI 61C - Running a Program

This preview shows page 1 out of 4 pages.

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

Unformatted text preview:

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/~cs61cCS61C : 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 allowsyou 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 levellanguage if efficiency is not critical ortranslated to a lower level language toimprove 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 asource language?• Interpreter: Directly executes aprogram in the source language• Translator: Converts a program fromthe source language to an equivalentprogram in another language• For example, consider a Schemeprogram 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 fromScheme 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 machinelanguage in software?• SPIM – useful for learning / debugging• Apple Macintosh conversion• Switched from Motorola 680x0instruction architecture to PowerPC.• Could require all programs to be re-translated from high level language• Instead, let executables contain oldand/or new machine code, interpret oldcode 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 givesbetter error messages (e.g., SPIM)• Translator reaction: add extra informationto help debugging (line numbers, names)• Interpreter slower (10x?) but code issmaller (1.5X to 2X?)• Interpreter provides instruction setindependence: run on any machine• Apple switched to PowerPC. Instead ofretranslating all SW, let executablescontain 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 may containpseudoinstructions• Pseudoinstructions: instructions thatassembler understands but not inmachine (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 CalendarCachesRunningProgram IIWedCachesMidtermgradesoutCachesCachesMidterm@ 7pm1 Pimintel#8MidtermweekCachesRunningProgramRunningProgram I#7This weekFriThurs LabMonWeek #CS 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 bugsfrom “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 stuff• 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 exceptionalcases, can appeal to TA to intervene.• If no appeal generated within a week,grade frozen, no way to change afterthat. (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 © UCBAssembler• Input: Assembly Language Code(e.g., foo.s for MIPS)• Output: Object Code, information tables(e.g., foo.o for MIPS)• Reads and Uses Directives• Replace Pseudoinstructions• Produce Machine Language• Creates Object FileCS 61C L18 Running a Program aka Compiling, Assembling, Loading, Linking (CALL) I (16 ) Garcia, Fall 2004 © UCBAssembler Directives (p. A-51 to A-53)• Give directions to assembler, but do notproduce machine instructions .text: Subsequent items put in user textsegment .data: Subsequent items put in user datasegment .globl sym: declares sym global and


View Full Document

Berkeley COMPSCI 61C - Running a Program

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 Running a Program
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 Running a Program 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 Running a Program 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?