0% found this document useful (0 votes)
180 views

L. D. College of Engineering Lab Manual: System Software (3160715)

This document is a lab manual for the System Software course at L.D. College of Engineering in Ahmedabad, India. It contains details about 11 programming assignments to be completed over the semester, covering topics like lexical analysis, parsing, macro processing, code generation, and system programming languages. It lists the course outcomes, provides faculty details, and includes rubrics for assessment. Certificates will be provided to students upon satisfactory completion of the practical work for the course.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
180 views

L. D. College of Engineering Lab Manual: System Software (3160715)

This document is a lab manual for the System Software course at L.D. College of Engineering in Ahmedabad, India. It contains details about 11 programming assignments to be completed over the semester, covering topics like lexical analysis, parsing, macro processing, code generation, and system programming languages. It lists the course outcomes, provides faculty details, and includes rubrics for assessment. Certificates will be provided to students upon satisfactory completion of the practical work for the course.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 53

L. D.

College of Engineering
Opp Gujarat University, Navrangpura, Ahmedabad - 380015

LAB MANUAL
Branch: Computer Engineering

System Software (3160715)


Semester: VI

Faculty Details:
1) Prof. Reshma Dayma
System Software (3160715)


Certificate

This is to certify that Mr./Ms. Tirth Bhatt,


Enrollment Number 190280107010 has satisfactorily completed the practical work in
System Software subject at L D College of Engineering, Ahmedabad-380015.

Date of Submission: 27th May 2022

Sign of Faculty: _______________

Head of Department: _______________

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 1


System Software (3160715)


Sr. CO AIM Date Page No. Marks Sign


No.

1 Write a C program to implement the


CO1 27/10/21 7
lexical analyzer.
2 Write a program in text file and generate
CO2 24/11/21 15
SYMTAB and LITTAB.
3 Demonstrate the Use macro features of C 01/12/21 20
CO3
language.
Write a Lexical Analyzer (using Lex utility
4 CO4 08/12/21 22
for UNIX).

5 Demonstrate the use of YACC with 12/01/22 24


CO4
example program.
6 Write a C program to left factor the given 19/01/22 29
CO4
grammar.
7 Write a C program to remove the Left
CO4 02/02/22 34
Recursion from a given grammar.
8 Write C program to Implement Recursive 16/02/22 37
Descendent Parsing for the given
Grammar.
CO4
E -> T + E / T
T -> F * T / F
F -> ( E ) / i
9 Implement Predictive Parser for the 09/03/22 40
CO4 arithmetic expression grammar using
YACC and Lex.
10 Write a C program which generates
06/04/22 45
CO5 Quadruple Table for the given postfix
String.
11 Case Study on System Programming
CO1 13/04/22 48
Languages.

L. D. College of Engineering, Ahmedabad

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 2


System Software (3160715)


Department of Computer Engineering


Subject Name: System Software Subject Code: 3160715

Term: 2021-22

Rubrics ID Criteria Marks Good (2) Satisfactory Need


(1) Improvement (0)

RB1 Regularity 05 High (>70%) Moderate (40- Poor (0-40%)


70%)

RB2 Problem Analysis 05 Apt & Full Limited Very Less


& Development Identification of Identification of Identification of
of the Solution the Problem & the Problem / the Problem /
Complete Incomplete Very Less
Solution for the Solution for the Solution for the
Problem Problem Problem

RB3 Testing of the 05 Correct Solution Partially Very less correct


Solution as required Correct solution for the
Solution for the problem
Problem

RB4 Documentation 05 Documentation Not up to Proper format not


completed neatly. standard. followed,
incomplete.

SIGN OF FACULTY

L. D. College of Engineering, Ahmedabad


Department of Computer Engineering
Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 3
System Software (3160715)


LABORATORY PRACTICALS ASSESSMENT

Subject Name: System Software

Term: 2021-22

Enroll. No.: 190280107010

Class:A

Practical CO RB1 RB2 RB3 RB4 Total Date Faculty


No. No. Sign

1
CO1
2
CO2
3
CO3
4
CO4
5
CO4
6
CO4
7
CO4
8
CO4
9
CO4
10
CO5
11
CO1

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD,

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 4


System Software (3160715)


COURSE CURRICULUM
COURSE TITLE: System Software
(Code: 3160715)
Degree Programmes in which this course is Semester in which offered
offered

Computer Engineering 6th Semester

1. RATIONALE

• To study basics of system software, its functions, types, working.


• To study concepts of language processor, gaps between domains of software, process to process
the program from source code to target code.
• To understand assembler, data structure use to process assembly program and general algorithm
of assembler process.
• To study concepts of macro and macro processor, data structure used in process and algorithms
of macro processor.
• To study various working and various types of linker and loader.
• To study programming language grammar, scanning and parsing and tools to generate scanner
and parser.
• To study concepts and compiler like binding, scope rule, memory allocation, compilation of
expression and control structure and optimization of code.
• To study about interpreter and debugger.

2. COMPETENCY
The course content should be taught to impart knowledge about System Software which is most
important component of any computer system. The aim of the course is to enable students to
understand fundamentals of System Software, different types of language process, how they
perform the task, data structure required for that, different approaches to perform the task.

3. COURSE OUTCOMES
Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 5
System Software (3160715)


After learning the course the students should be able to:


1. Explain and classify different methodologies, concepts and approaches to System Software
Programming.
2. Identify elements of language processors with various data structures used in development of
one-pass and multi-pass assemblers.
3. Examine macro processor, its usage and compare various loading and linking schemes.
4. Build various system programs using language processor development tools such as YACC
and Lex.
5. Design code optimization based solution for the given system problems by applying various
techniques of compiler, interpreter and debugger.

4. TEACHING AND EXAMINATION SCHEME

5. SUGGESTED LEARNING RESOURCES


A. LIST OF BOOK

1) System Programming by D M Dhamdhere, McGraw Hill Publication


2) System Programming by Srimanta Pal, OXFORD Publication
3) System Programming and Compiler Construction by R.K. Maurya & A. Godbole.
4) System Software – An Introduction to Systems Programming by Leland L. Beck, 3rd Edition,
Pearson Education Asia, 2000
5) System Software by Santanu Chattopadhyay, Prentice-Hall India,2007

B. LIST OF SOFTWARE / LEARNING WEBSITES

1. C compiler
2. Linux / Unix
3. Lex tool
4. YACC tool

Practical – 1

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 6


System Software (3160715)


AIM: Write a C program to implement the lexical analyzer.

#include<stdio.h>

#include<ctype.h>

#include<string.h>

void keyw(char *p);

int i=0,id=0,kw=0,num=0,op=0;

char keys[32][10]={"auto","break","case","char","const","continue","default",

"do","double","else","enum","extern","float","for","goto",

"if","int","long","register","return","short","signed",

"sizeof","static","struct","switch","typedef","union",

"unsigned","void","volatile","while"};

main()

char ch,str[25],seps[15]=" \t\n,;(){}[]#\"<>",oper[]="!%^&*-+=~|.<>/?";

int j;

char fname[50];

FILE *f1;

//clrscr();

printf("enter file path (drive:\\fold\\filename)\n");

scanf("%s",fname);

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 7


System Software (3160715)


f1 = fopen(fname,"r");

//f1 = fopen("Input","r");

if(f1==NULL)

printf("file not found");

exit(0);

while((ch=fgetc(f1))!=EOF)

for(j=0;j<=14;j++)

if(ch==oper[j])

printf("%c is an operator\n",ch);

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 8


System Software (3160715)


op++;

str[i]='\0';

keyw(str);

for(j=0;j<=14;j++)

if(i==-1)

break;

if(ch==seps[j])

if(ch=='#')

while(ch!='>')

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 9


System Software (3160715)


printf("%c",ch);

ch=fgetc(f1);

printf("%c is a header file\n",ch);

i=-1;

break;

if(ch=='"')

do

ch=fgetc(f1);

printf("%c",ch);

}while(ch!='"');

printf("\b is an argument\n");

i=-1;

break;

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 10


System Software (3160715)


str[i]='\0';

keyw(str);

if(i!=-1)

str[i]=ch;

i++;

else

i=0;

printf("Keywords: %d\nIdentifiers: %d\nOperators: %d\nNumbers: %d\n",kw,id,op,num);

//getch();

void keyw(char *p)

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 11


System Software (3160715)


int k,flag=0;

for(k=0;k<=31;k++)

if(strcmp(keys[k],p)==0)

printf("%s is a keyword\n",p);

kw++;

flag=1;

break;

if(flag==0)

if(isdigit(p[0]))

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 12


System Software (3160715)


printf("%s is a number\n",p);

num++;

else

//if(p[0]!=13&&p[0]!=10)

if(p[0]!='\0')

printf("%s is an identifier\n",p);

id++;

i=-1;

OUTPUT:

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 13


System Software (3160715)


Signature of Faculty: Grade:

Practical – 2
AIM: Write a program in text file and generate SYMTAB and LITTAB.
Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 14
System Software (3160715)


#include<stdio.h>

#include<stdlib.h>

struct sys{

char n[20];

int ad;

};

int main()

char ch[50],c;

int adr=0,f=0,fl=0,sp=0,lp=0;

struct sys stb[20],lt[20];

FILE *fr1;

fr1=fopen("inter.txt","r");

if(fr1== NULL){

printf("Failed to open\n");

printf("The ap is \n");

while((c=fgetc(fr1))!=EOF)

printf("%c",c);

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 15


System Software (3160715)


FILE *fr;

fr=fopen("inter.txt","r");

c=fgetc(fr);

printf("\n\nThe sys and lt is \n\n");

while((c)!=EOF)

if(c=='\t'&&f==0)

f =1;

else if(c!='\t'&&f==0&&fl==0)

int j=0;

while(c!='\t'&&(c)!=EOF){

stb[sp].n[j++]=c;

c=fgetc(fr);

stb[sp].n[j]='\0';

stb[sp++].ad=adr;

fl=1;

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 16


System Software (3160715)


else if(c=='=')

int j=0;

while(c!='\n'&&(c)!=EOF){

lt[lp].n[j++]=c;

c=fgetc(fr);

lt[lp].n[j-1]='\0';

lt[lp++].ad=adr;

f=1;

else if(c=='\n')

{ adr++; f=0;fl=0; }

c=fgetc(fr);

printf("\n");

fclose(fr);

int i;

for(i=0;i<sp;i++)

printf("%s %d\n",stb[i].n,stb[i].ad);

printf("\nlt table\n");

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 17


System Software (3160715)


for(i=0;i<lp;i++)

printf("%s %d\n",lt[i].n,lt[i].ad);

return 0;

OUTPUT:

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 18


System Software (3160715)


Signature of Faculty: Grade:

Practical – 3
AIM: Demonstrate the Use macro features of C language.

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 19


System Software (3160715)


 Program

#include <stdio.h>

#define PI 3.1415

int main()

float radius, area;

printf("Enter the radius: ");

scanf("%f", &radius);

area = PI*radius*radius;

printf("Area=%.2f",area);

return 0;

#include<stdio.h>

#define Area(x) x*x

#define Costpaint(x,y,z) (z*y + Area (x))

void main()

int A = 8, B= 6, C = 4;

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 20


System Software (3160715)


printf("The area of square= %d\n", Area(A));

printf("Cost of paint= %d\n", Costpaint(A,B,C));

 Output

Signature of Faculty: Grade:

Practical – 4
AIM: Write a Lexical Analyzer (using Lex utility for UNIX).

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 21


System Software (3160715)


 Program

/* Declaring two counters one for number

of lines other for number of characters */

%{

int no_of_lines = 0;

int no_of_chars = 0;

%}

/***rule 1 counts the number of lines,

rule 2 counts the number of characters

and rule 3 specifies when to stop

taking input***/

%%

\n ++no_of_lines;

. ++no_of_chars;

end return 0;

%%

/*** User code section***/

int yywrap(){}

int main(int argc, char **argv)

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 22


System Software (3160715)


yylex();

printf("number of lines = %d, number of chars = %d\n",

no_of_lines, no_of_chars );

return 0;

 Output

Signature of Faculty: Grade:

Practical – 5
AIM: Demonstrate the use of YACC with example program.

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 23


System Software (3160715)


 Program

Yex file

%{

/* Definition section */

#include<stdio.h>

int flag=0;

%}

%token NUMBER

%left '+' '-'

%left '*' '/' '%'

%left '(' ')'

/* Rule Section */

%%

ArithmeticExpression: E{

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 24


System Software (3160715)


printf("\nResult=%d\n", $$);

return 0;

};

E:E'+'E {$$=$1+$3;}

|E'-'E {$$=$1-$3;}

|E'*'E {$$=$1*$3;}

|E'/'E {$$=$1/$3;}

|E'%'E {$$=$1%$3;}

|'('E')' {$$=$2;}

| NUMBER {$$=$1;}

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 25


System Software (3160715)


%%

//driver code

void main()

printf("\nEnter Any Arithmetic Expression which can have operations Addition,Subtraction,


Multiplication, Division,Modulus and Round brackets:\n");

yyparse();

if(flag==0)

printf("\nEntered arithmetic expression is Valid\n\n");

void yyerror()

printf("\nEntered arithmetic expression is Invalid\n\n");

flag=1;

Lex file

%{

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 26


System Software (3160715)


/* Definition section */

#include<stdio.h>

#include "y.tab.h"

extern int yylval;

%}

/* Rule Section */

%%

[0-9]+ {

yylval=atoi(yytext);

return NUMBER;

[\t] ;

[\n] return 0;

. return yytext[0];

%%

int yywrap()

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 27


System Software (3160715)


return 1;

 Output

Signature of Faculty: Grade:

Practical – 6
AIM: Write a C program to left factor the given grammar.

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 28


System Software (3160715)


 Program

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

void main()

char ch,st[10][10],st1[10];

int i=0,j=0,w=0,p=0,k=0,l=0,z=0;

printf("Enter the production\nEnter '|' character to end the production\n\nA::=");

ch=getchar();

while(ch!='\n')

{ while(ch!='|')

st1[k++]=ch;

ch=getchar();

++w;

strcpy(st[w],st1);

for(i=k;i<10;i++)

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 29


System Software (3160715)


st[w][i]='\0';

k=0;

ch=getchar();

printf("\n");

for(i=1;i<=w;i++)

printf("%s\n",st[i]);

for(i=1;i<w;i++)

{ for(j=0;j<10;j++)

if(st[i][j]==st[i+1][j])

st[0][j]=st[i][j];

else

break;

for(i=1;i<=w;i++)

{ for(j=0;j<10;j++)

if(st[0][j]==st[i][j])

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 30


System Software (3160715)


st[0][j]=st[i][j];

else

for(l=j;l<10;l++)

{ st[0][j]='\0'; }

break;

z=strlen(st[0]); p=z;

printf("\ncommon string length %d\n",z);

printf("\ncommon string is %s\n",st[0]);

st[0][z]='A';

st[0][++z]='*';

++z;

for(i=z;i<10;i++)

st[0][i]='\0';

printf("\nA -> %s\n",st[0]);

printf("\nA* -> ");

for(i=1;i<=w;i++)

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 31


System Software (3160715)


{ for(j=p;j<10;j++)

if(st[i][p]=='\0')

printf("E"); break;

if(st[i][j]=='\0')

break;

printf("%c",st[i][j]);

if(i!=w)

printf(" | ");

printf("\n\n");

 Output

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 32


System Software (3160715)


Signature of Faculty: Grade:

Practical – 7

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 33


System Software (3160715)


AIM: Write a C program to remove the Left Recursion from a given grammar.
 Program

#include<stdio.h>
#include<string.h>
#define SIZE 10
int main () {
char non_terminal;
char beta,alpha;
int num;
char production[10][SIZE];
int index=3; /* starting of the string following "->" */
printf("Enter Number of Production : ");
scanf("%d",&num);
printf("Enter the grammar as E->E-A :\n");
for(int i=0;i<num;i++){
scanf("%s",production[i]);
}
for(int i=0;i<num;i++){
printf("\nGRAMMAR : : : %s",production[i]);
non_terminal=production[i][0];
if(non_terminal==production[i][index]) {
alpha=production[i][index+1];
printf(" is left recursive.\n");
while(production[i][index]!=0 && production[i][index]!='|')
index++;
if(production[i][index]!=0) {

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 34


System Software (3160715)


beta=production[i][index+1];
printf("Grammar without left recursion:\n");
printf("%c->%c%c\'",non_terminal,beta,non_terminal);
printf("\n%c\'->%c%c\'|E\n",non_terminal,alpha,non_terminal);
}
else
printf(" can't be reduced\n");
}
else
printf(" is not left recursive.\n");
index=3;
}
}

 Output
Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 35
System Software (3160715)


Signature of Faculty: Grade:

Practical – 8

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 36


System Software (3160715)


AIM: Write C program to Implement Recursive Descendent Parsing for the given Grammar.

E -> T + E / T
T -> F * T / F
F -> ( E ) / i

 Program

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void match(char t);
void T();
void TS();
void F();
void ES();
void E();
char l;
void main()
{ printf("Enter string \n");
l=getchar();
printf("\n\n Production symbol\n"); printf("\tE\t%c\n",l);
E();
if(l=='$')
printf("\nsuccess\n");
else
printf("\nerror\n");
}
void match(char t)
{
if(t==l) l=getchar();
else printf("\nerror\n");
}
void E()
{ printf("\tT\t%c\n",l); T();
printf("\tES\t%c\n",l); ES();
}
void ES()
{ if(l=='+')
{
Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 37
System Software (3160715)


match('+'); printf("\tE\t%c\n",l); E();


}
else return;
}
void T()
{ printf("\tF\t%c\n",l); F();
printf("\tTS\t%c\n",l); TS();
}
void TS()
{ if(l=='*')
{
match('*'); printf("\tT\t%c\n",l); T();
}
else
return;
}
void F()
{ if(l=='(')
{
match('('); printf("\tE\t%c\n",l); E(); match(')');
}
else
match('i');
}

 Output

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 38


System Software (3160715)


Signature of Faculty: Grade:

Practical – 9

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 39


System Software (3160715)


AIM: Implement Predictive Parser for the arithmetic expression grammar using YACC and Lex.

 Program

/* Lex program to recognize valid arithmetic expression

and identify the identifiers and operators */

%{

#include <stdio.h>

#include <string.h>

int operators_count = 0, operands_count = 0, valid = 1, top = -1, l = 0, j = 0;

char operands[10][10], operators[10][10], stack[100];

%}

%%

"(" {

top++;

stack[top] = '(';

"{" {

top++;

stack[top] = '{';

"[" {

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 40


System Software (3160715)


top++;

stack[top] = '[';

")" {

if (stack[top] != '(') {

valid = 0;

else if(operands_count>0 && (operands_count-operators_count)!=1){

valid=0;

else{

top--;

operands_count=1;

operators_count=0;

"}" {

if (stack[top] != '{') {

valid = 0;

else if(operands_count>0 && (operands_count-operators_count)!=1){

valid=0;

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 41


System Software (3160715)


else{

top--;

operands_count=1;

operators_count=0;

"]" {

if (stack[top] != '[') {

valid = 0;

else if(operands_count>0 && (operands_count-operators_count)!=1){

valid=0;

else{

top--;

operands_count=1;

operators_count=0;

"+"|"-"|"*"|"/" {

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 42


System Software (3160715)


operators_count++;

strcpy(operators[l], yytext);

l++;

[0-9]+|[a-zA-Z][a-zA-Z0-9_]* {

operands_count++;

strcpy(operands[j], yytext);

j++;

%%

int yywrap()

return 1;

int main()

int k;

printf("Enter the arithmetic expression: ");

yylex();

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 43


System Software (3160715)


if (valid == 1 && top == -1) {

printf("\nValid Expression\n");

else

printf("\nInvalid Expression\n");

return 0;

 Output

Signature of Faculty: Grade:

Practical – 10

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 44


System Software (3160715)


AIM: Write a C program which generates Quadruple Table for the given postfix String.

 Program
#include<stdio.h>

#include<string.h>

#include<stdlib.h>

void main()

char line[20]; int s[20]; int t=1; int i=0;

printf("Enter string.. :");

gets(line);

for(i=0;i<20;i++) s[i]=0;

printf("op\ta1\ta2\tres\n");

for(i=2;line[i]!='\0';i++)

if(line[i]=='/' || line[i]=='*')

printf("\n");

if(s[i]==0)

if(s[i+1]==0)

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 45


System Software (3160715)


printf(":=\t%c\t\t t%d\n",line[i+1],t);

s[i+1]=t++;

printf("%c\t",line[i]);

(s[i-1]==0)?printf("%c\t",line[i-1]):printf("t%d\t",s[i-1]);

printf("t%d \t t%d",s[i+1],t);

s[i-1]=s[i+1]=t++;

s[i]=1;

for(i=2;line[i]!='\0';i++)

if(line[i]=='+' || line[i]=='-')

printf("\n");

if(s[i]==0)

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 46


System Software (3160715)


if(s[i+1]==0)

{ printf(":=\t%c\t\t t%d\n",line[i+1],t); s[i+1]=t++; }

printf("%c\t",line[i]);

(s[i-1]==0)?printf("%c\t",line[i-1]):printf("t%d\t",s[i-1]);

printf("t%d \t t%d",s[i+1],t);

s[i-1]=s[i+1]=t++;

s[i]=1;

printf("\n:=\tt%d\t\t%c \n",t-1,line[0]);

 Output

Signature of Faculty: Grade:

Practical – 11

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 47


System Software (3160715)


AIM: Case Study on System Programming Languages.

ALGOL

ALGOL (ALGOrithmic Language) is one of several high-level languages designed


specifically for programming scientific computations. It started out in the late 1950's, first
formalized in a report titled ALGOL 58, and then progressed through reports ALGOL 60,
and ALGOL 68. It was designed by an international committee to be a universal
language. Their original conference, which took place in Zurich, was one of the first
formal attempts to address the issue of software portability. ALGOL's machine
independence permitted the designers to be more creative, but it made implementation
much more difficult. Although ALGOL never reached the level of commercial popularity
of FORTRAN and COBOL, it is considered the most important language of its era in
terms of its influence on later language development. ALGOL’s lexical and syntactic
structures became so popular that virtually all languages designed since have been
referred to as "ALGOL - like"; that is they have been hierarchical in structure with
nesting of both environments and control structures.

 First consider the data structures, which are very close to first generation structures. In
ALGOL 60 the block structure was introduced: the ability to create blocks of statements
for the scope of variables and the extent of influence of control statements. Along with
that, two different means of passing parameters to subprograms; call by value and call by
name. Structured control statements: if - then - else and the use of a general condition for
iteration control were also features, as was the concept of recursion: the ability of a
procedure to call itself.

One of the greatest impacts ALGOL 60 had was a result of its description as found in
Naur (1963). A major contribution of this report was the introduction of BNF notation for
defining the syntax of the language. Overall, ALGOL is considered to be perhaps the
most orthogonal programming language, meaning it has a relatively small number of
basic constructs and a set of rules for combining those constructs. Every construct has a
type associated with it and there are no restrictions on those types. In addition, most
constructs produce values. Several of ALGOL’s other characteristics are listed below:

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 48


System Software (3160715)


 Dynamic Arrays - one for which the subscript range is specified by variables so
that the size of the array is set at the time storage is allocated.
 Reserved Words - the symbols used for keywords are not allowed to be used as
identifiers by the programmer.
 User defined data types - allow the user to design data abstractions that fit
particular problems very closely.

ALGOL was used mostly by research computer scientists in the United States and in
Europe. Its use in commercial applications was hindered by the absence of standard
input/output facilities in its description and the lack of interest in the language by large
computer vendors. ALGOL 60 did however become the standard for the publication of
algorithms and had a profound effect on future language development.

C Language

Systems programming, although similar to applications programming, requires


developers to create programs that interact with other programs or systems, as opposed to
human users.

It requires specific interactions, usually with very specific and sometimes rigid formats.
And because of the presence of several non-trivial structures and architectures as well as
non-traditional execution models, the need to build specific performance characteristics is
crucially important for the programmer.

Although several languages are being used for systems programming, C is the still the
ideal choice, due to its flexibility, efficiency, performance, and closeness to the hardware.
Let’s look at some other reasons why C continues to be the preferred systems
programming language:

Easy to code: One of the biggest reasons why C works so well for systems programming
is because it is easy to code. C’s direct 1-1 interaction with machine code means there are
no complicated built-in data structures like trees or tables. Since the programmer can see

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 49


System Software (3160715)


any code and know exactly what it does in the hardware, the entire backend is
implemented by the programmer – unlike in other languages where the backend
implementation is not necessarily known to the programmer.

Low-level language: Another reason for using C for systems programming is its
proximity to the operating system. Since most C implementations compile directly to
machine code, the programmer has full power over what happens at the machine level.
There is no need for an interpreter or compiler. This feature makes C an efficient
language for systems programming because low-level resources, such as memory, can be
accessed effortlessly.

Explicit memory management: Another strong reason why C is so popular for systems
programming is the flexibility it offers for memory management. Unlike other
programming languages where a garbage collector takes care of memory allocation, C
allows programmers to do low-level memory handling themselves, giving them total
control over where, when, and how memory is allocated. Programmers can scale down a
program and run with a small amount of memory. This is extremely beneficial in today’s
digital age, where mobile devices demand that programmers keep memory requirement to
a minimum.

Flexible structure: Systems programming is never easy, especially while dealing with
large chunks of code. However, C’s flexible structure allows programmers to break down
the program into multiple blocks of code or functions for execution. So, it is easy to
understand and allows free movement of data across the different functions. Programmers
can manually copy data to different areas, move bits around, and process data in small
amounts. Although this is a tedious process, it is a lot more efficient – both in the usage
of RAM and in processing time, which is essential in systems programming.

No runtime dependencies: As compared to other languages, C has a very small runtime.


And unlike other programming languages, C has absolutely no runtime dependencies.
Programs can be run on bare minimum systems like embedded systems. This means
programmers can build a C program that runs directly on hardware – without expecting
any kind of memory manager or input or output layer. Also, much of the standard library

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 50


System Software (3160715)


doesn’t require an operating system. Those that do can be implemented minimally by the
programmer.

Compatibility: C is extremely compatible. Most languages that exist today already have
what it takes to interact and communicate with C. This means programmers can develop
a library in C using standard calling conventions, and have the confidence that every
other language can link to it, in a seamless manner. Any software developed using C#,
Java, Perl, Python, or PHP can all link with C libraries without much trouble.

High portability: A great aspect of C is that is it a highly portable language. It lies as


close to the system as possible while simultaneously providing high-level constructs –
there is at least one C compiler for almost every existing architecture. Because portability
is directly proportional to how flexible the software is, systems that are developed using
C are often extremely flexible. So, for programmers who are able to write portable code
in C, the end result is an application that can run on every major platform.

RUST

Sponsored by Mozilla and developed actively over the past decade by a large and diverse
community of contributors, Rust supports many common low-level programming idioms
and APIs derived from modern C++. However, unlike C++, Rust enforces the safe usage
of these APIs with a strong static type system.

In particular, like Java, Rust protects programmers from memory safety violations (for
example, "use-after-free" bugs). But Rust goes further by defending programmers against
other, more insidious anomalies that no other mainstream language can prevent. For
example, consider data races: unsynchronized accesses to shared memory (at least one of
which is a write). Even though data races effectively constitute undefined (or weakly
defined) behavior for concurrent code, most "safe" languages (such as Java and Go)
permit them, and they are a reliable source of concurrency bugs.35 In contrast, Rust's
type system rules out data races at compile time.

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 51


System Software (3160715)


Rust has been steadily gaining in popularity, to the point that it is now being used
internally by many major industrial software vendors (such as Dropbox, Facebook,
Amazon, and Cloudflare) and has topped Stack Overflow's list of "most loved"
programming languages for the past five years. Microsoft's Security Response Center
Team recently announced that it is actively exploring an investment in the use of Rust at
Microsoft to stem the tide of security vulnerabilities in system software.8

The design of Rust draws deeply from the wellspring of academic research on safe
systems programming. In particular, the most distinctive feature of Rust's design—in
relation to other mainstream languages—is its adoption of an ownership type system.
Ownership type systems help the programmer enforce safe patterns of lower-level
programming by placing restrictions on which aliases (references) to an object may be
used to mutate it at any given point in the program's execution.

However, Rust goes beyond the ownership type systems of prior work in at least two
novel and exciting ways:

Rust employs the mechanisms of borrowing and lifetimes, which make it much easier to
express common C++-style idioms and ensure they are used safely.
Rust also provides a rich set of APIs—for example, for concurrency abstractions,
efficient data structures, and memory management—which fundamentally extend the
power of the language by supporting more flexible combinations of aliasing and mutation
than Rust's core type system allows. Correspondingly, these APIs cannot be implemented
within the safe fragment of Rust: rather, they internally make use of potentially unsafe C-
style features of the language, but in a safely encapsulated way that is claimed not to
disturb Rust's language-level safety guarantees.
These aspects of Rust's design are not only essential to its success—they also pose
fundamental research questions about its semantics and safety guarantees that the
programming languages community is just beginning to explore.

Signature of Faculty: Grade:

Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15 52

You might also like