You are on page 1of 5

HOMEWORK I

SYSTEM SOFTWARE
CSE 318
PART – A

Q1: A user after traveling through all line and viewing it decides to change all
occurrences of ‘’inbox’’ to ‘’spam’’. With the help of structure of editors tell how
replacement actually going to occur.

Ans: An editor is a computer program that helps in editing, viewing, travelling and
displaying a target document as per our reference.
Now in the above problem, firstly the editing component start work to change all
occurrences of ‘’inbox’’ to ‘’spam’’. Editing component is a collection of modules
dealing with editing tasks. Editing component invokes the editing filter –
generates a new editing buffer – contains part of the document to be edited from
current editing pointer.
Now travelling component is used to find out all the occurrences of “inbox” in the
document. It travel through whole document to reached at “inbox”.
After using travelling component, viewing component is used. The start of the
area to be viewed is determined by the current viewing pointer maintained by the
viewing component. Viewing component invokes the viewing filter – generates a
new viewing buffer – contains part of the document to be viewed from current
viewing pointer
Now the display component starts its work. Viewing buffer is then passed to the
display component of the editor, which produces a display by mapping the buffer
to a rectangular subset of the screen.

Q2: How we can interlink Components of system program all together, elaborate
diagrammatically.
Ans:
- Compiler : A compiler is a program that reads a program in one language,
the source language and translates into an equivalent program in another
language, the target language. The translation process should also report
the presence of errors in the source program.

- Assembler : Converts assembly language programs into object files.


Object files contain a combination of machine instructions, data, and
information needed to place instructions properly in memory. It translates
assembly instructions and pseudo-instructions into machine instructions. It
converts decimal numbers, etc. specified by programmer into binary.

- Linker : It is a tool that merges the object files produced by separate


compilation or assembly and creates an executable file. It searches the
program to find library routines used by program, e.g. printf(), math
routines etc. It determines the memory locations that code from each
module will occupy and relocates its instructions by adjusting absolute
references.

- Loader : It is a part of the OS that brings an executable file residing on


disk into memory and starts it running. It create a new address space for
the program, copies instructions and data into address space and copies
arguments passed to the program on the stack. Loader initializes the
machine registers including the stack ptr and jumps to a startup routine
that copies the program’s arguments from the stack to registers and calls
the program’s main routine.

Q3: Is it necessary to have viewing filters and viewing buffers in structure of


editors, if yes then how they help in managing the text.
Ans: Yes, viewing filters and viewing buffers both are necessary in structure of
editors.
The start of the area to be viewed is determined by the current viewing pointer
maintained by the viewing component. Viewing component is a collection of
modules responsible for determining the next view. Current viewing pointer can
be set or reset as a result of previous editing operation. Viewing component
invokes the viewing filter – generates a new viewing buffer – contains part of the
document to be viewed from current viewing pointer.
Viewing buffer is then passed to the display component of the editor, which
produces a display by mapping the buffer to a rectangular subset of the screen –
called a window.

PART - B

Q4: Generate passes of assemblers for following code---

David START 0
USING *, 21
L 1, Four
A 1, Length
ST 1,Buffer
Four RESW 1
Length RESW 1
Buffer RESB 4096
END
Ans: Pass 1: First pass reads each line and records labels in a symbol table. It
assigns addresses to all statements in the program. Save the values assigned to
all labels for use in Second Pass. Perform some processing of assembler
directives.

Pass 2: Second pass use info in symbol table to produce actual machine code
for each line. It assemble instructions. It generates data values defined by BYTE,
WORD. Second Pass performs processing of assembler directives not done in
First Pass. It writes the object program and the assembly listing.

Pass 1
Source Code Relative Mnemonic
Address Code
David START 0 0 L 1, _ (0, 21)
USING *, 21 4 A 1, _ (0, 21)
L 1, Four 8 ST 1, _ (0, 21)
A 1, Length
ST 1,Buffer
Four RESW 1 12 1
Length RESW 1 16 1
Buffer RESB 4096 20 --
END

Pass 2
Relative Mnemonic
Address Code
0 L 1, 12 (0, 20)
4 A 1, 16 (0, 20)
8 ST 1, 20(0, 20)
12 1
16 1
20 --
Q5: An assembler can tell loader which part of object code needs modification,
how modification can be done in this case
Ans: Loader is a part of the OS that brings an executable file residing on disk into
memory and starts it running.
An assembler can tell loader which part of object code needs modification. The
only parts of the program that require modification at load time are those that
specify direct addresses and the rest of the instructions need not be modified.
From the object program, it is not possible to distinguish the address and
constant. The assembler must keep some information to tell the loader. The
object program that contains the modification record is called a relocatable
program. The modification can be done by following way:
- For an address label, its address is assigned relative to the start of the
program (START 0).
- Produce a Modification record to store the starting location and the length
of the address field to be modified.
- The command for the loader must also be a part of the object program.

Q6: Is there any need to design the pass2 of an assembler? Can we generate
both the passes in a single pass, if yes how?
Ans: Yes there is a need to design the pass 2 of an assembler. It is most
important and useful to solve the problem of forward references, references to
variables or subroutines that have not yet been encountered when parsing the
source code. A pass 1 scanner cannot assemble source code which contains
forward references.
Yes we can generate both the passes in a single pass. But the same problem
due to which pass 2 is needed i.e. forward references can occurs. It is easy to
eliminate forward references to data items. We can simply require that all such
areas be defined in the source program before they are referenced. The
programmer must place all storage reservation statements at the start of program
rather than at the end. To reduce the size of problem many one pass assemblers
prohibit forward references to data items.

You might also like