System Software
System Software
SYSTEM SOFTWARE
OUTLINE
• Chapter 1: Introduction
• Chapter 2: Assemblers
• Chapter 3: Macroprocessors
Source Object
Assembler Linker
Program Code
Executable
Code
Loader
OUTLINE
1. LITERALS
2. SYMBOL-DEFINING STATEMENTS
3. EXPRESSIONS
4. PROGRAM BLOCKS
5. CONTROL SECTIONS AND PROGRAM
LINKING
2.3 MACHINE INDEPENDENT
ASSEMBLER FEATURES
• Same:
– Operand field contains constant values
• Difference:
– Immediate addressing: the assembler put the constant
value as part of the machine instruction
– Literal: the assembler store the constant value elsewhere
and put that address as part of the machine instruction
LITERAL POOL
• Allow literals that refer to the current value of the location counter.
– Such literals are sometimes useful for loading base registers.
LDB =*
; register B=beginning address of statement=current LOC
BASE *
; for base relative addressing
• If a literal =* appeared on line 13 and 55
– Specify an operand with value 0003 (Loc) and 0020 (Loc).
IMPLEMENTATION OF LITERAL
• Pass 1
– As each literal operand is recognized
• Search the LITTAB for the specified literal name or value
• If the literal is already present, no action is needed
• Otherwise, the literal is added to LITTAB (store the name,
value, and length, but not address)
– As LTORG or END is encountered
• Scan the LITTAB
• For each literal with empty address field, assign the address
and update the LOCCTR accordingly
IMPLEMENTATION OF LITERAL
• Pass 2
– As each literal operand is recognized
• Search the LITTAB for the specified literal name or value
• If the literal is found, use the associated address as the operand of
the instruction
• Otherwise, error (should not happen)
– As LTORG or END is encountered
• insert the data values of the literals in the object program
– Modification record is generated if necessary
2.3.2 SYMBOL-DEFINING
STATEMENTS
• How to define symbols and their values
– Address label
• The label is the symbol name and the assigned
address is its value
FIRST STL RETADR
– Assembler directive EQU
symbol EQU value
• This statement enters the symbol into SYMTAB and
assigns to it the value specified
• The value can be a constant or an expression
– Assembler directive ORG
ORG value
USE OF EQU
• To improve the program readability, avoid using the magic numbers, make it
easier to find and change constant values
– Replace
+LDT #4096
– with
MAXLEN EQU 4096
+LDT #MAXLEN
– Registers A, X, L can be used by numbers 0, 1, 2.
Size of field
more meaningful
Allowed
Not allowed
FORWARD-REFERENCE
PROBLEM
Not allowed
Not allowed
2.3.2 EXPRESSIONS
• A single term as an instruction operand can be
replaced by an expression.
STAB RESB 1100