1 / 14

Lecture 25 (Assemblers)

Lecture 25 (Assemblers). Assemblers,Linkers,and Debuggers. Assembler -Translates assembly to machine code. - Resolves symbolic address. - Extends virtual machine with additional instruction . Similar to compiler in structure

eileen
Download Presentation

Lecture 25 (Assemblers)

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. Lecture 25 (Assemblers)

  2. Assemblers,Linkers,and Debuggers • Assembler -Translates assembly to machine code. - Resolves symbolic address. - Extends virtual machine with additional instruction . • Similar to compiler in structure -Translation process simpler since it is usually one-to-one

  3. * Each input instruction produces one output instruction - Generally make two passes over code * First pass finds the labels and counts instructions * Second pass actually produces code File.s File.o Scanner Parser Code Generator

  4. Types of Addresses • Two types of addresses -Relative addresses * Distance from known point e.g. bneq s2,s3,44 - Absolute addresses * Complete memory address e.g. load s4,xxx

  5. Assembler can fully resolve relative addresses by counting instructions - However ,doesn’t know where everything goes in memory * Linker resolves absolute addresses. * file.o contains of unresolved addresses for linker.

  6. Extending the Virtual Machine • Assembler can provide instructions and not supported by hardware . • Delayed branches and loads . -Instructions take two cycles,but in next instruction started in second cycle * Cannot use result of load in second cycle lw s4,5(s7) add s3,s5,s6

  7. * Instruction after branch executed beq s1,s2,foo add s3,s4,s5 - How does system present delayed instructions? * Inform programmers and compiler writers about it and let them handle it (SPARC) *Hide from programmers by letting assembler rearrange code to put useful instruction in slots (MIPS)

  8. Extended VM, cont’d • Filling delay slot after load -Find Instruction from same basic block (executed under the same conditions) -Instruction can’t produce address for load or use its result -Cannot move instruction ahead of other one that uses its value • Pseudo instructions extend instructions provided by hardware

  9. - Assembler produces short code sequences for pseudo instructions * e.g. blt s2,s3,label bge s2,s3,xxx j label xxx: * div s2,s3,s4 bneq s3,xxx trap xxx:divu s3,s4 mfhi s2

  10. Other Features • Branch Tensioning - Eliminate jumps to jumps • Bookkeeping - Directives -Data storage

  11. Linkers • Collect code from object files and produce executable program - Scan each object file to find list of unresolved addresses and lay out code and data in memory -can the libraries to find referenced routines - make another pass over the code to fix up unresolved addresses

  12. Can be tricky - May not know instruction size in first pass - la s2,foo li s2,foo lui s2,%hi(foo) ori s2,s2,%lo(foo)

  13. Debuggers • Simple debuggers only give view of assembly language (adb) -Don’t know about language satements,data types, or variables - e.g. SPIM debugger • Source level debuggers - Compiler and includes detailed information in object file * Which source files produced assembly file

  14. * Where each statement begins and ends * Where local variables are stored * Where global variables are stored * Types of variables * Descriptions of stack frames -Information stored at end of executable file * Doesn’t make program larger - Compiler may not do as much optimization

More Related