Answered step by step
Verified Expert Solution
Link Copied!

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 1 pass 2 convert it to c++ code that can be run this pass 1 assembler and pass 2 assembler algorithm Pase 1: begin read first input line 12 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 1 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(instruction length to LOCOTR else if OPCODE WORD then add 3 to LOCCTR else if OPCODE RESW then add 3 # [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 1 found then set error flag (duplicate symbol) olso insert (LABEL, LOCCTR) into SYMPAB and (if symboly search OPTAB for OPCODE if found then add 3(instruction length) to LOCCTR else if OPCODE = 'WORD' then add 3 to LOCCTR else it OPCODE = "RESW' then add 3* # (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 1) Figure 2.4(a) Algorithm for Pass 1 of assembler.Pass 2: 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 1f 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 0 as operand address assemble the object code instruction end (if opcode found) elso 11 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 12 Lou BD store symbol value as operand address olno begin store 0 as operand address set error flag (undefined symbol) and (if symbol) olsa store 0 as operand address assemble the object code instruction end (if opcode found) else 10 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 2) N Figure 2.4(b) Algorithm for Pass 2 of assembler.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions

Question

3. What would you do now if you were Mel Fisher?

Answered: 1 week ago

Question

14.3 Explain WHMISlegislation.

Answered: 1 week ago