Sei sulla pagina 1di 1

Algorithm for pass1 Assembler:

1.Read the input line.


2.Check to see if the opcode in the input line is �START�.
i. Find if there is any operand field after START, if so that indicates the
location from
which the program has to be loaded in the memory, so initialize the LOCCTR to the
operand value.
For eg .If START 2000,is the first statement, the LOCCTR value is set to 2000.
ii. Otherwise if there is no value in the operand field the LOCCTR is set to zero
and
the program starts loading from the starting address zero.
3.Write the line to the intermediate file.
4.Now start the following processing for the other lines in the program, if it is
not a comment
line, until the opcode is �END�.
A) If there is a symbol in the label field.
i. Check the symbol table to see if has already been stored over there. If so then
it is a
duplicate symbol, the error message should be displayed.
ii.Otherwise if the symbol is entered into the SYMTAB, along with the memory
address in which it is stored.
B) If there is an opcode in the line read.
i. Search the OPTAB to see if the opcode is present, if so increment the location
counter (LOCCTR) by three.
ii. a) If the opcode is �WORD�, increment the location counter by three.
SEC CSE/V SS LAB MANUAL
19
b) If the opcode is �BYTE� increment the location counter by one.
c) If opcode is RESW increment the location counter by the integer equivalent of
operand value *3.
d) If the opcode is RESB increment the location counter by the integer equivalent
of the operand value.
C) Write each and every line processed to the intermediate file along with their
Location counters.
5.Subtract the starting address of the program from the final value of the LOCCTR,
to
Calculate the length of the program.
6.Close all the operand files and exit

Potrebbero piacerti anche