Pass 2 of an assembler converts the assembly code into object code using the symbol table and literal table(intermediate) created in Pass 1. In this pass, symbolic addresses are replaced with actual memory addresses. Symbolic opcodes are translated into their numeric equivalents (machine code). Literals, such as constants, are also substituted with their memory addresses. The assembler processes instructions, generating the object code that the machine can execute. This pass ensures that all symbols, opcodes, and literals are resolved, and the program is ready for linking or execution. The final output is a machine-readable object file.
intermediate.txt
3000 sum START 3000
3000 first LDX ZERO
3003 +LDA ZERO LOOP
3006 ADD TABLE,X TIX
3009 COUNT JLT LOOP
300C +STA TOTAL MULF
300F ZERO ADD ONE
3012 RSUB TABLE RESW
3015 1000 COUNT RESW
3018 1 ZERO WORD
301B 0 TOTAL RESW
301E 1 STR1 BYTE
3021 C'EOF' STR2 BYTE
3024 X'01' END BYTE
Symbol_table.txt
sum 3000
first 3000
+LDA 3003
ADD 3006
COUNT 3009
+STA 300C
ZERO 300F
RSUB 3012
1000 3015
1 3018
0 301B
1 301E
C'EOF' 3021
X'01' 3024
object_code.txt
H^sum^003000
T^003000^03^00300FT^003003^03^000000T^003006^03^000000T^003009^03^000000T^00300C^03^000000T^00300F^03^000000T^003012^03^000000T^003015^03^000000T^003018^03^000000T^00301B^03^000000T^00301E^03^000000T^003021^03^000000E^003000