{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

l7_handouts_4up - Hennessy and Patterson ECE 3140/CS 3420...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 ECE 3140/CS 3420 Computer Organization S i 2009 Spring 2009 Assemblers, Loaders and Linkers ECE3140/CS3420 Announcements Homework 2 – Due Tue, Feb 17 at 10:00pm • Project 2 Project 2 – Due Tue, Feb 21 at 10:00pm ECE3140/CS3420 2 Hennessy and Patterson Read Chapter 1 – 1.1-1.9 • Read Chapter 2 Read Chapter 2 2.1 through 2.14, B.1-B.6, B.10 MIPS Calling Convention Document (website) – Notes on Programming in C (website) Read Chapter 3 – 3.1 through 3.2 ECE3140/CS3420 3.1 through 3.2 Read Appendix C (for Tuesday) – C.1-C.6 3 Assembly Assembler Object File Object File Object File Assembly Assembly Assembly Assembly C source Compiler Source Code to Execution “mostly” machine code Loader Executable Linker Library sqrt(), printf(), etc. all knowable addresses in place ECE3140/CS3420 DLL dynamically linked library (routines linked at runtime, i.e., addresses resolved)
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 400000 27bdffe8 400004 3c04???? 400008 2484???? 40000c 0c?????? .text .align 2 Assembly, Linking & Loading .text 400000 24020000 400004 90880000 4000b0 27bdffe8 4000b4 3c040040 4000b8 248402c0 4000bc 0c100038 400010 00000000 400014 0c?????? 400018 00402025 40001c 0c?????? 400020 24040000 400024 00000000 400028 00000000 40002c 00000000 main: s: .align 2 NumSpaces: # frame double-word aligned $start: lbu $8, 0($4) $skipinc: addiu $4, $4, 1 <puts> li a2,0 <strlen_loop> lbu t0,0(a0) addiu a2,a2,1 bnez t0,400124 <strlen_loop> addiu a0,a0,1 ... jr ra nop <read> li v0,4003 syscall jr ra nop <exit> li v0 4001 400008 00000000 40000c 19000007 400010 00000000 400014 24090020 400018 15090002 40001c 00000000 400020 24420001 400024 1000fff7 400028 24840001 40002c 03e00008 400030 00000000 400034 00000000 400038 00000000 400000 24060000 400004 90880000 400008 24c60001 40000c 1500fffd 400010 24840001 400014 00862823 400018 24c6ffff 40001c 08100051 400020 24040001 400000 24020fa4 400004 0000000c 400008 03e00008 40000c 00000000 4000bc 0c100038 4000c0 00000000 4000c4 0c10005b 4000c8 00402025 4000cc 0c100059 4000d0 24040000 4000d4 00000000 4000d8 00000000 4000dc 00000000 4000e0 24020000 4000e4 90880000 4000e8 00000000 4000ec 19000007 ECE3140/CS3420 s: .asciiz "a string with spaces" $done: <exit> li v0,4001 syscall <puti> lui t0,0x40 addiu t0,t0,784 bgez a0,40018c <positive> ... 400038 00000000 40003c 00000000 40000c 00000000 400000 24020fa3 400004 0000000c 400008 03e00008 40000c 00000000 ... 4000f0 00000000 4000f4 24090020 4000f8 15090002 4000fc 00000000 400100 24420001 400104 1000fff7 400108 24840001 40010c 03e00008 400110 00000000 400114 00000000 Source => Object => Image Assembling Programs Start at address 400000 (arbitrarily) – Track location of jumps – Track references to labels in data (e.g., globals) – Track unresolved references (e.g., exit, library calls) • Addresses get relocated by OS when ECE3140/CS3420 Addresses get by OS when program is loaded into memory All needed info saved in object file Assembling Programs ECE3140/CS3420 What Does the Assembler Do? Translates pneumonic instructions to machine code Determines address of each instruction* Resolves symbolic names Fills in Branch Delay Slot Keeps a symbol table with information d d b li k & l d ECE3140/CS3420 needed by linker & loader And ...
Image of page 2
3 Forward References Two-pass assembly First pass allocates instructions, determines label dd addresses Second pass assembles instructions (all labels are known) One-pass assembly (backpatching) – Assemble instructions, but use 0 as address for all unknowns keep track of those unknowns ECE3140/CS3420
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern