Q 1. Discuss Design Specification of A Assembler With Diagram? Ans
Q 1. Discuss Design Specification of A Assembler With Diagram? Ans
Synthesis phase:-
Two data structure are used in synthesis phas:-
1-symbol table
2-mneomonics table.
Q 2. How a assembler converts mnemonic code in to machine understandable
form? Explain?()()()()()(figers)
Ans The machine language consists of 0’s and 1’s and also Mnemonic
Codes(Assembly Languages).
In machine languages, the execution time is very less compare to other languages
because; the computer can understand instructions in code form. This machine languages
are difficult in nature.
In Assembly language, mnemonic codes were used instead of 0’s and 1’s used in
machine language.
Here translator is needed to convert assembly language into machine language. Hence
assembler is used.
Compare to machine language, it gives little more readability, and also easy to modify
and isolate errors.
Assembler uses the translator program for conversion through mnemonics code
into machine language.
Assembler
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.
Data bases
Assemblers are generally simpler to write than compilers for high-level languages, and
have been available since the 1950s. Modern assemblers, especially for RISC based
architectures, such as MIPS, Sun SPARC, and HP PA-RISC, as well as x86(-64),
optimize instruction scheduling to exploit the CPU pipeline efficiently.
Types of assembler:-
There are two types of assemblers based on how many passes through the source are
needed to produce the executable program.
One-pass assemblers go through the source code once and assumes that all symbols will
be defined before any in
struction that references them.
Two-pass assemblers (and multi-pass assemblers) create a table with all unresolved
symbols in the first pass, then use the 2nd pass to resolve these addresses. The advantage
of a one-pass assembler is speed, which is not as important as it once was with advances
in computer speed and capabilities. The advantage of the two-pass assembler is that
symbols can be defined anywhere in the program source. As a result, the program can be
defined in a more logical and meaningful way. This makes two-pass assembler programs
easier to read and maintain.
More sophisticated high-level assemblers provide language abstractions such as:
Advanced control structures
High-level procedure/function declarations and invocations
High-level abstract data types, including structures/records, unions, classes, and sets
Sophisticated macro processing (although available on ordinary assemblers since late
1960s for IBM/360, amongst other machines)
Object-Oriented features such as encapsulation, polymorphism, inheritance, interfaces
Assembler Developed-Many sophisticated assemblers offer additional
mechanisms to facilitate program development, control the assembly process, and
aid debugging. In particular, most modern assemblers include a macro facility
(described below), and are called macro assemblers.
Q 4. Assembler can perform operations of search and sort? Give your comments?
ANSWER:
It finds the maximum number and this can help you write the sort program
LXI H,ADD1
MOV C,M
INX H
MOV A,M
ADD2:
; Label to jump at
INX H
; Increment the address to point to the next location
CMP M
JNC LESS:
MOV A,M
; Move the content of the location M into the accumulator if the Jump
fails
LESS:
; Label to jump at
DCR C
JNZ ADD2
STA ADD_OUTPUT
; Accumulator will contain the Max no and move to the out put address.
Part B
Q1. What is the need for relocation of the program? With an example explain how
relocation can be done.
Ans- Program Relocation:
It is often desirable to have more than one program at a time sharing the
memory and other resources of machine. If we knew in advance exactly
which programs were to be executed concurrently in this way, we could
assign addresses when the programs were assembled so that they could fit
together without overlap or wasted space. Most of the time, however, it is
not practical to plan program execution this closely. Because of this, it is
desirable to be able to load a program into memory whenever there is
room for it. In such cases, the actual starting address of the program is
known until load time.
Since the assembler does not know the actual location where the program
will be loaded, it cannot make the necessary changes in the address used
by the program. However, the assembler can identify for the loader those
parts of the object program that needs modification. An object program
that contains necessary information to perform this kind of modification is
called relocation program.
Example-
how a program is loaded, beginning at address 0000.JSUB instruction is loaded at
address 0006. Consider that the address field of this instruction contains 01036,
which is the address of the instruction labeled RDREC. Now suppose we want to
load this program beginning at address 5000 as shown in fig 2. The address of this
instruction labeled RDREC is then 6036.
Thus the JSUB instruction must be modified as shown to contain this new
address. Likewise, if we loaded the program beginning at address 7420
(fig 3), the JSUB instruction would need to be changed to 4b108456 to
correspond to the new address of RDREC.
1. When the assembler generates the opcode for JSUB, we are considering, it will
insert the address RDREC relative to the start of the program.
2. The assembler will also produce a command for the loader, instructing it to add
the beginning address of the program to the address field in the JSUB instruction
at the load time.
Fig(1) Fig(2)
(+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.
Ans- Using an intermediate language is a well-known, effective technique for
constructing interpreters and compilers. This paper describes a retargetable,
optimizing compilation system centered around the use of two intermediate
languages (IL): one relatively high level, the other a low level corresponding to
target machine instructions. The high-level IL (HIL) models a stack-based,
hypothetical RISC machine. The low-level IL (LIL) models target machines at the
instruction-set architecture level. All code improvements are applied to the LIL
representation of a program. This is motivated by the observation that most
optimizations are machine dependent, and the few that are truly machine
independent interact with the machine-dependent ones. This paper describes
several machine-independent code improvements and shows that they are actually
machine dependent. To illustrate how code improvements can be applied to a LIL,
an algorithm for induction variable elimination is presented. It is demonstrated that
this algorithm yields better code than traditional implementations that are applied
machine-independently to a high-level representation.
Q3. What are the basic functions of a loader? Develop an algorithm for a bootstrap
loader.
Ans-
Functions of loader:
The software begins by checking for the signal to start the loader. If present, the
device performs user-requested boot-loader functions. When complete, or if no
loader stimulus was detected, the device will jump to location FFF0h, modify the
ROMSIZE register to disable internal EPROM, and jump back to the restart
vector. This simulates a device beginning execution at address 0000h following a
reset.