Spos - Lab Manual
Spos - Lab Manual
Spos - Lab Manual
SEMESTER-I
Class: TE
Semester: V
Pattern: 2019
INDEX
ASSN
TITLE
NO.
Group A
Design suitable Data structures and implement Pass-I and Pass-II of a two-pass
assembler for pseudo-machine. Implementation should consist of a few instructions
1 from each category and few assembler directives. The output of Pass-I (intermediate
code file and symbol table) should be input for Pass-II.
Design suitable data structures and implement Pass-I and Pass-II of a two-pass macro-
2 processor. The output of Pass-I (MNT, MDT and intermediate code file without any
macro definitions) should be input for Pass-II.
Group B
Write a program to simulate Memory placement strategies – best fit, first fit, next fit
3
andworst fit.
Assignment No- A1
Objectives:
• To study assembler.
• To understand algorithm of Pass-I.
• To implement assembler pass-I using JAVA programming language.
• To study Pass-II of a two pass assembler.
• To implement Pass-II using JAVA Programming language.
Problem Statement: Design suitable Data structures and implement Pass-I and Pass-II of a
two-pass assembler for pseudo-machine. Implementation should consist of a few instructions
from each category and few assembler directives. The output of Pass-I (intermediate code file
and symbol table) should be input for Pass-II.
Outcomes:
• Understand Pass I of two pass assembler.
• Implement Pass-I using JAVA.
• Understand Pass II of two pass assembler.
• Implement Pass-II using JAVA.
Software Requirements:
Hardware Requirements:
• 64 bit machine
• 4GB or 8 GB RAM
• 500 GB or 1TB HDD
Theory:
An assembler is a program that takes basic computer instructions and converts them into a
pattern of bits that the computer's processor can use to perform its basic operations. Some
people call these instructions assembler language and others use the term assembly language.
Department of Computer Engineering , ZCOER Narhe
Pune
Narhe Pune
TE: 310248: Laboratory Practice I
• Most computers come with a specified set of very basic instructions that correspond to
the basic machine operations that the computer can perform. For example, a "Load"
instruction causes the processor to move a string of bits from a location in the
processor's memory to a special holding place called a register. Assuming the processor has at
least eight registers, each numbered, the following instruction would move the value (string of
bits of a certain length) at memory location 3000 into the holding place called register 8:
L 8,3000
In this assignment we make use of Hashing for our Mneumonic table.This is to reduce the
overhead required to search a mneumonic in the mneumonic table.
The output of this program is going to be the input to Pass II hence we write all the tables and
IC to a File.
Thus the requisites for this assignment are File handling and Table handling method of
Hashing.
The Mneumonic table has been designed using hash function =([addition of ascii of all
alphabets of a mneumonic] mod 10 or 20)
• General IC(DL,code)
e. If an IS then
• code=machine opcode from optab(mneumonic table).
• LC=LC+length of instruction from optab.
f. If size!= 0 then
• Move contents of machine code buffer to the address code area+LC
• LC=LC+size
3. Processing of END statement
• Perform steps 2b and 2f
• Perform Error handling
• Write code to output file.
4. Stop.
Conclusion: Thus we have successfully studied and implemented the pass I and pass II of two pass
assembler.
Assignment No- A2
Objectives:
• To study Pass-I of a two pass macro processor.
Problem Statement: Design suitable data structures and implement Pass-I and Pass-II of a
two-pass macro- processor. The output of Pass-I (MNT, MDT and intermediate code file
without any macro definitions) should be input for Pass-II.
Outcomes:
Software Requirements:
• 64 bit machine
• 4GB or 8 GB RAM
• 500 GB or 1TB HDD
Theory:
Macro instruction is a notational convenience for the programmer.
It allows the programmer to write shorthand version of a program (module programming)
The macro processor replaces each macro invocation with the corresponding sequence of
statements
Department of Computer Engineering , ZCOER Narhe
Pune
Narhe Pune
TE: 310248: Laboratory Practice I
Macro
» the statement of expansion are generated each time the macro are invoked
Argument substitutions
Dummy arguments
» Positional argument
» Keyword argument
STRG &a3=DATA1, &a2=DATA2, &a1=DATA3 GENER
TYPE=DIRECT, CHANNEL=3
Data Structures used :-
MNT(Macro name table):-Stores the names of all macros alongwith their MDT index.
MACRO
&LAB INCR &ARG1,&ARG2,&ARG3
&LAB ADD 1,&ARG1
ADD 2,&ARG2
ADD 3,&ARG3
MEND
Output:-
MNT
MDT
Index Label Instruction operands
1 #0 ADD 1, #1
2 ADD 1, #2
3 ADD 1, #3
4 MEND
ALA
Argument Dummy name
&Lab #0
&Arg1 #1
&Arg2 #2
&Arg3 #3
Steps to follow:-
2. Read the ALP word by word using fgetc.
4. Go to Pass I
The task of pass II is macro expansion i.e deal with macro calls. For this we use the tables created in pass I of a
macro-processor. Whenever a call to a macro is found for eg:-
ADD 2 , Data2
ADD 3 , Data3
ALA
Argument Actual
Parameters
#0 LOOP
#1 Data1
#2 Data2
#3 Data3
Using these values we expand the macro with the help of MNT and MDT.
Steps to follow:-
1. Read the source program.
2. If an macro name is encounterd it means there is a call to the macro so do the following.
3. Read from MDT and replace dummy parameters with actual parameters.
Conclusion:- Thus we have successfully studied and implemented the pass I and pass II of two pass
macro-processor.
Assignment No- B1
Title: Memory placement strategies – best fit, first fit, next fit andworst fit.
Objectives:
• To study placement strategies.
Problem Statement: Write a program to simulate Memory placement strategies – best fit, first fit,
next fit andworst fit.
Outcomes:
• Understand placement strategies.
• Handle best fit, first fit, next fit and worst fit algorithm using JAVA Programming
language.
Software Requirements:
• Operating System : Windows or Ubuntu
• Eclipse
• JDK/JRE
Hardware Requirements:
• 64 bit machine
• 4GB or 8 GB RAM
• 500 GB or 1TB HDD
Theory:
1. First Fit: In the first fit, the partition is allocated which is the first sufficient block from the top of
Main Memory. It scans memory from the beginning and chooses the first available block that is large
enough. Thus it allocates the first hole that is large enough.
2. Best Fit Allocate the process to the partition which is the first smallest sufficient partition among the
free available partition. It searches the entire list of holes to find the smallest hole whose size is greater
than or equal to the size of the process.
3. Worst Fit Allocate the process to the partition which is the largest sufficient among the freely
available partitions available in the main memory. It is opposite to the best-fit algorithm. It searches the
entire list of holes to find the largest hole and allocate it to process.
4.Next Fit: Next fit is similar to the first fit but it will search for the first sufficient partition from the
last allocation point.
Conclusion: Thus we have studied and implemented the different Placement Algorithms.
Assignment No- B2
Objectives:
• To study page replacement strategies.
Outcomes:
• Understand page replacement policies.
• Handle LRU and optimal algorithm using JAVA Programming language.
Software Requirements:
• Operating System : Ubuntu or Fedora
• Eclipse
• JDK/JRE
Hardware Requirements:
• 64 bit machine
• 4GB or 8 GB RAM
• 500 GB or 1TB HDD
Theory:
Page Fault:-An interrupt that occurs when a program requests data that is not currently in real
memory. The interrupt triggers the operating system to fetch the data from a virtual memory
and load it into RAM.
The least recently used page (LRU) replacement algorithm, though similar in name to NRU,
differs in the fact that LRU keeps track of page usage over a short period of time, while NRU
just looks at the usage in the last clock interval. LRU works on the idea that pages that have
been most heavily used in the past few instructions are most likely to be used heavily in the
next few instructions too. While LRU can provide near-optimal performance in theory (almost
as good as Adaptive Replacement Cache), it is rather expensive to implement in practice.
When a page needs to be swapped in, the operating system swaps out the page whose next use
will occur farthest in the future. For example, a page that is not going to be used for the next 6
seconds will be swapped out over a page that is going to be used within the next 0.4 seconds.
This algorithm cannot be implemented in the general purpose operating system because it is
impossible to compute reliably how long it will be before a page is going to be used, except
when all software that will run on a system is either known beforehand and is amenable to the
static analysis of its memory reference patterns, or only a class of applications allowing run-
time analysis is allowed.
Conclusion: Thus we have studied and implemented the page replacement algorithm.
FAQs