This is a simple 2 pass assembler code written in Python
- Read starting address from file and store it in a variable
- Write address, check mnemonic + register opcode and write them accordingly(hardcode mo & ro and check)
- if STOP in statement > write string & address
- if flag==1 > decrement address, update address as per ORIGIN
- if ele of SYMBOL in line > update symtab, address, value and length accordingly
- if “=” equals words[0] > update literal table
- if “=” ! in words & if lit count != 0 > update pool table
- increment address
- if ! END goto step 2 else close all files 10.Open all closed files in read mode and create pass2 file
- In loop of file2 > if Address in words > continue
- In loop of file1 > if words1[-1] == words2[-1] > write(words1[0]+words2[0]+words1[-1]) > flag=1
- if flag==0 > write(words1[0]+_________+words1[-1])
- Similarly check lit table with file1 & write to pass2
- goto 11 until loop ends
- Close all files