Submission Assignment #1: BT602:System Programming

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

BT602:System Programming (Due: 25/04/19)

Submission Assignment #1

Faculty: Dr.Sandeep Kumar Poonia Name: Sarsij Mishra, Section: A

Problem 1: Explain different editors in details.

Line editor: In this, you can only edit one line at a time or an integral number of lines.
You cannot have a free-flowing sequence of characters. It will take care of only one line. Ex :
Teleprinter, edlin, teco

Screen editors: In this type of editors, the user is able to see the cursor on the screen and
can make a copy, cut, paste operation easily. It is very easy to use mouse pointer. Ex : vi,
emacs, Notepad

Multiple Window Editor: Multiple window editor allows you to work on more than one
file one file at a time and cut and paste text from file into another via yanking and putting.
The two fundamental concepts that lie behind multi-window editors are buffer and windows.
Buffer: Buffer holds the text to be edited. The text may come from a file or a brand new text
that you want to write on a file. A file only has one buffer associated with it.
Windows: Windows provides a view to the buffer to see what the buffer holds and edit and
modify it. A buffer may have multiple windows. Any changes made in any of the windows
will be reflected in all other windows associated with the same buffer. Once the last window
associated with a buffer is closed, the file gets hidden. But if you have made any changes to
the buffer and not have written them into the disk, it may not allow you to close the window.

Problem 2: Discuss different type of languages and also discuss translator.

Machine Language: A sequence of 0 and 1 is called machine language.A machine language


instruction has two parts. The first part is the operation code which tells the computer what
function to perform and the second part is the operand which tells the computer where to find
or store the data which is to be manipulated.

Assembly Language: It is a low level programming language that allows a user to write
a program using alphanumeric mnemonic codes, instead of numeric codes for a set of instruc-
tions.It requires a translator known as assembler to convert assembly language into machine
language so that it can be understood by the computer. It is easier to remember and write
than machine language.

High Level Language: It is a machine independent language. It enables a user to write


programs in a language which resembles English words and familiar mathematical symbols.
COBOL was the first high level language developed for business.

1
Sarsij Mishra – Submission Assignment #1 2

Translator:A program written in high-level language is called as source code. To convert


the source code into machine code, translators are needed.A translator takes a program written
in source language as input and converts it into a program in target language as output. The
most general term for a software code converting tool is translator. A translator, in software
programming terms, is a generic term that could refer to a compiler, assembler, or interpreter;
anything that converts higher level code into another high-level code (e.g., Basic, C++, Fortran,
Java) or lower-level (i.e., a language that the processor can understand), such as assembly
language or machine code.

Problem 3: Discuss different passes of two pass assembler.

An assembler is a translator, that translates an assembler program into a conventional ma-


chine language program. Basically, the assembler goes through the program one line at a time,
and generates machine code for that instruction. Then the assembler proceeds to the next
instruction. In this way, the entire machine code program is created. For most instructions
this process works fine, for example for instructions that only reference registers, the assembler
can compute the machine code easily, since the assembler knows where the registers are.

Consider an assembler instruction like the following

JMP LATER
LATER:
This is known as a forward reference. If the assembler is processing the file one line at a time,
then it doesn’t know where LATER is when it first encounters the jump instruction. So, it
doesn’t know if the jump is a short jump, a near jump or a far jump. There is a large difference
amongst these instructions. They are 2, 3, and 5 bytes long respectively. The assembler would
have to guess how far away the instruction is in order to generate the correct instruction. If
the assembler guesses wrong, then the addresses for all other labels later in the program woulds
be wrong, and the code would have to be regenerated. Or, the assembler could always choose
the worst case. But this would mean generating inefficiency in the program, since all jumps
would be considered far jumps and would be 5 bytes long, where actually most jumps are short
jumps, which are only 2 bytes long. So, scan the code twice. The first time, just count how
long the machine code instructions will be, just to find out the addresses of all the labels. Also,
create a table that has a list of all the addresses and where they will be in the program. This
table is known as the symbol table. On the second scan, generate the machine code, and use
the symbol table to determine how far away jump labels are, and to generate the most efficient
instruction.
This is known as a two-pass assembler. Each pass scans the program, the first pass generates
the symbol table and the second pass generates the machine code.
Sarsij Mishra – Submission Assignment #1 3

Figure 1: Two Pass Assembler

Pass 1: Assembler reads the entire source program and constructs a symbol table of names
and labels used in the program, that is, name of data fields and programs labels and their rela-
tive location (offset) within the segment. Pass 1 determines the amount of code to be generated
for each instruction.
Pass 2: The assembler uses the symbol table that it constructed in Pass 1. Now it knows
the length and relative of each data field and instruction, it can complete the object code for
each instruction. It produces .OBJ (Object file), .LST (list file) and cross reference (.CRF) files.

Problem 4: Discuss different passes of two pass assembler.

Most modern CPUs use an instruction queue. Several instructions are waiting in the queue,
ready to be executed. Separate electronic circuitry keeps the instruction queue full while the
control unit is executing the instructions. But this is simply an implementation detail that
allows the control unit to run faster. The essence of how the control unit executes a program
is represented by the single instruction register model.
Since instructions are simply bit patterns, they can be stored in memory. The instruction
pointer register always has the memory address of (points to) the next instruction to be exe-
cuted. In order for the control unit to execute this instruction, it is copied into the instruction
register.
Sarsij Mishra – Submission Assignment #1 4

The situation is as follows:


1. A sequence of instructions is stored in memory.
2. The memory address where the first instruction is located is copied to the program counter.
3. The CPU sends the address in the program counter to memory via the address bus.
4. Memory responds by sending a copy of the state of the bits at that memory location on
the
data bus, which the CPU then copies into its instruction register.
5. The instruction pointer is automatically incremented to contain the address of the next
instruction in memory.
6. The CPU executes the instruction in the instruction register.
7. Go to step .
Steps 3, 4 and 5 are called an instruction fetch.

Figure 2: Program Instruction Execution


Sarsij Mishra – Submission Assignment #1 5

Problem 5: Differentiate between Bootstrap, Absolute and Relocating Loader.

Absolute Loader: The operation of absolute loader is very simple. The object code is loaded
to specified locations in the memory. At the end the loader jumps to the specified address to
begin execution of the loaded program. The advantage of absolute loader is simple and efficient.
But the disadvantages are, the need for programmer to specify the actual address, and, difficult
to use subroutine libraries.
The object program and, the object program loaded into memory by the absolute loader are
also shown. Each byte of assembled code is given using its hexadecimal representation in char-
acter form. Easy to read by human beings. Each byte of object code is stored as a single
byte. Most machine store object programs in a binary form, and we must be sure that our file
and device conventions do not cause some of the program bytes to be interpreted as control
characters.

Figure 3: Absolute Loader

Bootstrap Loader: When a computer is first turned on or restarted, a special type of absolute
loader, called bootstrap loader is executed. This bootstrap loads the first program to be run
by the computer, usually an operating system. The bootstrap itself begins at address 0. It
loads the OS starting address 0x80. No header record or control information, the object code
is consecutive bytes of memory.
Absolute loader is simple and efficient, but the scheme has potential disadvantages One of the
most disadvantage is the programmer has to specify the actual starting address, from where the
program to be loaded. This does not create difficulty, if one program to run, but not for several
programs. Further it is difficult to use subroutine libraries efficiently. This needs the design
and implementation of a more complex loader. The loader must provide program relocation
and linking, as well as simple loading functions.

Relocating Loader: The concept of program relocation is, the execution of the object pro-
gram using any part of the available and sufficient memory. The object program is loaded
into memory wherever there is room for it. The actual starting address of the object program
is not known until load time. Relocation provides the efficient sharing of the machine with
larger memory and when several independent programs are to be run together. It also supports
the use of subroutine libraries efficiently. Loaders that allow for program relocation are called
relocating loaders or relative loaders.
Sarsij Mishra – Submission Assignment #1 6

Use of modification record and, use of relocation bit, are the methods available for specifying
relocation. In the case of modification record, a modification record M is used in the object
program to specify any relocation. In the case of use of relocation bit, each instruction is as-
sociated with one relocation bit and, these relocation bits in a Text record is gathered into bit
masks. Modification records are used in complex machines and is also called Relocation and
Linkage Directory (RLD) specification.

Figure 4: Relocating Loader

You might also like