Part10-AssemblyProcess

Part10-AssemblyProcess - Assembly and Linking Process...

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

View Full Document Right Arrow Icon
Assembly and Linking Process Thorne : Chapter 14 (Irvine Edition IV : Section 3.3) How does the Assembly Work he assembler is a program that reads your ASM file line y ne The assembler is a program that reads your .ASM file line-by-line. The assembler uses a two-pass approach –A pass = Processes all statements in .ASM file sequentially from start to finish SYSC3006 1
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
How does the Assembly Work 1st Pass : for each statement : heck syntax 1. Check syntax 2. Allocate any memory needed for image • For memory declaration (DB, DW) • For each instruction, allocate enough bytes for opcode + operand • For directives (pseudo opcodes): ? 3. For every label definition, assign a value to the label and record this (label,value) association in the Symbol Table (Throne, p. 342) If there were any syntax errors in 1 st pass, write errors to .LST file and stop, else . ... SYSC3006 2
Background image of page 2
How does the Assembly Work 2nd Pass : Build the binary image For each instruction, complete the instruction encoding . – Errors may result when calculating offsets •e . g. trying to jump too far for a conditional jump (target gy g j p j p (g out of range) • If so, write results to .LST file if no errors – write results to .OBJ file SYSC3006 3
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
1 st Pass in Detail • Intention: When the resulting program is loaded into memory, then the binary image associated with each statement (either instruction or memory declaration) will be loaded at the offset(s) of the allocated location(s) physical segment containing code Assembled : (.OBJ) Offset Contents .ASM source .code . . . Run-Time Memory : Offset Contents 0103 B2 31 0105 mov dl, ‘1’ . . . 0103 B2 31 0105 SYSC3006 4 assembler loader
Background image of page 4
1 st Pass in Detail : Memory Allocation each segment ( data code stack) allocation starts at In each segment (.data, .code, .stack), allocation starts at offset 0000H •A location counter ($) is used to track address of next byte to allocate – As bytes are allocated, adjust $ value SYSC3006 5
Background image of page 5

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

View Full Document Right Arrow Icon
ass in Detail : emor Allocation 1 st Pass in Detail : Memory Allocation • For each
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 17

Part10-AssemblyProcess - Assembly and Linking Process...

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

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