0% found this document useful (0 votes)
28 views3 pages

Algorithm For Pass

ALGORITHAM FOR PASS

Uploaded by

S G
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)
28 views3 pages

Algorithm For Pass

ALGORITHAM FOR PASS

Uploaded by

S G
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

Algorithm for Pass - II

It has been assumed that the target code is to be assembled in the area named
code_area.
1. Code_area_adress= address of code_areas;
Pooltab_ptr=1;
Loc_cntr=0;
2. While next statement is not an END statement
a) Clear machine_code_buffer;
b) If an LTORG statement
i) Process literals in LITTAB and assemble the literals in machine_code_buffer.
ii) Size= size of memory area required for literals
iii) Pooltab_ptr=pooltab_ptr +1;
c) If a START or ORIGIN statement
i) Loc_cntr=value specified in operand field;
ii) Size=0;
d) If a declaration statement
i) If a DC statement then assemble the constant in machine_code_buffer;
ii) Size= size of memory area required by DC/DS;
e) If an imperative statement
i) Get operand address from SYMTAB or LITTAB
ii) Assemble instruction in machine_code_buffer;
iii) Size=size of instruction;
f) If size≠ 0 then
i) Move contents of machine_code_buffer to the address
code_area_address+loc_cntr;
ii) Loc_cntr=loc_cntr+size;
3. Processing end statement
a) Perform steps 2(b) and 2(f)
b) Write code_area into output file.

Algorithm for Pass I


1) loc_cntr=0(default value)
pooltab_ptr=1; POOLTAB[1]=1;
littab_ptr=1;
2) While next statement is not END statement
a) If a label is present then
this_label=symbol in label field
Enter (this_label, loc_cntr) in SYMTAB
b) If an LTORG statement then
(i) Process literals LITTAB to allocate memory and put the address field.update
loc_cntr accordingly
(ii) pooltab_ptr= pooltab_ptr+1;
(iii) POOLTAB[ pooltab_ptr]= littab_ptr
c) If a START or ORIGIN statement then
loc_cntr=value specified in operand field;
d) If an EQU statement then
(i) this_address=value specified in <address spec>;
(ii) Correct the symtab entry for this_label to (this_label, this_address);
e) If a declaration
(i) Code= code of the declaration statement
(ii) Size= size of memory area required by DC/DS
(iii) loc_cntr=loc_cntr+size;
(iv) Generate IC ’(DL,code)’..
f) If an imperative statement then
(i) Code= machine opcode from OPTAB
(ii) loc_cntr=loc_cntr+instruction length from OPTAB;
(iii) if operand is a literal then
this_literal=literal in operand field;
LITTAB[littab_ptr]=this_literal;
littab_ptr= littab_ptr +1;
else
this_entry= SYMTAB entry number of operand
generate IC ‘(IS, code)(S, this_entry)’;
3) (processing END statement)
a) Perform step2(b)
b) Generate IC ‘(AD,02)’
c) Go to pass II

You might also like