Module 2
Module 2
MODULE 2
12-Aug-24 1
CSE, AJCE
SYLLABUS
SIC/XE Programming
Basic Functions of Assembler
Assembler Output Format – Header, Text and End Records.
Assembler Data Structures
Two Pass Assembler Algorithm
Hand Assembly of SIC/XE Programs.
12-Aug-24 2
CSE, AJCE
SIC Programming Examples
• Sample data movement operations
• No memory-to-memory move instructions
LDX ZERO
LOOP LDCH BLANK
STCH STR1,X
TIX TWENTY
JLT LOOP
:
STR1 RESW 20
BLANK BYTE C‘ ‘
ZERO WORD 0
TWENTY WORD 20
• Because of this, most assemblers make two passes over the source program
12-Aug-24 CSE, AJCE 45
Assemblers
Assemblers make two passes over the source program
• PASS 1: Scan the source program for label definitions and assign
addresses (such as the Loc column)
• Text records contain the translated (ie., machine code) instructions and data of the
program, together with an indication of the addresses where these are to be
loaded.
• End record marks the end of the object program and specifies the address in the
program where execution is to begin.
• Text
Col.1 T
Col.2~7 Starting address in this record (hex)
Col. 8~9 Length of object code in this record in bytes (hex)
Col. 10~69 Object code (69-10+1)/6=10 records
• End
Col.1 E
Col.2~7 Address of first executable instruction (hex)
ZERO WORD 0
THREE WORD 3
THIRTY WORD 30
ARRAY1 RESW 10
ARRAY2 RESW 10
12-Aug-24 CSE, AJCE 50
RESULT RESW 10
• LDS-6C
• LDT-74
• ADDR-90
• COMPR-A0
• HLT- FF
• The breaking of the entire assembly process into passes makes design
simpler and enables better control over the subtasks and
intermediate operations.
12-Aug-24 CSE, AJCE 55
Functions of Two Passes of
Assembler
• PASS 1 (Define symbols)
• Assign addresses to all statements in the program
• Save the values (addresses) assigned to all labels for use in Pass 2
• Perform some processing of assembler directives.
• (This includes processing that affects address assignment, such as determining
the length of data areas defined by BYTE, RESW, etc.)
• We must search OPTAB in the first pass to find the instruction length
for incrementing LOCCTR.
• SYMTAB includes the name and value(address) for each label in the
source program, together with flags to indicate error conditions(eg: a
symbol defined in two different places)
• One simple way to eliminate this problem: require that all areas be
defined before they are referenced.
• It is possible, although inconvenient, to do so for data items.
• Forward jump to instruction items cannot be easily eliminated.
• Programs are re-assembled nearly every time they are run, efficiency
of the assembly process is an important consideration.
• When loaded, the incorrect address 0 will be updated by the latter Text
record containing the symbol definition.
12-Aug-24 CSE, AJCE 121
Object code generated by one - pass
assembler
System software: an
introduction to systems
programming, Leland L. Beck,
3rd Edition, Addison Wesley,
Longman Inc., 1997.