0% found this document useful (0 votes)
2K views

1-Pass Assembler Algorithm

The algorithm describes a 1-pass assembler that reads assembly code lines, determines operation codes and operands, calculates memory locations, and writes output to an intermediate file. It initializes a location counter, searches symbol and operation tables, inserts symbols into a symbol table, increments the location counter based on operation codes like WORD, RESW, RESB, and BYTE, and sets error flags for invalid codes or duplicate symbols.

Uploaded by

Tejeshwar J
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

1-Pass Assembler Algorithm

The algorithm describes a 1-pass assembler that reads assembly code lines, determines operation codes and operands, calculates memory locations, and writes output to an intermediate file. It initializes a location counter, searches symbol and operation tables, inserts symbols into a symbol table, increments the location counter based on operation codes like WORD, RESW, RESB, and BYTE, and sets error flags for invalid codes or duplicate symbols.

Uploaded by

Tejeshwar J
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Algorithm for 1-Pass Assembler

Begin
Read first input line
If OPCODE = START then
Begin
Save #[OPERAND] as starting address
Initialize LOCCTR to starting address
Write line to intermediate file
Read next input line
End { if START }
Else
Initialize LOCCTR=0
While OPCODE != END do
Begin
If this is not a comment line then
Begin
If there is a symbol in the LABEL Field then
Begin
Search SYMTAB for LABEL
If found then
Set error flag (duplicate symbol)
Else
Insert (LABEL,LOCCTR) into SYMTAB
End {if Symbol }
Search OPTAB for OPCODE
If found then
Add 3 to LOCCTR
Else if OPCODE = WORD then
Add 3 to LOCCTR
Else if OPCODE = RESW then
Add 3 * #[OPERAND] to LOCCTR
Else if OPCODE = RESB then
Add #[OPERAND] to LOCCTR
Else if OPCODE = BYTE then
Begin
Find length of constant in bytes
Add length to LOCCTR
End
Else
Set error flag (invalid operation code )
End { if not comment }
Write line to intermediate file
Read next input line
End { While Loop }
Write last line to intermediate file
Save LOCCTR as program length
End { Pass 1 }

You might also like