System Software Unit-II
System Software Unit-II
Programming in machine code, by supplying the computer with the numbers of the
operations it must perform, can be quite a burden, because for every operation the
corresponding number must be looked up or remembered. Looking up all numbers
takes a lot of time, and mis-remembering a number may introduce computer bugs.
Although mnemonics differ between different CPU designs some are common, for
instance: "sub" (subtract), "div" (divide), "add" (add) and "mul" (multiply).
2) What is an Assembler?
An assembler is a program that accepts an assembly language program as input and
produces its machine language equivalent along with information for the loader
(An Assembler translates a program written in an assembly language to it machine
language equivalent)
Intermediate Object
Pass 1 Pass 2
file codes
10) Give an example of Assembly language along with the objectcode generated.
COPY 1000
FIRST 1000
CLOOP 1003
ENDFIL 1015
EOF 1024
THREE 102D
ZERO 1030
RETADR 1033
LENGTH 1036
BUFFER 1039
RDREC 2039
SYMBOL TABLE(SYMTAB)
a. # symbol.
i. Indication of the immediate addressing mode.
ii. Immediate addressing provides a faster access to an operand
reference.
b. @ symbol.
i. Indication of the indirect addressing mode.
ii. Indirect addressing reduces the number of instructions.
c. + symbol.
i. Explicit selection of the format 4 instruction with a direct
addressing mode.
ii. Format 4 is selected when the 12-bit displacement of format 3 is
too small.
d. BASE directive.
i. Indication that the base register B holds a base address used in a
base addressing.
ii. NOBASE directive disables the base register.
iii. LDB instruction loads the base register with a base address.
e. Register-to-register addressing.
i. Register addressing reduces the size of a machine instruction and
speeds up a computation
Assembling features.
f. Multiprogramming.
i. Larger memory allows us to load many programs.
ii. The object code is relative to zero because the load address is
variable.
iii. Program must be relocated when it is loaded in memory.
g. Register set mapping.
i. A separate register table can store the numeric values of the
registers.
ii. The numeric values of the registers can be preloaded with the
symbol table.
h. Relative (PC and base) addressing mode.
i. Operand value is subtracted from PC or base register value.
ii. PC relative addressing provides a displacement from –2048 to
+2047.
iii. Base relative addressing provides a displacement from 0 to 4095.
16) What is Program Relocation?
Program relocation
Principles.
o The load address of an object program is unknown at assembly time if the
system implements the multiprogramming feature.
o The assembler generates addresses relative to zero in the object program.
o At load time, relocation is performed by adding the load address to the
relative addresses.
o Operands of instructions that use direct addressing must be relocated, and
the assembler provides the relocation information in the object program.
o Operands of instructions that use relative addressing do not need to be
relocated.
o Relocation can be processed by the loader or by the CPU using relocation
registers.
17) What are the advantages of program relocation?
Program Relocation
The larger main memory of SIC/XE
o Several programs can be loaded and run at the same time.
o This kind of sharing of the machine between programs
o is called multiprogramming
To take full advantage
• Load programs into memory wherever there is room
• Not specifying a fixed address at assembly time
• Called program relocation
18) What are program blocks?
Program Blocks
Refer to segments of code that are rearranged within a single object program unit
USE [blockname]
At the beginning, statements are assumed to be part of the unnamed (default)
block
If no USE statements are included, the entire program belongs to this single block
Each program block may actually contain several separate segments of the source
program
19) How the program blocks are assembled?
Program Blocks - Implementation
Pass 1
Each program block has a separate location counter
Each label is assigned an address that is relative to the start of the block
that contains it
At the end of Pass 1, the latest value of the location counter for each block
indicates the length of that block
The assembler can then assign to each block a starting address in the
object program
Pass 2
The address of each symbol can be computed by adding the assigned
block starting address and the relative address of the symbol to that block
Each source line is given a relative address assigned and a block number
20) What is one pass assembler? Explain the functioning of one-pass assembler.
One-pass assemblers are used when
o it is necessary or desirable to avoid a second pass over the source program
o the external storage for the intermediate file between two passes is slow or
is inconvenient to use
Main problem: forward references to both data and instructions
One simple way to eliminate this problem: require that all areas be defined before
they are referenced.
o It is possible, although inconvenient, to do so for data items.
o Forward jump to instruction items cannot be easily eliminated.
undefined symbol
depending list
defining expression