Answered step by step
Verified Expert Solution
Question
1 Approved Answer
pass 1 pass 2 convert it to c + + code that can be run this pass 1 assembler and pass 2 assembler algorithm Pase
pass pass convert it to c code that can be run this pass assembler and pass assembler algorithm Pase : begin read first input line OPCODE START then begin save OPERAND as starting address initialize LOCCTR to starting address write line to intermediate file read next input line and if START also initialize LOCCTR to O while OPCODE 'END' do begin if this is not a comment line then begin 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 instruction length to LOCOTR else if OPCODE WORD then add to LOCCTR else if OPCODE RESW then add # OPERAND to LOCOTR else if OPCODE RESB' then add #TOPERAND to LOOCTR else it OPCODE RYTE then begin TH O PCbogin search SYMTAB for LABEL found then set error flag duplicate symbol olso insert LABEL LOCCTR into SYMPAB and if symboly search OPTAB for OPCODE if found then add instruction length to LOCCTR else if OPCODE 'WORD' then add to LOCCTR else it OPCODE "RESW' then add # OPERAND to LOCCTR else if OPCODE 'RESB' then add # OPERAND to LOCCTR else it OPCODE 'BYTE' then begin find length of constant in bytes add length to LOCCTR end fif BYTE else set error flag invalid operation code end if not a comment write line to intermediate file read next input line end while not END write last line to intermediate file save LOCCTR starting address as program length end Pass Figure a Algorithm for Pass of assembler.Pass : begin read first input line from intermediate file if OPCODE "START' then begin write listing line read next input line and if START write Header record to object program initialize first Text record while OPCODE END do begin f this is not a comment line then begin search OPTAB for OPCODE if found then begin if there is a symbol in OPERAND field then begin search SYMTAB for OPERAND if found then store symbol value as operand address else begin store O as operand address set error Flag undefined symbol end end if symbol else store as operand address assemble the object code instruction end if opcode found elso OPCODE BYTE' or WORD' then convert constant to object code if object code will not fit into the current Text record then begin write Text record to object program initialize new Text record end add object code to Text record end if not commentond Lou BD store symbol value as operand address olno begin store as operand address set error flag undefined symbol and if symbol olsa store as operand address assemble the object code instruction end if opcode found else OPCODE BYTE OF WORD' then convert constant to object code if object code will not fit into the current Text record than begin write Text record to object program initialize new Text record end add object code to Text record and if not comment write listing line read next input line end while not END write last Text record to object program write End record to object program write last listing line and Pass N Figure b Algorithm for Pass of assembler.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started