Beruflich Dokumente
Kultur Dokumente
Here the symbols {, ‘,’ and} are part of the notation. We call them
metasymbols to differentiate them from terminal symbols. Throughout
this discussion we assume that metasymbols are distinct from the
terminal symbols. If this is not the case, i.e. if a terminal symbol and a
meta symbol are identical, we enclose the terminal symbol in quotes to
differentiate it from the meta symbol. For example, the set of
punctuation symbols of English can be defined as where ‘,’ denotes the
terminal symbol ‘comma’.
Nonterminal symbols
Productions
expresses the fact that the noun phrase consists of an article followed by
a noun.
1. Let α= ‘S’.
Example
< Noun Phrase > :: = < Article > < Noun >
< Noun Phrase > is the distinguished symbol of the grammar, the boy
and an apple are some valid strings in the language.
Definition (Grammar)
Derivation
*
*
*
A
and let be a string such that ß = γAθ, then replacement of A by α in
string constitutes a derivation according to production p1 . We use the
notation N Þη to denote direct derivation of η from N and N Þ η to denote
transitive derivation of η (i.e. derivation in zero or more steps) from N,
respectively. Thus, A =>α only if A : = α is a production of G and A Þ δ if
A Þ … Þ δ. We can use this notation to define a valid string according to a
grammar G as follows: δ is a valid string according to G only if S Þ δ,
where S is the distinguished symbol of G.
< Noun Phrase > => < Article > < Noun >
< Sentence >::= < Noun Phrase > < Verb Phrase >
Example
3 < Article > < Noun > < Verb > an apple
4 < Article > < Noun > < Verb > < Article > apple
5 < Article > < Noun > < Verb > < Article > < Noun >
6 < Noun Phrase > < Verb > < Article > < Noun >
7 < Noun Phrase > < Verb > < Noun Phrase >
Parse trees
B) Classification of Grammars
Type – 0 Grammars
Type – 1 grammars
Type – 2 grammars
Type – 3 grammars
A::= tB | t or A ::= Bt | t
Operator grammars
3. Compilation time of P
System software is usually not what a user would buy a computer for -
instead, it can be seen as the basics of a computer which come built-in
or pre-installed. In contrast to system software, software that allows
users to do things like create text documents, play games, listen to
music, or surf the web is called application software.
B) Application Software
C) System Programming
A) Data Structure
5. A table, the Symbol Table (ST) that is used to store each label and its
corresponding value.
6. A table, the literal table (LT) that is used to store each literal
encountered and its corresponding assignment location.
7. A work space INST that is used to hold each instruction as its various
parts are being assembled together.
The third step in our design procedure is to specify the format and
content of each of the data structures. Pass 2 requires a machine
operation table (MOT) containing the name, length, binary code and
format; pass 1 requires only name and length. Instead of using two
different tables, we construct single (MOT). The Machine operation table
(MOT) and pseudo-operation table are example of fixed tables. The
contents of these tables are not filled in or altered during the assembly
process.
The following figure depicts the format of the machine-op table (MOT)
START 101
READ N 101) + 09 0 113
MOVER BREG, ONE 102) + 04 2 115
MOVEM BREG, TERM 103) + 05 2 116
AGAIN MULT BREG, TERM 104) + 03 2 116
MOVER CREG, TERM 105) + 04 3 116
ADD CREG, ONE 106) + 01 3 115
MOVEM CREG, TERM 107) + 05 3 116
COMP CREG, N 108) + 06 3 113
BC LE, AGAIN 109) + 07 2 104
MOVEM BREG, 110) + 05 2 114
RESULT
PRINT RESULT 111) + 10 0 114
STOP 112) + 00 0 000
N DS 1 113)
RESULT DS 1 114)
ONE DC ‘1’ 115) + 00 0 001
TERM PS 1 116)
END
Pass I:
3. Perform LC processing.
Definition : macro
For instance,
Defines the macro max, taking two arguments a and b. This macro
may be called like any C function, using identical syntax. Therefore, after
preprocessing
z = max(x, y);
Macro Expansion.
Example
In the above program a macro call is shown in the middle of the
figure. i.e. INITZ. Which is called during program execution. Every macro
begins with MACRO keyword at the beginning and ends with the ENDM
(end macro).when ever a macro is called the entire is code is substituted
in the program where it is called. So the resultant of the macro code is
shown on the right most side of the figure. Macro calling in high level
programming languages
(C programming)
Main () {
int x , y;
x=4; y=6;
z = max(x, y); }
Becomes z = x>y ? x: y;
After macro expansion, the whole code would appear like this.
main()
{ int x , y;
C) Macros Parameters
Syntax:
MOV A,#CONSTANT
ADD A,REGISTER
ENDM
MY_SECOND 42, R5
MOV A,#42
ADD A,R5
are inserted into the program, and assembled. The parameter names
CONSTANT and REGISTER have been replaced by the macro arguments
"42" and "R5". The number of arguments, passed to a macro, can be less
(but not greater) than the number of its formal parameters. If an
argument is omitted, the corresponding formal parameter is replaced by
an empty string. If other arguments than the last ones are to be omitted,
they can be represented by commas.
Fig. 3.0
Example 4
If it is called as follows,
OPTIONAL 1,2,,,5,6
the formal parameters P1, P2, P5 and P6 are replaced by the arguments
1, 2, 5 and 6 during substitution. The parameters P3, P4, P7 and P8 are
replaced by a zero length string.
Bootstrap loading
Compiler Bootstraping
ADDR_A DW OFFSET A
For linking, however both segment base address and offset of the
external symbol must be computed by the linker. Hence there is no
reduction in the linking requirements.