Assembler Questions | Compiler Design

Question 1
A simple two-pass assembler does which of the following in the first pass:
A
Checks to see if the instructions are legal in the current assembly mode
B
It allocates space for the literals.
C
It builds the symbol table for the symbols and their values.
D
All of these
Question 1 Explanation: 
1st pass: scan label definitions and assign addresses
2nd pass: actual translation (object code)

Pass 1 : define symbols (assign addresses)
  • Assign addresses to all statements in the program
  • Save the values assigned to all labels for use in Pass 2
  • Process some assembler directives
  • Table creation , Adding literals to literal table
  • Allocate space for literals
  • Compute total length of a program
Pass 2 : assemble instructions and generate object program
  • Assemble instructions
  • Generate data values defined by BYTE, WORD, etc.
  • Process the assembler directives not done in Pass 1
  • Write the object program and the assembly listing
Finally, assembler must write the generated object code to some output device
- Called object program
- Will be later loaded into memory for execution
Question 2
In a single pass assembler, most of the forward references can be avoided by putting the restriction
A
On the number of strings/lifereacs
B
That the data segment must be defined after the code segment
C
On unconditional rump
D
That the data segment be defined before the code segment
Question 2 Explanation: 
A single pass assembler scans the program only once and creates the equivalent binary program
Question 3
Pseudo-instructions are
A
Assembler directives
B
Instructions in any program that have no corresponding machine code instruction
C
Instruction in any program whose presence or absence will not change the output for any input
D
None of these
Question 3 Explanation: 
Pseudo Instructions are special commands to the assembler about the positioning of the program, the address the program should presumed to be assembled at, the name of the module, data declarations, the title and printing options for the program, defining and calling macros, macro looping and test, and end of source code. Unless a machine instruction is issued, these do not generate executable code.

Refer : https://en.wikibooks.org/wiki/360_Assembly/Pseudo_Instructions
Question 4
Which activity is not included in the first pass of two pass assemblers ?
A
Build the symbol table
B
Construct the intermediate code
C
Separate mnemonic opcode and operand fields
D
None of the above
Question 4 Explanation: 
option A,B,C are included.
Two Pass Assembler
Question 5
Which activity is included in the first pass of two pass assemblers ?
A
Build the symbol table
B
Construct the intermediate code
C
Separate mnemonic opcode and operand fields
D
None of these
E
None
Question 5 Explanation: 
option A,B,C are included.
Two Pass Assembler
Question 6
In two pass assembler the symbol table is used to store :
A
Label and value
B
Only value
C
Mnemonic
D
Memory Location
Question 6 Explanation: 
  • In two pass assembler the symbol table is used to store memory locations
  • The symbol table contains information to locate and relocate symbolic definitions and references. The assembler creates the symbol table section for the object file. It makes an entry in the symbol table for each symbol that is defined or referenced in the input file and is needed during linking.
  • The symbol table is then used by the link editor during relocation. The symbol table's section header contains the symbol table index for the first non-local symbol.
  • Instead of using an absolute memory address it uses a symbolic address.
Question 7
A general macroprocessor is an in built function of :
A
Loader
B
Linker
C
Editor
D
Assembler
Question 7 Explanation: 
  • A general-purpose macro processor or general purpose preprocessor is a macro processor that is not tied to or integrated with a particular language or piece of software.
  • A macro processor is a program that copies a stream of text from one place to another, making a systematic set of replacements as it does so.
  • Macro processors are often embedded in other programs, such as assemblers and compilers. Sometimes they are standalone programs that can be used to process any kind of text.
  • Macro processors have been used for language expansion (defining new language constructs that can be expressed in terms of existing language components), for systematic text replacements that require decision making, and for text reformatting (e.g. conditional extraction of material from an HTML file).
Question 8
Which activities is not included in the first pass of two pass assembler ?
A
Build the symbol table
B
Construct the Intermediate code
C
Separate mnemonic opcode and operand field.
D
None of these
Question 8 Explanation: 
option A,B,C are included.
Two Pass Assembler
Question 9
Which of the following are Assembler Directives ?
(i) EQU
(ii) ORIGIN
(iii) START
(iv) END
A
(ii), (iii) and (iv)
B
(i), (iii) and (iv)
C
(iii) and (iv)
D
(i), (ii), (iii) and (iv)
Question 9 Explanation: 
An assembler directive is a message to the assembler that tells the assembler something it needs to know in order to carry out the assembly process; for example, an assemble directive test the assembler where a program is to be located in memory.
Basic Assembly directives
EQU →Equate
ORG →Origin
START → Start (Define the start of the first control section in a program)
END → End (End of assembly language program and "starting address" for execution)
Question 10
Assembler program is :
A
Dependent on the operating system
B
Dependent on the compiler
C
Dependent on the hardware
D
Independent of the hardware
Question 10 Explanation: 
  • Assembly languages are hardware dependent; there is a different one for each CPU series.
  • Assembly language (or Assembler) is a compiled, low-level computer language. It is processor-dependent, since it basically translates the Assembler's mnemonics directly into the commands a particular CPU understands, on a one-to-one basis.
  • These Assembler mnemonics are the instruction set for that processor
Question 11
Which variable does not drive a terminal string in grammar?
S → AB
A → a
B → b
B → C
A
A
B
B
C
C
D
S
Question 11 Explanation: 
C is the useless variable as there is no production rule which replaces C with a terminal. Thus, it does not derive any non terminal.
There are 11 questions to complete.

Leave a Reply