JasonDsouza - 9537 - Batch A
JasonDsouza - 9537 - Batch A
JasonDsouza - 9537 - Batch A
10. Assignment 2
11. Assignment 3
Department of Computer Engineering
Practical No: 1
Evaluation:
2
Practical No:
Implementing Lexical Analyzer
Title:
12/02/2024
Date of Performance:
26/2/24
Date of Submission:
9537
Roll No:
Jason dsouza
Name of the Student:
Evaluation:
Experiment No 2
Theory:
THE ROLE OF LEXICAL ANALYZER
The lexical analyzer is the first phase of a compiler. Its main task is to read the input
characters and produce as output a sequence of tokens that the parser uses for syntax analysis. Upon
receiving a “get next token” command from the parser, the lexical analyzer reads input characters
until it can identify the next token.
Since the lexical analyzer is the part of the compiler that reads the source text, it may also perform
certain secondary tasks at the user interface. One such task is stripping out from the source program
comments and white spaces in the form of blank, tab, and new line characters. Another is correlating
error messages from the compiler with the source program. Sometimes lexical analyzers are divided
into a cascade of two phases first called “scanning” and the second “lexical analysis”. The scanner is
responsible for doing simple tasks, while the lexical analyzer proper does the more complex operations.
Implementation Details
Source Code:
import java.util.ArrayList;
import java.util.Scanner;
import java.io.File;
import java.util.Arrays;
public RefinedSymbolTable() {
tokens = new ArrayList<>();
}
Output:
SPCC_Data.txt
Conclusion: Thus, we have successfully read file input consisting of various expressions and
converted them into tokens stored in the symbol table.
Post Lab Questions:
lass
C : T.E. (Computer)
Subject Name :System Programming and Compiler Construction
Subject Code :(CPC601)
3
Practical No:
Design recursive descent parser
Title:
09/02/2024
Date of Performance:
9564
Roll No:
Vedant Pathare
Name of the Student:
Evaluation:
Experiment No 3
Procedure for E
otethatthe'next'looksaheadandalwaysprovidesthenextcharacterthatwillbereadfrom
N
theinputstream.Thisfeatureisessentialifwewishourparserstobeabletopredictwhatis
due to arrive as input.
ote that 'errorhandler' is a procedure that notifies the user that a syntax error has been made
N
and then possibly terminates execution.
I n order to recognize a T, the parser must figure out which of the productions to execute. This
is not difficult and is done in the procedure that appears below.
Procedure for T
I n the above routine, the parser determines whether T had the form (E) or x. If not then the
error routine was called, otherwise the appropriate terminals and nonterminals were
recognized.
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Algorithm:
1. Make grammar suitable for parsing i.e. remove left recursion(if required).
2. Write a function for each production with error handler.
3 . Given input is said to be valid if input is scanned completely and no error function is
called.
Source Code:
import java.util.Scanner;
}
class RecursiveDecentParser {
private String input;
private Scanner inputScanner;
RecursiveDecentParser() {
acceptInputString();
inputScanner = new Scanner(input);
}
}
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Output:
onclusion:Thus,wehavesuccessfullyimplementedarecursivedescentparserandverified
C
that it can correctly parse valid strings.
Postlab:
1. What is left Recursion ? Write the rules for removing left recursion.
2. What is left factoring ? Write rules for eliminating left factoring.
3. Difference between top down and Bottom up parsing
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Practical No: 4
Evaluation:
Experiment No 4
● If a compiler translates the source language to its target machine language without
having the option for generating intermediate code, then for each new machine, a full
native compiler is required.
● Intermediate code eliminates the need of a new full compiler for every unique
machine by keeping the analysis portion same for all the compilers.
● The second part of compiler, synthesis, is changed according to the target machine.
● It becomes easier to apply the source code modifications to improve code
performance by applying code optimization techniques on the intermediate code.
● Three-Address Code
Intermediate code generator receives input from its predecessor phase, semantic
analyzer, in the form of an annotated syntax tree. That syntax tree then can be
converted into a linear representation, e.g., postfix notation. Intermediate code tends
to be machine independent code. Therefore, code generator assumes to have
unlimited number of memory storage (register) to generate code.
● For example:
● a = b + c * d;
● The intermediate code generator will try to divide this expression into
sub-expressions and then generate the corresponding code.
● r1 = c * d;
● r2 = b + r1;
● a = r2
Quadruples
Each instruction in quadruples presentation is divided into four fields: operator, arg1, arg2,
and result. The above example is represented below in quadruples format:
* c d r1
+ b r1 r2
+ r2 r1 r3
= r3 a
Triples
Each instruction in triples presentation has three fields : op, arg1, and arg2.The results of
respective sub-expressions are denoted by the position of expression. Triples represent
similarity with DAG and syntax tree. They are equivalent to DAG while representing
expressions.
Op arg1 arg2
* c d
+ b (0)
+ (1) (0)
= (2)
Triples face the problem of code immovability while optimization, as the results are
positional and changing the order or position of an expression may cause problems.
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Indirect Triples
This representation is an enhancement over triples representation. It uses pointers instead of
position to store results. This enables the optimizers to freely re-position the sub-expression
to produce an optimized code.
Source Code:
import java.util.Scanner;
while (true) {
System.out.println("Generate three-address code for: 1)Assignment 2)Conditional
3)Indexed Assignment 4)Copy 5)Exit");
System.out.print("Enter your choice: ");
int choice = scanner.nextInt();
scanner.nextLine();
System.out.println();
switch (choice)
{case 1:
generateAssignmentCode();
break;
case 2:
generateConditionalCode();
break;
case 3:
generateIndexedAssignmentCode();
break;
case 4:
generateCopyCode();
break;
case 5:
System.out.println("Exiting...");
scanner.close();
System.exit(0);
default:
System.out.println("Invalid choice. Please enter a number from 1 to 5.");
}
System.out.println();
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
}
}
System.out.println("Three-address code:");
System.out.println(code.toString());
}
System.out.println("Three-address code:");
System.out.println(code.toString());
}
System.out.println("Three-address code:");
System.out.println(code.toString());
}
}
Output:
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Postlab Question
1. Write the intermediate code generated for------while ( a<b ) do
If ( c< d) then
X= y+z
Else
X= y-z
2. Write the intermediate code generated for----- switch E
Begin
case V1 : S1
case V2 : S2
….
default: Sn
end
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
5
Practical No:
Evaluation:
Experiment No 5
Lex is a program generator designed for lexical processing of character input streams.
Itaccepts a high-level, problem oriented specification for character string matching,
andproduces a program in a general purpose language which recognizes regular
expressions.The regular expressions are specified by the user in the source specifications
given to Lex.The Lex written code recognizes these expressions in an input stream and
partitions theinput stream into strings matching the expressions. At the boundaries between
stringsprogram sections provided by the user are executed. The Lex source file associates
theregular expressions and the program fragments. As each expression appears in the input
tothe program written by Lex, the corresponding fragment is executed.The user supplies the
additional code beyond expression matching needed to complete histasks, possibly including
code written by other generators. The program that recognizesthe expressions is generated in
the general purpose programming language employed for theuser's program fragments. Thus,
a high level expression language is provided to write thestring expressions to be matched
while the user's freedom to write actions isunimpaired. This avoids forcing the user who
wishes to use a string manipulationlanguage for input analysis to write processing programs
in the same and ofteninappropriate string handling language.
Lex is not a complete language, but rather a generator representing a new language
featurewhich can be added to different programming languages, called ``host languages.'' Just
asgeneral purpose languages can produce code to run on different computer hardware,
Lexcan write code in different host languages. The host language is used for the output
codegenerated by Lex and also for the program fragments added by the user. Compatible
runtimelibraries for the different host languages are also provided. This makes Lex
adaptableto different environments and different users. Lex itself exists on UNIX, GCOS, and
OS/370; but the code generated by Lex may be taken anywhere where appropriate compilers
exist.
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Lex turns the user's expressions and actions (called source in this pic) into the hostgeneral-
purpose language; the generated program is named yylex. The yylex program willrecognize
expressions in a stream (called input in this pic) and perform the specifiedactions for each
expression as it is detected.
For a trivial example, consider a program to delete from the input all blanks or tabs at the
ends of lines.
%%
[ \t]+$ ;
is all that is required. The program contains a %% delimiter to mark the beginning of
therules, and one rule. This rule contains a regular expression which matches one or
moreinstances of the characters blank or tab (written \t for visibility, in accordance with the
Clanguage convention) just prior to the end of a line. The brackets indicate the characterclass
made of blank and tab; the + indicates ``one or more ...''; and the $ indicates ``end ofline,'' as
in QED. No action is specified, so the program generated by Lex (yylex) willignore these
characters. Everything else will be copied. To change any remaining string ofblanks or tabs to
a single blank, add another rule:
%%
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
[ \t]+$ ;
The finite automaton generated for this source will scan for both rules at once, observingat
the termination of the string of blanks or tabs whether or not there is a newlinecharacter, and
executing the desired rule action. The first rule matches all strings of blanksor tabs at the end
of lines, and the second rule all remaining strings of blanks or tabs.
Lex can be used alone for simple transformations, or for analysis and statistics gatheringon a
lexical level. Lex can also be used with a parser generator to perform the lexicalanalysis
phase.
{definitions}
%%
{rules}
%%
{user subroutines}
where the definitions and the user subroutines are often omitted. The second %% isoptional,
but the first is required to mark the beginning of the rules. The absoluteminimum Lex
program is thus
%%
(no definitions, no rules) which translates into a program which copies the input to theoutput
unchanged.In the outline of Lex programs shown above, the rules represent the user's
controldecisions; they are a table, in which the left column contains regular expressions and
the rightcolumn contains actions, program fragments to be executed when the expressions
arerecognized. Thus an individual rule might appearinteger printf("found keyword INT");to
look for the string integer in the input stream and print the message ``found keyword
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
INT''whenever it appears. In this example the host procedural language is C and the C
libraryfunction printf is used to print the string. The end of the expression is indicated by the
firstblank or tab character. If the action is merely a single C expression, it can just be given on
theright side of the line; if it is compound, or takes more than a line, it should be enclosed
inbraces.
Implementation Details:
2. Enter keywords, rules for identifier and constant, operators and relational operators. In
a) %{
%}
b) Regular Expressions
%%
Transition rules
%%
4. Call lex tool on the terminal e.g. [root@localhost]# lex Mylex.l This lex tool will convert
5. Compile the file lex.yy.c e.g. gcc lex.yy.c .After compiling the file lex.yy.c, this will
7. Give input on the terminal to the a.out file upon processing output will be displayed
Sample Code
%{
#include<stdio.h>
int key_word=0;
%}
%%
"include"|"for"|"define" {key_word++;}
%%
int main()
{
printf("enter the sentence");
yylex();
printf("keyword are: %d\n ",key_word);
}
int yywrap() { return 1; }
%{
#include <stdio.h>
int vowels = 0;
int consonants = 0;
%}
%%
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
[aeiouAEIOU] vowels++;
[a-zA-Z] consonants++;
[\n] ;
.;
%%
int main()
printf ("This Lex program counts the number of vowels and ");
yylex();
return 0;
Output:
#lex alphalex.l
#gcc lex.yy.c
#./a.out
This Lex program counts the number of vowels and consonants in given text.
Iceream
Test Cases:
Theory:
Parser for a grammar is a program which takes in the language string as its input and
produces either a corresponding parse tree or a error.Syntax of a LanguageThe rules which
tells whether a string is a valid program or not are called the syntaxSemantic s of Language
The rules which give meaning to programs are called the semantic of a languageTokensWhen
a string representing a program is broken into sequence of substrings, such that each
substring represents a constant, identifier, operator, keyword etc of the language, these
substrings are called the tokens of the language.
Lexical Analysis
The function of lexical Analyzer is to read the input stream representing the source program ,
one character at a time and translate into valid tokens.
Implementation Details
1: Create a lex file
1. Definitions
2. Rules
Definitions consists of any external ‘C’ definitions used in the lex actions or subroutines. The
other types of definitions are definitions are lex definitions which are essentially the lex
substitution strings, lex start states and lex table size declarations. The rules is the basic part
which specifies the regular expressions and their corresponding actions. The user Subroutines
are the functions that are used in the Lex actions.
2 : Yacc is the Utility which generates the function ‘yyparse’ which is indeed the Parser. Yacc
describes a context free, LALR(1) grammer and supports both bottom up and top-down
parsing. The general format for the yacc file is very similar to that of the lex file.
1. Declarations
2. Grammar Rules
3. Subroutines
In declarations apart from the legal ‘C’ declarations here are few Yacc specific declarations
which begins with a % sign.
1. %union It defines the Stack type for the Parser.
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Yacc Rule-
P: A b C { /* ‘C’ actions*/}
The general style of coding the rules is to have all Terminals in lower –case and all
non-terminals in upper –case.
To facilitate a proper syntax directed translation the Yacc has something calls pseudo-
variables which forms a bridge between the values of terminals/non-terminals and the
actions. These pseudo variables are $$, $1, $2, $3,….................. The $$ is the L.H.S value
of the rule whereas $1 is the first R. H. S value of the rule, so is the $2 etc. The default
type for pseudo variables is integer unless they are specified by % type.
%token <type> etc.
Perform the following steps, in order, to create the desk calculator example program:
1. Process the yacc grammar file using the -d optional flag (which tells the yacc
command to create a file that defines the tokens used in addition to the C language
source code):
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
yacc -d calc.yacc
2. Use the li command to verify that the following files were created:
y.tab.c The C language source file that the yacc command created for the parser.
y.tab.h A header file containing define statements for the tokens used by the parser.
3. Process the lex specification file:
lex calc.lex
4. Use the li command to verify that the following file was created:
lex.yy.c The C language source file that the lex command created for the lexical
analyzer.
cc y.tab.c lex.yy.c
6. Use the li command to verify that the following files were created:
y.tab.o The object file for the y.tab.c source file
lex.yy.o The object file for the lex.yy.c source file
a.out The executable program file
7. To then run the program directly from the a.out file, enter:
8. $ a.out
Conclusion:
Postlab:
%{
int vow_count=0;
%}
%%
[aeiouAEIOU] {vow_count++;}
[a-zA-Z] {const_count++;}
%%
int yywrap(){}
int main()
yylex();
return 0;
2. Operands Operations
%{
#include<stdio.h>
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
%}
%%
[a-zA-Z]+[\+\-\*\/][a-zA-Z]+ { n=0; }
[0-9]+[\+\-\*\/][0-9]+ { n=0; }
%%
int yywrap()
{return 1;
int main()
yylex();
printf("\nValid expression\n");
else
printf("\nInvalid expression\n");
return 0;
}
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
3. Find Positive and negative integers and positive and negative fractions in the text file
%{
int postiveno=0;
int negtiveno=0;
int positivefractions=0;
int negativefractions=0;
%}
DIGIT [0-9]
%%
\+?{DIGIT}+ postiveno++;
-{DIGIT}+ negtiveno++;
\+?{DIGIT}*\.{DIGIT}+ positivefractions++;
-{DIGIT}*\.{DIGIT}+ negativefractions++;
.;
%%
void main()
yylex();
}
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
4. Find number of lines ,words , small letters, capital letters , special character, digits and total
characters
%{
#include<stdio.h>
%}
%%
\n { lines++; words++;}
[A-Z] c_letters++;
[a-z] s_letters++;
[0-9] num++;
. spl_char++;
%%
main(void)
yyin= fopen("test.txt","r");
yylex();
total=s_letters+c_letters+num+spl_char;
printf("\n\t%d words",words);
int yywrap()
return(1);
postlab
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Practical No: 6
Date of Performance:
Date of Submission:
Evaluation:
Experiment No 6
Aim : Generate a target code for the optimized code.
Algorithm:
The final phase in compiler model is the code generator. It takes as input an intermediate
representation of the source program and produces as output an equivalent target program.
The code generation algorithm takes as input a sequence of three address statements
constituting a basic block. For each three address statement of the form x=y op z we perform
following function:
1. Invoke a function getreg to determine the location L where the result of computation y op
z should be stored. ( L cab be a register or memory location .
2. Consult the address descriptor for y to determine y, the current locations of y. Prefer the
register for y if the value of y is currently both in memory and register. If value of y is not
already in L , generate the instruction MOV y, L to place a copy of y in L.
4. If the current values of y and z have no next uses , are not live on exit from the block , and
are in registers alter the register descriptor to indicate that , after execution of x=y op z, those
register no longer will contain y and z, resply.
3. Failing (2) , if X has a next use in the block, or op is an operator , such as indexing, that
requires a register find an occupied register R. Store the values of R into a memory location
( MOV R ,M) if it is not already in the proper memory location M, update the address
descriptor for M , and return R. if R holds the value of several variables, a MOV
instruction must be generated for each variable that needs to be stored. A suitable register
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
might be one whose data is referenced furthest in the future, or one whose value is also in
memory. We leave the exact choice unspecified, since there is no one proven best way to
make the selection.
4. If x is not used in the block , or no suitable occupied register can found, select the memory
location of x as L.
Conclusion:
Postlab:
Explain design issues of code generator phase?
What are basic blocks? State their properties
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
import re
operatorTable = {
"+": "ADD",
"-": "SUB",
"*": "MUL",
"/": "DIV",
registerTable = {}
def getRegisterByIndex(index):
return key
return -1
def getRegisterByOperand(operand):
return registerTable[operand]
def parseLine(line):
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
print(line)
return
expression = line.split("=")
# print(operands)
# print(operators)
setVarCode = ""
operationCode = ""
for op in operators:
if op not in operatorTable:
operand1 = operands.pop(0)
register1 = getRegisterByOperand(operand1)
if len(setVarCode) > 1:
setVarCode += register1
operand2 = operands.pop(0)
if operand2 in registerTable.keys():
operand2 = getRegisterByOperand(operand2)
operationCode += f"{operand2},{register1}"
if len(setVarCode) > 0:
print(setVarCode)
if len(operationCode) > 0:
print(operationCode)
print(f"{expression[0]} : {getRegisterByOperand(expression[0])}")
print()
code = open("code.txt").readlines()
parseLine(line)
code text
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
v=d+e
u=t-v
w = t+u
a=w
Output
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Experiment No 7
Practical No: 7
Date of Performance:
Date of Submission:
Evaluation:
Learning Objective: Translating mnemonic operation codes to their machine language equivalents.
Assigning machine addresses to symbolic labels used by the programmer. Lastly to convert assembly
language to binary.
Algorithm:
Pass 1:
1. Start
Go to step 9
5.2 If it is ‘EQU’
Go to step 3
5.4 If it is ‘END’
Go to step 3
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
SystemOpcode
6. Search opcode in Machine Programming
Table. and Compiler Construction
11.Go to step 3.
12. Stop.
Pass2:
1. Start
Go to step 6.4
5.3 If it is ‘USING’
Evaluate operand and enter base reg no. and value into base table
Go to step 3
5.4 If it is ‘DROP’
5.5 If it is ‘END’
Go to step 12
System
7. Get opcode byte and Programming and Compiler Construction
format code
VI Semester ( Computer) Academic Year: 23-24
8. Assign its length to ‘L’.
10.1 Evaluate both register expressions and insert into second byte.
10.4.Go to step 3.
11.1 Evaluate register and index expressions and insert into second byte.
13 Stop.
Implementation Details
2. Display output of Pass1 as the output file with Op-code Table, Symbol Table.
3. Display output of pass2 as the Op-code Table, Symbol Table , Copy file.
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Conclusion:
PASS-1
Code:
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Input:
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Output:
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Code:
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Input:
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Output:
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Experiment No 8
Learning Objective: To understand how the pre-processor replaces all the macros in the program by
its real definition prior to the compilation process of the program.
Algorithm:
Pass1:
6. Enter Macro name found in step 5 in name field of MNT ( macro name table)
7. Increment MNTC by 1.
8. Prepare ALA
10.Increment MDTC by 1.
12. Create and substitute index notation for arguments in the source statement if any.
15. Check if currently read source statement is pseudo-opcode MEND. If yes then goto step 3 else
goto step 11.
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
17.Check if pseudo-opcode END is encountered. If yes goto step 18 else goto step 19
19. Go to step 3
Pass2:
3. If macro name found then goto step 4 else goto step 11.
9. Check if currently retrieved line is pseuodo-opcode MEND, if yes goto step 1 else goto step 10
10. Write statement formed in step 8 to expanded source file and goto step 6
12. Check if pseudo-opcode END encountered, if yes goto step 13 else goto step 1
Implementation Details
2. Display output of Pass1 as the output file, MDT, MNT, and ALA tables.
3.Display output of pass2 as the expanded source file, MDT, MNT and ALA tables.
Test Cases :
Conclusion:
PASS-1
Code:
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Input:
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Output:
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
PASS-2
Code:
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Input:
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
Output:
FR. CONCEICAO RODRIGUES COLLEGE OF ENGINEERING
s.Aa, 1
s A
S-5bdatdra,
15dc,tsdc: S
Step 3
Sbats
Actipn
S3
2 actept
6
84
Sle
A
A) J
A S8 a
Jtate
Actio A
2
S3 Sy
2 SS
fala Co)-plula)
Page No.
Date.
fallalc)=geslo)ºla,)ofsele)
Follsu Le = follae Cg)=SgeA
Fotto D)=sb3
fellau lelpiagtle)= E}ugalkalod
extle)=S6,13
s3aAb6Aagle
A folsula) la,bi
Page No.
Date.
b
SaAbB
AS
ShepIi Aogment
S 5.(L)Csft)
tep3: Tahle
Stade petien
)
Arcept
S2
Se
8
Yy
Paga No.
Data.
SCDe
p5d
step Li pugment
Stepi
To
stDr a(0-ss
(s>acbeADE
lexical aalyis
b)Semantit analyeis
c Syrhase analys
dexieal analysi
lexical analytis
Semant t anas
Semantic nalyei'e
H)Syre ahaysi's
uklized
3\Likals f in Aith he Eanslat
Cyn Pass i
2
encsunted INerds|deing Passti datu
proqam
f lecaion encounted H
em
n asomdy Synbal inknedateatmesate
passa tianslated
codenaddeses bexal helps syrbcl 3na
taci stucues
in si Ha
1able' seslwe
blq tahle'- taaes
to the countey:9
being able:
pass
instsotlim coiesposng o
ode allesing
for acdesses fn pass cason
eslae Tae assembly assembled synbols B
sSimlax 2 maine
epreAkttation synbol stakes souxce This asemblet to
to smlns smbol tatbe-ck process
ssian a into akulaton keeps
to adaess
instctiang Jostctions chcct and This all and code 4537
tade Ss
tade talteHcxats coleolate along the passl
botn
eses pass)
maclaecode and of code taale inciemezled QSAemblsq
tneix ot of is soith all FR.
hsgenemted the t ade encoxtie CONCEICAO
iate adtesses Cuent neessaty taeix sqmbcls
K
kode. theix and
toadtfesses
itcsal -2
ntengediate nchix cddæsi RODP
Code. pass
itorals in This apass instuchions cocesponding(Lhds, IGUES
fo r locaton ia
posslis
table shcing taule code 2 fon uilize 2 COLLEGE
enlont th e the Hae yoriable,
s 84mbolsSoze OF
cnde stants or
Ironsatoa alse QSsenbky calcolatg ate In ENGINEERING
qenemtg addueses. difftent
ICd ued alg ebe)
e and code
fatemenbs localion
af9f
6f
of
locatton
hex sp s in ite yaloe
daop asldvess)psevdo
advesso)
sorce of a
<equted
1space
Detcmine locatbn
counte 'of curtent
length
the a find presehce
frocess to elativenot to the coitth
litralsupdate
(elativeJR
set 3pecifies
Sedsched
examined. fox aleng
ceonterc)is sromned
table pioqsam
Ctee
in
label Loith
LC
valee
Foond statenenksp
ode enty table
LITSTO is
|Symbol
STSTO
is opcode(M)
MoTis sumbol
in field feld.
otiontion
6p-codefield
'mathed
cprond
is
Inilialae Gctof
length lecnstuc opcede
inst¯tions it Coont.
Read labe |Se.asclh
Pesevd
o
MCof
Serkh HOTeETJ
ofptable
SnitallySoUsce, machine foond'
The
Table 1* The. The
used
psog that
Befor
LNGSLRG
counter
and thal
o symbo! teomioad
OL
fotnatinstucicn.
saxed fidd.
to
KODPGULSOLLIGL
the ssined
td Xandlocatiornpasslis
us define
tpe
icis
to in both ce
CONCKAO
haueexpuesion encaunkied
R
stoikdepented afkct loratians
we
fostaucfians cps
op
sequenteisot is pas2
pseo code op
eualuaion
to
pseudo ENDpseudo
of Eqo conttols
sonne
IengthSomeof sequiNeS
OE
tzansks
pass2 case and Hhe
Then So Ihus cohen
Ds
Teqisteo
unavibte
Indisate
base
Exit Country
octton
Updak
assenbler. avoilable
Tncate "teqistes
base
End (Lc)
paas Type? Constant space
thoo Convett
and
Datemine
ef
ctpass2 fand
by
Snstwetier peand
ket
sqmbel
¬xpressions
Evalvate taqet
p'sct
parts'
of
an'iny fSearhing
o Snstucon
Inihaixe Search
Mc lengtth
kype STEETleAssemb
Psevduep GET
MOT the
her
Design Read
PoSTGETcf
table
Code
volues
coffegn asin insboctibaf
evalualed
o anefeckieotfes base ENe
ENGINEERING
same EQu
staztiorn. is
zequine for necessoX 2 alzady anly
campk bese
maching
OF is evaleokd The poss
COLLEGE
field done in toble copplett
fomats qacakebase-xeqisBex nextinae
in
xeqistea is base to in
definiticn
pat to pocesing
RODRIGUES
ielkdsaie 2
similargzocesrg
goint thm pas 2to
nprands
CONCEICAQ toneach to is souce
af
nskuc euoluotel
sitableit to special ealuakd in pas
FR.
index
fetmat, assembled
lsadez. Sgnbol
incemented stoage
eSsenially
puocesed
puoceKe
eent eques Yn
and is a by a8 eha
exknsaels
aèe
RR opcanfinddetcimine is pracesing tot
egistex nstrcion cp Piel Pes the
(ountens
of fos
iets
t
atesscdhecked thus
epeand
pseusde indkateA
the latex least displacennenk
nsed
Ad is Aftty. Iocationinpass1
sBoxoge is displaement
Por tade op
opC. fonot BI equles
1pasá
Fcspoat
Firaly psecalo
RARRThe Then FortYat As in ayd bose
he
3
femp If
bs Inlex MoT
thre
A, Ci, w 4emp three Two PG2 Symbol
table
R,22 Son2 oStatPaSource Syob
2824 22 SR ST Ingtrucion
AAR
32 2829 22 22 Le
m6jao,32(o)4)
2
Sh ST
2,2 A)-Co4)|
2 outeut R A R
I,-0,yps23 Inde
o2
2 D6
2 03 pass 2
2 oltput
- 124 (nStructon
Sfavt PoT
2 2.
(os4) (0,
4)
heval
|iteal
table
le
length
4
R/A
CATL
Tadle
statmMnt NO netuchia
FIVe
aseslur
lasinaahen
MOT
02
0
M
ST
SK
|POT
dndex
K
29
2
THREG 244
TeMP 29 R
titexl Zatle
PAM 2
utpue etput
Pa6TRTO
LI,-C04)
02) 2 ylo)
91,-lo,4) 03) 24 to,4)
I, THREE
04 32 (0/4)
sHI, F2
20 STI,(o, 4) 05, ) 23(04)
STI, TeMP
SR 2, 2 22 5R 212
24
2 22 2
2 24
AND
Spce ECONCEK SO RODPILES OLLEGE OF ENGINLERING
a631
Fune tisA
ae reçraceSed Taey ave lemçiled
Eoatex. slouex
fuactins are er
hese are
a texhual subkhtitn:
nacre çexfazms eytual suh replacing
fracro fo aleuate
Lmul AX, nu m
mov AX, s(Imul ax)
Darametri3ed macros: barod
Patemehers allowing for dynamic behaviour
macros Can tak
Valure
input valves
¬9- depine may (asb) a)> Cb) ? Ca):(b))
main()
nt ma va lue = max
c Con ditiona (o
macro rocessoY Can mpiLaton:
enable oY disable parts op Co de bas on
Conditional ireciives.
E:- tt define DEBuG -ENABLED
Fee EBUa-EnaBlED
t* define
t# elSe DEBUhLoncmsa)print f DE8 U6: 1S \n'msg)
fvom he macYO
hame
ame
Poun yes
wnite
pssemSler
|schup mLA
Teme pybm
JSubotitute
AMND Nuite
ad) Varinble
Canghant
xee
Contant yoe Cangth alee Syabal 2
table erdion Data
ree
alue Symos
ee table
ÎNCR
2
Toshutian 4ing
tble t'sne întruç machine ahle, ans
)tinstuch' Pseudo
Vaniable tem
R
Conatant Ahree
R
Constant
ic 2 S R
Contant 2
2
lheral name regram
table Litesale ype (Rangh alye Sym
Symbalable
2
Qu0macros
tohle
NGNEERING COLLEGE ODRIGUES
OF CONCHCA
R