{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture 21-23 - Lecture 21-23 Announcements Test 2 Oct 27th...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 21-23 –10/18/10-10/22/10 Announcements Test 2 Oct 27 th see location on Blackboard Covers material in Lectures 11-23 In-class review on the 27th Hwk7 due Friday Last week I/O in the LC-3 This week (P&P 7.3, Chap. 1, 4 & 10 http://www.iecc.com/linker/ ) Assemblers & Linkers Static vs. dynamic linking Next week Intro to C Test 2 CS310 Fall 2010 -Boral Assemblers, Linkers & Loaders Pgm1.asm Pgm2.asm Assembler Pgm1.obj Assembler Pgm2.obj Linker a.out Loader RAM CS310 Fall 2010 -Boral
Background image of page 1

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

View Full Document Right Arrow Icon
Assembler Function Convert assembly language code to machine language Including directives .ORIG x3000 D AND R0, R0, #0 ; Set R0 to 0 BRn D .FILL xBEEF .BLKWTO x3020 .END Assembler needs to: Resolve symbols Check for errors Opcodemnemonics Bit width of immediates Translate to binary LC-3 assembler creates: .obj–binary format .hex –text format with hex digits .dbg–debugger file with symbol table built in CS310 Fall 2010 -Boral LC-3 Object & Symbol Files (.obj, .sym) (0000) 5000 0101000000000000 ( 1) .ORIG x5000 (5000) 5020 0101000000100000 ( 2) AND R0 R0 #0 (5001) 1021 0001000000100001 ( 3) ADD R0 R0 #1 (5002) 2205 0010001000000101 ( 4) LD R1 val (5003) F020 1111000000100000 ( 5) TRAP x20 (5004) F021 1111000000100001 ( 6) TRAP x21 (5005) F020 1111000000100000 ( 7) TRAP x20 (5006) F021 1111000000100001 ( 8) TRAP x21 (5007) F025 1111000000100101 ( 9) TRAP x25 (5008) 1234 0001001000110100 ( 10) val .FILL x1234 //Symbol Name Page Address //---------------- ------------ // val 5008 CS310 Fall 2010 -Boral
Background image of page 2
How The Assembler Works Lex: break program down into a stream of tokens .ORIG x3000 D AND R0 , R0 , #0 ; Set R0 to 0 BRn… Parse: perform syntax analysis Requires the existence of a grammar ADD #5, R1, R0 ; wrong parameter order AND AND R1, R1, #0 ; AND used as a label & opcode Translate: generate machine code .ORIG x3000 sets start address in executable ADD R4, R5, R1 0001 1001 0100 0001 BRn D 0000 1001 1111 1110 .FILL xBEEF 1011 1110 1110 1111 Address resolution can be a problem With forward references: when the assembler hasn’t seen them yet CS310 Fall 2010 -Boral Forward Address Resolution 1 Occurs when program references a label that is defined later in the program JSR, JMP, BR instructions Data locations Two-pass assembler: Create a symbol table in the 1 st pass (no code generation) Resolve references & generate code in the 2 nd pass Symbol table associates a label with an address D x3000 Assembler fills in the missing data in the 2 nd pass Missing labels Labels that are “too far” CS310 Fall 2010 -Boral
Background image of page 3

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

View Full Document Right Arrow Icon
Forward Address Resolution 2 The 2 nd pass in a two-pass assembler is wasteful Just need to fill in the missing references Why rescan the program text again?
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}