Beruflich Dokumente
Kultur Dokumente
HOME WORK – II
Analysis phase:-
The function performed by the analysis phase is the building of the symbol table.
For this purpose it must determine the addresses with which the symbolic names
use in a program are associated memory allocation
1. Scanning (tokenizing)
2. Parsing (validating the instructions)
3. Creating the symbol table
4. Resolving the forward references
5. Converting into the machine language
The place of assembler in a system .
The above diagram shows the place of assembler in a complete system.
Q 2. How a assembler converts mnemonic code in to machine understandable
form? Explain?
ANSWER: Typically a modern assembler creates object
code by translating assembly instruction mnemonics
into opcodes, and by resolving symbolic names for memory
locations and other entities. The use of symbolic references
is a key feature of assemblers, saving tedious calculations
and manual address updates after program modifications.
Most assemblers also include macro facilities for performing
textual substitution—e.g., to generate common short
sequences of instructions as inline, instead
of called subroutines, or even generate entire programs or
program suites.
The assembler
3One-Pass Assembler
●Except for forward references, all could be done in
a single pass.
●Forward references can be handled by creating links of
references to fill: fill at end or when attributes become
known.
4Load-and-go Assembler
●it must run in a fixed location.
●it cannot be combined with other modules.
●there must be enough memory for the assembler
and the code (the code must be in main storage to
facilitate filling backward the links)
1. Sorting algorithms:
a. Simple exchange sort
b. Classic bubble sort
c. Simple insertion sort
d. Recursive quick sort
Searching
If an insulated application specifies an assembly
dependency, side-by-side first searches for the assembly
among the shared assemblies in the WinSxS folder. If the
required assembly is not found, side-by-side then searches
for a private assembly installed in a folder of the
application's directory structure.
Part B
Q1. What is the need for relocation of the program? With an example explain
how relocation can be done.
ANSWER:
(+JSUB RDREC)
7420 .
. .
. .
.7426 4B101036
. .
. .
8456 B410 RDREC
. .
. .
. .
8496 .
Q2. Enlist the various assembler features that are machine dependent and
machine independent. Explain any one of them from each.
ANSWER:
Machine dependent assembler features:
1) Instruction format
2) addressing modes
3) Relocation
6. Register-to-register instructions
6. Expressions
7.
Control Section
Program Linking
Q3. What are the basic functions of a loader? Develop an algorithm for a
bootstrap loader.
Answer:
FUNCTIONS OF LOADER: -
1. bringing an object program into memory
2. starting its execution
3. The loader is capable of loading modules in a range of
object formats, and knowledge of these formats is built
in to the loader.
4. Knowledge of new object formats can be added to the
loader in a straightforward manner. This makes it
possible to provide OS-independent modules (for a
given CPU architecture type).
5. The loader is capable of loading modules in a range of
object formats.
a. The knowledge of these formats is built in to the
loader.
b. The knowledge of new object formats can be
added to the loader in a straightforward manner.
6. This makes it possible to provide OS-independent
modules (for a given CPU architecture type).
7. In addition to this, the loader can load modules via the
OS-provided dlopen (3) service where available. Such
modules are not platform independent, and the
semantics of dlopen () on most systems results in
significant limitations in the use of modules of this type.
Support for dlopen () modules in the loader is primarily
for experimental and development purposes.
8. Special registration functions of loader are:
a. The loader contains some functions for registering
some classes of modules. These may be moved
out of the loader at some point.
b. Void Load Extension (Extension Module *ext)
c. This registers the entry points for the extension
identified by ext.This registers the entry points for
the font rasteriser module identified by font.
Begin
X=0x80 (the address of the next memory location
to be loaded)
Loop
A? GETC (and convert it from the ASCII character
code to the value of the hexadecimal digit)
Save the value in the high-order 4 bits of S
A? GETC
Combine the value to form one byte A? (A+S)
Store the value (in A) to the address in register X
X? X+1
End
Program Linking
Goal - Resolve the problems with EXTREF and EXTDEF from different
control sections