Professional Documents
Culture Documents
SAGAR(M.P.)
Submitted To Submitted By
Department of CSE Suyash Vishwakarma
vsuyash165@gmail.com
0608CS21MT18
Experiment No. - 01
Introduction of system programming and its components.
The dictionary definition of a system is “a set of things working together as parts of a mechanism
or an interconnecting network.” This is a pretty apt way of thinking about systems as they pertain
specifically to the IT world. A computer system is a collection of components (both hardware and
software) that function as a part of a whole.
A system is comprised of five primary elements: architecture, modules, components, interfaces, and
data.
Systems design involves defining each element of a system and how each component fits into the
system architecture. System designers focus on top-level concepts for how each component should
be incorporated into the final product. They accomplish this primarily through the use of Unified
Modeling Language (UML) and flow charts that give a graphical overview of how each component
is linked within the system.
Systems programming involves the development of the individual pieces of software that allow the
entire system to function as a single unit. Systems programming involves many layers such as the
operating system (OS), firmware, and the development environment.
1) Loader
2) Assembler
3) Compiler
4) Macro
5) Interpreter
1) Loader: Loader plays an important role in system programming. It palaces the program in the main memory
and prepare it for execution. Loading program means reading contents of executable file and loading program in
the memory and then carryout tasks and prepare them for running, as the loading is complete the operating
system starts the program execution by passing control to program code.
2) Assembler: An assembler is used to convert assembly language program into machine level language.
Assembler provides access to Software and Application developers to manage computer hardware and its
components. Assembler act as a compiler of assembly language program.
3) Compiler: A Compiler is program used to convert high level programming language to low level
programming language. Compilers are a type of translator that translates digital devices and computer
languages.
i) Cross Compiler: A cross compiler is a compiler which is capable of generating an executable code
for other platform where it resides on another platform.
ii) Source to Source Compiler: A source to source compiler accepts an input written in one
programming language and produces output for same written in another language.
4) Macro A macro is a single line abbreviation for group of statements or block of code. Macro allows
programmer to write the short part of the program. A macro can be expanded into no. of instructions.
5) Interpreter In System Programming interpreter is a program which directly executes the program without
compiling it to the machine language.
Experiment No - 02
To write a program to generate the symbol table for the given assembly
language.
1. Starting symtabtest.cc...
2. Inside p2:
3. symbol:
4. id: c
5. type: INTEGER
6. level: 3
7. hash_link: 15
8. back_link: 99
9. offset: 0
10. tag: SYM_VAR
11. class: variable_symbol
12.
13. symbol:
14. id: b
15. type: REAL
16. level: 2
17. hash_link: 11
18. back_link: 98
19. offset: 0
20. tag: SYM_VAR
21. class: variable_symbol
22.
23. symbol:
24. id: a
25. type: INTEGER
26. level: 1
27. hash_link: -1
28. back_link: 97
29. offset: 0
30. tag: SYM_VAR
31. class: variable_symbol
32.
33. Inside p1:
34. symbol:
35. id: c
36. type: REAL
37. level: 2
38. hash_link: 12
39. back_link: 99
40. offset: 8
41. tag: SYM_VAR
42. class: variable_symbol
43.
44. symbol:
45. id: b
46. type: REAL
47. level: 2
48. hash_link: 11
49. back_link: 98
50. offset: 0
51. tag: SYM_VAR
52. class: variable_symbol
53.
54. symbol:
55. id: a
56. type: INTEGER
57. level: 1
58. hash_link: -1
59. back_link: 97
60. offset: 0
61. tag: SYM_VAR
62. class: variable_symbol
63.
64. 7GLOBAL.4VOID7INTEGER4REAL4READ5WRITE7INT-ARG5TRUNC8REAL-ARG4prog1a1b1c2p11b1c2p21c
65. -----------------------------------------------------------------------------------^ (pool_pos = 83)
66.
67. Symbol table (size = 17):
68. Pos Name Lev Hash Back Offs Type Tag
69. -----------------------------------------------
70. 0: GLOBAL. 0 -1 159 0 GLOBAL. SYM_PROC lbl = -1 ar_size = 0
71. 1: VOID 0 -1 82 0 VOID SYM_NAMETYPE
72. 2: INTEGER 0 -1 462 0 VOID SYM_NAMETYPE
73. 3: REAL 0 -1 324 0 VOID SYM_NAMETYPE
74. 4: READ 0 -1 316 0 INTEGER SYM_FUNC lbl = 0 ar_size = 0
75. 5: WRITE 0 -1 139 0 VOID SYM_PROC lbl = 1 ar_size = 0
76. 6: INT-ARG 0 -1 210 0 INTEGER SYM_PARAM
77. 7: TRUNC 0 -1 332 0 INTEGER SYM_FUNC lbl = 2 ar_size = 0
78. 8: REAL-ARG 0 -1 427 0 REAL SYM_PARAM
79. 9: prog 0 -1 24 0 VOID SYM_PROC lbl = 3 ar_size = 24
80. 10: a 1 -1 97 0 INTEGER SYM_VAR
81. 11: b 1 -1 98 8 INTEGER SYM_VAR
82. 12: c 1 -1 99 16 INTEGER SYM_VAR
83. 13: p1 1 -1 161 0 VOID SYM_PROC lbl = 4 ar_size = 16
84. 14: b 2 -1 98 0 REAL SYM_VAR
85. 15: c 2 -1 99 8 REAL SYM_VAR
86. 16: p2 2 -1 162 0 VOID SYM_PROC lbl = 5 ar_size = 8
87. 17: c 3 -1 99 0 INTEGER SYM_VAR
88. ENDING TEST PROGRAM RUN -----------------------------
Experiment No. - 03
Write a program to create symbol table for a given high-level language
program.
class Node {
public:
Node()
{
next = NULL;
}
void print()
{
cout << "Identifier's Name:" << identifier
<< "\nType:" << type
<< "\nScope: " << scope
<< "\nLine Number: " << lineNo << endl;
}
friend class SymbolTable;
};
class SymbolTable {
Node* head[MAX];
public:
SymbolTable()
{
for (int i = 0; i < MAX; i++)
head[i] = NULL;
}
if (start == NULL)
return "-1";
if (start == NULL)
return "-1";
if (start->identifier == id) {
start->print();
return start->scope;
}
start = start->next;
}
if (head[index] == NULL) {
head[index] = p;
cout << "\n"
<< id << " inserted";
return true;
}
else {
Node* start = head[index];
while (start->next != NULL)
start = start->next;
start->next = p;
cout << "\n"
<< id << " inserted";
return true;
}
return false;
}
// Driver code
int main()
{
SymbolTable st;
string check;
cout << "**** SYMBOL_TABLE ****\n";
// insert 'if'
if (st.insert("if", "local", "keyword", 4))
cout << " -successfully";
else
cout << "\nFailed to insert.\n";
// insert 'number'
if (st.insert("number", "global", "variable", 2))
cout << " -successfully\n\n";
else
cout << "\nFailed to insert\n";
// find 'if'
check = st.find("if");
if (check != "-1")
cout << "Identifier Is present\n";
else
cout << "\nIdentifier Not Present\n";
// delete 'if'
if (st.deleteRecord("if"))
cout << "if Identifier is deleted\n";
else
cout << "\nFailed to delete\n";
// modify 'number'
if (st.modify("number", "global", "variable", 3))
cout << "\nNumber Identifier updated\n";
return 0;
}
Experiment No. – 04
Exploring various features of debug command and also use of LAX and
YACC tools.
Lexical Analyzer
Algorithm:
Step 1: Start Step 2: Read the file and open the file as read mode. Step 3: Read the
string for token identifiers, variables.
Step 4: Take parenthesis also a token.
Step 5: Parse the string
Step 6: Stop
52 ! so rcnp( st r, " st ruct" ) | | ! st rcnp( st r, "goto" ) )
53 return ( t rue ) , |
54 retu rn T false) ;
55 }
56
57 // Returns 'true' if the strinj is an INTEGER.
58 book isInIeger(char* str)
59
60 int i, ten = str{en(str),
61
62 if (ten 0)
63 return ( fa 1se ) ;
64 for ( 1 = 6 ; 1 < ten; 1++) ¿
65 if (st r [1] != ' 0 ' 66 st r [1] != ' 1 ' 66 st r [1] != ' 2 '
66 66 st r [1] != ' 3 ' 66 st r [1] != ' 4 ' 6A st r [1] != ' 5 '
67 66 st r [ 1] != ' 6 ' 66 sI r [ 1] != ' 7 ' &A st r [1] != '8'
68 66 st r [1] != ' 9 ' | | ( st r [ 1] == ' — ' GA 1 > 6) )
69 return ( la 1se ) ;
70
71 return ltrue),
72
73
74 // Returns 'true' if the string is a REAL NUMBER.
75 book isRealNumber(char* str)
76
77 int i, len = strIen(str);
78 book hasDecimal = false,
79
80 if (ten 0)
81 return ( fa 1se ) ,
82 for ( 1 = 6 ; 1 < ten; 1++) ¿
83 if (st r [1] != ' 0 ' 66 st r [1] != ' 1 ' 66 st r [1] != ' 2 '
84 66 st r [1] != ' 3 ' 66 st r [1] != ' 4 ' 6A st r [1] != ' 5 '
85 66 st r [ 1] != ' 6 ' 66 sI r [ 1] != ' 7 ' &A st r [1] !='8'
86 66 st r [1] != ' 9 ' 66 st r [1] != ' . ' I I
87 (st r [1] 66 1 > 0) )
88 return (false);
89 If (str[1] ')
9 hasDec1mal I rue ;
91
92 ret u rn ( has Dec 1ma 1 ) ,
93
94
95 // Ext ract s the SUBSTRING.
96 char* subSIring(char* str, int left, int right)
97 {
98 int i;
99 cha re substr = (char*)malloc(
Output:
Experiment No. – 05
Introduction
Attributes (like phone numbers) that are explicitly repeated in a class definition are
not the only design problem that we might have to correct. Suppose that we want to
know what hobbies each person on our contact list is interested in (perhaps to help
us pick birthday or holiday presents). We might add an attribute to hold these. More
likely, someone else has already built the database, and added this attribute without
thinking about it.
With data entered, the new table looks similar to the PhoneNumbers. It can also be
joined to Contacts on matching pk-fk contactID pairs, re-creating the original data in
a form that we can now conveniently use for queries.
Experiment No. – 07
ER Model: Entity relationship (ER) models are based on the real-world entities
and their relationships. It is easy for the developers to understand the system by
simply looking at the ER diagram. ER models are normally represented by ER-
diagrams.
Components:
ER diagram basically having three components:
Entities − It is a real-world thing which can be a person, place, or even a
concept. For Example: Department, Admin, Courses, Teachers, Students,
Building, etc are some of the entities of a School Management System.
Example 1 : -
In a university,
A student is an entity,
University is the database,
Name and age and sex are the attributes.
The relationships among entities define the logical association between entities.
Example 2 :-
Features of ER :
The features of ER Model are as follows −
Graphical Representation is Better Understanding − It is easy and simple
to understand so it can be used by the developers to communicate with the
stakeholders.
Database Design − This model helps the database designers to build the
database.
Advantages :
The advantages of ER are as follows −
The ER model is easy to build.
This model is widely used by database designers for communicating their
ideas.
This model can easily convert to any other model like network model,
hierarchical model etc.
It is integrated with the dominant relational model.
Disadvantages :
The disadvantages of ER are as follows −
There is no industry standard for developing an ER model.
Information might be lost or hidden in the ER model.
There is no Data Manipulation Language (DML).
There is limited relationship representation.
Experiment No. – 08
General rules:
Simple query:
The following example illustrates how one might retrieve the CPU-speed of all
PCs with more than 64MB of RAM from a fictional PC database:
SELECT pc.cpuspeed
FROM PCs pc
WHERE pc.ram > 64;