CDG
CDG
CDG
SYSTEM SOFTWARE
System programs, on the other hand,are intended to support the operation and use of the
computer itself,rather than any particular application.
Loader or linker - load machine language program into memory and prepared for
execution
Memory structure
Registers
Data formats
Instruction formats
Addressing modes
Instruction set
SIC
SIC refers to Simplified Instruction Computer which is a hypothetical computer that has
been designed to include the hardware features most often found on real machines,while
avoiding unusual and irrelevant complexities. This allows to clearly separate the central
concepts of a system software from the implementation details associated with a
particular machine.
Memory
8-bit bytes
Registers
PC 8 Program counter
Data Formats
No floating-point hardware
Instruction Formats
opcode (8)
address (15)
X(1)
Addressing Modes
INSTRUCTION SET
comparison: COMP
Input and output are performed by transferring 1 byte at a time to or from the
rightmost 8 bits of register A
The Test Device (TD) instruction tests whether the addressed device is ready to
send or receive a byte of data
Memory
8-bit bytes
Data Formats
No floating-point hardware
REGISTERS
Data Formats
frac: 0~1
exp: 0~2047
Instruction Set
Input/Output
SIO, TIO, HIO: start, test, halt the operation of I/O device
Instruction Formats
format 3
TA=(B)+disp
Base relative b=1, p=0 (0<=disp<=4095) (TA)
TA=(PC)+disp (-
PC-relative b=0, p=1 2048<=disp<=2047) (TA)
ADDRESSING MODES
INSTRUCTION SET
Instruction Set
INPUT/OUTPUT
computer. This software makes it possible for the user to focus on an application of other
problem to be solved, without needing to know the details of how the machine works
internally.
Input and output are performed by transferring 1 byte at a time to or from the
If bit i = 0 and n = 1, the word at the location given by the target address is
1 5 5
7 6 3
7 4
10
interrupt that can be used for communication with the operating system.
B,S,T,F
7.In SIC / XE, what is the difference between simple addressing and immediate addressing?
In simple addressing, the instruction gives the address of the operand.
8.Mention one advantage and one disadvantage of using program blocks in SIC / XE
assembly language programs.
Advantage :
Program blocks can reduce the sizes of a program since some 4-byte instructions may be
shortened to 3-bytes.
Disadvantage :
Advantage :
Disadvantage :
10.When addressing programs written using the assembly language of SIC / XE, the
assembler may need to use PC – relative mode even when the BASE directive is in effect.
Why?
Loader / linker : load resulting code into memory and prepare for execution.
12.Write a program for SIC machine to copy 11 byte string from one location to another.
JLT MOVECH
String constant
STR2 RESB 11
ZERO WORD 0
ELEVEN WORD 11
But in SIC /XE, the exponent is interpreted as an unsigned binary number between 0 and
2047. If the exponent has the value e and fraction has value f, the absolute value of the
number represented is f * 2 (e – 1024)
The test device (TD) instruction tests whether the addressed device is ready to send or
receive a byte of data. The condition code is set to indicate the result of this test.
15.How I/O channels are used to perform input and output operations.
I/O channels can be used to perform input and output while the CPU is executing other
instructions. This allows overlap of computing and I/O, resulting in more efficient system
operation. The instruction SIO, TIO and HIO are used to start, test and halt the operation of
I/O channels.
16.Define a subroutine.
A subroutine is a section of the program that is written once, and can be used many times by
simply calling it from any point in the program.
PART – B
(OR)
ASSEMBLER
An assembler is a program that accepts an assembly language program as input and produces its
machine language equivalent along with information for the loader
Label field.
The label is a symbolic name that represents the memory address of an executable
statement or a variable.
Opcode/directive fields.
The opcode (e.g. operation code) specifies the symbolic name for a machine
instruction.
The directive specifies commands to the assembler about the way to assemble the
program.
Operand field.
Comment field.
START
END
Indication of the end of the program and optionally the address of the first
executable instruction.
BYTE
WORD
RESB
RESW
Assemble instructions
Header record:
Col. 1 H
Text record
Col.1 T
End record
Col.1 E
(END program_name)
PASS1 ALGORITHM
PASS 2 ALGORITHM
FEATURES OF A SYMBOL TABLE.
• Content
• Usage
Pass 1: labels are entered into SYMTAB with their address (from
• Implementation
1) # symbol.
2) @ symbol.
3) + symbol.
4) BASE directive.
a. Indication that the base register B holds a base address used in a base
addressing.
5) Register-to-register addressing.
Assembling features.
1) Multiprogramming.
b. The object code is relative to zero because the load address is variable.
a. A separate register table can store the numeric values of the registers.
b. The numeric values of the registers can be preloaded with the symbol
table.
Program relocation
• Principles.
The load address of an object program is unknown at assembly time if the system
implements the multiprogramming feature.
At load time, relocation is performed by adding the load address to the relative
addresses.
Operands of instructions that use direct addressing must be relocated, and the
assembler provides the relocation information in the object program.
Program Relocation
• Refer to segments of code that are rearranged within a single object program unit
• USE [blockname]
• At the beginning, statements are assumed to be part of the unnamed (default) block
• If no USE statements are included, the entire program belongs to this single block
• Each program block may actually contain several separate segments of the source
program
Pass 1
Each label is assigned an address that is relative to the start of the block that contains it
At the end of Pass 1, the latest value of the location counter for each block indicates the length of
that block
The assembler can then assign to each block a starting address in the object program
Pass 2
The address of each symbol can be computed by adding the assigned block starting address and
the relative address of the symbol to that block
the external storage for the intermediate file between two passes is slow or is
inconvenient to use
• One simple way to eliminate this problem: require that all areas be defined before they
are referenced.
Load-and-go assembler generates their object code in memory for immediate execution.
It is useful in a system oriented toward program development and testing such that the efficiency
of the assembly process is an important consideration.
Load-and-go assembler
Omits the operand address if the symbol has not yet been defined
Enters this undefined symbol into SYMTAB and indicates that it is undefined
Adds the address of this operand address to a list of forward references associated with the
SYMTAB entry
Scans the reference list and inserts the address when the definition for the symbol is encountered.
Reports the error if there are still SYMTAB entries indicated undefined symbols at the end of the
program
Search SYMTAB for the symbol named in the END statement and jumps to this location to
begin execution if there is no error
OBJECT CODE IN MEMORY AND SYMTAB
MULTI-PASS ASSEMBLERS
A multi-pass assembler that can make as many passes as are needed to process the definitions of
symbols.
Only the portions of the program that involve forward references in symbol definition are saved
for multi-pass reading.
For a two pass assembler, forward references in symbol definition are not allowed:
DELTA RESW 1
Reason: symbol definition must be completed in pass 1.
Implementation
5.What are the functions performed in pass 1 and pass 2 of a two assembler?
Pass 1
1.Assign addresses to all statements in the program.
2.Save the values assigned to all labels for use in pass 2.
3.Perform some processing of assembler directives.
Pass 2
1.Assemble instructions.
2.Generate data values defined by BYTE, WORD etc.
3.Perform processing of assembler directives not done during pass 1.
4.Write the program and the assembling listing.
6.Write down the pass number (PASS 1 / PASS 2) of the following activities that occur in a two
pass assembler.
a.Object code generation.
b.Literals added to literal table.
c.Listing printed.
d.Address resolution of local symbols.
Answer :
Pass II
Pass I
Pass II
Pass I
PART - B
1.Explain the functions of SIC assembler in detail.
2.Explain the algorithm and data structures used for SIC assembler in detail.
3.Explain two pass assembler functions with suitable example program.
4.Explain machine dependant features of an assembler functions.
5.Explain machine independent features of an assembler functions.
6.Explain one-pass assembler functions with example program.
7.Discuss in detail about multi-pass assembler.
8.Discuss in detail about MASM assembler.
UNIT –III- LOADERS AND LINKERS
Loading
Relocation
– Modifies an program so it can be loaded at a location different from the one specified at
assembly or compilation.
Linking
– Combines two or more object files and the references between them.
Loader
– Performs the linking function.Compilers & assemblers for a given machine produce
files in the same format
The most fundamental functions of a loader:
Header record
Check the Header record for program name, starting address, and length (available memory)
Text record
Bring the object program contained in the Text record to the indicated address
End record
ABSOLUTE LOADER
Explain SIC bootstrap loader.
• No header record or control information, the object code is consecutive bytes of memory
• After load the OS, the control is transferred to the instruction at address 80.
Bootstrap loader
When a computer is first tuned on or restarted, a special type of absolute loader, the
bootstrap loader loads the first program (usually O.S.) to be run into memory
Bootstrap loader for SIC/XE
begin
Loop
A¬GETC ; read one char. From device F1 and convert it from the
A¬GETC
X¬X+1
End
Programmer needs to specify the actual address at which it will be loaded into
memory.
RELOCATABLE LOADERS
Loaders that allow for program relocation are called relocating loaders or relative loaders.
o Two methods for specifying relocation as part of the object program
Modification records
o Suitable for a small number of relocations required when relative or immediate addressing
modes are extensively used
Relocation bits
o Suitable for a large number of relocations required when only direct addressing mode can be
used in a machine with fixed instruction format (e.g., the standard SIC machine)
DYNAMIC LINKING
Dynamic Linking refers to postponing 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, dynamic loading, or load on call)
In object-oriented system, it allows the implementation of the object and its methods to
be determined at the time the program is run
Dynamic linking provides the ability to load the routines only when they are needed
Dynamically loaded must be called via an operating system service request
Load-and-call service
OS examines its internal tables to determine whether or not the routine is already
loaded
Subroutine is finished
Dynamic Linking : Binding of the name to an actual address is delayed from load time
until execution time
Advantages
Load the routines when they are needed, the time and memory space will be saved.
Avoid the necessity of loading the entire library for each execution
Allow several executing programs to share one copy of a subroutine or library (Dynamic
Link Library, DLL)
A linkage editor
A simple relocating loader can be used to load the linked version of program into
memory
Resolution of external references and library searching are only performed once
To allow subsequent relinking of the program to replace control sections, modify external
references, etc
Linking loader
Searches libraries and resolves external references every time the program is executed.
Linkage editor
Resolution of external reference and library searching are only performed once
Linking loader
Linkage editor
loading and linking are often thought of as operating system service functions.
Loader Options
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.
At the end of Pass 1, the symbols in ESTAB that remain undefined represent unresolved
external references
The loader searches the 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
Since the subroutines fetched from a library may themselves contain external references
,the library search process may be repeated.
The programmers can override the standard subroutines
INCLUDE program-name(library-name)
Direct the loader to read the designed object program name specified as a part of input
program.
DELETE csect-name
Delete the named control section(s) from the program loaded when not used
Change the external symbol name 1 to name 2 appeared in the object program
Example
INCLUDE READ(UTLIB)
INCLUDE WRITE(UTILB)
MS-DOS Linker
MS-DOS LINK is a linkage editor that combines one or more modules to produce a
complete executable program (.EXE)
Control sections
External definitions
External references
REF4 (ENDA-LISTA+LISTC)
Control section A
The values of ENDA and LISTA are internal. Only the value of LISTC is unknown.
+LISTC
Control section B
+ENDA
-LISTA
+LISTC
Control section C
LISTC is defined in this control section but ENDA and LISTA are unknown.
+ENDA
-LISTA
1.Define Linking.
Linking is a process in which the object modules created by the translator are bound with
necessary library routines. In the linking process ready to execute program is prepared. Thus
linking is a process of resolving external references between object modules.
PART - B
1.Explain Absolute Loader concept with algorithm.
2.Explain Bootstrap loader with its program in detail.
3.Explain machine independent loader features in detail.
4.Explain machine dependant loader features in detail.
5.Explain linkage editor with neat diagram.
6.Explain program relocation concept with suitable example program.
7.Explain direct linking loader with examples.
8.Explain dynamic linking for loading and calling of a subroutine concept.
9.Explain MS-DOS Linker in detail.
10.Explain algorithm and data structures used for a linking loader in detail.
UNIT – IV – MACROPROCESSORS
MACROPROCESSORS
Define Macro.
handles. It doesn‟t concern the meaning of the involved statements during macro
expansion
Macro definitions
o A body is simply copied or substituted at the point of call Expansion with substitution
of parameters
MACRO DEFINITION
:
body
:
MEND
o Parameters: the entries in the operand field identify the parameters of the macro
instruction
o Body: the statements that will be generated as the expansion of the macro.
The macro name and parameters define a pattern or prototype for the macro instructions
used by the programmer
MACRO INVOCATION
MACRO EXPANSION
Each macro invocation statement will be expanded into the statements that form the
body of the macro.
o 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.
o The first argument in the macro invocation corresponds to the first parameter in the
macro prototype, etc.
Solution
DATASTRUCTURES
Macro prototype
After macro processing, the expanded file can be used as input to the assembler.
The statements generated from the macro expansions will be assembled exactly as though
they had been written directly by the programmer.
The statements that form the body of the macro are generated each time a macro
is expanded.
Statements in a subroutine appear only once, regardless of how many times the
subroutine is called.
Pre-concatenation
LDA X&ID1
Post-concatenation
LDA X&ID1
Concatenation Example
Generation of Unique Labels
Example
JEQ *-3
$LOOP TD =X‟&INDEV‟
1st call:
$AALOOP TD =X‟F1‟
2nd call:
$ABLOOP TD =X‟F1‟
TWO MARKS WITH ANSWERS
1.Define macro.
A Macro instruction is simply a notational convenience for the programmer. That is a macro
represents commonly used (or repeated ) group of statements used in the source programming
language. The Macro processor replaces each macro invocation (or call) with the corresponding
group of source language statements. That is called macro expansion.
5.What are the three main data structures used by our macro processor?
1.Definition table (DEFTAB)
2.Name table (NAMTAB)
3.Argument table (ARGTAB)
10.What if the last argument of an expansion is null? How can the assembler distinguish between
a missing last argument and a null one?
If the last argument is null, it should be preceded by a comma. A missing last comma indicates a
missing argument.
11.Normally, the definition of a macro must precede nay expansions of it. If we eliminate that
restriction, what modifications do we have to make to the assembler?
Add another pass (pass – 1?) to collect all macro definitions and store them in the MDT. Pass 0
would now be concerned only with macro expansions.
12.What could be a practical example of justifying the actual removal of a macro from the
MDT?
Nested macro definition. In such a case, each expansion of certain macros causes another macro
definition to be stored in the MDT, and space in the MDT may be exhausted very rapidly.
13.What is the difference between attributes of symbols and of macro arguments?
The difference is in scope. Attributes of macro arguments exist only while the macro is
expanded. Attributes of a symbol exist while the symbol is stored in the symbol table.
17.What should be printed in the object code field when a macro definition is listed?
Nothing, since the assembler does not process the macro lines at definition time.
18.Library routines are in the form of object files. Can such a routine be an absolute object file?
Yes, but then it can be used only by an absolute loader.
19.What are the basic tasks that must be performed by the macroprocessor?
1.Recognize the macro definition.
2.Save the definition.
3.Recognize the call.
4.Expand call and substitute arguments.
22.How could a non-recursive macro pre-processor allow for the invocation of macros within the
macros? What would be the advantages and disadvantages of such an approach?
Non-recursive macro pre-process allow for the invocation of macros within macros as follows:
1.Recognize call processor must recognize macro calls that appear as operations mnemonics.
2.Expand call and subroutine argument.
3.The processor must store the macro instruction definitions, which it will need for expanding
macro calls.
4.A macro instruction processor must recognize macro definitions identified by the MACRO and
MEND pseudo-op.
PART B
1.Explain recursive macro expression in detail.
2.With suitable example explain macro processor design options in detail.
3.What is a general purpose macro processor? Explain.
4.Write notes on MASM macro processor
5.State and explain the algorithm for an one pass macro processor.
6.With an example explain conditional macro expansion.
7.Write an algorithm for a simple one pass macro processor.
8.Explain machine dependent macro processor features in detail.
9.Explain machine independent macro processor features in detail.
10.Explain ANSI-C macro processor with example.
UNIT –V- SYSTEM SOFTWARE TOOLS
TEXT EDITORS
These are the primary interface to the computer for all types of “Knowledge workers” as
they compose,organize,study and manipulate computer-based information
An interactive editor is a computer program that allows a user to create and revise a target
document.
Text editor is one in which the primary elements being edited are character strings of the
target text.
Determine how to format this view on-line and how to display it.
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”
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 then determines how the result 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.
USER INTERFACE
The user of an interactive editor is presented with a conceptal model of the editing
system. The model is an abstract framework on which the editor and the world on which
the operations are based.
Some of the early line editors simulated the world of 80-character card image lines.
The user interface is also concerned with the input devices,the output devices,and the
interaction language of the system.
Input Devices : The input devices are used to enter elements of text being edited ,to enter
commands,and to designate editable elements.
1)Text devices
2)Button devices
3)Locator devices
1)Text or string devices are typically typewriter like keyboards on which user presses
and release keys ,sending unique code for each key. Virtually all computer key boards are
of the QWERTY type.
Text devices with arrow(Cursor) keys can be used to simulate locator devices. Each of
these keys shows an arrow that points up,down,left,or right.Pressing an arrow key
typically generates an appropriate character sequence ,the program interpretsw this
sequence and moves the cursor in the direction of the arrow on the key pressed.
OUTPUT DEVICES
The output devices let the user view the elements being edited and the result of the
editing operations. The first output devices were teletypewriters and other character-
printing terminals that generated output on paper. Next CRT(Cathode Ray Tube)
technology which uses CRT screen essentially to simulate the hard-copy teletypewriter.
Todays advanced CRT terminals use hardware assistance for such features as moving the
cursor,inserting and deleting characters and lines,and scrolling lines and pages.
INTERACTION LANGUAGE
The interaction language of the text editor is generally one of several common types.
is the oldest of the major editing interfaces. The user communicate with the editor by
typing text stringsboth for command names and and for operands. These strings are sent
to the editor and are usually echoed to the output device.
Typed specification often requires the user to remember the exact form of all
commands ,or at least their abbreviations.
He Help facility have to be used or manuals have to be refered. Time consuming for
in-experienced users.
2) Function key interfaces :
A menu is a multiple choice set of text strings or icons which are graphical symbols that
represent objects or operations
The user can perform actions by selecting items for the menus
One problem with menu oriented system can arise when there are many possible actions
and several choices are required to complete an action. The display area of the menu is
rather limited.E
The command Language Processor 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
lsuch as editing and viewing.
.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.
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.
When the user issues an editing command,the editing component invokes the editing
filter. This component filters the document to generate a new editing buffer based on the
current editing ponter as well as on the editing filter parameters. These parameters,which
are specified by both by the user and the system,provide information such as the range of
the text that can be affected by an operation. Filtering may consist of the selection of
contiguous characters beginning at the current point.
The current viewing pointer can be set or resetexplicitly by the user or implicitly by the
systemas a result of previous editing operation.
When the display needs to be updated,the viewing component invokes the viewing filter.
This componet filters the document to generate a new viewing buffer based on the current
viewing pointer as well as on the viewing filter parameters.
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. Ina
simplest case ,they are identical:theuser edits the material directly on the screen.On the
other hand ,the editing and viewing buffers may be completely disjoint.
EG 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
As apart 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 correspoing updates of the view
Mapping viewing buffers to windows that cover only part of the screen is especially
useful for editors on modern graphics based workstations.
Such systems can support multiple windows, simultaneously showing different portions
of the same file or portions of different file. This approach allows the user to perform
interfile editing operations much more effectively than with a system only a single
window.
The components of the editor deal with a user documents on two levels:
in main memory and in the disk file system. Loading an entiredocument into main
memory may be infeasible. However if only part ofa document is loaded and if many user
specified operations require a disk read by the editor to locate the affected portions,
editing might beunacceptably slow. In some systems this problem is solved by the
mapping the entire file into virtual memory and letting the operating system perform
efficient demand paging .An alternative is to provide is the editor paging routines which
read one or more logical portions of a document into memory as needed. Such portions
are often termed
pages, although there is usually no relationship between these pages and the hard copy
document pages or virtual memory pages. These pages remain resident in main memory
until a user operation requires that another portion of the document be loaded.
DEBUGGER
A debugger is a computer program that is used to test and debug other programs.
When the program crashes, the debugger shows the position in the original code if it is a
source-level debugger or symbolic debugger, commonly seen in integrated
development environments(IDEs)
Typically, debuggers also offer more sophisticated functions such as running a program
in the following manner
stopping (breaking) (pausing the program to examine the current state) at some kind of
event by means of breakpoint, and tracking the values of some variables.
Some debuggers have the ability to modify the state of the program while it is running,
rather than merely to observe it.
An interactive debugging system provides programmers with facilities that aid in testing
and debugging of programs interactively
One important requirement of any IDS is the observation and control of the flow of
program execution
Setting break points – execution is suspended, use debugging commands to analyze the
progress of the program, résumé execution of the program
Setting some conditional expressions, evaluated during the debugging session, program
execution is suspended, when conditions are met, analysis is made, later execution is
resumed
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…
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 context being used has many different effects on the debugging interaction
Fortran - X = 6.5
C - X = 6.5
It is also important that a debugging system be able to deal with optimized code
All these optimizations create problems for the debugger, and should be handled
carefully
Must appear as part of the run-time environment and an integral part of the system
When an application fails during a production run, work dependent on that application
stops
The debugger must also exist in a way that is consistent with the security and integrity
components of the system
The debugger must coordinate its activities with those of existing and future language
compilers and interpreters
Software tool is a system program which Interfaces a program with the entity generating its input
data or Interfaces the results of a program with the entity consuming them.
2.List out the different forms of editor and hint on each editor form.
1.Line editors.
2.Steam editors.
3.Screen editors.
4.Word processors.
5.Structure editors.
Profile monitor is a software tool that collects information regarding the execution behavior of a
program.
2.Command menu
3.Direct manipulation
Locator devices are two dimensional analog to digital converters that positions a cursor symbol on
the screen by observing the user’s movement of the device.
8.What is a menu?
A menu is a multiple choice set of text strings or icons, which are graphic symbols that represent
objects or operations.
View component formulates an ideal view often expressed in a device independent intermediate
representation. Another method is display component,which takes idealized view from the viewing
component and maps it to a physical output device in the most efficient manner possible.
It is also important that a debugging system be able to deal with optimized code
The debugger must communicate and cooperate with other operating system components
such as interactive subsystems
When the display needs to be updated,the viewing component invokes the viewing filter.
PART - B