l7_handouts_4up

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

Info iconThis 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 Spring 2009 Assemblers, Loaders and Linkers ECE3140/CS3420 Announcements • Homework 2 – Due Tue, Feb 17 at 10:00pm roject 2 • Project 2 – Due Tue, Feb 21 at 10:00pm ECE3140/CS3420 2 Hennessy and Patterson • Read Chapter 1 – 1.1-1.9 ead 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 .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 Library Library sqrt(), printf(), etc. all knowable addresses in place ECE3140/CS3420 DLL dynamically linked library (routines linked at runtime, i.e., addresses resolved)
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 400000 27bdffe8 400004 3c04???? 400008 2484???? 40000c 0c?????? .text .align 2 .globl main .ent main Assembly, Linking & Loading .text lign 2 400000 24020000 400004 90880000 4000b0 27bdffe8 4000b4 3c040040 4000b8 248402c0 000bc 0c100038 400010 00000000 400014 0c?????? 400018 00402025 40001c 0c?????? 400020 24040000 400024 00000000 400028 00000000 40002c 00000000 main: addiu $sp,$sp,-24 la $4, s jal NumSpaces or $4,$2,$0 jal puti li $4, 0 jal exit .end main .data .align 2 : sciiz string with spaces" .align 2 .entry NumSpaces NumSpaces: # frame double-word aligned 0 words li $2, 0 # $v0 = 0 $start: lbu $8, 0($4) # $t0 = *s blez $8, $done # goto $done # if (*s == 0) li $9, 32 # $t1 = ‘ ‘ bne $8, $9, $skipinc addiu $2, $2, 1 # $v0 = count++ $skipinc: addiu $4, $4, 1 # s++ <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> 0 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 00038 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 0000c 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" beq $0, $0, $start $done: jr $31 <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) ddresses get located y OS when ECE3140/CS3420 Addresses get relocated 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 ECE3140/CS3420 needed by linker & loader • And . ..
Background image of page 2
3 Forward References • Two-pass assembly – First pass allocates instructions, determines label addresses
Background image of page 3

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

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

This note was uploaded on 03/11/2009 for the course ECE 3140 taught by Professor Mckee/long during the Spring '07 term at Cornell.

Page1 / 8

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

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online