Beruflich Dokumente
Kultur Dokumente
Assemblers
1
Module 2 -- Outline
Machine Dependent Features –
• Instruction Formats & Addressing Modes
• Program Relocation.
Machine Independent Features –
• Literals
• Symbol Definition Statements
• Expression,
• Program Blocks
• Control Sections and Programming Linking
Assembler Design Operations –
• One-Pass Assembler
• Multi-Pass Assembler
Implementation Examples –
• MASM Assembler
• SPARC Assembler
2
Assembler Design
Machine Dependent Assembler Features
instruction formats and addressing modes
program relocation
3
Machine-dependent
Assembler Features
Program relocation
4
Instruction Format and Addressing Mode
SIC/XE
PC-relative or Base-relative addressing: op m
Indirect addressing: op @m
Immediate addressing: op #c
Extended format: +op m
Index addressing: op m,x
register-to-register instructions
larger memory -> multi-programming (program allocation)
5
Instruction formats
8
Format 1 (1 byte) op
8 4 4
Format 2 (2 bytes) op r1 r2
e=0 Relative
6 1 1 1 1 1 1 12 addressing
Format 3 (3 bytes) op n i x b p e disp
e=1 Extended
6 1 1 1 1 1 1 20 addressing
Format 4 (4 bytes) op n i x b p e address
6
Translation
Register translation
register name (A, X, L, B, S, T, F, PC, SW) and their
values (0,1, 2, 3, 4, 5, 6, 8, 9)
preloaded in SYMTAB
Address translation
Most register-memory instructions use program
counter relative or base relative addressing
Format 3: 12-bit address field
base-relative: 0~4095
pc-relative: -2048~2047
8
Generate the object code for following SIC/XE program.
Op codes: LDCH= 50, STCH=54, JLT=38, LDT=74, LDX=04, TIXR=B8.
9
Copy string ‘RNSIT’ from location STR1 to STR2
Find object code
LOC LABEL OPCODE OPERAND OBJECT CODE Addr. mode
15
16
Program Relocation
Program relocation is the ability of loading the
program in different memory location other than the
actual starting address
17
18
19
Relocatable Program
Modification record
Col 1 M
Col 2-7 Starting location of the address field to be
modified, relative to the beginning of the program
Col 8-9 length of the address field to be modified, in half-
bytes
20
21
22
Object Code
23
Why Relative addressing need not
require modification?
24
TA = [PC] + disp
= 2003 + 02D
= 2030
25