Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Module 1
General concepts - Review of assembly and machine language
programming , distinction between system software and application
software, Language processors :- Introduction , Language
processing activities.
Introduction
Language processing activities arise due to the differences b/w the manner in which a s/w
designer describes the ideas concerning the behaviour of a s/w and the manner in which these
ideas are implemented in a computer s/m.
Application domain: The designer expresses the ideas in terms related to the application domain
of the s/w.
Execution domain: To implement the ideas, their description has to be interpreted in terms
related to the execution domain of the computer s/m.
PL domain: Software implementation using a Programming Language introduces a new domain
called PL domain.
Semantic gap: Represent the difference b/w the semantics of two domains.(Semantic represent
the rules of meaning of a domain.
Semantic gap
Application Execution
domain domain
Continued…..
Execution gap: It is the gap b/w the semantics of programs (that perform the same task)written in
different programming languages.(The gap b/w the PL and execution domain).
Application PL Execution
domain domain domain
The language processing activities can be divided into those that bridge the
specification gap and those that bridge the execution gap. The activities are
Program Generation
Errors
Program
Program specification generator Program in target PL
Continued…..
. Specification gap
Program translation
The program translation model bridges the execution gap by translating a
program written in a PL(Source program), into an equivalent program in the
machine or assembly language of the computer system(target program).
Errors
Program interpretation
Characteristics of interpretation
Language processor
Errors Errors
ASSEMBLERS
ASSEMBLERS
The assembly-language program must be translated into
machine code by a separate program called an assembler.
Egs,
START 101
MULT BREG,TERM
ONE DC ‘1’
Assembly language Statements
I. Imperative statements
Syntax:
[Label] DS <constant>
[Label] DC ‘<value>’
A DS 1 :- reserves memory area of 1 word and associates the name A with it.
G DS 200 :- reserves a block of 200 memory words. Name G is associated
with the first block. Other blocks in the block can be accessed by adding the
offset. E.g. G+5 .
ONE DC ‘1’ :- associates the name ONE with a memory word containing
the value ‘1’.
Use of constants
START <constant>
Indicates that the first word of the target program generated by the
assembler should be placed in the memory word with address
<constant>.
Indicates the end of the source program. The optional <operand spec>
indicates the address of the instruction where the execution of the
program should begin.(By default, execution begins with the first
instruction of the assembled program).
Assembler’s functions
Process of Translation
Phases of Assembler
Analysis Synthesis
Source phase phase Object
pgm pgm
Symbol Address
AGAIN 104
N 113 Data access
Control transfer
Symbol Table
Fig: Data structures of the assembler
PASS STRUCTURES OF ASSEMBLERS
By the time the END statement is processed, the symbol table would
contain the address of all symbols defined in the source program and
TII would contain information describing all forward references.
The assembler can now process each entry in TII to complete the
concerned instruction.
For eg, the entry (101, ONE) would be processed by obtaining the
address of ONE from symbol table and inserting it in the operand
address field of the instruction with assembled address 101.
Backpatching
Pass 1 Pass 2
Source Target
pgm pgm
Intermediate code
Data access
Control transfer
SYMTAB
literal address literal
1 =‘5’ #1
2 =‘1’ #3
3 =‘1’ -
LITTAB POOLTAB
SYMTAB entry contains the fields symbol, address and length. If the assembly
statement contains a symbol, the symbol and the value of LC is copied into a
new entry of SYMTAB.
Declaration Assembler
Statements Directives
DC 01 START 01
DS 02 END 02
ORIGIN 03
EQU 04
LTORG 05
IC for Imperative Statements
The first operand is represented by a single digit number which is a code for
register (1-4) or the condition code itself(1-6 for LT-ANY).
The second operand is a memory operand, is represented by a pair of the form
(operand class,code)
For a constant, the code field contains the internal representation of the
constant itself.
For a symbol or literal, the code field contains the ordinal number of the
operand’s entry in SYMTAB or LITTAB.
LTORG
EQU
The EQU assembler directive simply equates a symbolic name to a numeric value.