Submitted To: Submited by
Submitted To: Submited by
1
NAME OF THE EXPERIMENT PAGENO. REMARKS
2. ASSEMBLERS
4. EDITORS
2
To multiply two 3-digit numbers without direct multiplication
#include<iostream.h>
#include<conio.h>
void main()
{ int flag;
int m1,m2;
int r1,temp1=0,r2,temp2=0;
do
{ clrscr();
int n1,n2;
cout<<"Enter multiplicand:";
cin>>n1;
m1=n1;
cout<<"\n\nEnter multiplier:";
cin>>n2;
m2=n2;
if(temp1!=3||temp2!=3)
{
cout<<"\n\nPlease enter three digit no.......";
flag=0;
temp1=0;
temp2=0;
getch();
}
else
flag=1;
3
}while(flag==0);
int term=0,mul=0;
cout<<"\n\nMultiplication is......";
cout<<"\n\n\t\t\t"<<m1;
cout<<"\n\n\t\t\t "<<m2;
cout<<"\n\n\t\t ------------------";
//loop to multiply
int k=1;
while(m2!=0)
{ r1=m2%10;
term=m1*r1;
m2=m2/10;
cout<<"\n\n\t\t\t"<<setw(5)<<term;
term=term*k;
k=k*10;
mul=mul+term;
}
cout<<"\n\n\t\t ------------------";
cout<<"\n\n\t\t\t"<<mul;
getch();
}
4
Output:
Enter multiplicand:345
Enter multiplier:456
Multiplication is......
345
456
------------------
2070
1725
1380
------------------
26248
5
To perform various set operations
#include<iostream.h>
#include<conio.h>
void main()
{ clrscr();
int a[20],b[20],c[40],j,n,m,k,choice;
int i;
cout<<"Enter no of elements of a";
cin>>n;
cout<<"\nEnter ";
for(i=0;i<n;i++)
{ cin>>a[i];
}
cout<<"Enter no of elements of b";
cin>>m;
cout<<"\nEnter ";
for(i=0;i<m;i++)
{ cin>>b[i];
}
while(1)
{cout<<"\n\t\tMENU";
cout<<"\n\t\t1.inter";
cout<<"\n\t\t2.union";
int ch;
cout<<"\nEnter choice";
cin>>ch;
if(ch==2)
{ for(i=0;i<n;i++)
{ c[i]=a[i];
}
int k=n;
for(i=0;i<m;i++)
{ for(j=0;j<n+i;j++)
{ if(c[j]==b[i])
break;
}
if(j==n+i)
{
c[k]=b[i];
k++;
}
6
}
cout<<"\nUNION ";
for(i=0;i<k;i++)
{ cout<<c[i];
}
}
k=0;
if(ch==1)
{ for(i=0;i<n;i++)
{ for(j=0;j<m;j++)
{ if(a[i]==b[j])
{ c[k]=a[i];
k++;
break;
}
}
}
cout<<"\nINTERSECTION ";
for(i=0;i<k;i++)
{ cout<<c[i];
}
}
cout<<"\nWANT TO EXIT?(enter1)";
cin>>choice;
if(choice==1)
break;
}
}
7
Output:
Enter no of elements of a4
Enter 5
2
7
1
Enter no of elements of b4
Enter 7
3
8
2
MENU
1.inter
2.union
Enter choice2
UNION 527138
WANT TO EXIT?(enter1)
8
To find the inverse of a matrix
#include<iostream.h>
#include<conio.h>
int a[2][2];
int det(int,int);
void main()
{ clrscr();
int i,j;
cout<<"Enter elements";
for(i=0;i<2;i++)
{ //cout<<"\n";
for(j=0;j<2;j++)
{ //a[i][j]=getche();
//cout<<"\t";
cin>>a[i][j];
}
}
cout<<"\nElements are";
for(i=0;i<2;i++)
{ cout<<"\n\n";
for(j=0;j<2;j++)
{ cout<<a[i][j]<<"\t";
}
}
cout<<det(0,0);
getch();
}
9
Output:
Enter elements5
7
2
3
Elements are
5 7
2 3 1
10
To find the reverse of a number
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num,rev;
cout<<"\nEnter num";
cin>>num;
cout<<"\Rev is";
while(num>1)
{
rev=num%10;
cout<<rev;
num=num/10;
}
getch();
}
Output:
Enter num573
Rev is375
11
//PROGRAM TO PERFORM SWITCH CASE STATEMENTS
#include<iostream.h>
#include<conio.h>
#include<process.h>
void table();
void prime();
void matrix();
void fibo();
void fact();
void evodd();
void main()
{ char ch;
do{
clrscr();
cout<<"MENU:-";
cout<<"\n\n1. To generate table of the no.";
cout<<"\n2. To check wheteher the no. is prime or not";
cout<<"\n3.To perform matrix operations";
cout<<"\n4.To print fibonacci series";
cout<<"\n5.To print factorial of no.";
cout<<"\n6.To check whether the no. is even or odd";
cout<<"\n7.Exit";
int cho;
cout<<"\n\nEnter your choice(1-7):";
cin>>cho;
switch(cho)
{ case 1: table();
break;
case 2: prime();
break;
case 3: matrix();
break;
case 4: fibo();
break;
case 5: fact();
break;
case 6: evodd();
break;
case 7: exit(0);
12
default : cout<<"\nWrong choice!!!";
}
void table()
{ int n;
cout<<"\nEnter the no.:";
cin>>n;
for(int i=1;i<=10;i++)
{
cout<<"\n"<<n<<"\t"<<"*\t"<<i<<"\t"<<"="<<"\t"<<n*i;
}
}
void prime()
{ int n;
cout<<"\nEnter the no.:";
cin>>n;
for(int i=2;i<n;i++)
{ if(n%i==0)
{ cout<<"\n\nNo. is not prime";
break; }
}
if(n==i)
cout<<"\n\nThe no is prime";
void matrix()
{ clrscr();
int a[20][20],b[20][20],c[20][20];
int m,n,p,q,r,s;
int i,j;
cout<<"\nEnter the no. of rows in first matrix:";
cin>>m;
cout<<"\nEnter the no. of coulmns in first matrix:";
cin>>n;
cout<<"\nEnter the no. of rows in second matrix:";
13
cin>>p;
cout<<"\nEnter the no. of columns in second matrix:";
cin>>q;
//input for matrix a
cout<<"\n\nEnter the elements of first matrix......";
for(i=1;i<=m;i++)
{ for(j=1;j<=n;j++)
{ cout<<"\nEnter the ("<<i<<","<<j<<") element of the matrix:";
cin>>a[i][j];
}
}
//input for matrix b
cout<<"\n\nEnter the elements of second matrix......";
for(i=1;i<=p;i++)
{ for(j=1;j<=q;j++)
{ cout<<"\nEnter the ("<<i<<","<<j<<") element of the matrix:";
cin>>b[i][j];
}
}
//asking for operation
cout<<"\n\nWhat do you want to perform:";
cout<<"\n\n1.Addition";
cout<<"\n2.Subtraction";
cout<<"\n3.Multiplication";
cout<<"\n4.Exit";
int ch1;
cout<<"\n\nEnter your choice:";
cin>>ch1;
switch(ch1)
{ case 1 : if((m==p)&&(n==q))
{ for(i=1;i<=p;i++)
{ for(j=1;j<=q;j++)
{ c[i][j]=a[i][j]+b[i][j];
}
}
cout<<"\n\nMatrix obtained after addition is:";
for(i=1;i<=p;i++)
{ cout<<"\n\n";
for(j=1;j<=q;j++)
{ cout<<c[i][j]<<"\t";
}
14
cout<<"\n";
}
}
else
{ cout<<"\n\nMatrix can not be added";
}
break;
case 2 : if((m==p)&&(n==q))
{ for(i=1;i<=p;i++)
{ for(j=1;j<=q;j++)
{ c[i][j]=a[i][j]-b[i][j];
}
}
cout<<"\n\nMatrix obtained after subtraction is:";
for(i=1;i<=p;i++)
{ cout<<"\n\n";
for(j=1;j<=q;j++)
{ cout<<c[i][j]<<"\t";
}
cout<<"\n";
}
}
else
{ cout<<"\n\nMatrix can not be subtracted";
}
break;
case 3 : if(n==p)
{ for(i=1;i<=m;i++)
{ for(j=1;j<=q;j++)
{c[i][j]=0;
for(int k=1;k<=n;k++)
{ c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
cout<<"\n\nMatrix obtained after multiplication is:";
for(i=1;i<=m;i++)
{ cout<<"\n\n";
for(j=1;j<=q;j++)
{ cout<<c[i][j]<<"\t";
}
15
cout<<"\n";
}
}
else
{ cout<<"\n\nMatrix can not be multiplied";
}
break;
default : cout<<"\n\nReturning to main menu....";
}
}
void fibo()
{ int curr=1,prev=0,next;
int n;
cout<<"\n\nHow many elements of the fibonacci series you want:";
cin>>n;
if(n==1)
{ cout<<"\n"<<prev;
}
else if(n==2)
{ cout<<"\n"<<prev<<"\t"<<curr; }
else
{ cout<<"\nThe fibonacci series is:\n";
curr=1;
prev=0;
next=prev+curr;
cout<<prev<<"\t"<<curr<<"\t";
for(int i=3;i<=n;i++)
{ cout<<next<<"\t";
prev=curr;
curr=next;
next=prev+curr;
}
}
}
void fact()
{ int n,fact=1;
cout<<"\n\nEnter the no. whose factorial is to be find out:";
cin>>n;
for(int i=n;i>=1;i--)
{fact=fact*i;
}
16
cout<<"\n\nThe factorial of the no. is:"<<fact;
void evodd()
{ int n;
cout<<"\n\nEnter the no.:";
cin>>n;
if(n%2==0)
cout<<"\n\nThe no. "<<n<<" is even no.";
else
cout<<"\n\nThe no. "<<n<<" is odd no.";
17
MENU:-
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50
MENU:-
The no is prime
18
ASSEMBLERS :-
Assembler is a system program which converts a program written in assembly language into
machine language. Assembly language is a special language in which we use special mnemonic
symbols for each instruction . It takes input of an assembly language program known as source
program and converts it into an equivalent machine language program which is our object program.
Passes in assembler :-
There are two passes in assembler.
(1) Pass1 & (2) Pass2
PASS1 :-
The purpose of pass1 is to define symbols and literals . following are the steps included in pass1.
1. determine length of machine imstruction .it is known as MOTGET1.
2. Keep track of location counter .
3. rememeber values of symbols until pass2. it is known as STSTO.
19
4. process some pseudo ops like EQU, DS . it is known as POTGET!.
5. remember literals . it is known as LITSTO(literal store).
PASS 2 :-
The purpose of pass2 is to generate object program. Following are steps included in pass2.
1. look up value of symbols . it is known as STGET(single table get).
2. Generate instructions . it is known as MOTGET.
3. Generate data for DS(define storage), DC(define constant) and literals.
4. Process of pseudo ops .it is known as POTGET2.
20
program to implement pass1 of assembler
#include<stdio.h>
#include<conio.h>
#include<process.h>
void main()
{
clrscr();
struct mot
{
char mnemonic[15];
int length;
};
char another;
struct mot m;
FILE *a;
a=fopen ("aman.dat","a");
int l;
do
{
printf("enter mnemonic:");
scanf("%s",m.mnemonic);
printf("enter length:");
scanf("%d",&m.length);
fwrite(&m,sizeof(m),l,a);
printf("enter another (y/n):");
another=getche();
}
while(another=='y');
fclose (a);
struct pot
{
int memory;
char pop[15];
};
struct pot p;
FILE *d;
char more;
d=fopen("aman1.dat","a");
do
21
{
printf("\n enter psuedoopcode:");
scanf("%s",&p.pop);
printf("enter memory length:");
scanf("%d",&p.memory);
fwrite(&p,sizeof(p),l,d);
printf("enter more (y/n):");
scanf("%s",&more);
}
while(more=='y');
fclose(d);
}
22
#include<stdio.h>
#include<process.h>
#include<conio.h>
void main()
{
clrscr();
struct st
{
char symbol[15];
int value;
int length;
};
struct st s;
char another='y';
FILE *a;
a=fopen("har.cpp","w");
struct lt l;
while(another=='y')
{
printf("enter symbol");
scanf("%s",&s.symbol);
printf("enter value");
scanf("%s",&s.value);
getch();
printf("enter length");
scanf("%d,",s.length);
fwrite(&s,sizeof(s),1,a);
printf("enter more");
scanf("%s",&another);
}
fclose(a);
}
23
#include <stdio.h>
#include<conio.h>
Void main( )
{
Clrscr( );
Struct assembly
{
Char label [15];
Char opcode[15];
Char op1 [10];
Char op2 [10];
};
Char another;
Struct assembly s;
File *a;
a = fopen (“aman2.dat”,”a”);
do
{
Print f (“entr label:”);
Scanf(“%s”,&s.label);
Print f(“entr opcode:”);
Scanf (“%s”,&s.opcode);
Print f(“entr op1:”);
Scan f(“%s”,&s.op1);
Print f(“entr op2:”);
Scan f(“%s”,&s.op2);
Fwrite(&s,sizeof(s),1,a);
Print f(“enter another (y/n):”);
Another=getche( );
Print f(“\n”);
}
While(another= =’y’);
Fclose(a);
}
24
4. Program to generate value of LOCATION COUNTER
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<string.h>
struct assembly
{
char label[15];
char opcode[15];
char op1[10];
char op2[10];
};
struct mot
{
char mnemonic[15];
int length;
};
struct pot
{
int memory;
char pop[15];
};
void main()
{
struct assembly s;
struct mot m;
struct pot p;
int x;
int lc;
FILE *a,*b,*c;
a=fopen("aman2.dat","r");
b=fopen("aman.dat","r");
c=fopen("aman1.dat","r");
while(fread(&s,sizeof(s),1,a)>0)
{
b=fopen("aman.dat","r");
while(fread(&m,sizeof(m),1,b)>0)
{
if(strcmp(s.opcode,m.mnemonic)==0)
25
{
lc=lc+m.length;
}
}
while(fread(&p,sizeof(p),1,c)>0)
{
if(strcmp(s.opcode,p.pop)==0)
{
lc=lc+p.memory;
}
}
fclose(b);
fclose(c);
}
fclose(a);
printf("lc is %d",lc);
getch();
}
26
STUDY OF LEXICAL & SYNTAX ANALYSIS
LEXICAL ANALYSIS:
It is a first phase of the compiler. In this phase compiler separates characters
of source language into groups that logical belongs together. These groups are tokens. This part of
compiler is known as lexical analyzer or scanner. On order to perform lexical analyzer must know
what are the tokens of the language to implemented .i.e. It must we know identifiers ,keywords ,
operators or punctuations symbols etc. so that when it scan the source program it will be able to
return a suitable tokens.
SYNTAX ANALYSIS:
It is also known as passing and the program used for this purpose is known
as parser. A parser obtains a string of tokens from the lexical analyzer and verify whether the string
is valid instruct of the source language .for this purpose of parser either attempts to derive the string
of tokens W from the start symbol S or attempts to reduce W to start symbol S of the grammar.
LEFTMOST DERIVATION:
If while generating a language from a given grammar. We don’t scan
the next variable until the leftmost variable scanned as leftmost derivation.
RIGHTMOST DERIVATION:
While generating a language from a given grammar we don’t scan
the next variable until the rightmost variable is scanned is known as rightmost derivation.
TOP-DOWN PARSING:
27
In an attempt to generate a leftmost derivation of a given grammar. The
basic idea is to parse our program starting from top and moving bottom. It means until or unless our
first line is not error free or correct according to syntax .we can not move on to next line. E.g.
LL(K) grammar context free grammars called LL(K) from left to right scan producing a left most
derivation with K symbols look ahead if we can always make a correct decision by checking at
most the first K symbols of W. Let this is our context free grammar.
P is S A+B-C
A b
B c
C d
28
Instruction set of 8085 microprocessor
INTRODUCTION:
An instruction is a command given to the computer to perform a specified operation on given data.
These instructions are classified into following groups:
1. Data Transfer Group
2. Arithmetic Group
3. Logical Group
4. Branch Control
5. I/O and machine Control
Data Transfer Group: Instructions which are used to transfer data from one register to another
register, from memory to register or register to memory. Various commands are:
1. MOV r1, r2: Move data; Move the content of one register to another.
2. MOV r, M: Move the content of memory to register.
3. MOV M, r: Move the content of register to memory.
4. MVI r, data: Move immediate data register.
5. LXI rp, data 16: Load registers pair immediate.
6. LDA addr: Load accumulator direct.
7. STA addr: Store accumulator direct.
8. LHLD addr: Load H-L pair direct.
9. SHLD addr: Store H-L pair direct.
10. XCHG: Exchange the contents of H-L with D-E pair.
Arithmetic Group: The instructions of this group perform arithmetic operations such as addition,
subtraction, increment, decrement of the contents of the register or memory. Various commands are:
29
2. ADD M: Add memory to accumulator.
3. ADC r: Add register with carry to accumulator.
4. ADC M: Add memory with carry to accumulator.
5. ADI data: Add immediate data to accumulator.
6. DAD rp: Add register pair to accumulator.
7. SUB r: Subtract register from accumulator.
8. SUB M: Subtract memory from accumulator.
9. SBI data: Subtract immediate data from accumulator with borrow.
10. INR r: Increment registers content.
11. INR M: Increment memory content.
12. DCR r: Decrement registers content.
Logical Group: The instructions under this group perform logical operations such as AND, OR,
COMPARE, ROTATE etc.Various commands are:
30
Branch Control Group:
This group includes the instructions for conditional and unconditional jump, subroutine call and
return and restart.Various Commands are:
1. JMP addr (label): unconditional Jump: jump to the instruction specified by the address.
2. Conditional jump addr: after the execution of the conditional jump instruction the program
jumps to the instruction specified by the address. If the specified condition is fulfilled.
3. CALL addr: Unconditional call; Call the subroutine identify by the address.
4. RET: Return from subroutine.
5. RST n: Restart: It is a one word CALL instruction.
Stack and I/O, Machine Control Group: This group includes the instructions from I/O ports,
Stack and machine control. Various commands are:
1. IN Port addr: Input to accumulator from I/O port.
2. OUT Port addr: Output from accumulator to I/O port.
3. PUSH PSW: Push processor status word.
4. PUSH rp: Push the content of register pair to Stack.
5. POP rp: Pop the content of register pair to Stack.
6. HLT: Halt
7. EI: Enable interrupts.
8. DI: Disable interrupts.
9. SIM: Set interrupt mask.
10. RIM: Read interrupt mask.
11. NOP: No operation.
COMPILER:
31
Compiler is a system program which converts a program written in high level language into
machine language. The high level language program given as input is known as source program and
machine equivalent is known as object program. The functionality of compiler is divided into seven
phases:
Phases of a compiler
32
1. LEXICAL PHASE:
Action of parsing source program into proper classes is the task of lexical analyzer. The
program is scanned and separated into basic elements known as tokens. The basic elements
like identifier, literals are placed into tables as other phases recognize the use and meaning of
elements further information is entered into these tables like data types, length, storage
classes etc.
2. SYNTAX PHASE:
Compiler interprets the meaning of the constant syntax analyzer is also known as parsing.
The basic function of the syntax phase is to recognize the major constructs of language and to
calculate the appropriate action routines that will generate the intermediate form or matrix for
these constructs.
INTERMEDIATE PHASE:
Once the program is correct according to syntax , the compiler generates a intermediate code
, in this phase , the intermediate code is compiler directed .This intermediate co ode may be
in form of parse tree ,postfix notation and three address code .
OPTIMISATION:
Any program is set to be optimized, if it is consumes less memory and the compiler time is
fast.The code optimizer receives intermediate code and optimize them considering the like
memory,execution time and other. This phase removes the retandent code.
STORAGE ASSUGNMENT:
It is the process of allocating memory to various resources. The memory can be allocated to
various literals, storage, symbols, machine-OP etc. also the processing environment may
need some memory. All these memory allocation are performed by compiler in this phase.
33
CODE GENERATION:
It is the last phase of compiler. This phase receives optimized intermediate code and
generates the code for execution. This code generated generally will be relocatable machine
code or assembly code. This phase generates the executed code. It receives the input from
intermediate code generator from code optimizer in case of optimizing compilers. The input
to code generator must be error free, it must have undergone lexical analysis, syntax and
other intermediate phases. The target program may be in the form of
1. Assembly language
2. Relocate machine code
3. Absolute machine language
The absolute machine code is 1 which is ready to be executed. It is
Linker and loaded by the loader, thus making it ready for execution.
DEBUGGING
Debugging Procedure:
34
1. Type any program in the given language.
2. Compile it.
3. Look for errors.
4. Remove errors and recompile the program.
5. Repeat steps 3 & 4 until our program becomes error free.
There are three main methods of debugging in C++ ewnvironment under this category:
a) Single line control
b) Watch window
c) Procedure control
Single line control: Aftewr compliation if there are any errors in our program then pressing the F7
key will check our program in a single line control. Where there is any error or bug in
any line then that particular line is skipped and the control is transferred to the next adjacent line.
Watch window: After pressing F7 key, if we press Ctrl+F7 then a watch window will be displayed
on the screen. The user has to type a variable in the add watch window and the value of that variable
will be displayed.
35
Procedure control: This debugging technique is used if our program is very large and it is divided
into several sub-procedures. Simply pressing F8 key will result our program to be compiled on
procedure basis.
The break point methopd as the name employs allows the user to set break points in the program in
order to check the cointents of registers, memories and other programming entitites like variables
etc. In fact the break point allows the user to halt the execution of the program at that break point.
Then the user can examine thhe iunbtermediate results or contents of various registers, memories,
variables, addresses and I/O ports. The break point can be inserted at any particualr position in opur
program by the user himself.
Editor is a system program that interfaces a program with the entity that generates a data
(originator). It also interfaces the results of the program with the entity that consumes them
(consumer).There are a few steps in program development:
36
Design and Coding:
Program Generator
It generates a program which performs a set of functions described in its specifications. The user
has to only specify the functions to be performed and not how to perform them.
Program Environment
The soft tools used are text editors. Editor function in two modes
1. Command Mode
It accepts the user commands specifying the editing function to be performed.
2. Data Mode
The user keys in the text to be added to the files.
Various task to be performed here are selection of test data for the programs, analysis of test results
to detect errors if any and debugging. Software tools used to implement these steps are:
37
Here the program correctness is verified by subjecting is to a standard set of tests after every
modification. This is called regression testing.
3. Debug Monitors
It is a software which provides debugging support for a program. It executes the program
been debugged under its control. It also enables the monitor to perform dynamically specified
debugging actions. They perform the following facilities for dynamic debugging:
Program efficiency depends on efficiency of the algorithm and efficiency of the coding.
1) Line editor
2) Stream editor
3) Screen editor
4) Word processors
5) Structure editor
6) Graphical editors
LINE EDITOR
38
The line is designated:
Positonaly
By specifying a serial number in text
Contextually
By specifying a unique character string in it.
The primary advantage of line editors is there simplicity.
STREAM EDITOR
A stream editor views the entire text as a stream of character this permits edit operations to cross line
boundaries.stream editors typically supports character oriented , line oriented and context oriented
modes. The current pointer can be manipulated using all these modes.
SCREEN EDITORS
Line or stream editors does not display the text in manner it would appear if printed.screen editor
uses the “What-you-see-is-what-you-get principle.the editor displays a screen full of text at a time
the user can move the cursor over the screen , position it at a point where we want to perform. Some
editing proceed with the editing directly. Thus it is possible to see the effect of an edit operation on
screen.
WORD PROCESSOR
Word processors are document editors with additional features to produce well formatted hard copy
output. Essential features of word processor are command for moving, merging of texts and
searching and replacing of words. Many word processors supports spell check options with the
adventure of personal computers. Word processors have seen wide spread use among authors,office
personal and computer professional.
STRUCTURE EDITIOR
39
CASE STUDY OF MS-WORD , DOS EDITOR , VI –EDITOR
DOS EDITOR
Introduction
The DOS Editor is used to display , create , print , and modify files.
EDIT
Type EDIT at the command prompt and press the ENTER key.
To name a file before starting type EDIT and the filename. Press the ENTER key.
BATCH FILE
40
What do you do with a batch file?
Batch file are like icons on a toolbar . They simplify your life.
Imagine if you had a room full of computers. You wanted ti perform the same function on each of the
computers. You have a few options.
Sit at each computer and perform the function.
Build a batch file. Execute the batch file. Have time to relax before your next project.
What are some special batch file commands and what is the purpose of each?
ECHO OFF
This turns off all DOS commands after the ECHO OFF command.
If a DOS command has related questions you will see the questions . The only thing you
do not see are the DOS commands.
@ ECHO OFF
This turn off all DOS commands including the ECHO OFF command .
Now , do you understand the difference between ECHO OFF and @ECHO OFF?
ECHO.
41
This create a blank line.
ECHO
PAUSE
VI EDITOR
INTRODUCTION
The VI editor is a screen based editor used by many Unix users . The VI editor has a powerful
feature to aid programmer, but many beginning users avoid using VI because the different features
overwhelm them. This tutorial is written to help beginning users get accustomed to using the VI
editor , but also contains section relevant to regular users of VI as well. Examples are provided , and
the best way to learn is to try these examples as well………. There’s no better way than to
experience things yourself.
The VI editor lets a user create new files or edit existing files . The command to start
the VI editor is vi, followed by the file name. For example to edit a file called
temporary, you would type vi temporary and then return . You can start VI without a
filename , but when you want to save your work , you will have to save your work ,
you will have to tell VI which filename to save it into later.
The first thing most users learn about the VI editor is that it has two modes : command
and insert . The command mode allows the entry of commands to manipulate text .
these commands are usually one or two characters long, and can be entered with few
keystrokes . The insert mode puts anything typed on the keyboard into the current
42
file. into insert mode . The most commonly used commands to get into insert mode
are a and i . These VI starts out in command mode. There are several commands
that put the VI editor two commands are described below . Once you are in insert
mode , you get out of it by hitting the escape key . If your terminal does not have an
escape key , ^ [ should work(control-)]. You can hit escape two times in a row and VI
would definitely be in command mode . Hitting escape while you are already in
command mode doesn’t take the editor out of command mode . It may beep to tell
you that you are already in that mode.
SYNTAX ANALYSIS:
It is also known as passing and the program used for this purpose is known
as parser. A parser obtains a string of tokens from the lexical analyzer and verify whether the string
is valid instruct of the source language .for this purpose of parser either attempts to derive the string
of tokens W from the start symbol S or attempts to reduce W to start symbol S of the grammar.
LEFTMOST DERIVATION:
43
If while generating a language from a given grammar. We don’t scan
the next variable until the leftmost variable scanned as leftmost derivation.
RIGHTMOST DERIVATION:
While generating a language from a given grammar we don’t scan
the next variable until the rightmost variable is scanned is known as rightmost derivation.
TOP-DOWN PARSING:
In an attempt to generate a leftmost derivation of a given grammar. The
basic idea is to parse our program starting from top and moving bottom. It means until or unless our
first line is not error free or correct according to syntax .we can not move on to next line. E.g.
LL(K) grammar context free grammars called LL(K) from left to right scan producing a left most
derivation with K symbols look ahead if we can always make a correct decision by checking at
most the first K symbols of W. Let this is our context free grammar.
P is S A+B-C
A b
B c
C d
44
45