In a two pass assembler pseudo code EQU is to be evaluated duringa)Pas...
In 2-pass assembler during pass-1 pseudo code EQU is to be evaluated.
View all questions of this test
In a two pass assembler pseudo code EQU is to be evaluated duringa)Pas...
Pass 1 and Pass 2 in a Two Pass Assembler
In a two pass assembler, the assembly process is divided into two passes. Each pass performs specific tasks to convert the assembly code into machine code.
Pass 1:
During the first pass, the assembler reads the entire assembly source code and performs the following tasks:
1. Symbol Table Creation: The assembler creates a symbol table to store the symbols (labels, variables, constants) defined in the assembly code. It assigns unique addresses to each symbol encountered.
2. Literal Table Creation: The assembler creates a literal table to store the literals (constant values) defined in the assembly code. It assigns unique addresses to each literal encountered.
3. Location Counter (LC) Calculation: The assembler keeps track of the location counter (LC), which represents the current memory address being assigned to instructions and data. It updates the LC based on the size of each instruction or data encountered.
4. EQU Evaluation: During the first pass, the assembler evaluates the EQU statements encountered. EQU is a directive used to define symbolic constants with specific values. The assembler replaces the EQU statement with its corresponding value in the symbol table.
5. Intermediate Code Generation: The assembler generates an intermediate code that represents the assembly code in a format that is easier to process in the second pass.
Pass 2:
During the second pass, the assembler performs the following tasks:
1. Address Resolution: The assembler resolves the addresses of symbols and literals encountered in the intermediate code by referring to the symbol table and literal table created in the first pass. It replaces the symbolic references with their corresponding addresses.
2. Object Code Generation: The assembler generates the final object code by converting the resolved instructions and data into machine code format.
3. Relocation: If necessary, the assembler performs relocation, which adjusts the addresses in the object code to reflect the actual memory locations where the program will be loaded.
4. Listing File Generation: The assembler generates a listing file that provides a printable representation of the assembly code, including the object code, symbol addresses, and any errors or warnings encountered.
EQU Evaluation in Pass 1:
The given question asks when the EQU statements are evaluated in a two pass assembler. According to the standard two pass assembly process, EQU statements are evaluated during Pass 1.
During Pass 1, the assembler encounters the EQU statements and replaces them with their corresponding values in the symbol table. This allows the assembler to handle symbolic constants efficiently during Pass 2 and generate the correct object code.
Evaluating EQU statements during Pass 1 ensures that the symbolic constants are resolved and their values are known before the actual assembly process begins in Pass 2. This helps in correctly calculating memory addresses and generating accurate object code.
Hence, the correct answer is option 'A' - Pass 1.