0% found this document useful (0 votes)
9 views89 pages

15BECS403 System Software 3 0 0 3

The document outlines the course objectives and structure for a System Software course, covering topics such as assemblers, loaders, linkers, macro processors, and operating system functionalities. It includes detailed unit breakdowns, teaching hours, and references for further reading. The course aims to provide a comprehensive understanding of the design and implementation of various system software components in relation to machine architecture.

Uploaded by

udayaveeramani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views89 pages

15BECS403 System Software 3 0 0 3

The document outlines the course objectives and structure for a System Software course, covering topics such as assemblers, loaders, linkers, macro processors, and operating system functionalities. It includes detailed unit breakdowns, teaching hours, and references for further reading. The course aims to provide a comprehensive understanding of the design and implementation of various system software components in relation to machine architecture.

Uploaded by

udayaveeramani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 89

3 0 0 3

15BECS403 System Software

Course Objectives:

 To have an understanding of foundations of design of assemblers, loaders, linkers,


and macro processors
 To understand the relationship between system software and machine architecture.
 To know the design and implementation of assemblers
 To know the design and implementation of linkers and loaders.

UNIT- I Introduction 9

System software and machine architecture – The Simplified Instructional Computer (SIC) -
XE - Machine architecture - Data and instruction formats - addressing modes - instruction
sets - I/O and programming.

UNIT- II Assemblers 9

Basic assembler functions - A simple SIC assembler – Assembler algorithm and data
structures - Machine dependent assembler features - Instruction formats and addressing
modes – Program relocation - Machine independent assembler features - Literals – Symbol-
defining statements – Expressions - One pass assemblers and Multi pass assemblers -
Implementation example - MASM assembler.

UNIT- III Loaders and Linkers 9

Basic loader functions - Design of an Absolute Loader – A Simple Bootstrap Loader -


Machine dependent loader features - Relocation – Program Linking – Algorithm and Data
Structures for Linking Loader - Machine-independent loader features - Automatic Library
Search – Loader Options - Loader design options - Linkage Editors – Dynamic Linking –
Bootstrap Loaders - Implementation example - MSDOS linker.

UNIT-IV Macro Processors 9

Basic macro processor functions - Macro Definition and Expansion – Macro Processor
Algorithm and data structures - Machine-independent macro processor features -
Concatenation of Macro Parameters – Generation of Unique Labels – Conditional Macro
Expansion – Keyword Macro Parameters-Macro within Macro-Implementation example -
MASM Macro Processor – ANSI C Macro language.

UNIT- V Operating system and system software tools 9

Basic Operating System Functions-Machine Dependent Operating System Features:Interrupt


Processing-Process Scheduling-I/O Supervision- Machine Independent Operating System
Features: File Processing, Operating System Design Options: Multiprocessor Operating
Systems-Distributed Operating Systems-Object Oriented Operating Systems. Text editors -
Editor Structure. - Interactive debugging systems

Total Hours: 45
Text Books:

1. Leland L. Beck, “System Software – An Introduction to Systems Programming “,


Pearson Education Asia.3rd edition,2011

References:

1. Dhamdhere.D.M, “Systems Programming and Operating Systems “, Tata McGraw-


Hill, New Delhi, 2009
2. John J. Donovan, “Systems Programming “, Tata McGraw-Hill , New delhi, 2002
KARPAGAM ACADEMY OF HIGHER EDUCATION
FACULTY OF ENGINEERING
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

15BECS403 System Software Lecture plan

Reference
Book & Page
DESCRIPTION OF PORTION TO BE Nos.
S.NO HOURS
COVERED Used for
teaching
TEACHING
2 Discussion on the need of studying the 1 AIDS
course
3 Discussion on the fundamentals of hardware 1 T[1]
and software
4 1 R[3]
Introduction to different types of windows
UNIT I Introduction
1.1 System software and machine T[1] Page no
5 architecture 1
3-4

1.2 The Simplified Instructional Computer T[1] Page no


6 1
(SIC) 5-7

T[1] Page no
7 1.3 Machine architecture 1
5
Tutorial hour-Test is to be conducted for
8 1
the topics covered from 1.1 to 1.2.3
R[3] Page no
9 1.4 Data and instruction formats 1
5 BB
T[1] Page no &
6 PPT
10 1.5 Addressing modes 1
R[3] Page no
5
T[1] Page no
11 1.6 Instruction sets 1
7-9
T[1] Page no
1.7 I/O and programming 1
7-9

UNIT-II Assemblers

2.1 Basic assembler functions T[1] Page no


12 1
2.1.1 A simple SIC assembler 46-52

2.1.2 Assembler algorithm and data T[1] Page no


13 1
structures 52-54
2.2 Machine dependent assembler features
T[1] Page no
14 2.2.1 Instruction formats and addressing 1
54-63
modes
2.3 Program relocation T[1] Page no
15 1
63-67
2.3.1 Machine independent assembler feature T[1] Page no
16 2.3.1.1.Literals 1
67-72
2.4 Symbol
R[3] Page no
17 2.4.1 Defining statements 1
26-29
Tutorial hour-Test is to be conducted for
18 the topics covered from 2.1 to 2.4.1 1

R[3] Page no
2.5 Expressions
19 1 29-30,34-40
2.6 One pass assemblers

R[3] Page no
20 2.6.1 Multi pass assemblers 1
41-44

2.7 Implementation example R[3] Page no BB


21 1
2.8 MASM assembler 45-46 &
PPT
Tutorial hour-Test is to be conducted for
22 1
the topics covered from 2.5 to 2.8

UNIT –III Loaders and Linkers

R[3] Page no
23 3.1 Basic loader functions 1
3.2 to 3.5
R[3] Page no
24 1
3.1.1 Design of an Absolute Loader 3.5 to 3.9
T[1] Page no
25 3.2 A Simple Bootstrap Loader 1
132 to 135
3.3 Machine dependent loader features T[1] Page no
26 1
3.3.1 Relocation 135 to 141
T[1] Page no
27 3.3.2 Program Linking 1
141 to 148
Tutorial hour-Test is to be conducted for
28 1
the topics covered from 3.1 to 3.3.2
3.3.2.1 Algorithm and Data Structures for T[1] Page no
29 1
Linking Loader 148 to 154

3.4 Machine independent loader features T[1] Page no


30 1
3.5 Automatic Library Search 154-156

T[1] Page no
31 3.6 Loader Options 1
156-158
32 Tutorial hour-Test is to be conducted for
1
the topics covered from 3.3 to 3.3.2.1

3.7 Loader design options


T[1] Page no
33 3.7.1 Linkage editor 1
158-165
3.7.1.2 Dynamic linking

R[3] Page no
34 3.8 Bootstrap Loaders 1
3.25 to 3.26
R[3] Page no
3.27 to 3.28
35 1
3.9 Implementation example T[1] Page no
3.10 MSDOS linker. 167 to 169
UNIT IV Macro Processors

4.1 Basic macro processor functions R[3] Page no


36 1
4.1.1 Macro Definition and Expansion 4.2 to 4.7

4.1.2 Macro Processor Algorithm and data R[3] Page no


37 1
structures 4.8 to 4.12

4.2 Machine-independent macro processor R[3] Page no


features 4.13 to 4.15
38 1
4.2.1 Concatenation of Macro Parameters R[3] Page no
4.2.2 Generation of Unique Labels 4.15 to 4.16

Tutorial hour-Test is to be conducted for


39 1
the topics covered from 4.1 to 4.2.1
R[3] Page no
4.2.3 Conditional Macro Expansion 4.16 to 4.18
40 1
4.2.4 Keyword Macro Parameters R[3] Page no
4.21 to 4.22
4.3 Macro within Macro R[3] Page no
41 1
4.3.1 Implementation example 4.24 to 4.26
T[1] Page no
42 4.4 MASM Macro Processor 1
214 to 216
T[1] Page no
43 4.5 ANSI C Macro language 1
216 to 220
UNIT-V OPERATING SYSTEM AND
SYSTEM SOFTWARE TOOLS BB
&
T[1] Page no PPT
44 5.1 Basic Operating System Functions 1
317 to 320

5.2 Machine Dependent Operating System T[1] Page no


45 1
Features: Interrupt Processing 320 to 326

T[1] Page no
46 5.3 Process Scheduling-I/O Supervision 1
328 to 335

5.4 Machine Independent Operating System T[1] Page no


47 1
Features: File Processing 355 to 361

5.5 Operating System Design Options: T[1] Page no BB


48 1 &
Multiprocessor Operating Systems 367 to 370
PPT
Tutorial hour-Test is to be conducted for
49 1
the topics covered from 5.1 to 5.5

T[1] Page no
50 5.6 Distributed Operating Systems 1
370-373
T[1] Page no
5.7 Object Oriented Operating Systems 373-375
51 1
5.8 Text editors - Editor Structure R[3] Page no
5.2 to 5.8
R[3] Page no
52 5.9 Interactive debugging systems 1
5.10 to 5.14

Tutorial hour-Test is to be conducted for


53 1
the topics covered from 5.6 to 5.9

54 Revision ESE question papers 1

Text Books:

2. Leland L. Beck, “System Software – An Introduction to Systems Programming “,


Pearson Education Asia.3rd edition,2011

References:

3. Dhamdhere.D.M, “Systems Programming and Operating Systems “, Tata McGraw-


Hill, New Delhi, 2009
4. John J. Donovan, “Systems Programming “, Tata McGraw-Hill , New delhi, 2002
UNIT- I INTRODUCTION

System software and machine architecture – The Simplified Instructional Computer (SIC) -
Machine architecture - Data and instruction formats - addressing modes - instruction sets - I/O
and programming.

1.1 SYSTEM SOFTWARE AND MACHINE ARCHITECTURE


System software consists of a variety of programs that support the operation of a computer. It
is a set of programs to perform a variety of system functions as file editing, resource
management, I/O management and storage management. The characteristic in which system
software differs from application software is machine dependency. An application program is
primarily concerned with the solution of some problem, using the computer as a tool. System
programs on the other hand are intended to support the operation and use of the computer itself,
rather than any particular application. For this reason, they are usually related to the architecture
of the machine on which they are run. For example, assemblers translate mnemonic instructions
into machine code.
The instruction formats, addressing modes are of direct concern in assembler design.
There are some aspects of system software that do not directly depend upon the type of
computing system being supported. These are known as machine-independent features. For
example, the general design and logic of an assembler is basically the same on most computers.

1.1.1 TYPES OF SYSTEM SOFTWARE:


1. Operating system
2. Language translators
a. Compilers
b. Interpreters
c. Assemblers
d. Preprocessors
3. Loaders
4. Linkers
5. Macro processors

1.1.1.1 OPERATING SYSTEM


It is the most important system program that act as an interface between the users and the
system. It makes the computer easier to use. It provides an interface that is more user-friendly
than the underlying hardware. The functions of an operating system are:
1. Process management
2. Memory management
3. Resource management
4. I/O operations
5. Data management
6. Providing security to user’s job.

1.1.1.2 LANGUAGE TRANSLATORS

It is the program that takes an input program in one language and produces an output in
another language.
1
Fig.no 1.1 Working of Language translator

1.1.1.3 COMPILERS
A compiler is a language program that translates programs written in any high-level
language into its equivalent machine language program. It bridges the semantic gap between a
programming language domain and the execution domain. Two aspects of compilation are:
It should generate code to increment meaning of a source program in the execution domain. It
should provide diagnostics for violation of programming language, semantics in a source
program. The program instructions are taken as a whole.

Fig. no. 1.2 Working of Compiler

1.1.1.4 INTERPRETERS
It is a translator program that translates a statement of high-level language to machine
language and executes it immediately. The program instructions are taken line by line. The
interpreter reads the source program and stores it in memory. During interpretation, it takes a
source statement, determines its meaning and performs actions which increments it. This
includes computational and I/O actions. Program counter (PC) indicates which statement of
the source program is to be interpreted next. This statement would be subjected to the
interpretation cycle. The interpretation cycle consists of the following steps:
 Fetch the statement.
 Analyze the statement and determine its meaning.
 Execute the meaning of the statement.
The following are the characteristics of interpretation: The source program is retained in the
source form itself, no target program exists. A statement is analyzed during the interpretation.

Fig. no. 1.3 Working of Interpreter

2
1.1.1.5 ASSEMBLERS

Programmers found it difficult to write or red programs in machine language. In a quest


for a convenient language, they began to use a mnemonic (symbol) for each machine instructions
which would subsequently be translated into machine language. Such a mnemonic language is
called Assembly language. Programs known as Assemblers are written to automate the
translation of assembly language into machine language.

Fig. no. 1.4 Working of an Assembler

Fundamental functions of an assembler are:


 Translating mnemonic operation codes to their machine language equivalents.
 Assigning machine addresses to symbolic tables used by the programmers.

1.2 THE SIMPLIFIED INSTRUCTIONAL COMPUTER (SIC):


It is similar to a typical microcomputer. It comes in two versions:
o The standard model
o XE version

1.2.1 SIC MACHINE STRUCTURE


1.2.1.1 Memory:
It consists of bytes(8 bits) ,words (24 bits which are consecutive 3 bytes) addressed
by the location of their lowest numbered byte. There are totally 32,768 bytes in
memory.

1.2.1.2 Registers:
There are 5 registers namely
1. Accumulator (A)
2. Index Register(X)
3. Linkage Register (L)
4. Program Counter (PC)
5. Status Word (SW).
Accumulator is a special purpose register used for arithmetic operations. Index register is used
for addressing. Linkage register stores the return address of the jump of subroutine instructions
(JSUB). Program counter contains the address of the current instructions being executed. Status
word contains a variety of information including the condition code.

1.2.1.3 Data formats:


Integers are stored as 24-bit binary numbers: 2’s complement representation is used
for negative values characters are stored using their 8 bit ASCII codes. They do not
support floating – point data items.

1.2.1.4 Instruction formats:

3
Fig no. 1.5 Instruction format

All machine instructions are of 24-bits wide. X-flag bit that is used to indicate indexed-
addressing mode. There are two types of addressing are available namely,
 Direct addressing mode
 Indexed addressing mode or indirect addressing mode

Fig no. 1.6 Addressing mode

Where(x) represents the contents of the index register(x)

1.2.1.4.1 Instruction set:


It includes instructions like:
 Data movement instruction - Ex: LDA, LDX, STA, STX.
 Arithmetic operating instructions - Ex: ADD, SUB, MUL, DIB.
 This involves register A and a word in memory, with the result being left in the
register.
 Branching instructions - Ex: JLT, JEQ, TGT.
 Subroutine linkage instructions - Ex: JSUB, RSUB.

1.2.1.4.2 Input and Output:


The I/O is performed by transferring one byte at a time to or from the rightmost 8
bits of register A. Each device is assigned a unique 8-bit code. There are 3 I/O
instructions : The Test Device (TD) instructions tests whether the addressed device is
ready to send or receive a byte of data. A program must wait until the device is ready, and
then execute a Read Data (RD) or Write Data (WD). The sequence must be repeated for
each byte of data to be read or written.

1.3 SIC/XE ARCHITECTURE & SYSTEM SPECIFICATION

Memory
 1 word = 24 bits (3 8-bit bytes)
 Total (SIC/XE) = 220 (1,048,576) bytes (1Mbyte)

Registers:
 10 x 24 bit registers

4
MNEMONIC Register Purpose
A 0 Accumulator
X 1 Index register
L 2 Linkage register (JSUB/RSUB)
B 3 Base register
S 4 General register
T 5 General register
F 6 Floating Point Accumulator (48 bits)
PC 8 Program Counter (PC)
SW 9 Status Word (includes Condition Code, CC)

Data Format:
Integers are stored in 24 bit, 2's complement format. Characters are stored in 8-bit
ASCII format. Floating point is stored in 48 bit signed-exponent-fraction format: as shown
below

Fig no 1.7 Storage of floating point format


The fraction is represented as a 36 bit number and has value between 0 and 1. The
exponent is represented as a 11 bit unsigned binary number between 0 and 2047. The sign of
the floating point number is indicated by s : 0=positive, 1=negative. Therefore, the absolute
floating point number value is: f*2(e-1024)

Instruction Format:

There are 4 different instruction formats available:


Format 1 (1 byte):

op {8}

Format 2 (2 bytes):

op {8} r1 {4} r2 {4}


Format 3 (3 bytes):

Format 4 (4 bytes):

5
Formats 3 & 4 introduce addressing mode flag bits:

 n=0 & i=1


Immediate addressing - TA is used as an operand value (no memory
reference)
 n=1 & i=0
Indirect addressing - word at TA (in memory) is fetched & used as an
address to fetch the operand from
 n=0 & i=0
Simple addressing TA is the location of the operand
 n=1 & i=1
Simple addressing same as n=0 & i=0

Flag x:
x=1 Indexed addressing add contents of X register to TA calculation Flag b & p
(Format 3 only):
 b=0 & p=0
Direct addressing displacement/address field containsTA (Format 4
always uses direct addressing)
 b=0 & p=1
PC relative addressing - TA=(PC)+disp (-2048<=disp<=2047)*
 b=1 & p=0
Base relative addressing - TA=(B)+disp (0<=disp<=4095)**

Flag e:
 If e=0 use Format 3
 If e=1 use Format 4

1.3.1 Instructions:

SIC provides 26 instructions, SIC/XE provides an additional 33 instructions (59 total).


SIC/XE has 9 categories of instructions:
The Load/store registers (LDA, LDX, LDCH, STA, STX, STCH, etc.). The
integer arithmetic operations (ADD, SUB, MUL, DIV) these will use register A and a
word in memory, results are placed into register A. The compare (COMP) compares
contents of register A with a word in memory and sets CC (Condition Code) to <, >, or =
conditional jumps (JLT, JEQ, JGT) - jumps according to setting of CC. The subroutine
linkage (JSUB, RSUB) - jumps into/returns from subroutine using register L. The input
& output control (RD, WD, TD) are explained in the next section. The floating point -
arithmetic operations (ADDF, SUBF, MULF, DIVF). The register manipulation,
operands-from-registers, and register-to-register arithmetics (RMO, RSUB, COMPR,
SHIFTR, SHIFTL, ADDR, SUBR, MULR, DIVR, etc)

Input and Output (I/O):

The SIC/XE has 28 (256) I/O devices may be attached, each has its own unique 8-
bit address and 1 byte of data will be transferred to/from the rightmost 8 bits of register
A. Three I/O instructions are provided:

6
 RD Read Data from I/O device into A

 WD Write data to I/O device from A

 TD Test Device determines if addressed I/O device is ready to


send/receive a byte of data. The CC (Condition Code) gets set with results
from this test:

< device is ready to send/receive


= device isn't ready

SIC/XE Has capability for programmed I/O (I/O device may input/output data
while CPU does other work) - 3 additional instructions are provided:

o SIO Start I/O


o HIO Halt I/O
o TIO Test I/O

TWO MARKS

1. Define System Software.


System software consists of a variety of programs that supports the operations of a
computer.
Eg. Compiler, Assembler, Editor

2. What are the types of software?


1. System software
2. Application software.

3. Illustrate how input and output operations are performed in SIC. (or) Write I/O
instructions used in SIC?
In SIC IO operations are performed using I/O instruction like
TD – Test Device
RD – Read Data
WD – Write Data

4. How the target address will be calculated in Relative addressing modes


The Relative addressing modes are,
1. Base relative addressing mode
2. PC relative addressing mode
In Base relative addressing mode, the target address will be calculated, adding
displacement value with Base register value
TA = (B) + disp
In Program Counter Relative addressing the displacement value will be added with
program counter value
TA = PC + disp

5. Write about Direct and Indirect addressing modes.


Direct Addressing Mode:
7
In this address mode the operand value is present in the target address.
In Direct Address: The address mode in which the operands address is present in
the target address.

6. Compare RISC and CISC machines.


RISC CISC
1. It contains less No. of instructions It contains more number of Instructions.
2. It has more registers. It has less registers.
3. Reduced Instruction set Computer Complex Instruction set computer
4. Eg .VAX, Pentium Pro Eg. Ultra SPARC, Power PC

7. Explain the term Virtual address space (virtual memory)


The virtual memory allows programs to operate as though they had access to an
extremely large memory, regardless of the amount of memory actually present on the
system. For Eg. VAX architecture supports virtual address space.

8. What is Process Status Long Word (PSL)


PSL contains state variable and flags associated with a process. The PSL also
includes a condition code and a flag that specifies whether compatibility mode is being
used or not.

9. Explain about trailing and leading numeric?


Trialing Numeric:
Numeric format is used to represent numeric values with one digit per byte. In
this format if sign appears in the last byte then it is called Trialing numeric.
Leading Numeric:
If sign appears as a separate byte preceding the first digit called leading separate
numeric.

10. What is little Endian Byte ordering?


The least significant part of a numeric value is stored at the lower numbered
address. This is called little endian byte ordering because the “little end” of the value
comes first in memory.

11. What is Big endian Byte Ordering?


The least significant part of the numeric value is stored at the lowest numbered
address is called Big Endian Byte Ordering.

12. Write about Immediate addressing mode?


The value of the operand is specified as part of the instruction itself is called
immediate addressing.
Eg. LDX #100

13. Define Data Format.


Each Architecture is having its own format for defining a data. It is called Data
format .For example in SIC integers are stored as 24 bit binary number.

14. What is Instruction Set?


Each Architecture provides set of Instruction for performing some task. For
example in SIC arithmetic instructions like LDA,LDX.
8
15. Define Program counter.
Program Counter is a register which is used to store the address of the next
instruction to be fetched for execution.

16. Describe the use of the registers A, X, L, PC, SW.


Register Purpose
A Accumulator –used for Arithmetic operations
X Index Register-used for addressing.L Linkage register
PC Program Counter- Contains the address of the next instruction to be fetched for
execution.
SW -Status Word

17. Explain the use of the registers B,S,T,F.


Register Purpose
B Base Register –Used for Addressing
S General working register
T General Working register
F Floating Point Accumulator.

18.Define is compiler and interpreter?


An Interpreter is a program that implements or simulates a virtual machine
using the base set of instructions of a programming language as its machine language.
A Compiler is a program that translates code of a programming language in
machine code, also called object code. The object code can be executed directly on the
machine where it was compiled.

19. Define assembly language?


Instructions are supplied to a processor in binary form. A program in this form is
called machine language program. For human understanding each machine instruction is
coded into English. This type of mnemonic coding is called assembly coding. A program
in which instructions are in assembly coding is called assembly language program.

20. Define immediate addressing.


The value of an operand contained in the address part of an instruction and
used as data by this instruction.

************************************************************************

9
UNIT- II ASSEMBLERS

Basic assembler functions - A simple SIC assembler – Assembler algorithm and data structures -
Machine dependent assembler features - Instruction formats and addressing modes – Program
relocation - Machine independent assembler features - Literals – Symbol-defining statements –
Expressions - One pass assemblers and Multi pass assemblers - Implementation example –
MASM assembler.

2.1 BASIC ASSEMBLER FUNCTIONS


The fundamental functions of an assembler are to translate the mnemonic operation codes
to their machine language equivalents and assigning machine addresses to symbolic labels used
by the programmer.

10
Figure 2.1: Assembler language program for basic SIC version

Indexed addressing is indicated by adding the modifier “ X” following the operand. Lines
beginning with “.” contain comments only. The following assembler directives are
used:
 START: Specify name and starting address for the program.
 END : Indicate the end of the source program and specify the first executable
instruction in the program.
 BYTE: Generate character or hexadecimal constant, occupying as many bytes as
needed to represent the constant.
 WORD: Generate one- word integer constant.
 RESB: Reserve the indicated number of bytes for a data area.
 RESW: Reserve the indicated number of words for a data area.
The program contains a main routine that reads records from an input device( code F1)
and copies them to an output device(code 05). The main routine calls subroutines:
RDREC – To read a record into a buffer and WRREC – To write the record from the
buffer to the output device. The end of each record is marked with a null character
(hexadecimal 00).

11
2.2 A SIMPLE SIC ASSEMBLER
The translation of source program to object code requires the following functions:
Convert mnemonic operation codes to their machine language equivalents. Eg: Translate
STL to 14 (line 10). Convert symbolic operands to their equivalent machine addresses.
Eg:Translate RETADR to 1033 (line 10). Build the machine instructions in the proper
format. Convert the data constants specified in the source program into their internal machine
representations. Eg: Translate EOF to 454F46(line 80). Write the object program and the
assembly listing. All fuctions except function 2 can be established by sequential processing
of source program one line at a time.
Consider the statement
10 1000 FIRST STL RETADR 141033
This instruction contains a forward reference (i.e.) a reference to a label
(RETADR) that is defined later in the program. It is unable to process this line because
the address that will be assigned to RETADR is not known. Hence most assemblers make
two passes over the source program where the second pass does the actual translation.
The assembler must also process statements called assembler directives or pseudo
instructions which are not translated into machine instructions. Instead they provide
instructions to the assembler itself. Examples: RESB and RESW instruct the assembler to
reserve memory locations without generating data values. The assembler must write the
generated object code onto some output device. This object program will later be loaded
into memory for execution. The Object program format contains three types of records:
 Header record: Contains the program name, starting address and length.
 Text record: Contains the machine code and data of the program.
 End record: Marks the end of the object program and specifies the address in
the program where execution is to begin

The record format is as follows:


Header record:
Col. 1 H
Col.2-7 Program name
Col.8-13 Starting address of object program
Col.14-19 Length of object program in bytes
Text record:
Col.1 T
Col.2-7 Starting address for object code in this record
Col.8-9 Length of object code in this record in bytes
Col 10-69 Object code, represented in hexadecimal (2 columns per byte of
object code)
End record:
Col.1 E
Col.2-7 Address of first executable instruction in object program

Following are the functions of the two passes of assembler:


Pass 1 (Define symbols) – It sssign addresses to all statements in the program, saves the
addresses assigned to all labels for use in Pass 2 and finally perform some processing of
assembler directives.
Pass 2 (Assemble instructions and generate object programs) – It assembles the instructions
(translating operation codes and looking up addresses), generates data values defined by
12
BYTE,WORD etc, perform processing of assembler directives not done in Pass 1 and write the
object program and the assembly listing.

Fig no : 2.2 Object program


2.3 ASSEMBLER ALGORITHM AND DATA STRUCTURES
Assembler uses two major internal data structures: Operation Code Table
(OPTAB) : Used to lookup mnemonic operation codes and translate them into their
machine language equivalents. Symbol Table (SYMTAB) : Used to store
values(Addresses) assigned to labels.
2.3.1 Location Counter (LOCCTR):
This variable is used to help in the assignment of addresses. It is initialized to the
beginning address specified in the START statement. After each source statement is processed,
the length of the assembled instruction or data area is added to LOCCTR. Whenever a label is
reached in the source program, the current value of LOCCTR gives the address to be associated
with that label.
2.3.2 Operation Code Table (OPTAB):
The table contains the mnemonic operation and its machine language equivalent. It also
contains information about instruction format and length. In Pass 1, OPTAB is used to lookup
and validate operation codes in the source program. In Pass 2, it is used to translate the operation
codes to machine language program. During Pass 2, the information in OPTAB tells which
instruction format to use in assembling the instruction and any peculiarities of the object code
instruction.
2.3.3 Symbol Table (SYMTAB) :
The table includes the name and value for each label in the source program and flags to
indicate error conditions. During Pass 1 of the assembler, labels are entered into SYMTAB as
they are encountered in the source program along with their assigned addresses. During Pass 2,
symbols used as operands are looked up in SYMTAB to obtain the addresses to be inserted in the
assembled instructions.
Pass 1 usually writes an intermediate file that contains each source statement together with
its assigned address, error indicators. This file is used as the input to Pass 2. This copy of the
source program can also be used to retain the results of certain operations that may be performed
during Pass 1 such as scanning the operand field for symbols and addressing flags, so these need
not be performed again during Pass 2.

13
2.4 MACHINE DEPENDENT ASSEMBLER FEATURES
Consider the design and implementation of an assembler for SIC/XE
version.

Fig no 2.3 Design and Implementation of SIC/XE

14
Indirect addressing is indicated by adding the prefix @ to the operand (line70).
Immediate operands are denoted with the prefix # (lines 25, 55,133). Instructions that refer to
memory are normally assembled using either the program counter relative or base counter
relative mode.
The assembler directive BASE (line 13) is used in conjunction with base relative
addressing. The four byte extended instruction format is specified with the prefix + added to the
operation code in the source statement.
Register-to-register instructions are used wherever possible. For example the statement
on line 150 is changed from COMP ZERO to COMPR A,S. Immediate and indirect addressing
have also been used as much as possible.
Register-to-register instructions are faster than the corresponding register-to-memory
operations because they are shorter and do not require another memory reference.
While using immediate addressing, the operand is already present as part of the
instruction and need not be fetched from anywhere. The use of indirect addressing often avoids
the need for another instruction

2.5 INSTRUCTION FORMATS AND ADDRESSING MODES - SIC/XE


 PC-relative or Base-relative addressing: op m
 Indirect addressing: op @m
 Immediate addressing: op #c
 Extended format: +op m
 Index addressing: op m,x
 register-to-register instructions
 larger memory -> multi-programming (program allocation)

2.5.1 Translation
Register translation
The register name (A, X, L, B, S, T, F, PC, SW) and their values (0,1, 2, 3, 4, 5, 6, 8,
9)are preloaded in SYMTAB
Address translation
Most register-memory instructions use program counter relative or base relative
addressing Format 3: 12-bit address field , base-relative: 0~4095, pc-relative: -
2048~2047. Format 4: 20-bit address field

2.6 PROGRAM RELOCATION


The main aim is the need for program relocation. It is desirable to load and run several
programs at the same time. The system must be able to load programs into memory wherever
there is room. The exact starting address of the program is not known until load time.

2.6.1 Absolute Program


The Program with starting address specified at assembly time. The address may
be invalid if the program is loaded into somewhere else.

15
Fig no : 2.4 Example

Fig no : 2.5 Example: Program Relocation


The only parts of the program that require modification at load time are those that specify
direct addresses. The rest of the instructions need not be modified.
o Not a memory address (immediate addressing)
o PC-relative, Base-relative
From the object program, it is not possible to distinguish the address and constant.
o The assembler must keep some information to tell the loader.
o The object program that contains the modification record is called a relocatable
program.
The way to solve the relocation problem is that for an address label, its address is
assigned relative to the start of the program (START 0) and 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.

16
2.6.2 Modification record
It is mandatory that one modification record for each address has to be modified.
The length is stored in half-bytes (4 bits). The starting location is the location of the byte
containing the leftmost bits of the address field to be modified. If the field contains an
odd number of half-bytes, the starting location begins in the middle of the first byte

Fig no: 2.6 Modification record

Fig no: 2.7 Relocatable Object Program


2.7 MACHINE INDEPENDENT ASSEMBLER FEATURES
2.7.1 Literals
The programmer writes the value of a constant operand as a part of the instruction
that uses it. This avoids having to define the constant elsewhere in the program and make
a label for it. Such an operand is called a Literal because the value is literally in the
instruction. Consider the following example

Fig no: 2.8 Example for literals


It is convenient to write the value of a constant operand as a part of instruction. A literal
is identified with the prefix =, followed by a specification of the literal value.

17
Fig no: 2.9 Example for literal value
2.7.2 Literals vs. Immediate Operands
Literals
The assembler generates the specified value as a constant at some other memory location.

Immediate Operands

The operand value is assembled as part of the machine instruction. We can have
literals in SIC, but immediate operand is only valid in SIC/XE.

2.7.3 Literal Pools


Normally literals are placed into a pool at the end of the program. In some cases,
it is desirable to place literals into a pool at some other location in the object program
Assembler directive LTORG. When the assembler encounters a LTORG statement, it
generates a literal pool (containing all literal operands used since previous LTORG)
Reason: keep the literal operand close to the instruction otherwise PC-relative addressing
may not be allowed

2.7.4 Duplicate literals


The same literal used more than once in the program. Only one copy of the
specified value needs to be stored For example, =X’05’. Inorder to recognize the
duplicate literals compare the character strings defining them is easier to implement, but
has potential problem
e.g. =X’05’

Compare the generated data value


Better, but will increase the complexity of the assembler
e.g. =C’EOF’ and =X’454F46’

2.7.4.1 Problem of duplicate-literal recognition


The symbol ‘*’ denotes a literal refer to the current value of program counter
BUFEND EQU *

18
There may be some literals that have the same name, but different values
BASE *
LDB =* (#LENGTH)
The literal =* repeatedly used in the program has the same name, but different values.
The literal “=*” represents an “address” in the program, so the assembler must generate the
appropriate “Modification records”.

2.7.5 Literal table – LITTAB


The table content are:
 Literal name
 Operand value and length
 Address
LITTAB is often organized as a hash table, using the literal name or value as the key.

2.7.5.1 Implementation of Literals


Pass 1
Build LITTAB with literal name, operand value and length, leaving the address
unassigned. When LTORG or END statement is encountered, assign an address to each
literal not yet assigned an address. updated to reflect the number of bytes occupied by
each literal
Pass 2
Search the LITTAB for each literal operand encountered. Generate data values
using BYTE or WORD statements. Generate Modification record for literals that
represent an address in the program

2.7.6 SYMTAB & LITTAB

Fig no : 2.10 Example for SYMTAB and LITTAB


2.7.6.1 Symbol-Defining Statements
Most assemblers provide an assembler directive that allows the programmer to define
symbols and specify their values.

19
2.7.6.2 Assembler directive used is EQU.
Syntax: symbol EQU value. It is used to improve the program readability, avoid using
magic numbers, make it easier to find and change constant values.
Replace +LDT #4096 with
MAXLEN EQU 4096
+LDT #MAXLEN
Define mnemonic names for registers.
A EQU 0 RMO A,X
X EQU 1
Expression is allowed
MAXLEN EQU BUFEND-BUFFER
2.7.6.3 Assembler directive ORG
Allow the assembler to reset the PC to values
o Syntax: ORG value
When ORG is encountered, the assembler resets its LOCCTR to the specified value.
ORG will affect the values of all labels defined until the next ORG. If the previous value
of LOCCTR can be automatically remembered, we can return to the normal use of
LOCCTR by simply writing ORG

Example: using ORG

If ORG statements are used

We can fetch the VALUE field by LDA VALUE, X = 0, 11, 22, … for each entry

Forward-Reference Problem
The forward reference is not allowed for either EQU or ORG. All terms in the value field
must have been defined previously in the program. The reason is that all symbols must have
been defined during Pass 1 in a two-pass assembler.

Allowed:
ALPHA RESW 1
BETA EQU ALPHA

Not Allowed:
BETA EQU ALPHA
ALPHA RESW 1

20
2.8 EXPRESSIONS
The assemblers allow “the use of expressions as operand”. The assembler
evaluates the expressions and produces a single operand address or value. Expressions
consist of
Operator  +,-,*,/ (division is usually defined to produce an integer result)
Individual terms  Constants, User-defined symbols and Special terms, e.g., *, the
current value of LOCCTR
Examples
MAXLEN EQU BUFEND-BUFFER
STAB RESB (6+3+2)*MAXENTRIES

2.8.1 Relocation Problem in Expressions


The values of terms can be Absolute (independent of program location) constants or may
be Relative (to the beginning of the program) or Address labels * (value of LOCCTR).
Expressions can be Absolute - Only absolute terms.
MAXLEN EQU 1000
Relative terms in pairs with opposite signs for each pair.
MAXLEN EQU BUFEND-BUFFER
All the relative terms except one can be paired as described in “absolute”. The
remaining unpaired relative term must have a positive sign.
STAB EQU OPTAB + (BUFEND – BUFFER)

2.8.2 Restriction of Relative Expressions


Following are some of the restrictions in relative expressions i.e., There are no relative
terms may enter into a multiplication or division operation
3 * BUFFER
Expressions that do not meet the conditions of either “absolute” or “relative” should be
flagged as errors.
BUFEND + BUFFER
100 – BUFFER

2.8.3 Handling Relative Symbols in SYMTAB


To determine the type of an expression, we must keep track of the types of all symbols
defined in the program. We need a “flag” in the SYMTAB for indication

21
2.8.4 Program Blocks
It allows the generated machine instructions and data to appear in the object program in a
different order. Separating blocks for storing code, data, stack, and larger data block.
Program blocks versus. Control sections
Program blocks
Segments of code that are rearranged within a single object program unit.
Control sections
Segments of code that are translated into independent object program units.
Assembler rearranges these segments to gather together the pieces of each block and assign
address. Separate the program into blocks in a particular order. Large buffer area is moved to the
end of the object program. Program readability is better if data areas are placed in the source
program close to the statements that reference them.

2.8.4.1 Assembler directive: USE


The USE is the 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

Example

22
In the above program three blocks are used as specified below:
 default: executable instructions.
 CDATA: all data areas that are less in length.
 CBLKS: all data areas that consists of larger blocks of memory.

Rearrange Codes into Program Blocks - Pass 1


A separate location counter for each program block is specified. Save and
restore LOCCTR when switching between blocks. At the beginning of a block, LOCCTR
is set to 0. Assign each label an address relative to the start of the block. Store the block
name or number in the SYMTAB along with the assigned relative address of the label.
Indicate the block length as the latest value of LOCCTR for each block at the end of
Pass1. Assign to each block a starting address in the object program by concatenating the
program blocks in a particular order

23
Pass 2
Calculate the address for each symbol relative to the start of the object program by
adding.
o The location of the symbol relative to the start of its block
o The starting address of this block

2.8.5 Program Blocks Loaded in Memory

The Object Program are used in the above program


It is not necessary to physically rearrange the generated code in the object program. The
assembler just simply inserts the proper load address in each Text record. The loader will load
these codes into correct place

2.8.6 CONTROL SECTIONS AND PROGRAM LINKING


2.8.6.1 CONTROL SECTIONS
The control sections can be loaded and relocated independently of the other are
most often used for subroutines or other logical subdivisions of a program the
programmer can assemble, load, and manipulate each of these control sections separately
because of this, there should be some means for linking control sections together
assembler directive: CSECT and secname CSECT - separate location counter for each
control section

2.8.2 External Definition and Reference


Instructions in one control section may need to refer to instructions or data located in
another section
External definition
EXTDEF name [, name]
EXTDEF names symbols that are defined in this control section and may be used
by other sections
Ex: EXTDEF BUFFER, BUFEND, LENGTH
External reference
EXTREF name [,name]
EXTREF names symbols that are used in this control section and are defined
elsewhere
Ex: EXTREF RDREC, WRREC

24
To reference an external symbol, extended format instruction is needed.

25
2.8.3 External Reference Handling
Case 1
The line no:15 0003 CLOOP +JSUB RDREC 4B100000.
The operand RDREC is an external reference. The assembler has no idea where RDREC is it
inserts an address of zero. It can only use extended format to provide enough room (that is,
relative addressing for external reference is invalid). The assembler generates information for
each external reference that will allow the loader to perform the required linking.

Case 2
The line no:190 0028 MAXLEN WORD BUFEND-BUFFER
000000. There are two external references in the expression, BUFEND and BUFFER.
The assembler inserts a value of zero and passes information to the loader, add this data area the
address of BUFEND and finally subtracts from this data area the address of BUFFER

Case 3
On line 107, BUFEND and BUFFER are defined in the same control section and
the expression can be calculated immediately.
107 1000 MAXLEN EQU BUFEND-BUFFER

2.8.3.1 Records for Object Program


The assembler must include information in the object program that will cause the loader
to insert proper values where they are required.
Define record (EXTDEF)
Col. 1 D
Col. 2-7 Name of external symbol defined in this control section
Col. 8-13 Relative address within this control section (hexadeccimal)
Col.14-73 Repeat information in Col. 2-13 for other external symbols
Refer record (EXTREF)
Col. 1 R
Col. 2-7 Name of external symbol referred to in this control section
Col. 8-73 Name of other external reference symbols

26
Modification record
Col. 1 M
Col. 2-7 Starting address of the field to be modified (hexiadecimal)
Col. 8-9 Length of the field to be modified, in half-bytes (hexadeccimal)
Col.11-16 External symbol whose value is to be added to or subtracted from the
indicated field
Control section name is automatically an external symbol, i.e. it is available for use in
Modification records.
Object Program

Expressions in Multiple Control Sections


 Extended restriction
o Both terms in each pair of an expression must be within the same control section
o Legal: BUFEND-BUFFER
o Illegal: RDREC-COPY
 How to enforce this restriction
o When an expression involves external references, the assembler cannot determine
whether or not the expression is legal.
o The assembler evaluates all of the terms it can, combines these to form an initial
expression value, and generates Modification records.
o The loader checks the expression for errors and finishes the evaluation.

27
2.9 ASSEMBLER DESIGN
The assembler design deals with
o Two-pass assembler with overlay structure
o One-pass assemblers
o Multi-pass assemblers

2.9.1 ONE-PASS ASSEMBLER - Load-and-Go Assembler


The Load-and-go assembler generates their object code in memory for immediate
execution. No object program is written out, no loader is needed. It is useful in a system with
frequent program development and testing The efficiency of the assembly process is an
important consideration. Programs are re-assembled nearly every time they are run; efficiency of
the assembly process is an important consideration.

2.9.1.1 ONE-PASS ASSEMBLERS


The Scenario for one-pass assemblers are : Generate their object code in memory for
immediate execution – load-and-go assembler and External storage for the intermediate file
between two passes is slow or is inconvenient to use. The main problem - Forward references
i.e., Data items and Labels on instructions. The solution to this problem is that it requires that all
areas be defined before they are referenced. It is possible, although inconvenient, to do so for
data items. Forward jump to instruction items cannot be easily eliminated.
 Insert (label, address_to_be_modified) to SYMTAB
 Usually, address_to_be_modified is stored in a linked-list

Fig.no: 2.11 Sample program for a one-pass assembler

28
2.9.1.2 Forward Reference in One-pass Assembler
The assembler omits the operand address if the symbol has not yet been defined. It enters
this undefined symbol into SYMTAB and indicates that it is undefined. It adds the address of
this operand address to a list of forward references associated with the SYMTAB entry. When
the definition for the symbol is encountered, scans the reference list and inserts the address. At
the end of the program, reports the error if there are still SYMTAB entries indicated undefined
symbols. For Load-and-Go assembler - Search SYMTAB for the symbol named in the END
statement and jumps to this location to begin execution if there is no error.

2.9.2 TWO-PASS ASSEMBLER WITH OVERLAY STRUCTURE


Most assemblers divide the processing of the source program into two passes. The
internal tables and subroutines that are used only during Pass 1 are no longer needed after the
first pass is completed. The routines and tables for Pass 1 and Pass 2 are never required at the
same time. There are certain tables (SYMTAB) and certain processing subroutines (searching
SYMTAB) that are used by both passes. Since Pass 1 and Pass 2 segments are never needed at
the same time, they can occupy the same locations in memory during execution of the assembler.
Initially the Root and Pass 1 segments are loaded into memory. The assembler then makes the
first pass over the program being assembled.
At the end of the Pass1, the Pass 2 segment is loaded, replacing the Pass 1 segment. The
assembler then makes its second pass of the source program and terminates. The assembler needs
much less memory to run in this way than it would be if both Pass 1 and Pass 2 were loaded at
the same time. A program that is designed to execute in this way is called an Overlay program
because some of its segments overlay others during execution.

Fig.no:2.11 Structure of Two pass assembler

2.9.3 MULTI-PASS ASSEMBLERS


For a two pass assembler, forward references in symbol definition are not allowed:
ALPHA EQU BETA
BETA EQU DELTA
DELTA RESW 1
The symbol BETA cannot be assigned a value when it is encountered during Pass 1 because
DELTA has not yet been defined. Hence ALPHA cannot be evaluated during Pass 2. Symbol
definition must be completed in pass 1. Prohibiting forward references in symbol definition is
not a serious inconvenience. Forward references tend to create difficulty for a person reading
the program. The general solution for forward references is a multi-pass assembler that can
make as many passes as are needed to process the definitions of symbols. It is not necessary
for such an assembler to make more than 2 passes over the entire program. The portions of

29
the program that involve forward references in symbol definition are saved during Pass 1.
Additional passes through these stored definitions are made as the assembly progresses. This
process is followed by a normal Pass 2.

2.9.3.1 Implementation
For a forward reference in symbol definition, we store in the SYMTAB:
The symbol name
The defining expression
The number of undefined symbols in the defining expression
The undefined symbol (marked with a flag *) associated with a list of symbols depend on this
undefined symbol. When a symbol is defined, we can recursively evaluate the symbol
expressions depending on the newly defined symbol.

Fig.no : 2.12 Example of Multi-pass assembler

Consider the symbol table entries from Pass 1 processing of the statement.
HALFS2 EQU MAXLEN/2

Since MAXLEN has not yet been defined, no value for HALFS2 can be
computed. The defining expression for HALFS2 is stored in the symbol table in place of
its value. The entry &1 indicates that 1 symbol in the defining expression undefined.
SYMTAB simply contain a pointer to the defining expression. The symbol MAXLEN is
also entered in the symbol table, with the flag * identifying it as undefined. Associated
with this entry is a list of the symbols whose values depend on MAXLEN.

30
TWO MARKS

1. Define Assembler.
An assembler is a set of programs, which is used to translate the assembly language into
machine language, and also gives the necessary information to the loader.

2. Write the uses of assembler Directives and give an Example.


The Assembler Directives are used to give necessary information to the Assembler. The
Assembler Directives are,
START: Specifies name and starting address of the program.
RESW: Reserves word
RESB: Reserves byte
END : Indicates the end of the source program

3. What is Forward Reference?


Forward Reference means, the symbols in the program may be referred before that is
defined. For
eg.
B LDA B
BYTE 10
Here B value is referred before it is defined.

4. Write the Data Structure used in Assembler.


The Data structures used in Assembler are,
• SYMTAB – is used to store values assigned to labels.
• OPCODE TAB – is used to look up mnemonic operation codes and translate
them to their machine language equivalents.

5. How the Assembler gives Program Relocation Information to the Loader? (Relocatable
pgm)
The Assembler does not know the actual location where the program will be loaded. It
cannot make the necessary changes in the addresses used by the Program at load time. However
the assembler can identify the object program that needs modification. An object program that
contains the information necessary to perform this kind of modification is called Relocatable
Program. Thus the information would be given to the loader.

6. Write the various records used n Object Program?


• Head Record
• Text Record
• End Record
• Modification Record
• Refer Record
• Define Record

7. Write about Define Record and Refer Record.


Define Record: A Define Record gives information about external symbols that are
defined in the same control section. (These symbols can be used by other sections)
Refer Record:

31
A Refer Record gives information about external reference ie. That symbols are defined in
another sections.

8. Define Literals?
In Literals, the value of constants operand as a part of the instructions, itself. This avoids
having to define the constant elsewhere in the program. The Literals are identified with prefix
‘=’. Which is followed by the specification of the Literal value. For eg, LDA = C ‘EOF’

9. Write about Expressions?


There are 2 types of expressions.
• Absolute Expressions
• Relative Expressions
An Expression that contains only absolute terms (independent of program location) is
called Absolute Expressions. In Relative Expressions, the Operand values are Relative to the
Starting of the Program Location.

10. Define Program Block


Program Block refer to segment of code are handled by the assembler as one entity
resulting in a single block of object code. In this object code the generated machine instructions
and data appeared in the same order as they are written in the source program.

11. Define Control Sections?


Control Sections refer to segments that are translated into independent object program
units. Different control sections are used for subroutine or other logical subdivisions of a
program. Symbols defined in one control section, but that symbol must be declared as an
external symbol.

12. What is Load and Go Assembler?


The Load and Go Assembler is a one-pass assembler that generates the object code in
memory for immediate execution. No object program is written out and no loader is needed. This
is used in a system that oriented toward program development and testing.

13. Write the uses of Multi pass Assembler?


A symbol defined in assembler needs more passes to resolve or process the definition of
symbols.

14. What is LTORG?


LTORG is a constant operand that is written as part of the instruction that uses it (ie) the
value is stated “literally” in the instruction.

15. What is Near Jump?


In a Neat jump the Target is in the same code segment. A near jump is assembled using
the current code segment registers. The assembled machine instruction for a near jump occupies
2 or 3 bytes.

Eg. JMP Target

32
16. What is Far jump?
A far jump is a Jump to a target in a different code segment. A Far Jump is assembled
using a different segment register, which is specified in an instruction profix. The assembled
instruction for a Far Jump requires 5 bytes.
Eg. JMP
FARPTR
TARGET

17. Define the basic functions of assembler.


*translating mnemonic operation codes to their machine language equivalents.
*Assigning machine addresses to symbolic labels used by the programmer.

18. What are the three different records used in object program?
The header record, text record and the end record are the three different records used in
object program. The header record contains the program name, starting address and length of the
program. Text record contains the translated instructions and data of the program. End record
marks the end of the object program and specifies the address in the program where execution is
to begin.

19. Differentiate absolute expression and relative expression.


If the result of the expression is an absolute value (constant) then it is known as absolute
expression.
E.g. : BUFEND - BUFFER
If the result of the expression is relative to the beginning of the program then it is known as
relative expression, label on instructions and data areas and references to the location counter
values are relative terms.
E.g.: BUFEND + BUFFER

20. Write the steps required to translate the source program to object program.
*Convert mnemonic operation codes to their machine language equivalents.
*Convert symbolic operands to their equivalent machine addresses
*Build the machine instruction in the proper format.
*Convert the data constants specified in the source program into their internal machine
representation
*Write the object program and assembly listing.

*************************************************************

33
UNIT- III LOADERS AND LINKERS

Basic loader functions - Design of an Absolute Loader – A Simple Bootstrap Loader - Machine
dependent loader features - Relocation – Program Linking – Algorithm and Data Structures for
Linking Loader - Machine-independent loader features - Automatic Library Search – Loader
Options - Loader design options - Linkage Editors – Dynamic Linking – Bootstrap Loaders -
Implementation example - MSDOS linker.

Loader is a system program that performs the loading function. Many loaders also
support relocation and linking. Some systems have a linker (linkage editor) to perform the
linking operations and a separate loader to handle relocation and loading. One system loader or
linker can be used regardless of the original source programming language. Loading →Brings
the object program into memory for execution. Relocation → Modifies the object program so
that it can be loaded at an address different from the location originally specified. Linking →
Combines two or more separate object programs and supplies the information needed to allow
references between them.

3.1 BASIC LOADER FUNCTIONS


Fundamental functions of a loader:
o Bringing an object program into memory.
o Starting its execution.
3.2 DESIGN OF AN ABSOLUTE LOADER
In order to design for a simple absolute loader, all functions are accomplished in a single
pass as follows: The Header record of object programs is checked to verify that the correct
program has been presented for loading. As each Text record is read, the object code it contains
is moved to the indicated address in memory. When the End record is encountered, the loader
jumps to the specified address to begin execution of the loaded program.
An example object program is shown in Fig (a).

34
Fig (b) shows a representation of the program from Fig (a) after loading.

Algorithm for Absolute Loader

It is very important to realize that in Fig (a), each printed character represents one byte of
the object program record. In Fig (b), on the other hand, each printed character represents one
hexadecimal digit in memory (a half-byte). Therefore, to save space and execution time of
loaders, most machines store object programs in a binary form, with each byte of object code
stored as a single byte in the object program. In this type of representation a byte may contain
any binary value.

35
3.3 A SIMPLE BOOTSTRAP LOADER
When a computer is first turned on or restarted, a special type of absolute loader, called a
bootstrap loader, is executed. This bootstrap loads the first program to be run by the computer –
usually an operating system.

3.3.1 Working of a simple Bootstrap loader


The bootstrap begins at address 0 in the memory of the machine. It loads the operating
system at address 80. Each byte of object code to be loaded is represented on device F1 as two
hexadecimal digits just as it is in a Text record of a SIC object program. The object code from
device F1 is always loaded into consecutive bytes of memory, starting at address 80. The main
loop of the bootstrap keeps the address of the next memory location to be loaded in register X.
After all of the object code from device F1 has been loaded, the bootstrap jumps to address 80,
which begins the execution of the program that was loaded. Much of the work of the bootstrap
loader is performed by the subroutine GETC. GETC is used to read and convert a pair of
characters from device F1 representing 1 byte of object code to be loaded. For example, two
bytes = C “D8” ‘4438’H converting to one byte ‘D8’H. The resulting byte is stored at the
address currently in register X, using STCH instruction that refers to location 0 using indexed
addressing. The TIXR instruction is then used to add 1 to the value in X.

3.3.2 Source code for bootstrap loader

36
3.4 MACHINE-DEPENDENT LOADER FEATURES
The absolute loader has several potential disadvantages. One of the most obvious is the
need for the programmer to specify the actual address at which it will be loaded into memory.
On a simple computer with a small memory the actual address at which the program will be
loaded can be specified easily. On a larger and more advanced machine, we often like to run
several independent programs together, sharing memory between them. We do not know in
advance where a program will be loaded. Hence we write relocatable programs instead of
absolute ones. Writing absolute programs also makes it difficult to use subroutine libraries
efficiently. This could not be done effectively if all of the subroutines had pre-assigned absolute
addresses.
The need for program relocation is an indirect consequence of the change to larger and
more powerful computers. The way relocation is implemented in a loader is also dependent upon
machine characteristics. Loaders that allow for program relocation are called relocating loaders
or relative loaders.

Relocation
Two methods for specifying relocation as part of the object program:
The first method :
A Modification is used to describe each part of the object code that must be changed
when the program is relocated. Most of the instructions in this program use relative or
immediate addressing. The only portions of the assembled program that contain actual
addresses are the extended format instructions on lines 15, 35, and 65. Thus these are the
only items whose values are affected by relocation.

Fig(1) :Consider the program

37
Object program

38
Each Modification record specifies the starting address and length of the field whose
value is to be altered. It then describes the modification to be performed. In this example, all
modifications add the value of the symbol COPY, which represents the starting address of the
program. Fig(2) :Consider a Relocatable program for a Standard SIC machine

The Modification record is not well suited for use with all machine
architectures. Consider, for example, the program in Fig (2) .This is a relocatable program
written for standard version for SIC. The important difference between this example and the one
in Fig (1) is that the standard SIC machine does not use relative addressing. In this program the
addresses in all the instructions except RSUB must modified when the program is relocated. This
would require 31 Modification records, which results in an object program more than twice as
large as the one in Fig (1).

39
The second method :
There are no Modification records.
The Text records are the same as before except that there is a relocation bit
associated with each word of object code. Since all SIC instructions occupy one word,
this means that there is one relocation bit for each possible instruction.
Fig (3): Object program with relocation by bit mask

The relocation bits are gathered together into a bit mask following the length indicator in
each Text record. In Fig (3) this mask is represented (in character form) as three hexadecimal
digits. If the relocation bit corresponding to a word of object code is set to 1, the program’s
starting address is to be added to this word when the program is relocated. A bit value of 0
indicates that no modification is necessary. If a Text record contains fewer than 12 words of
object code, the bits corresponding to unused words are set to 0. For example, the bit mask FFC
(representing the bit string 111111111100) in the first Text record specifies that all 10 words of
object code are to be modified during relocation. Example: Note that the LDX instruction on line
210 (Fig (2)) begins a new Text record. If it were placed in the preceding Text record, it would
not be properly aligned to correspond to a relocation bit because of the 1-byte data value
generated from line 185.
3.5 PROGRAM LINKING
Consider the three (separately assembled) programs in the figure, each of which consists
of a single control section.
Program 1 (PROGA):

40
Program 2 (PROGB):

Program 3 (PROGC):

Consider first the reference marked REF1. For the first program (PROGA), REF1 is simply a
reference to a label within the program. It is assembled in the usual way as a PC relative
instruction. No modification for relocation or linking is necessary. In PROGB, the same operand
refers to an external symbol. The assembler uses an extended-format instruction with address

41
field set to 00000. The object program for PROGB contains a Modification record instructing
the loader to add the value of the symbol LISTA to this address field when the program is linked.
For PROGC, REF1 is handled in exactly the same way.
Corresponding object programs
PROGA

PROGB:

42
PROGC

The reference marked REF2 is processed in a similar manner. REF3 is an immediate


operand whose value is to be the difference between ENDA and LISTA (that is, the length of the
list in bytes). In PROGA, the assembler has all of the information necessary to compute this
value. During the assembly of PROGB (and PROGC), the values of the labels are unknown.
In these programs, the expression must be assembled as an external reference (with two
Modification records) even though the final result will be an absolute value independent of the
locations at which the programs are loaded.
Consider REF4. The assembler for PROGA can evaluate all of the expression in REF4
except for the value of LISTC. This results in an initial value of ‘000014’H and one Modification
record. The same expression in PROGB contains no terms that can be evaluated by the
assembler. The object code therefore contains an initial value of 000000 and three Modification
records. For PROGC, the assembler can supply the value of LISTC relative to the beginning of
the program (but not the actual address, which is not known until the program is loaded). The
initial value of this data word contains the relative address of LISTC (‘000030’H). Modification
records instruct the loader to add the beginning address of the program (i.e., the value of
PROGC), to add the value of ENDA, and to subtract the value of LISTA. PROGA has been
loaded starting at address 4000, with PROGB and PROGC immediately following.
For example, the value for reference REF4 in PROGA is located at address 4054 (the beginning
address of PROGA plus 0054).

Fig (4): The three programs as they might appear in memory after loading and linking.

43
Fig (5): Relocation and linking operations performed on REF4 in PROGA

44
The initial value (from the Text record) is 000014. To this is added the address assigned to
LISTC, which 4112 (the beginning address of PROGC plus 30). Algorithm and Data Structures
for a Linking Loader  The algorithm for a linking loader is considerably more complicated
than the absolute loader algorithm. A linking loader usually makes two passes over its input, just
as an assembler does. In terms of general function, the two passes of a linking loader are quite
similar to the two passes of an assembler: Pass 1 assigns addresses to all external symbols. Pass 2
performs the actual loading, relocation, and linking. The main data structure needed for our
linking loader is an external symbol table ESTAB. This table, which is analogous to SYMTAB
in our assembler algorithm, is used to store the name and address of each external symbol in the
set of control sections being loaded. A hashed organization is typically used for this table.Two
other important variables are PROGADDR (program load address) and CSADDR (control
section address).
o PROGADDR is the beginning address in memory where the linked program is to
be loaded. Its value is supplied to the loader by the OS.
o CSADDR contains the starting address assigned to the control section currently
being scanned by the loader. This value is added to all relative addresses within
the control section to convert them to actual addresses.
PASS 1
During Pass 1, the loader is concerned only with Header and Define record types in the
control sections.
Algorithm for Pass 1 of a Linking loader

The beginning load address for the linked program (PROGADDR) is obtained from the OS. This
becomes the starting address (CSADDR) for the first control section in the input sequence.
The control section name from Header record is entered into ESTAB, with value given by
CSADDR. All external symbols appearing in the Define record for the control sectionare also
entered into ESTAB. Their addresses are obtained by adding the value specified in the Define
record to CSADDR.

45
When the End record is read, the control section length CSLTH (which was saved from
the End record) is added to CSADDR. This calculation gives the starting address for the next
control section in sequence. At the end of Pass 1, ESTAB contains all external symbols defined
in the set of control sections together with the address assigned to each. Many loaders include as
an option the ability to print a load map that shows these symbols and their addresses.
PASS 2
Pass 2 performs the actual loading, relocation, and linking of the program.
Algorithm for Pass 2 of a Linking loader
As each Text record is read, the object code is moved to the specified address (plus
the current value of CSADDR). When a Modification record is encountered, the symbol
whose value is to be used for modification is looked up in ESTAB. This value is then
added to or subtracted from the indicated location in memory. The last step performed by
the loader is usually the transferring of control to the loaded program to begin execution.
The End record for each control section may contain the address of the first instruction in
that control section to be executed. Our loader takes this as the transfer point to begin
execution. If more than one control section specifies a transfer address, the loader
arbitrarily uses the last one encountered. If no control section contains a transfer address,
the loader uses the beginning of the linked program (i.e., PROGADDR) as the transfer
point. Normally, a transfer address would be placed in the End record for a main
program, but not for a subroutine.

46
This algorithm can be made more efficient. Assign a reference number, which is
used (instead of the symbol name) in Modification records, to each external symbol
referred to in a control section. Suppose we always assign the reference number 01 to the
control section name.

3.6 MACHINE-INDEPENDENT LOADER FEATURES


Loading and linking are often thought of as OS service functions. Therefore, most loaders
include fewer different features than are found in a typical assembler. They include the use of an
automatic library search process for handling external reference and some common options that
can be selected at the time of loading and linking.

3.6.1 Automatic Library Search


Many linking loaders can automatically incorporate routines from a subprogram library
into the program being loaded. Linking loaders that support automatic library search must keep
track of external symbols that are referred to, but not defined, in the primary input to the loader.
At the end of Pass 1, the symbols in ESTAB that remain undefined represent unresolved external
references.
The loader searches the library or libraries specified for routines that contain the
definitions of these symbols, and processes the subroutines found by this search exactly as if they
had been part of the primary input stream. The subroutines fetched from a library in this way
may themselves contain external references. It is therefore necessary to repeat the library search
process until all references are resolved. If unresolved external references remain after the library
search is completed, these must be treated as errors.

3.6.2 Loader Options


Many loaders allow the user to specify options that modify the standard processing
Typical loader option 1: Allows the selection of alternative sources of input. Ex : INCLUDE
program-name (library-name) might direct the loader to read the designated object program from
a library and treat it as if it were part of the primary loader input. Loader option 2: Allows the
user to delete external symbols or entire control sections. Ex : DELETE csect-name might
instruct the loader to delete the named control section(s) from the set of programs being loaded.
CHANGE name1, name2 might cause the external symbol name1 to be changed to name2
wherever it appears in the object programs. Loader option 3: Involves the automatic inclusion of
library routines to satisfy external references. Ex. : LIBRARY MYLIB
Such user-specified libraries are normally searched before the standard system libraries.
This allows the user to use special versions of the standard routines. NOCALL STDDEV,
PLOT, CORREL. To instruct the loader that these external references are to remain unresolved.
This avoids the overhead of loading and linking the unneeded routines, and saves the memory
space that would otherwise be required.

3.7 LOADER DESIGN OPTIONS


Linking loaders perform all linking and relocation at load time. There are two
alternatives:  Linkage editors, which perform linking prior to load time. Dynamic linking, in
which the linking function is performed at execution time. Precondition: The source program is
first assembled or compiled, producing an object program. A linking loader performs all linking
and relocation operations, including automatic library search if specified, and loads the linked
program directly into memory for execution. A linkage editor produces a linked version of the
program (load module or executable image), which is written to a file or library for later
execution.

47
3.7.1 Linkage Editors
The linkage editor performs relocation of all control sections relative to the start of the
linked program. Thus, all items that need to be modified at load time have values that are relative
to the start of the linked program. This means that the loading can be accomplished in one pass
with no external symbol table required. If a program is to be executed many times without being
reassembled, the use of a linkage editor substantially reduces the overhead required. Linkage
editors can perform many useful functions besides simply preparing an object program for
execution. Ex., a typical sequence of linkage editor commands used:
INCLUDE PLANNER (PROGLIB)
DELETE PROJECT {delete from existing PLANNER}
INCLUDE PROJECT (NEWLIB) {include new version}
REPLACE PLANNER (PROGLIB)
Linkage editors can also be used to build packages of subroutines or other control sections that
are generally used together. This can be useful when dealing with subroutine libraries that
support high-level programming languages. Linkage editors often include a variety of other
options and commands like those discussed for linking loaders. Compared to linking loaders,
linkage editors in general tend to offer more flexibility and control.

Fig (7): Processing of an object program using (a) Linking loader and (b) Linkage editor

3.8 DYNAMIC LINKING


Linkage editors perform linking operations before the program is loaded for execution.
Linking loaders perform these same operations at load time. Dynamic linking, dynamic loading,
or load on call postpones the linking function until execution time: a subroutine is loaded and
linked to the rest of the program when it is first called. Dynamic linking is often used to allow
several executing programs to share one copy of a subroutine or library, ex. run-time support
routines for a high-level language like C. With a program that allows its user to interactively call
any of the subroutines of a large mathematical and statistical library, all of the library subroutines
could potentially be needed, but only a few will actually be used in any one execution. Dynamic

48
linking can avoid the necessity of loading the entire library for each execution except those
necessary subroutines.

Fig (a): Instead of executing a JSUB instruction referring to an external symbol, the program
makes a load-and-call service request to OS. The parameter of this request is the symbolic name
of the routine to be called.
Fig (b): OS examines its internal tables to determine whether or not the routine is already loaded.
If necessary, the routine is loaded from the specified user or system libraries.

49
Fig (c): Control is then passed from OS to the routine being called
Fig (d): When the called subroutine completes it processing, it returns to its caller (i.e., OS). OS
then returns control to the program that issued the request.
Fig (e): If a subroutine is still in memory, a second call to it may not require another load
operation. Control may simply be passed from the dynamic loader to the called routine.

3.9 BOOTSTRAP LOADERS


With the machine empty and idle there is no need for program relocation. We can specify
the absolute address for whatever program is first loaded and this will be the OS, which occupies
a predefined location in memory. We need some means of accomplishing the functions of an
absolute loader. To have the operator enter into memory the object code for an absolute loader,
using switches on the computer console. To have the absolute loader program permanently
resident in a ROM. To have a built –in hardware function that reads a fixed –length record from
some device into memory at a fixed location.
When some hardware signal occurs, the machine begins to execute this ROM program.
On some computers, the program is executed directly in the ROM: on others, the program is
copied from ROM to main memory and executed there. The particular device to be used can
often be selected via console switches. After the read operation is complete, control is
automatically transferred to the address in memory where the record was stored, which contains
machine where the record was stored, which contains machine instructions that load the absolute
program that follow. If the loading process requires more instructions that can be read in a single
record, this first record causes the reading of others, and these in turn can cause the reading of
still more records – boots trap. The first record is generally referred to as bootstrap loader:
Such a loader is added to the beginning of all object programs that are to be loaded into an empty
and idle system. This includes the OS itself and all stand-alone programs that are to be run
without an OS.

TWO MARKS
1. What are the basic functions of loaders?
Loading -brings the object program into memory for execution.
Relocation -modifies the object program so that it can be loaded at an address different from
the location originally specified.
Linking -combines two or more separate object programs and also supplies the information
needed to reference them.

2. List the disadvantages of absolute loader.


- the need for programmer to specify the actual address.
- difficult to use subroutine libraries.

3. What is meant by bootstrap loader?


- When a computer is first tuned 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

4. What are relative (re locative) loaders?


Loaders that allow for program relocation are called relocating loaders.

5. What is the use of modification record?

50
- Modification record is used for program relocation. Each modification record specifies the
starting address and the length of the field whose value is to be altered and also describes the
modification to be performed

6. What are the 2 different techniques used for relocation?


Modification record method and relocation bit method.

7.What is Relocation bit method?


If the relocation bit corresponding to a word of object code is set to 1, the program's starting
address is to be added to this word when the program is relocated. Bit value 0 indicates no
modification is required.

8.Define absolute loader.


The loader, which is used only for loading, is known as absolute loader.
E.g. Bootstrap loader

9.What is the function of pass 2 of a loader?


Pass 2 of loader extracts the translated instructions and data from the object modules and builds
an image of the executable program. It performs the actual loading, relocation and linking of the
program.

10. What is the need of ESTAB?


It is used to store the name and address of the each external symbol. It also indicates in which
control section the symbol is defined.

11. What is the use of the variable PROGADDR?


It gives the beginning address in memory where the linked program is to be loaded. The starting
address is obtained from the operating system.

12. Write the two passes of a linking loader.


Pass1: assigns address to all external symbols.
Pass2: it performs actual loading, relocation and linking.

14. What is the function of MS-DOS LINK?


MS-DOS LINK is a linkage editor that combines one or more object modules to produce a
complete executable program. This executable program has the file extension. EXE.LINK can
also combine the translated program with other modules from object code libraries.

15. Define automatic library search.


In many linking loaders the subroutines called by the program being loaded are automatically
fetched from the library, linked with the main program and loaded. This feature is referred to as
automatic library search.

16. List the loader options INCLUDE &DELETE.


- The general format of INCLUDE is INCLUDE program name (library name)This command
direct the loader to read the designated object program from a library and treat it as the primary
loader input.
- The general format of DELETE command is DELETE Csect-name it instructs the loader to
delete the named control sections from the sets of programs loaded.

51
17. Give the functions of the linking loader.
The linking loader performs the process of linking and relocation. It includes the operation of
automatic library search and the linked programs are directly loaded into the memory. The
relocation and linking is performed each time the program is loaded It produces a linked version
of a program and which is written in a file for later execution Here the loading can be
accomplished in a single o passes are required.

18. Define dynamic linking.


If the subroutine is loaded and linked to the program during its first call (run time), then it is
called as dynamic loading or dynamic linking.

19. What is the use of linkage editor?


i. Simply preparing an object program for execution.

ii. Linkage editor can be used to replace old version of subroutine by new subroutine without
affecting the original version of all the other subroutine.

iii. Linkage editor can also be used to build package of subroutines or other control sections that
are generally used together. This can be useful when dealing with subroutine libraries that
support high-level programming language.

20. Write the advantage of dynamic linking.


- The dynamic linking allows several executing programs to share one copy of subroutine or
library.
- It has the ability to load the routine only when they are needed.
- The dynamic linking avoids the loading of entire library for each execution.
- In an object oriented system, dynamic linking is often used for reference of software object.

52
UNIT-IV

MACRO PROCESSORS

Basic macro processor functions - Macro Definition and Expansion – Macro Processor
Algorithm and data structures - Machine-independent macro processor features - Concatenation
of Macro Parameters – Generation of Unique Labels – Conditional Macro Expansion –
Keyword Macro Parameters-Macro within Macro-Implementation example - MASM Macro
Processor – ANSI C Macro language.

4.1 MACRO INSTRUCTIONS


A macro instruction (macro) is simply a notational convenience for the
programmer to write a shorthand version of a program. It represents a commonly used group
of statements in the source program. It is replaced by the macro processor with the
corresponding group of source language statements. This operation is called “expanding the
macro” For example: Suppose it is necessary to save the contents of all registers before
calling a subroutine. This requires a sequence of instructions. We can define and use a macro,
SAVEREGS, to represent this sequence of instructions.

4.1.1 Macro Processor


A macro processor is a function which is essential to involve the substitution of
one group of characters or lines for another. Normally, it performs no analysis of the text it
handles. It doesn’t concern the meaning of the involved statements during macro expansion.
Therefore, the design of a macro processor generally is machine independent.
Macro processors are used in assembly language, high-level programming languages, e.g., C or
C++, OS command languages and general purpose

4.1.1.1 Format of macro definition


A macro can be defined as follows
MACRO - MACRO pseudo-op shows start of macro definition.
Name [List of Parameters] - Macro name with a list of formal parameters.
- Sequence of assembly language instructions.
MEND - MEND (MACRO-END) Pseudo shows the end of macro definition.
Example:
MACRO
SUM X,Y
LDA X
MOV BX,X
LDA Y
ADD BX
MEND

4.2 BASIC MACROPROCESSOR FUNCTIONS


The fundamental functions common to all macro processors are:
1. Macro Definition
2. Macro Invocation

53
3. Macro Expansion

4.2.1 Macro Definition and Expansion


There are two new assembler directives are used in macro definition:
MACRO: identify the beginning of a macro definition
MEND: identify the end of a macro definition
The prototype for the macro is that each parameter begins with ‘&’ label, op
operands name MACRO parameters : body : MEND as shown below:

54
4.2.2 Macro Expansion

Each macro invocation statement will be expanded into the statements that form the
body of the macro. Arguments from the macro invocation are substituted for the parameters
in the macro prototype. The arguments and parameters are associated with one another
according to their positions. The first argument in the macro invocation corresponds to the
first parameter in the macro prototype, etc. Comment lines within the macro body have been
deleted, but comments on individual statements have been retained. Macro invocation
statement itself has been included as a comment line.

Fig 4.1: Example of a macro expansion

In expanding the macro invocation on line 190, the argument F1 is substituted for
the parameter and INDEV wherever it occurs in the body of the macro. Similarly BUFFER
is substituted for BUFADR and LENGTH is substituted for RECLTH. Lines 190a through
190m show the complete expansion of the macro invocation on line 190. The label on the
macro invocation statement CLOOP has been retained as a label on the first statement
generated in the macro expansion. This allows the programmer to use a macro instruction
in exactly the same way as an assembler language mnemonic. After macro processing the
expanded file can be used as input to assembler. The macro invocation statement will be
treated as comments and the statements generated from the macro expansions will be
assembled exactly as though they had been written directly by the programmer.
There are 3 main data structures involved in our macro processor.
55
4.2.2.1 Definition table (DEFTAB)
The macro definition themselves are stored in definition table (DEFTAB),
which contains the macro prototype and statements that make up the macro body.
Comment lines from macro definition are not entered into DEFTAB because they
will not be a part of macro expansion.

4.2.2.2 Name table (NAMTAB)


References to macro instruction parameters are converted to a positional
entered into NAMTAB, which serves the index to DEFTAB. For each macro
instruction defined, NAMTAB contains pointers to beginning and end of definition in
DEFTAB.

4.2.2.3 Argument table (ARGTAB)


The third Data Structure in an argument table (ARGTAB), which is used
during expansion of macro invocations. When macro invocation statements are
recognized, the arguments are stored in ARGTAB according to their position in
argument list.

4.3 MACHINE INDEPENDENT MACRO PROCESSOR FEATURES

Machine independent macro processor features are extended features that are not directly
related to architecture of computer for which the macro processor is written.

4.3.1 Concatenation of Macro Parameter

Most Macro Processor allows parameters to be concatenated with other character


strings. A program contains a set of series of variables:
XA1, XA2, XA3,…
XB1, XB2, XB3,…
If similar processing is to be performed on each series of variables, the programmer might want
to incorporate this processing into a macro instruction. The parameter to such a macro
instruction could specify the series of variables to be operated on (A, B, C …). The macro
processor constructs the symbols by concatenating X, (A, B, …), and (1,2,3,…) in the macro
expansion.
Suppose such parameter is named &ID, the macro body may contain a statement:
LDA X&ID1, in which &ID is concatenated after the string “X” and before the string “1”.
0 LDA XA1 (&ID=A)
0 LDA XB1 (&ID=B)
Ambiguity problem: E.g., X&ID1 may mean “X” + &ID + “1” “X” + ID1. This problem
occurs because the end of the parameter is not marked.

Solution to this ambiguity problem: Use a special concatenation operator “-»” to specify the
end of the parameter LDA X&ID -»1 So that the end of parameter &ID is clearly identified.

56
4.3.1.1 Macro definition

4.3.1.2 Macro invocation statement:

4.3.2 Conditional Macro Expansion

The arguments in macro invocation can be used to substitute the parameters in the
macro body without changing the sequence of statements expanded and to modify the
sequence of statements for conditional macro expansion (or conditional assembly when
related to assembler). This capability adds greatly to the power and flexibility of a macro
language. Macro-time variable (SET symbol) can be used to store working values during the
macro expansion, store the evaluation result of Boolean expression and to control the macro-
time conditional structures with the following rules such that the program begins with “&” and
that is not a macro instruction parameter, it should be initialized to a value of 0 and should be
set by a macro processor directive, SET. Following are the Macro-time conditional structure :
 IF-ELSE-ENDIF
 WHILE-ENDW

4.3.2.1 Implementation of Conditional Macro Expansion (IF-ELSE-ENDIF Structure)

A symbol table is maintained by the macroprocessor. This table


contains the values of all macro-time variables used. Entries in this table are made or
modified when SET statements are processed. This table is used to look up the current
57
value of a macro-time variable whenever it is required. The testing of the condition and
looping are done while the macro is being expanded. When an IF statement is encountered
during the expansion of a macro, the specified Boolean expression is evaluated.

If value is
TRUE
The macro processor continues to process lines from DEFTAB until
it encounters the next ELSE or ENDIF statement. If ELSE is encountered,
then skips to ENDIF
FALSE
The macro processor skips ahead in DEFTAB until it finds the next ELSE
or ENDLF statement.

4.3.2.2 Implementation of Conditional Macro Expansion (WHILE-ENDW Structure)


When an WHILE statement is encountered during the expansion of a macro, the
specified Boolean expression is evaluated. If value is
TRUE
The macro processor continues to process lines from DEFTAB until it
encounters the next ENDW statement. When ENDW is encountered, the
macro processor returns to the preceding, WHILE, re-evaluates the Boolean
expression, and takes action again.
FALSE
The macro processor skips ahead in DEFTAB until it finds the next
ENDW statement and then resumes normal macro expansion.

4.4 ONE-PASS MACRO PROCESSOR


A one-pass macro processor that alternate between macro definition and macro
expansion in a recursive way is able to handle recursive macro definition. Because of the
one-pass structure, the definition of a macro must appear in the source program before any
statements that invoke that macro.

4.4.1 Handling Recursive Macro Definition


In DEFINE procedure - When a macro definition is being entered into DEFTAB,
the normal approach is to continue until an MEND directive is reached. This would not work
for recursive macro definition because the first MEND encountered in the inner macro will
terminate the whole macro definition process. To solve this problem, a counter LEVEL is
used to keep track of the level of macro definitions.
■ Increase LEVEL by 1 each time a MACRO directive is read.
■ Decrease LEVEL by 1 each time a MEND directive is read.
■ A MEND can terminate the whole macro definition process only when
LEVEL reaches 0.
58
This process is very much like matching left and right parentheses when scanning an arithmetic
expression.

4.5 TWO-PASS MACRO PROCESSOR


The two-pass macro processor has two types:
 Pass 1: Process macro definition
 Pass 2: Expand all macro invocation statements
Problem  This kind of macro processor cannot allow recursive macro definition, that is,
the body of a macro contains definitions of other macros.

4.5.1 Example of Recursive Macro Definition

MACROS (for SIC)


 Contains the definitions of RDBUFF and WRBUFF written in SIC
instructions.
MACROX (for SIC/XE)
 Contains the definitions of RDBUFF and WRBUFF written in SIC/XE
instructions.
A program that is to be run on SIC system could invoke MACROS whereas a program to
be run on SIC/XE can invoke MACROX. Defining MACROS or MACROX does not define
RDBUFF and WRBUFF. These definitions are processed only when an invocation of MACROS or
MACROX is expanded.

59
Fig 4.2 Example

4.6 General-Purpose Macro Processors


The main goal of Macro processors is that it does not dependent on any
particular programming language, but can be used with a variety of different languages.
The advantages of general purpose macro processor are the programmers do not need to
learn many macro languages. Although its development costs are somewhat greater than
those for a language- specific macro processor, this expense does not need to be repeated
for each language, thus save substantial overall cost.

Some of its disadvantages are that large number of details must be dealt with in a real
programming language. Situations in which normal macro parameter substitution should not
occur,e.g., comments. Facilities for grouping together terms, expressions, or statements
Tokens, e.g., identifiers, constants, operators, keywords and syntax.

4.6.1 Macro Processing within Language Translators


The Macro processors can be:
Preprocessors

60
The processor processes macro definitions. It expands macro
invocations and produces an expanded version of the source
program, which is then used as input to an assembler or compiler.

Line-by-line macro processor


It is been used as a sort of input routine for the assembler or
compiler. Read source program and processes macro definitions
and expand macro invocations.
Integrated macro processor
An integrated macro processor can potentially make use of any
information about the source program that is extracted by the language
translator. As an example in FORTRAN
DO 100 I = 1,20 – a DO statement:
DO: keyword
100: statement number
I: variable name
DO 100 I = 1 – An assignment statement
DO100I: variable (blanks are not significant in FORTRAN)
An integrated macro processor can support macro instructions that depend
upon the context in which they occur.
4.6.1.1 Drawbacks of Line-by-line or Integrated Macro Processor

They must be specially designed and written to work with a particular


implementation of an assembler or compiler. The cost of macro processor development is
added to the costs of the language translator, which results in a more expensive software. The
assembler or compiler will be considerably larger and more complex.
TWO MARKS
1. Define macro.
A macro represents a group of statements in a source language, for performing some
function macro can be defined
Macro name macro parameters
This pattern is called macro prototype.
2. What is macro Expansion?
A macro would be called within a main program, using macro invocation statement or
macro call. Then the macro processor replaces this macro with the corresponding group of source
language statements. This is called macro expansion.
3. How can you define a macro?
A macro can be defined using macro prototype and its statements.
For eg macro name macro parameter
.............
Macro statements macro body
.........
61
mend
Here macro and mend are directly used to identify the beginning and end of the macro.
4. What are all the Data structures used in macro?
• DEF TAB
• NAM TAB
• ARG TAB
DEFTAB: contains the macro prototype and the statements that make the macro body.
NAMTAB: contains the macro name and it serves as a index to DEFTAB.
ARGTAB: This is used to store the arguments according to their position.

5. Write about concatenation of macro parameter?


Most macro processor allows parameter to be concatenated with other character string.
For Eg. The macro parameter named &ID means, the body of the macro definition might be
LDA X&ID1. Here X and 1are strings. A is an arguments. This ‘A’ would be concatenated like
LDA XA1 during expansion.

6. What is the need for generating unique labels?


The body of the macro contains no labels. If label present within a macro, and that macro
called 2 times means this would result a duplicate label definition when a program is assembled.
So, many macroprocessor avoid these problems by allowing the creation of special types of
labels within macro instruction.

7. Write about macro time variable? (set symbol)


A variable which presents only within a macro is called macro time variable. Which is
used to store working values during the macro expansion. Any symbol that begins with the
character ‘&’ and that is not a macro instruction parameter is assumed to be a macro time
variable. Eg. &EOR

8. Write different types of parameters.


Positional parameter
Keyword parameter

9. What is positional parameter?


The parameter from macro prototype and arguments from the macro call are associated
with each other according to their positions. This is called positional parameter. In positional
parameter the programmer must be careful to specify the arguments in the proper order.
Eg. GENER , , , DIR , , , 3 , ,

10. Write about keyword parameter?


In the macro prototype, each parameter name is followed by an equal sign which
identifies a keyword parameter. After the equal sign , a default value is specified for some of the
parameters. The parameter is assumed to have this default value if its name does not appear in
the macro invocation statement. For Eg. GENER TYPE = DIRECT, CHAN = 3
11. Write about general purpose macro processor?
General purpose macro processor are not dependent on any particular programming
language but can be used with a variety of different language .

12. Write the advantage and disadvantages of general purpose macro processor?
Advantage:
1) The programmer does not need to learn about a different macro facility for
62
each complier or assembly language.
2) Cost is high when compared to a special purpose macro processor, but this
expense does not need to be repeated for each language.
Disadvantage:
1) Difference between the programming languages should be identified for Eg.
Comment statements.
2) The syntax used for macro definitions and macro invocations are differed I
each language.

13. Write about Integrated macro processor?


It is possible to have closer cooperation between the macro processor and the assembler
or compiler is called integrated macro processor. Here the information about the source program
is extracted by the language translator.

14. Write the Disadvantages of macro processor within a language translator?


1) That must be specially designed and written to work with a particular implementation.
2) The cost is high
3) Integrated macro processor consumes more time.

15. Explain the term conditional assembly?


Conditional assembly means writing conditional statements within a macro definition
which is called Conditional macro expansion. These statements are processed and not appeared
during the macro expansion.

16. Write about DEFTAB?


DEFTAB (Definition Table) is the main data structures involve in macro processor. It
contains the macro prototype and the statements that make up the macro body with a few
modifications.

17. Write about NAMTAB?


NAMTAB is the major data structures of macro processor, which contains macro name
and it serves as an index to DEFTAB

18. Write about NAMTAB?


The ARGTAB is used during the expansion of macro invocation. When macro invocation
statement is recognized the argument are stored in ARGTAB according to their position in the
argument list.

19. Write the advantages of line-by-line macro processor?


1) It avoids making an extra pass over the source program.
2) Some of the data structures required by the macro processor and language translator
can be combined.

20. Write notes on MASM Macro processor?


The macro processor of MASM is integrated with pass1 of the assembler. It supports all
of the main macro processor functions, including the definition and invocation of macro
instructions within macros.
The comment line which begins with ;; is a macro comment. It serves only as
documentation for the macro definition, it is ignored when the macro is expanded. The comment
line begins with ; is an ordinary assembler language comment.
63
UNIT- V

OPERATING SYSTEM AND SYSTEM SOFTWARE TOOLS

Basic Operating System Functions-Machine Dependent Operating System Features: Interrupt


Processing-Process Scheduling-I/O Supervision- Machine Independent Operating System
Features: File Processing, Operating System Design Options: Multiprocessor Operating
Systems-Distributed Operating Systems-Object Oriented Operating Systems. Text editors -
Editor Structure. - Interactive debugging systems

5.1 BASIC OPERATING SYSTEM FUNCTIONS


An operating system (OS) is software that manages computer hardware and software
resources and provides common services for computer programs. The operating system is an
essential component of the system software in a computer system. Application programs usually
require an operating system to function.
Time-sharing operating systems schedule tasks for efficient use of the system and may
also include accounting software for cost allocation of processor time, mass storage, printing,
and other resources.
For hardware functions such as input and output and memory allocation, the operating
system acts as an intermediary between programs and the computer hardware, although the
application code is usually executed directly by the hardware and will frequently make a system
call to an OS function or be interrupted by it. Operating systems can be found on almost any
device that contains a computer—from cellular phones and video game consoles to
supercomputers and web servers.

5.2 OPERATING SYSTEM FEAUTURES

5.2.1 Data and User security


Each user has to be authenticated with an username and password (network and
multi-user operating system).
Their data and files will be kept private from other users, unless they choose to
make some shareable with others. The operating system will only allow administrators
('super users') to change parts of the operating system and install applications.

5.2.2 Providing system services such as print spooling


Printing out is a time consuming process, so it makes sense to allow users to
hand-off a print job to the operating system so they can get on with other things. This is
called 'print spooling' and is common on multi-user and networked operating systems.

5.2.3 Managing input / output


Data and applications are stored on secondary storage devices such as hard disks,
optical drives, magnetic tape when not in use. The operating system has a file
management system that allows the user to organize their files, to move, delete and copy
files as they wish.
64
Specialized input devices such as graphics tablets and scanners are also handled
by the operating system.

5.2.4 Handling Network communication


Data packets traveling to and from the connected computers on the network are
handled by the operating system. When an user drags a file from their hard disk to a
shared networked drive, they do not care how it happens - the operating system takes care
of all the details.

5.2.1 MACHINE DEPENDENT OPERATING SYSTEM FEATURES


Machine-dependent is a term for application software that runs only on a particular type
of computer. Conversely, applications that run on a variety of different types of computers are
called machine-independent, or cross-platform.
Before deploying machine-dependent applications on non-native computer architectures
or operating systems, such an application usually undergoes porting. This process involves
writing, or re-writing, the application's computer code to suit the target architecture or operating
system.

5.2.2 MACHINE INDEPENDENT OPERATING SYSTEM FEATURES


The loading and linking are often thought of as operating system service functions.
Following are the Machine independent loader features:
 Automatic Library Search......
 Loader Options
This feature allows programmers to use standard subroutines without explicitly including
them in the program to be loaded. The routines are automatically retrieved from a library as they
are needed during linking.

5.2.2.1 FILE PROCESSING, OPERATING SYSTEM DESIGN OPTIONS:


In computing, a file system (or filesystem) is used to control how data is stored and
retrieved. Without a file system, information placed in a storage area would be one large body of
data with no way to tell where one piece of information stops and the next begins. By separating
the data into individual pieces, and giving each piece a name, the information is easily separated
and identified. Taking its name from the way paper-based information systems are named, each
group of data is called a "file". The structure and logic rules used to manage the groups of
information and their name is called a "file system".
There are many different kinds of file systems. Each one has different structure and logic,
properties of speed, flexibility, security, size and more. Some file systems have been designed to
be used for specific applications. For example, the ISO 9660 file system is designed specifically
for optical discs.
File systems can be used on many different kinds of storage devices. Each storage device
uses a different kind of media. The most common storage device in use today is a hard drive
whose media is a disc that has been coated with a magnetic film. The film has ones and zeros
'written' on it sending electrical pulses to a magnetic "read-write" head. Other media that are used
are magnetic tape, optical disc, and flash memory. In some cases, the computer's main memory
(RAM) is used to create a temporary file system for short term use.
Some file systems are used on local data storage devices;[1] others provide file access via
a network protocol (for example, NFS,[2] SMB, or 9P clients). Some file systems are "virtual",
65
in that the "files" supplied are computed on request (e.g. procfs) or are merely a mapping into a
different file system used as a backing store. The file system manages access to both the content
of files and the metadata about those files. It is responsible for arranging storage space;
reliability, efficiency, and tuning with regard to the physical storage medium are important
design consideration

5.3 DISTRIBUTED OPERATING SYSTEMS


A distributed operating system is software over a collection of independent, networked,
communicating, and physically separate computational nodes. Each individual node holds a
specific software subset of the global aggregate operating system. Each subset is a composite of
two distinct service provisioners. The first is a ubiquitous minimal kernel, or microkernel, that
directly controls that node’s hardware. Second is a higher-level collection of system management
components that coordinate the node's individual and collaborative activities. These components
abstract microkernel functions and support user applications.
The microkernel and the management components collection work together. They support
the system’s goal of integrating multiple resources and processing functionality into an efficient
and stable system. This seamless integration of individual nodes into a global system is referred
to as transparency, or single system image; describing the illusion provided to users of the global
system’s appearance as a single computational entity.

5.4 OBJECT ORIENTED OPERATING SYSTEMS.


An object-oriented operating system is an operating system that internally uses object-
oriented methodologies.
An object-oriented operating system is in contrast to an object-oriented user interface or
programming framework, which can be placed above a non-object-oriented operating system like
DOS or Unix.
There are already object-based concepts involved in the design of a more typical
operating system such as Unix. While a more traditional language like C does not support object
orientation as fluidly as more recent languages, the notion of, for example, a file, stream, or
device driver (in Unix, each represented as a file descriptor) can be considered a good example
of objects they are, after all, abstract data types, with various methods in the form of system
calls, whose behavior varies based on the type of object and whose implementation details are
hidden from the caller.
Object-oriented has been defined as objects + classes + inheritance and the latter is only
one approach to the more general problem of delegation that occurs in every operating system.
Object-orientation has been more widely used in the user interfaces of operating systems than in
their kernels.

5.5 TEXT EDITORS


An interactive editor is a computer program that allows a user to create and revise a target
document. The term document includes objects such as computer programs, texts, equations,
tables, diagrams, line art and photographs-anything that one might find on a printed page. Text
editor is one in which the primary elements being edited are character strings of the target text.
The document editing process is an interactive user-computer dialogue designed to accomplish
four tasks:

66
 Select the part of the target document to be viewed and manipulated
 Determine how to format this view on-line and how to display it.
 Specify and execute operations that modify the target document.
 Update the view appropriately.

Traveling – Selection of the part of the document to be viewed and edited. It involves first
traveling through the document to locate the area of interest such as “next
screenful”, ”bottom”,and “find pattern”. Traveling specifies where the area of
interest is;
Filtering - The selection of what is to be viewed and manipulated is controlled by filtering.
Filtering extracts the relevant subset of the target document at the point of
interest such as next screenful of text or next statement.
Formatting: Formatting determines how the results of filtering will be seen as a visible
representation (the view) on a display screen or other device.
Editing: In the actual editing phase, the target document is created or altered with a set
of operations such as insert, delete, replace, move or copy.
Manuscript oriented editors operate on elements such as single characters, words, lines,
sentences and paragraphs;
Program-oriented editors operates on elements such as identifiers, keywords and
statements

5.5.1 EDITOR STRUCTURE

Fig no : 5.1 Structure of Editor


67
5.5.1.1 The command Language Processor
It accepts input from the user‟s input devices, and analyzes the tokens and syntactic
structure of the commands. It functions much like the lexical and syntactic phases of a compiler.
The command language processor may invoke the semantic routines directly. In a text editor,
these semantic routines perform functions such as editing and viewing. The semantic routines
involve traveling, editing, viewing and display functions. Editing operations are always specified
by the user and display operations are specified implicitly by the other three categories of
operations. Traveling and viewing operations may be invoked either explicitly by the user or
implicitly by the editing operations

5.5.1.2 Editing Component


In editing a document, the start of the area to be edited is determined by the current editing
pointer maintained by the editing component, which is the collection of modules dealing with
editing tasks. The current editing pointer can be set or reset explicitly by the user using travelling
commands, such as next paragraph and next screen, or implicitly as a side effect of the previous
editing operation such as delete paragraph.

5.5.1.3 Traveling Component


The traveling component of the editor actually performs the setting of the current editing
and viewing pointers, and thus determines the point at which the viewing and /or editing filtering
begins.

5.5.1.4 Viewing Component


The start of the area to be viewed is determined by the current viewing pointer. This
pointer is maintained by the viewing component of the editor, which is a collection of modules
responsible for determining the next view. The current viewing pointer can be set or reset
explicitly by the user or implicitly by system as a result of previous editing operation. The
viewing component formulates an ideal view, often expressed in a device independent
intermediate representation. This view may be a very simple one consisting of a window‟s
worth of text arranged so that lines are not broken in the middle of the words.

5.5.1.5 Display Component


It takes the idealized view from the viewing component and maps it to a physical output
device in the most efficient manner. The display component produces a display by mapping the
buffer to a rectangular subset of the screen, usually a window

5.5.1.6 Editing Filter


Filtering consists of the selection of contiguous characters beginning at the current point.
The editing filter filters the document to generate a new editing buffer based on the current
editing pointer as well as on the editing filter parameters

5.5.1.7 Editing Buffer


It contains the subset of the document filtered by the editing filter based on the editing
pointer and editing filter parameters

5.5.1.8 Viewing Filter

68
When the display needs to be updated, the viewing component invokes the viewing filter.
This component filters the document to generate a new viewing buffer based on the current
viewing pointer as well as on the viewing filter parameters.

5.5.1.9 Viewing Buffer


It contains the subset of the document filtered by the viewing filter based on the viewing
pointer and viewing filter parameters. E.g. The user of a certain editor might travel to line 75,and
after viewing it, decide to change all occurrences of “ugly duckling” to “swan” in lines 1 through
50 of the file by using a change command such as
[1,50] c/ugly duckling/swan/
As a part of the editing command there is implicit travel to the first line of the file. Lines
1 through 50 are then filtered from the document to become the editing buffer. Successive
substitutions take place in this editing buffer without corresponding updates of the view

In Line editors, the viewing buffer may contain the current line; in screen editors, this
buffer may contain rectangular cut out of the quarter-plane of text. This 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, usually called a window.
The editing and viewing buffers, while independent, can be related in many ways. In a
simplest case, they are identical: the user edits the material directly on the screen. On the other
hand, the editing and viewing buffers may be completely disjoint.

5.5.2 INTERACTIVE DEBUGGING SYSTEMS


An interactive debugging system provides programmers with facilities that aid in testing
and debugging of programs interactively.

5.5.2.1 DEBUGGING FUNCTIONS AND CAPABILITIES


Execution sequencing: It is the observation and control of the flow of program execution.
For example, the program may be halted after a fixed number of instructions are executed.

5.5.2.1.1 Breakpoints – The programmer may define break points which cause execution
to be suspended, when a specified point in the program is reached. After execution is
suspended, the debugging command is used to analyze the progress of the program and to
diagnose errors detected. Execution of the program can then be removed.

5.5.2.1.2 Conditional Expressions – Programmers can define some conditional


expressions, evaluated during the debugging session, program execution is suspended,
when conditions are met, analysis is made, later execution is resumed

5.5.2.1.3 Gaits- Given a good graphical representation of program progress may even be
useful in running the program in various speeds called gaits. A Debugging system should
also provide functions such as tracing and traceback. Tracing can be used to track the
flow of execution logic and data modifications. The control flow can be traced at
different levels of detail – procedure, branch, individual instruction, and so on…

5.5.2.1.4 Traceback can show the path by which the current statement in the program
was reached. It can also show which statements have modified a given variable or
parameter. The statements are displayed rather than as hexadecimal displacements.
Program-display Capabilities It is also important for a debugging system to have good
program display capabilities. It must be possible to display the program being debugged,
69
complete with statement numbers. Multilingual Capability A debugging system should
consider the language in which the program being debugged is written. Most user
environments and many applications systems involve the use of different programming
languages. A single debugging tool should be available to multilingual situations.

5.5.2.1.5 Context Effects


The context being used has many different effects on the debugging interaction.
For example: The statements are different depending on the language

COBOL - MOVE 6.5 TO


X FORTRAN - X = 6.5

Likewise conditional statements should use the notation of the source


language

COBOL - IF A NOT EQUAL TO B FORTRAN - IF (A .NE. B)

Similar differences exist with respect to the form of statement labels, keywords and so
on. The language translator may provide the source code or source listing tagged in some
standard way so that the debugger has a uniform method of navigating about it.

5.5.2.1.6 Optimization:
It is also important that a debugging system be able to deal with optimized code.
Many optimizations involve the rearrangement of segments of code in the program. For
eg. - invariant expressions can be removed from loop - separate loops can be combined
into a single loop - redundant expression may be eliminated - elimination of unnecessary
branch instructions The debugging of optimized code requires a substantial amount of
cooperation from the optimizing compiler.

TWO MARKS
1.Define interactive editor.
Interactive Editor is a computer program that allows a user to create and revisea target
document.

2. What are the tasks performed in the editing process?


*select the part of the target document to viewed and manipulated.
* determine how to format this view online & how to display it
* specify and execute operation thar modify the target document.
* update the view apporiately.

3. What are the three categories of editor’s devices?


1.Text device /string device.
2.button device/choice device.
3. locator device

4. What is the function performed in editing phase?


In the actual editing phase,the target document is created or altered with a set of operation
such as insert,delete,replace, move and copy.

5. Define Locator device


Locator device are two-dimensional analog-to-digital converters that position a cursor symbol
70
on the screen by observing the user's movement of the device.The most common such device for
editing application are the mouse and the data tablet

6. What is the function performed in voice input device?


Voice input devices, which translate spoken words to their textual equivalents,may prove to
be the text input devices of the future.voice recognizers are currently available for common input
on some systems.

7. Name some of text editors.


* line editors
* stream editors
*screen editors
* word processor
* structure editors

8. What for debug monitors are used?


Debug monitor is apowerful grahical and console mode tool for monitoring all activities
handled by the WinDriver kernel.we may also use the debug monitor to debug your windows CE
driver code running on CE emulation on a windows platform.

9. What are the methods in Interaction language of a text editor?


* typing-oriented or text command oriented method
*function key method
*menu oriented method

10. Give the components of editor structure.


* common language processor
* Editing component & display components
*Travelling component & viewing components
* Editing filiter & viewing filter

11. What are the basic types of computing environments used in editor’s functions?
Editors function in three basic types of computing environments
*Time sharing
* stand-alone
*Distributed

12. What are called tokens?


The lexical analyzer tracks the source program one character at a time by making
the source program into sequence of atomic units is called tokens.

13. Name some of typical tokens.


Identifiers,keywords,constants and punctuation symbols such as coomos ant
parentheses are typical tokens.

14. What is operating system?


The operating system is the core software component of your computer. It performs
many functions and is, in very basic terms, an interface between your computer and the outside
world. In the section about hardware, a computer is described as consisting of several component
parts including your monitor, keyboard, mouse, and other parts.
71
15. What are the functions of Operating System?
1.Convenience:An OS makes a computer more convenient to use.
2.Efficiency: An OS allows the computer system resources to be used in an efficient
manner.
3. Ability to Evolve: An OS should be constructed in such a way as to permit the effective
development, testing and introduction of new system functions without at the same time
interfering with service.

16. What is I/O system Management?


The module that keeps track of the status of devices is called the I/O traffic controller. Each I/O
device has a devicehandler that resides in a separate process associated with that device.

17. What are the service provide by os?


1.Program execution
2.I/O operation
3.File system manipulation
4.Communications
5.Error detection

18. List out the os components


Modern operating systems share the goal of supporting the system components. The
system components are :
1.Process Management
2.Main Memory Management
3.File Management
4.Secondary Storage Management
5.I/O System Management
6.Networking

19. What is multi programming?


When two or more programs are in memory at the same time, sharing the processor is
referred to the multiprogramming operating system. Multiprogramming assumes a single
processor that is being shared. It increases CPU utilization by organizing jobs so that the CPU
always has one to execute.

20. What are essential properties of os?


*batch
*Time sharing
*Interactive
*Real time system
*distributed

72
QUESTION BANK

UNIT-I
1. Explain the SIC machine architecture
2. Explain in detail about data format and addressing modes of SIC.
3. Explain in detail the different stages of the SIC machine architecture.
4. i) Data formats and instruction formats of SIC
ii) Instruction set and I/O programming
5. Explain in detail the architecture of a SIC machine.
6. Explain in detail about system software and machine architecture.
7. What is system software? Explain about components of system software.

UNIT-II
1. Explain the various machine dependent features of assembler
2. Explain the necessity of one pass and multi pass assemblers.
3. i) State and explain the pass 1 algorithm of an assembler.
ii) With an example, explain the concept of program relocation.
4. Explain about the different data structures used by an assembler.
5. Discuss in brief about the machine independent features of an assembler
6. Write short notes on MASM assembler
7. What are the functions performed in pass 1 and pass 2 of a two pass assembler?
8. Differentiate between control sections and program blocks.
9. State and explain the pass 2 algorithm of an assembler.
10. Write notes on program relocation.

UNIT-III
1. With examples, explain the machine independent features of a loader.
2. Discuss the basis loader functions and design relocatable loader.
3. Explain the basic loader functions and states the design of an absolute loader.
4. Explain in brief about the bootstrap loader.
5. Explain in detail how linkage editors are implemented in various machines.
6. Explain dynamic linking concepts in brief.
7. Explain the algorithm and data structure of a linking loader.
8. Differentiate linkage editors with linkage loaders.
9. With diagram, explain how loading and calling of a subroutine is done using dynamic
linking.
10. State the concept of relocation and program linking in detail.

UNIT-IV
1. i) State and explain the algorithm for one pass macro processor.
ii) What are the different data structures used by a macro processor? Explain.
2. Explain the basic macro processor functions with example programs to illustrate macro
definition and expansion.
3. Explain the various machine independent macro processor features, in detail.
4. Write an algorithm for a simple one pass macro expansion.
5. State the algorithm and data structure of a macro processor.
6. Explain in brief about
i) Macro expansion
ii) MASM macro processor
7. Explain the concept of recursive macro expansion in detail
73
8. What is a general purpose macro processor? Explain.
9. Explain conditional macro expansion
10. Discuss in detail about the macro processor design options.

UNIT-V
1. Various features that a basic text editor should possess
2. Discuss about the
i) Interrupt processing
ii) Process scheduling
3. Briefly discuss about machine independent operating system features.
4. Discuss in detail about the various issues related to an interactive debugging system.
5. Briefly discuss about machine dependent operating system features.
6. Discuss in detail about the object oriented operating systems.
7. Write short notes on
i) Multiprocessor operating systems
ii) Distributed operating systems
8. i) How are user interfaces useful? Explain.
ii) Explain the concept of resource allocation.
9. Discuss about the
i) File processing
ii) Job scheduling
10. Explain various operating system design options.

74
B.E. / B.Tech. DEGREE EXAMINATION, Nov/Dec 2009
Third Year – Fifth Semester
Information Technology
CS2304 - System Software
Model Question Paper – I
(Regulations 2008)
Time : 3 Hours Maximum Marks : 100
Answer all questions
PART A – (10 x 2 = 20 Marks)
1. Define system software. Give examples.
2. Explain the instruction format and addressing modes in SIC.
3. What are different assembler directives?
4. What is a literal?
5. Distinguish between program blocks and control sections.
6. Write an algorithm for an absolute loader.
7. Define macro definition and macro expansion.
8. Distinguish between a subprogram and a macro processor.
9. What is the importance of User Interface?
10. What are various functions of a debugger?

PART B - (5 x 16 = 80 Marks)
11. (a) Discuss the SIC/XE architecture, explaining in detail the data and instruction formats. (16)
Or.
(b)Write short notes on
(i) Data and instruction formats.
(ii) Addressing modes of SIC/XE. (16)
12. (a) Discuss in detail pass1 of a two pass assembler. Mention the data structures used.
Or
(b) Explain in detail the features of MASM assembler for Pentium system. (16)
13. (a) Briefly describe the basic Loader Functions and
(ii) Features of machine dependent loader (16)
Or
(b) Explain in detail about
(i) Linkage editors and (ii) Dynamic Linking (16)
14. (a) What are the machine independent features of macro processor?
Explain in detail any two of them (16)
Or
(b) Explain in detail with examples
(a) Conditional Macro expansion
(b) ANSI C Macro Language (16)
15. (a) With a neat block diagram, explain the different components of an editor structure.
(16)
Or
(b) Discuss in detail about an interactive debugging system (16)

75
B.E. / B.Tech. DEGREE EXAMINATION,Nov/Dec 2010
Third Year - Fifth Semester
Information Technology
CS2304 - System Software
Model Question Paper – II
(Regulations 2008)
Time : 3 Hours Maximun Marks : 100
Answer all questions
PART A – (10 x 2 = 20 Marks)
1. Explain the Instruction formats in SIC/XE.
2. What are the different addressing modes in SIC/XE?
3. What are the basic assembler functions?
4. What is the use of Location Counter(LOCCTR)?
5. What are different type of loaders?
6. Differentiate functions of Linking Loader and Linkage Editors.
7. What are the data structures used by a macro processor?
8. What are the functions of MASM macro processor?
9. What are the tasks performed in the editing process?
10. What are tracing and trace back functions?

PART B - (5 x 16 = 80 Marks)
11. (a) Explain with diagram SIC machine architecture. (16)
Or.
(b) Give examples of a) data movement operations and b) Looping and indexing operations
of
SIC/XE (16)
12. (a) Explain in detail the functions of Pass1 and pass2 of two pass assembler and the data
structures used. (16)
Or
(b) Explain the functioning of a) Load-and-go assemblers and b) Multipass assemblers (16)
13. (a) Write an algorithm for Boot strap Loader for SIC/XE
(16)
Or
(b) Explain in detail the functioning of a Linking loader with algorithm and data structures.
(16)

14. (a) Explain in detail the functioning of a macro processor with an algoritm and its data
structures. (16)
Or
(b) What are the machine independent macro processor features? Explain in detail any two of
them (16)
(ii) Explain in detail the MAXM macro processor features. (16)
15. (a) Explain in detail the overview of editing process (16)
Or
(b) Discuss briefly about the need for debugging system and b) user interface criteria (16)

76
B.E. / B.Tech. DEGREE EXAMINATION,Nov/Dec 2010
Third Year - Fifth Semester
Information Technology
CS2304 - System Software
Model Question Paper – III
(Regulations 2008)
Time : 3 Hours Maximun Marks : 100
Answer all questions

PART A – (10 x 2 = 20 Marks)

1. What are the additional registers provided in SIC/XE than SIC??


2. How floating point data type is represented in SIC/XE?
3. What are assembler directives?.
4. Differentiate literals and immediate operands..
5. What are different types of loaders?.
6. What are the two types of relocation?.
7. What are key word macro parameters? How iit is useful?.
8. What are general purpose macro processors?.
9. What are the tasks performed by a document editing process?
10. What are the various functions of a debugger?

PART B - (5 x 16 = 80 Marks)

11. (a) Explain different addressing modes of SIC/XE and explain how the
target address is caculated.. (16)
Or
(b) Explain briefly (i) SIC/XE data formats and b) Pentium Pro architecture (16)

12. (a) Explain in detail i) pass2 of a two pass assembler and ii) Object code format (16)
Or
(b) Explain in detail assembler data structures and their formats. (16)

13. (a) Explain in detail machine independent loader features. l (16).


Or
(b) What are different design options of loaders? Explain in detail functions of any two
Of them. (16)
14. (a) Explain in brief about a) Macro definition b) Macro Expansion (16)
Or
(b) Explain a) Nested macro definitions b) Macro processor with language translators (16)
15. (a) (i) Discuss clearly the functional components of a text editor. (16)
Or
(b) Discuss in detail various issues related to interactive debugger (16)

77
B.E/B.Tech. DEGREE EXAMINATION, NOVEMBER/DECEMBER 2011.
Fifth Semester
Computer Science and Engineering
CS2304 SYSTEM SOFTWARE
(Regulation 2008)
Time: Three hours Maximum:100 marks
Answer ALL questions.
Part A - (10x2=20 marks)
1. Define system software
2.write the abbreviation for the following:
(a)SIC b)XE C) CISC D)RISC
3.Distingush between assembler and interpreter
4. What do you mean by literal?
5. What are the functions of loader and linker?
6. Define relocation.
7.Write any two basic macroprocessor functions.
8. Briefly write about MASM macr processor.
9.Define text editor.
10.What do you mean by debugger?

Part B - (5x 16=80 marks)


11. (a) Explain the SIC machine architecture in detail.
OR
(b)Describe the following in VAX architecture
(i)Memory (ii)Registers
(iii)Data formats (iv)Instruction formats
(v) Addressing modes (vi)instruction/output
(vii)instruction set and

12. (a) Discuss in detail the assembler design options.


OR
(b)Explain machine dependent assemblerfeatures in details.
13. (a) Describe machine dependent loader features in detail.
OR
(b) Explain the following in details al macro expansion
14.(a) Explain the features of machine independent maxcro processor in details.
OR
(b)Describe the following in detail:
(i)Conditional macro expansion (ii) MASM macro processor (iii) ANSI C macro
language
15. (a) Explain the editor structure with neat diagram
OR
(b)Discuss interactive debugging systems in detail.

78
79
80
SYSTEM SOFTWARE

ONLINE QUESTIONS
Questions opt1 opt2 opt3 opt4 Answer
The ________________ has become an program
important part of almost any computing interactive text oriented interactive
environment editor line editor editor screen editor text editor
_________ should be considered as the interactive
primary interface to the computer Text editor document editor preprocessor Text editor
An _______________ is a computer program
program that allows a user to create and oriented interactive interactive
revise target document screen editor line editor editor editor editor
.The term _______ includes object such as
computer
programs,text,equations,tables,diagrams,line
art and photographs Editor Vieewer document element document
In text editors the primary elements edited Character Character
are ___________ of the target text strings numbers character strings strings
Selection of the part of the document to be
viewed and edited involves first _________
through the document to locate the area of
interest editing traveling viewing display traveling
The search is accompolished with operations
such as next screenful,________ top and find bottom and bottom and none of the bottom and
and___________ document formatting find pattern above find pattern
The selection of what is to be viewed and
manipulated is controlled by _________ editing viewing displaying filtering filtering
_________ extracts the relevant subset of
the target document at the point of interest
such as the next screenful of text editing viewing filtering displaying filtering
In editing process the target document is move and
created or altered with a set of oprations like insert & delete replace copy all the above all the above
____________________ might oprate on program program
elements such as identifiers,keywords and oriented interactive oriented
statements screen editor line editor editor editor editor
.______ editors allow operations on program
numbered sequences of 80-character card- oriented interactive
image lines screen editor line editor editor editor line editor
The user interface is concerned with the output interaction
________________ of the system input devices devices language all the above all the above
______ are used to enter elements of the
text being edited,to enter commands,and to output interaction input
designate editable elements input devices devices language all the above devices
The three categories of input devices are choice locator voice input locator
text,button and________ devices string devices devices devices devices devices
_ are typically type-writer like keyboards on
which a user presses and releases keys choice locator voice input string
sending a unique code for each key string devices devices devices devices devices
The _________can be simulated in software
by displaying text strings or symbols on the none of the
screen button textbox mouse above button
The most common locator devices for mouse and
editing applications are the _____________ keyboard mouse data tablet both b and c both b and c
The _____________ is a flat rectangular mouse and
electromagnetically sensitive panel keyboard mouse data tablet both b and c data tablet
A ball point pen like ________ a small device none of the
similar to mouse,is moved over the surface stylus locator button above stylus
The program can map data-tablet
coordinates to __________and move the system screen both a and none of the screen
cursor to the corresponding screen position coordinates coordinates b above coordinates
__________ usually incorporate one or more
buttons that can be used to specfy editing button locator voice input locator
operations string devices devices devices devices devices
text devices text devices
.__________ can be used to simulate locator with the none of the with the
devices cursor keys mouse cursor keys above cursor keys
pressing an arrow key typically generates an number character string of character
appropriate __________ sequence sequence characters all the above sequence
______________ translate spoken words to
their textual equilants may prove to be the choice locator voice input voice input
text input devices of the future string devices devices devices devices devices
______________ are currently available for choice locator voice voice
command input on some systems string devices devices devices recognizers recognizers
character
printing both a and none of the
The first output devices were ___________ teletypewriters terminals b above both a and b
The glass teletypes based on _________
technology used CRT screen essentially to
simulate a hardcopy teletype writer Nano CRT hardware all the above CRT
text
The __________ method is the oldest of the typing- command- both a and none of tha
major editor interfaces oriented oriented b above both a and b
.___________ system require familiarity
with the system and language and expertise typing- menu- functionkey- typing-
in typing oriented oriented oriented editing oriented
____________ system have few keys typing- menu- functionkey- functionkey-
requiring multiple-stroke commands oriented oriented oriented editing oriented
A _____ is a multiple-choice set of text
strings or icons textbox menu function all the above menu
program
.In a _________ the semantic routines oriented
perform function such as editing and viewing text editor line editor editor screen editor text editor
viewing and
display
The semantic routines involve __________ traveling editing functions all the above all the above
current current
.The start of the area to be edited is current editing editing viewing editing
determined by the __________ pointer editing filter buffer pointer pointer
The current editing pointer is maintained by traveling editing viewing editing
the ___________ component component component editing buffer component
The _______________ of the editor
performs the setting of the current editing traveling editing viewing traveling
and viewing pointers. component component component editing buffer component
current
The editing filter filters the document to current editing editing viewing
generate a new_________ pointer editing filter buffer pointer editing buffer
current current
The start of the area to be viewed is current editing editing viewing viewing
determined by the __________ pointer editing filter buffer pointer pointer
The current viewing pointer is maintained by traveling editing viewing viewing
the ___________ component component component editing buffer component
when the display needs to be updated the current
viewing component invokes current editing viewing viewing
the____________ pointer editing filter filter pointer viewing filter
current
The viewing filter filters the document to current editing viewing editing viewing viewing
generate a new_________ pointer buffer buffer pointer buffer
A debugging should also provide functions both a and none of the
like _____________ tracing traceback b above both a and b
__________ can show the path by which the
current statement was reached gaits tracing breakpoints traceback traceback
The _________ takes the idealized view
from the viewing component and maps it to a editing display viewing mapping display
physical output device component component component component component
The components of the editor deal with a
user document in ________ levels 6 7 4 2 2
.Editor datastructure allows _____________
with a minimum of I/O and character
movement addition deletion modification all the above all the above
_________ produce the needed information
in a standard external form for the debugger language language
regardless of the internal form comiler assembler translator interpreter translator

You might also like