Submission Assignment #1: BT602:System Programming
Submission Assignment #1: BT602:System Programming
Submission Assignment #1
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.
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.
1
Sarsij Mishra – Submission Assignment #1 2
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
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.
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
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.
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.