Lecture 21-23 - Lecture 21-23 10/18/10-10/22/10...

Info iconThis preview shows pages 1–4. 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 Hwk 7 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/ ) Static vs. dynamic linking Next week Intro to C Test 2 CS310 Fall 2010 - Boral 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 DocumentRight 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 Opcode mnemonics 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 (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
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 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) nd pass Symbol table associates a label with an address D x3000 Assembler fills in the missing data in the 2
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 11/30/2010 for the course CS 310 taught by Professor Fussell during the Spring '08 term at University of Texas.

Page1 / 11

Lecture 21-23 - Lecture 21-23 10/18/10-10/22/10...

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