UNIT-03 ASSEMBLERS

ASSEMBLER 

Assembler is a translator which translates an assembler language program into machine language . 

Assembly language program low level language programs which are machine dependents but easier as compare to machine language.

It generates instructions by evaluating the mnemonics (symbols) in operation field and find the value of symbol and literals to produce machine code. Now, if assembler do all this work in one scan then it is called single pass assembler, otherwise if it does in multiple scans then called multiple pass assembler. Here assembler divide these tasks in two passes:
  • Pass-1:
    1. Define symbols and literals and remember them in symbol table and literal table respectively.
    2. Keep track of location counter
    3. Process pseudo-operations
  • Pass-2:
    1. Generate object code by converting symbolic op-code into respective numeric op-code
    2. Generate data for literals and look for values of symbols



FEATURES OF AN ASSEMBLY LANGUAGE 

• We can use mnemonic rather than numeric operation code and it also supports an indication of coding error.
ʉۢ In this language symbolic operand specification is possible means operand can be represented in the form of symbolic references rather than machine address of data.
ʉۢ Data can be declared by using decimal notation.
The format of an assembly language statement is as follow :- [label] Mnemonic operand , [operand 1 , operand 2 , _ _ _ _ _ ] The field label is optional. 

ELEMENTS OF AN ASSEMBLY LANGUAGE PROGRAM

 An assembly program contain three types of statement :-
1. Imperative statements
2. Declarative statements
3. Assembler Directive statements

1. Imperative statements:-

The sentence which is used to convey a command, a request, or a forbiddance is called an imperative sentence. This type of sentence always takes the second person (you) for the subject but most of the time the subject remains hidden. Examples: Bring me a glass of water.

2. Declarative statements:-

Declarative programming is when you write your code in such a way that it describes what you want to do, and not how you want to do it. It is left up to the compiler to figure out the how.
Examples of declarative programming languages are SQL and Prolog.


3. Assembler Directive statements:-

Assembler directives are instructions that direct the assembler to do something.Directives do many things; some tell the assembler to set aside space for variables, others tell the assembler to include additional source files, and others establish the start address for your program. 

A SIMPLE ASSEMBLY SCHEME:-

ANALYSIS PHASE:-

1. It isolates label, mnemonics and operand field of a statement.
2. It enter symbol found in label field if any and address of text available machine word into symbol table.
3. It validates the mnemonic by looking it up in to the mnemonic code table.

SYNTHESIS PHASE :-

1. It obtained machine op code corresponding mnemonic op code by searching mnemonic table.
2. It obtained the machine address of operand symbol table. 
3. It makes synthesis of the machine instruction the machine form of constant. 

PASS STRUCTURE OF ASSEMBLER:-

The pass of a language processor is defined as one complete scan of the source program or it’s equivalent representation .
 There are two type of assembler :- 
1. Single pass assembler 
2. Multi pass assembler 

1. SINGLE PASS ASSEMBLER:-

 An assembler pass is one complete scan of source program input to the assembler or equivalent representation and a translation on a statement by statement basis would be termed as single pass translation or one pass assembler. 

 PROGRAM OF SINGLE PASS ASSEMBLER:-

START 100 
A DS 1
 B DS I 
FIRST READ A 
READ B 
LOAD A 
SUB B 
TRIM LARGE B 
PRINT A 
STOP
 LARGE B 
PRINT B 
STOP 
END FIRST

  2. MULTI PASS ASSEMBLER 

  • In multi pass assembler, an assembler goes through assembly language program several times and generates object code.
  •  First pass second pass and third pass are called as pass1, pass2, pass3 respectively. 
  • last passed is called as synthesis phase.
  • This assembler requires several form of intermediate codes, which are generate by each pass. 



Post a Comment