0% found this document useful (0 votes)
23 views1 page

Garu

Uploaded by

sreetemp10
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)
23 views1 page

Garu

Uploaded by

sreetemp10
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

Assembler Pass 1:

begin Assembler Pass2:


read first input line begin
if OPCODE ='START' then read first input line (from intermediate file)
begin if OPCODE ='START' then
save #[OPERAND] as starting address begin
initialize LOCCTR to starting address write listing line
write line to intermediate file read next input line
read next input line end {if START}
end {if START} write Header record to object program
else initialize first Text record
initialize LOCCTR to 0 while OPCODE != 'END' do
while OCODE != 'END' do begin
if this is not a comment line then
begin
begin
if this is not a comment line then
search OPTAB for OPCODE
begin
if found then
if there is a symbol in the LABEL field then begin
begin if there is a symbol in OPERAND field then
search SYMTAB for LABEL begin
if found then search SYMTAB for OPERAND
set error flag (duplicate symbol) if found then
else store symbol value as operand address
insert (LABEL,LOCCTR) into SYMTAB else
end {if symbol} begin
search OPTAB for OPCODE store 0 as operand address
if found then set error flag (undefined symbol)
add 3 {instruction length} to LOCCTR end
else if OPCODE='WORD' then end {if symbol}
add 3 to LOCCTR else
else if OPCODE = 'RESW' then store 0 as operand address
add 3 * #[OPERAND] to LOCCTR assemble the object code instruction
else if OPCODE = 'RESB' then end {if opcode found}
add #[OPERAND] to LOCCTR else if OPCODE ='BYTE' or 'WORD' then
else if OPCODE = 'BYTE' then convert constant to object code
begin if object code will not fit into the current Text record then
find length of constant in bytes begin
add length to LOCCTR write Text record to object program
end {if BYTE} initialize new Text record
else end
set error flag (invalid operation code) add object code to Text record
end {if not comment}
end {if not a comment}
write listing line
write line to intermediate file
read next input line
read next input line
end(while not END)
end {while not END} write last Text record to object program
write last line to intermediate file write End record to object program
save (LOCCTR – starting address) as program length write last listing line
end {Pass 1} end{Pass 2}

You might also like