Implement a Pass I of Two Pass Assembler
Aim: To write a C program to perform pass1 of a two assembler.
- Start the assembly process by processing the assembly program statements.
- Location counter is initialized to the starting address if OPCODE = “START” else if it is initialized to 0.It is incremented depending upon the size of next consecutive instruction.
- If there is any symbol present in lable field, location counter is entered into symbol table.The opcode table must be present in the memory during pass1.
- Search the OPTAB.If it is found add 3 to locctr.
- If not found in OPTAB, update the location value by checking whether the opcode is WORD,RESW,RESB or BYTE.
- Write the program line with locctr value to intermediate file.
- Read the next input line.
- Steps3 to 7 is carried out till the end statement is reached.
- Finally save the value of 1 locctr-starting address) and program length.