SIC/XE System Software Basics
SIC/XE System Software Basics
UNIT 1 – Introduction
PART A:
1. What is the purpose of test device instruction? (May’06)
The test device 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.
2. How is a floating point value represented using exponent in SIC? (May’06)
There is no floating-point hardware on the standard version of SIC.
3. What is the need of Assembler directive? (May’06)
Assembler directives are not translated into machine instructions; instead they provide
instructions to the assembler itself.
Eg: BYTE and WORD, which directs the assembler to generate constants as part of the object
program. RESW and RESB, which instruct the assembler to reserve memory locations
without generating data values.
4. What is the use of location counter? (May’06)
LOCCTR is a variable that is used to help in the assignment of addresses. LOCCTR is
initialized to the beginning address specified in the START stmt. After each source stmt is
processed the length of the assembled instruction or data area to be generated is added to
LOCCTR. Thus whenever we reach a label in the source program the current value of
LOCCTR gives the address associated with that label.
5. What are the registers used in SIC? (Nov’06)
Mnemonic Number Special use
A 0 Accumulator, used for arithmetic
Operations
X 1 Index register, used for addressing
L 2 Linkage register, JSUB Stores the
Return address in this register
PC 8 Program counter, address of the next
instruction to be fetched for execution
SW 9 Status word, contains a variety of
Information including a cc (condition code)
Indicatio
Mode Target address calculation
n
TA=address+(X) Eg: J
Indexe
x=1 @RETADR
d
Mnemoni Numbe
Special use
c r
B 3 Base register
opcode x address
Indicatio
Mode Target address calculation
n
Data Formats
o Integers are stored as 24-bit binary numbers; 2’s complement
representation is used for negative values
o No floating-point hardware
Instruction Formats
opcode x address
Instruction set:
o Load/store registers: LDA, LDX, STA, STX
o Integer arithmetic: ADD, SUB, MUL, DIV
All involve register A and a word in memory, result stored in
register A
o COMP
Compare value in register A with a word in memory
Set a condition code CC (<, =, or >)
o Conditional jump instructions: JLT, JEQ, JGT: test CC and jump
o Subroutine linkage : JSUB, RSUB: return address in register L
JSUB jumps to the subroutine, placing the return address in
register L
RSUB returns by jumping to the address contained in
register L
o Input and output
Performed by transferring 1 byte at a time to or from the
rightmost 8 bits of register A
Each device is assigned a unique 8-bit code, as an operand
of I/O instructions
Test Device (TD): < (ready), = (not ready)
Read Data (RD), Write Data (WD)
2. Write short notes on:
a) Data and instruction formats of SIC/XE
b) Addressing modes of SIC/XE
c) Instruction set SIC/XE
d) Input and output SIC/XE
a) Data and instruction formats
Memory
o Maximum memory available on a SIC/XE system is 1 megabyte (220 bytes)
o An address (20 bits) cannot be fitted into a 15-bit field as in SIC Standard
o Must change instruction formats and addressing modes
Registers
o Additional registers are provided by SIC/XE
B 3 Base register
Data Format
o There is a 48-bit floating-point data type
fraction is a value between 0 and 1
exponent is an unsigned binary number between 0 and 2047
zero is represented as all 0
Instruction formats
n i x b p e
opcode 1 0 disp
n i x b p e
opcode 0 1 disp
n i x b p e
opcode 0 0 disp
n i x b p e
opcode 1 0 0 disp
n i x b p e
opcode 0 1 0 disp
n i x b p e
opcode 1 0 0 disp
n i x b p e
opcode 0 0 disp
n i x b p e
opcode 1 1 disp
Fig: Sequence of instruction to add elements in ALPHA & BETA arrays and store it in
GAMMA
SIC subroutine call and I/O operation:
Fig: Sequence of instruction to copy 100 record from device F1 using subroutine
UNIT – II
ASSEMBLER
… … … … …
1012 J CLOOP
… … … … …
Hash function based data structures are used to organize the symbol table. Hash
function is used to perform well with random keys. Division of the entire key by a prime
table length gives good results.
14. Describe how assembler handles literals.
It is convenient for the programmer to write the value of a constant operand as a
part of the instruction that uses it. If we have the constant operand as a part of the
instruction, avoids confusion of defining it elsewhere. Literal is identified with a prefix
‘=’ followed by value.
Eg: 001A ENDFIL LDA = C’EOF’
1062 WLOOP TD = X’05’
15. What is meant by literal pool?
All the literal operands used in the program are gathered together into one or more
literal pools. Normally literals are placed into a pool at the end of the program. It is
desirable to place literals into a pool at some other location using the assembler directive
LTORG.
16. What is load-and go assembler?
Assembler produces object code directly in memory for execution. It does not
generate any object program and hence no loader is needed. This is called as load-and-go
assembler.
17. Write the difference between near and far jump statements of MASM.
Near Jump Far Jump
A near jump is a jump to a target in the A far jump is a jump to a target in a
same segment and it is assembled by using different code segment and it is assembled
a current code segment CS. by using different segment registers
18. What is an object program?
An object program contains translated instructions and data values from the source
program and specifies address in memory where these items are to be loaded.
19. What is MASM Assembler?
MASM Assembler is a translator that converts an X86 assembly language
program into machine language program. It is a Pentium (X86) family assembler,
developed by Microsoft.
20. How are forward references handled in one pass assembler?
It is easy to eliminate forward references to data items by defining them in the
source program before they are referenced. Programmer can place all storage reservation
statements at the start of the program rather than at the end. But forward references to
labels on instructions cannot be eliminated.
21. Give the use of LTORG.
It is desirable to place literals into a pool at some other location using the
assembler directive LTORG. When the assembler encounters a LTORG statement, it
creates a literal pool that contains all the literal operands used from the previous LTORG
(or beginning of the program).
22. What is meant by external references?
Assembler program can be divided into many sections known as control sections and each
control section can be loaded and relocated independently of the others. If the instruction in
one control section needs to refer instruction or data in another control section the assembler
is unable to process these references in normal way. Such references between controls are
called external references.
23. What is the difference between the assembler directive EXTREF and EXTDEF?
EXTDEF names external symbols that are defined in a particular control section and
may be used in other sections.
EXTREF names external symbols that are referred in a particular control section and
defined in another control section.
24. Give the general format of define record.
This record gives information about external symbols that are defined in a particular
control section. The format is
Col 1 D
Col 2-7 name of external symbol defined in this control section
Col 8-13 relative address of the symbol with in this control section
Col 14-73 name and relative address for other external symbols.
25. Define modification record and give its format.
This record contains the information about the modification in the object code during
program relocation. The general format is
Col 1 M
Col 2-7 Starting location of the address field to be modified relative to the
beginning of the program
Col 8-9 length of the address field to be modified in half bytes.
26. What is the use of base register table in AIX assembler?
A base register table is used to remember which of the general purpose registers are
currently available as base registers and also the base addresses they contain. USING
statement causes entry to the table and .DROP statement removes the corresponding table
entry.
27. Differentiate absolute expression and relative expression.
Absolute Expression
If the result of the expression is an absolute value (constant) then it is known as
absolute expression. Eg: BUFEND – BUFFER
Relative Expression
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. Eg: BUFEND + BUFFER
28. Write the steps required to translate the source program to object program.
assembler? Pass 1
Since assembler will not know actual location where the program will get loaded, it
cannot make the necessary changes in the addresses used in the program. However, the
assembler identifies for the loader those parts of the program which need modification.
An object program that has the information necessary to perform this kind of modification
is called the relocatable program.
The above diagram shows the concept of relocation. Initially the program is
loaded at location 0000. The instruction JSUB is loaded at location 0006. The address
field of this instruction contains 01036, which is the address of the instruction labeled
RDREC. The second figure shows that if the program is to be loaded at new location
5000. The address of the instruction JSUB gets modified to new location 6036. Likewise
the third figure shows that if the program is relocated at location 7420, the JSUB
instruction would need to be changed to 4B108456 that correspond to the new address of
RDREC.
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. The
instructions which doesn’t require modification are the ones that is not a memory address
(immediate addressing) and PC-relative, Base-relative instructions. From the object
program, it is not possible to distinguish the address and constant. The assembler must
keep some information to tell the loader. The object program that contains the
modification record is called a relocatable program. For an address label, its address is
assigned relative to the start of the program (START 0). The assembler produces 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. The
Modification has the following format:
Modification record
Col. 1 M
Col. 2-7 Starting location of the address field to be modified, relative to the
beginning of the program (Hex)
Col. 8-9 Length of the address field to be modified, in half-bytes (Hex)
One modification record is created for each address 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
6. Explain in detail about the machine independent features of assembler. (May ’06)
Machine-Independent features: These are the features which do not depend on
the architecture of the machine. These are:
Literals
Expressions
Literals: A literal is defined with a prefix = followed by a specification of the literal
value. Example:
e.g. 45 001A ENDFIL LDA =C’EOF’ 032010
….
93 LTORG
002D * =C’EOF’ 454F46
The example above shows a 3-byte operand whose value is a character string EOF. The
object code for the instruction is also mentioned. It shows the relative displacement value of the
location where this value is stored. In the example the value is at location (002D) and hence the
displacement value is (010).
e.g. 215 1062 WLOOP TD =X’05’ E32011
As another example the given statement above shows a 1-byte literal with the
hexadecimal value “05”.
Literals vs. Immediate Operands: It is important to understand the difference between a
constant defined as a literal and a constant defined as an immediate operand.
In case of literals the assembler generates the specified value as a constant at some other
memory location.
e.g. 45 001A ENDFIL LDA =C’EOF’ 032010
In immediate mode the operand value is assembled as part of the instruction itself.
Example
e.g. 55 0020 LDA #3 010003
Literal Pool: All the literal operands used in a program are gathered together into one or more
literal pools. This is usually placed at the end of the program. The assembly listing of a program
containing literals usually includes a listing of this literal pool, which shows the assigned
addresses and the generated data values. In some cases it is placed at some other location in the
object program.
LTORG assembler directives: An assembler directive LTORG is used. Whenever the LTORG is
encountered, it creates a literal pool that contains all the literal operands used since the beginning
of the program. The literal pool definition is done after LTORG is encountered. It is better to
place the literals close to the instructions.
Literal Table: A literal table is created for the literals which are used in the program. The literal
table contains the literal name, operand value and length. The literal table is usually created as a
hash table on the literal name.
Implementation of Literals:
During Pass-1:
The literal encountered is searched in the literal table.
o If the literal already exists, no action is taken;
o if it is not present, the literal is added to the LITTAB and for the address value it
waits till it encounters LTORG for literal definition.
When Pass 1 encounters a LTORG statement or the end of the program, the assembler
makes a scan of the literal table.
At this time each literal currently in the table is assigned an address.
As addresses are assigned, the location counter is updated to reflect the number of bytes
occupied by each literal.
During Pass-2:
The assembler searches the LITTAB for each literal encountered in the instruction and
replaces it with its equivalent value as if these values are generated by BYTE or WORD.
If a literal represents an address in the program, the assembler must generate a
modification relocation for, if it all it gets affected due to relocation.
The following figure shows the difference between the SYMTAB and LITTAB
Symbol-Defining Statements:
EQU Statement: Most assemblers provide an assembler directive that allows the programmer to
define symbols and specify their values. The directive used for this EQU (Equate). The general
form of the statement is:
Symbol EQU value
where value can be: constant, other symbol, expression
This statement defines the given symbol (i.e., entering in the SYMTAB) and assigning to it the
value specified. One common usage is to define symbolic names that can be used to improve
readability in place of numeric values and there won’t be any forward reference
+LDT #4096
This loads the register T with immediate value 4096; this does not clearly what exactly
this value indicates.
If a statement is included as:
MAXLEN EQU 4096 and then
+LDT #MAXLEN
Then it clearly indicates that the value of MAXLEN is some maximum length value.
When the assembler encounters EQU statement, it enters the symbol MAXLEN along with its
value in the symbol table. During LDT the assembler searches the SYMTAB for its entry and its
equivalent value as the operand in the instruction. The object code generated is the same for both
the options discussed, but is easier to understand.
Another common usage of EQU statement is for defining values for the general-purpose
registers. The assembler can use the mnemonics for register usage like a-register A, X – index
register and so on. But there are some instructions which require numbers in place of names in the
instructions. For example in the instruction RMO 0, 1 instead of RMO A, X. The programmer can
assign the numerical values to these registers using EQU directive.
A EQU 0
X EQU 1 and so on
These statements will cause the symbols A, X, L… to be entered into the symbol table
with their respective values. An instruction RMO A, X would then be allowed.
As another usage if in a machine that has many general purpose registers named as R1,
R2,…, some may be used as base register, some may be used as accumulator. Their usage may
change from one program to another. In this case we can define these requirement using EQU
statements.
BASE EQU R1
COUNT EQU R2
INDEX EQU R3
One restriction with the usage of EQU is whatever symbol occurs in the right hand side of
the EQU should be predefined. For example, the following statement is not valid:
BETA EQU ALPHA
ALPHA RESW 1
As the symbol ALPHA is assigned to BETA before it is defined. The value of ALPHA is
not known.
ORG Statement: This directive can be used to indirectly assign values to the symbols. The
directive is usually called ORG (for origin). Its general format is:
ORG value
where value is a constant or an expression involving constants and previously defined symbols.
When this statement is encountered during assembly of a program, the assembler resets its
location counter (LOCCTR) to the specified value. Since the values of symbols used as labels are
taken from LOCCTR, the ORG statement will affect the values of all labels defined until the next
ORG is encountered. ORG is used to control assignment storage in the object program.
Sometimes altering the values may result in incorrect assembly.
ORG can be useful in label definition. Suppose there is a need to define a symbol table with the
following structure:
SYMBOL 6 Bytes
VALUE 3 Bytes
FLAG 2 Bytes.
The table looks like the one given below.
The symbol field contains a 6-byte user-defined symbol; VALUE is a one-word
representation of the value assigned to the symbol; FLAG is a 2-byte field specifies symbol type
and other information. The space for the table can be reserved by the statement:
STAB RESB 1100
The table entries can be referred using indexed addressing, place the offset value of the
desired entry from the beginning of the table in the index register. To refer to the fields SYMBOL,
VALUE, and FLAGS individually, the values should be assigned first as shown below:
SYMBOL EQU STAB
VALUE EQU STAB+6
FLAG EQU STAB+9
To retrieve the VALUE field from the table indicated by register X, we can write a
statement:
LDA VALUE, X
The same thing can also be done using ORG statement in the following way:
STAB RESB 1100
ORG STAB
SYMBOL RESB 6
VALUE RESW 1
FLAG RESB 2
ORG STAB+1100
The first statement allocates 1100 bytes of memory assigned to label STAB. In the second
statement the ORG statement initializes the location counter to the value of STAB. Now the
LOCCTR points to STAB. The next three lines assign appropriate memory storage to each of
SYMBOL, VALUE and FLAG symbols. The last ORG statement reinitializes the LOCCTR to a
new value after skipping the required number of memory for the table STAB (i.e., STAB+1100).
While using ORG, the symbol occurring in the statement should be predefined as is
required in EQU statement. For example for the sequence of statements below:
ORG ALPHA
BYTE1 RESB 1
BYTE2 RESB 1
BYTE3 RESB 1
ORG
ALPHA RESB 1
The sequence could not be processed as the symbol used to assign the new location
counter value is not defined. In first pass, as the assembler would not know what value to assign
to ALPHA, the other symbol in the next lines also could not be defined in the symbol table. This
is a kind of problem of the forward reference.
EXPRESSIONS: Assemblers also allow use of expressions in place of operands in the
instruction. Each such expression must be evaluated to generate a single operand value or address.
Assemblers generally arithmetic expressions formed according to the normal rules using
arithmetic operators +, - *, /. Division is usually defined to produce an integer result. Individual
terms may be constants, user-defined symbols, or special terms. The only special term used is *
( the current value of location counter) which indicates the value of the next unassigned memory
location. Thus the statement:
BUFFEND EQU *
Assigns a value to BUFFEND, which is the address of the next byte following the buffer
area. Some values in the object program are relative to the beginning of the program and some are
absolute (independent of the program location, like constants). Hence, expressions are classified
as either absolute expression or relative expressions depending on the type of value they produce.
Absolute Expressions: The expression that uses only absolute terms is absolute expression.
Absolute expression may contain relative term provided the relative terms occur in pairs with
opposite signs for each pair. Example: MAXLEN EQU BUFEND-BUFFER
In the above instruction the difference in the expression gives a value that does not
depend on the location of the program and hence gives an absolute immaterial of the relocation of
the program. The expression can have only absolute terms: MAXLEN EQU 1000
Relative Expressions: All the relative terms except one can be paired as described in “absolute”.
The remaining unpaired relative term must have a positive sign. Example:
STAB EQU OPTAB + (BUFEND – BUFFER)
Handling the type of expressions: to find the type of expression, we must keep track the
type of symbols used. This can be achieved by defining the type in the symbol table against each
of the symbol as shown in the table below:
7. Describe the design of one pass assembler. (Nov ’06 /May ’07)
One-Pass Assembler: The main problem in designing the assembler using single pass
was to resolve forward references. We can avoid to some extent the forward references
by: Eliminating forward reference to data items, by defining all the storage reservation
statements at the beginning of the program rather at the end. Unfortunately, forward
reference to labels on the instructions cannot be avoided. (forward jumping) To provide
some provision for handling forward references by prohibiting forward references to data
items. There are two types of one-pass assemblers: One that produces object code directly
in memory for immediate execution (Load-and-go assemblers). The other type produces
the usual kind of object code for later execution.
Load-and-Go Assembler:
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
o 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.
Forward Reference in One-Pass Assemblers: In load-and-Go assemblers when a forward
reference is encountered:
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
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
After scanning line 40 of the program:
40 2021 J CLOOP 302012
The status is that upto this point the symbol RREC is referred once at location
2013, ENDFIL at 201F and WRREC at location 201C. None of these symbols are
defined. The figure shows that how the pending definitions along with their addresses are
included in the symbol table.
If One-Pass needs to generate object code:
If the operand contains an undefined symbol, use 0 as the address and write the
Text record to the object program.
Forward references are entered into lists as in the load-and-go assembler.
When the definition of a symbol is encountered, the assembler generates another
Text record with the correct operand address of each entry in the reference list.
When loaded, the incorrect address 0 will be updated by the latter Text record
containing the symbol definition.
Algorithm for One pass Assembler
Begin
read first input line
if OPCODE = ‘START’ then
begin
save #[Operand] as starting addr
initialize LOCCTR to starting address
write line to intermediate file
read next input line
end( if START)
else
initialize LOCCTR to 0
While OPCODE != ‘END’ do
begin
if this is not a comment line then
begin
if there is a symbol in the LABEL field then
begin
search SYMTAB for LABEL
if found then
begin
if symbol value as null
set symbol value as LOCCTR and search the
linked list with the corresponding operand
PTR addresses and generates operand
addresses as corresponding symbol values
set symbol value as LOCCTR in symbol table and
delete the linked list
end
else
insert (LABEL, LOCCTR) into STMTAB
end
search OPTAB for OPCODE
if found then
begin
search SYMTAB for OPERND address
if found then
if symbol value not equal to null then
store symbol value as operand address
else
insert at the end of the linked list with a node with address as
LOCCTR
else
insert ( symbol name, null)
add 3 (instr length) to LOCCTR
end
else if OPCODE = ‘WORD’ then
add 3 to LOCCTR
else if OPCODE = ‘RESW’ then
add 3 * #[OPERAND] to LOCCTR
else if OPCODE = ‘RESB’ then
add #[OPERAND] to LOCCTR
else if OPCODE = ‘BYTE’ then
begin
find length of constant in bytes
add length to LOCCTR
convert constant to object code
end
if object code doesn’t fit into current Text record then
begin
Write text record to object program
initialize new Text record
end
add object code to Text record
end {if not comment}
write listing line
read next input line
end
write last text record to object pgm
write end record to object pgm
Write last listing line
end
8. Explain in detail about the machine dependent features of assembler. (May
’07)
MACHINE-DEPENDENT FEATURES:
a) Instruction formats and addressing modes
b) Program relocation
1. Instruction formats and Addressing Modes: The instruction formats depend on
the memory organization and the size of the memory. In SIC machine the memory
is byte addressable. Word size is 3 bytes. So the size of the memory is 2 12 bytes.
Accordingly it supports only one instruction format. It has only two registers:
register A and Index register. Therefore the addressing modes supported by this
architecture are direct, indirect, and indexed. Whereas the memory of a SIC/XE
machine is 220 bytes (1 MB). This supports four different types of instruction
types, they are:
1 byte instruction
2 byte instruction
3 byte instruction
4 byte instruction
Instructions can be:
Instructions involving register to register
Instructions with one operand in memory, the other in Accumulator (Single
operand instruction)
Extended instruction format
Addressing Modes are:
Index Addressing(SIC): Opcode m, x
Indirect Addressing: Opcode @m
PC-relative: Opcode m
Base relative: Opcode m
Immediate addressing: Opcode #c
Translations for the Instruction involving Register-Register addressing mode:
During pass 1 the registers can be entered as part of the symbol table itself.
The value for these registers is their equivalent numeric codes.
During pass 2, these values are assembled along with the mnemonics object
code. If required a separate table can be created with the register names and
their equivalent numeric values.
Translation involving Register-Memory instructions:
In SIC/XE machine there are four instruction formats and five addressing modes.
For formats and addressing modes refer chapter 1. Among the instruction formats, format
-3 and format-4 instructions are Register-Memory type of instruction. One of the operand
is always in a register and the other operand is in the memory. The addressing mode tells
us the way in which the operand from the memory is to be fetched.
There are two ways: Program-counter relative and Base-relative. This addressing
mode can be represented by either using format-3 type or format-4 type of instruction
format. In format-3, the instruction has the opcode followed by a 12-bit displacement
value in the address field. Where as in format-4 the instruction contains the mnemonic code
followed by a 20-bit displacement value in the address field.
Program-Counter Relative: In this usually format-3 instruction format is used. The instruction
contains the opcode followed by a 12-bit displacement value. The range of displacement values
are from 0 -2048. This displacement (should be small enough to fit in a 12-bit field) value is
added to the current contents of the program counter to get the target address of the operand
required by the instruction. This is relative way of calculating the address of the operand relative
to the program counter. Hence the displacement of the operand is relative to the current program
counter value. The following example shows how the address is calculated:
Base-Relative Addressing Mode: In this mode the base register is used to mention the
displacement value. Therefore the target address is TA = (base) + displacement value This
addressing mode is used when the range of displacement value is not sufficient. Hence the
operand is not relative to the instruction as in PC-relative addressing mode. Whenever this mode
is used it is indicated by using a directive BASE. The moment the assembler encounters this
directive the next instruction uses base-relative addressing mode to calculate the target address of
the operand.
When NOBASE directive is used then it indicates the base register is no more used to
calculate the target address of the operand. Assembler first chooses PC-relative, when the
displacement field is not enough it uses Base-relative.
LDB #LENGTH (instruction)
BASE LENGTH (directive)
:
NOBASE
For example:
12 0003 LDB #LENGTH 69202D
13 BASE LENGTH
::
100 0033 LENGTH RESW 1
105 0036 BUFFER RESB 4096
::
160 104E STCH BUFFER, X 57C003
165 1051 TIXR T B850
In the above example the use of directive BASE indicates that Base-relative addressing
mode is to be used to calculate the target address. PC-relative is no longer used. The value of the
LENGTH is stored in the base register. If PC-relative is used then the target address calculated is:
The LDB instruction loads the value of length in the base register which 0033. BASE
directive explicitly tells the assembler that it has the value of LENGTH.
BUFFER is at location (0036)16
(B) = (0033)16
disp = 0036 – 0033 = (0003)16
20
000A
L D A
LENGTH 032026
::
175 1056 EXIT STX LENGTH 134000
Consider Line 175. If we use PC-relative
Disp = TA – (PC) = 0033 –1059 = EFDA
PC relative is no longer applicable, so we try to use BASE relative addressing mode.
Immediate Addressing Mode: In this mode no memory reference is involved. If immediate mode
is used the target address is the operand itself.
If the symbol is referred in the instruction as the immediate operand then it is immediate with
PC-relative mode as shown in the example below:
Indirect and PC-relative mode: In this type of instruction the symbol used in the
instruction is the address of the location which contains the address of the operand. The
address of this is found using PC-relative addressing mode. For example:
The instruction jumps the control to the address location RETADR which in turn has the
address of the operand. If address of RETADR is 0030, the target address is then 0003 as
calculated above.
2. Program relocation:
Sometimes it is required to load and run several programs at the same time. The
system must be able to load these programs wherever there is place in the memory.
Therefore the exact starting is not known until the load time.
Absolute Program: In this the address is mentioned during assembling itself.
This is called Absolute Assembly. Consider the instruction:
55 101B LDA THREE 00102D
This statement says that the register A is loaded with the value stored at location
102D. Suppose it is decided to load and execute the program at location 2000 instead of
location 1000. Then at address 102D the required value which needs to be loaded in the
register A is no more available. The address also gets changed relative to the displacement
of the program. Hence we need to make some changes in the address portion of the
instruction so that we can load and execute the program at location 2000. Apart from the
instruction which will undergo a change in their operand address value as the program
load address changes. There exist some parts in the program which will remain same
regardless of where the program is being loaded.
Since assembler will not know actual location where the program will get loaded,
it cannot make the necessary changes in the addresses used in the program. However, the
assembler identifies for the loader those parts of the program which need modification.
An object program that has the information necessary to perform this kind of modification
PART-A:
1. Define loader.
Loading brings the object program into memory for execution. A loader is a
system program that performs the loading function. Many loaders also support relocation
and linking.
2. What is a bootstrap Loader? (Nov/Dec 2005)
When a computer is turned on or restarted, a special type of absolute loader, called
a bootstrap loader is executed. This bootstrap loader in-turn loads the operating system.
The operating system then calls the loader to load the executable programs that is ready
for execution into memory and executes them.
3. What is the use of linkage editor? (Nov/Dec 2005)
Linkage editor can be used to replace old version of subroutine by new subroutine
without affecting the original version of all the other subroutine.
It simply prepares an object program for execution
Linkage editor can also be used to build packages old subroutines or other control
sections that are generally bused together. This can useful in dealing with
subroutine libraries that support high-level programming language.
4. What is the function of MS-DOS LINK? (May/June 2006)
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 name
extension .Exe. MS-DOS Link can also combine the translated programs with other
modules from object code libraries.
5. Mention the use of FIXUPP records. (Nov/Dec 2006)
FIXUPP records are used to resolve external references, and to carry out address
modifications that are associated with relocation and grouping of segments within the
program. This is similar to the function performed by the SIC/XE modification records.
6. What are the advantages of dynamic linking? (May/June 2007)
i) Dynamic linking allows several programs to share one copy of subroutine
or library.
ii) Dynamic linking avoids necessity of loading the entire library for each
execution.
iii) In an object oriented system, dynamic linking is often used for reference of
software objects
iv) Dynamic linking provides the ability to load the routines only when they
are needed.
7. What is the function of Pass2 of loader? (May/June 2007)
Pass2 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.
8. What is the function of a linkage editor? (May/June 2006)
Linkage editor performs linking prior to load time and some relocation. Linkage
editor produces a linked version of the program often called a load module or an
executable image, which is written to a file or library for later execution.
9. Define the processes allocation, loading, linking, and relocation.
Allocation: Allocate space in memory for the programs.
Loading: Physically place the machine instructions and data into memory.
Linking: Combines two or more separate object programs and resolves symbolic
references between them.
Relocation: Modifies all address dependent locations in the object program so that
it can be loaded at the allocated space.
10. Define program relocation.
It is the task of adjusting programs so that they may be placed in arbitrary memory
locations. Relocation Modifies all address dependent locations in the object program so
that it can be loaded at the allocated space.
24. What are the disadvantages of absolute loader or machine dependent loader?
i) The program has to specify the actual address (i.e.) at which the object code will
be loaded into memory.
ii) The starting address of the program should be known in advance. On larger and
more advanced machines this is not easy.
25. List outs the various design options of a loader.
Linking loader
Linkage editors
Dynamic Linking
Bootstrap loaders
26. What is a load map?
Many loaders include an option to print, which is called as a load map. The Load
map values are same as ESTAB.
Dynamically
loaded must
be called via an
operating system service request
o dynamic loader is one part of the OS
o Instead of executing a JSUB instruction that refers to an external
symbol, the program makes a load-and-call service request to the
OS
Load-and-call service
o OS examines its internal tables to determine whether or not the
routine is already loaded
o Routine is loaded from library
o Control is passed from OS to the called subroutine
o Subroutine is finished
o Calling to a subroutine which is already in memory
Dynamic Linking: Binding of the name to an actual address is delayed
from load time until execution time.
3. Explain the design of relocating loader with an example. (May/June 2006)
Motivation
efficient sharing of the machine with larger memory and when several
independent programs are to be run together
support the use of subroutine libraries efficiently
Two methods for specifying relocation
a) modification record
b) relocation bit
i. each instruction is associated with one relocation bit
ii. these relocation bits in a Text record is gathered into bit masks
1. Modification record
col 1: M
col 2-7: relocation address
col 8-9: length (halfbyte)
col 10: flag (+/-)
col 11-17: segment name
E.g M^000007^05
Pass the address – modification information to the relocatable loader
Beginning address of the program is to be added to a field that begins at addr
ox000007 and is 5 bytes in length.
2. relocation bit
For simple machines
Relocation bit
o 0: no modification is necessary
o 1: modification is needed
Twelve-bit mask is used in each Text record
o since each text record contains less than 12 words
o unused words are set to 0
o any value that is to be modified during relocation must coincide
with one of these 3-byte segments
4. Write short notes on (May/June 2006)
i) Linkage editor
A linking loader performs
All linking and relocation operations
Automatic library search
Loads the linked program directly into memory for execution
A linkage editor
Produces a linked version of program (often called a load module or
an executable image), which is written to a file or library for later
execution
A simple relocating loader can be used to load the linked version of
program into memory
o The loading can be accomplished in one pass with no external
symbol table required
Resolution of external references and library searching are only
performed once
In the linked version of programs
o All external references are resolved, and relocation is
indicated by some mechanism such as modification records
or a bit mask
External references is often retained in the linked program
o To allow subsequent relinking of the program to replace
control sections, modify external references, etc.
5. Explain the different machine dependent loader features in detail. (Nov/Dec
2006)
Machine-Dependent Loader Features
Absolute loader is simple and efficient, but the scheme has potential disadvantages
.One of the most disadvantage is the programmer has to specify the actual starting
address, from where the program to be loaded. This does not create difficulty, if one
program to run, but not for several programs. Further it is difficult to use subroutine
libraries efficiently.
This needs the design and implementation of a more complex loader. The loader
must provide program relocation and linking, as well as simple loading functions
Relocation:
The concept of program relocation is, the execution of the object program using
any part of the available and sufficient memory. The object program is loaded into
memory wherever there is room for it. The actual starting address of the object program is
not known until load time. Relocation provides the efficient sharing of the machine with
larger memory and when several independent programs are to be run together. It also
supports the use of subroutine libraries efficiently. Loaders that allow for program
relocation are called relocating loaders or relative loaders.
Methods for specifying relocation
Use of modification record and,
Use of relocation bit, are the methods available for specifying
relocation.
Modification Record:
In the case of modification record, a modification record M is used in the object
program to specify any relocation. Modification records are used in complex machines
and are also called Relocation and Linkage Directory (RLD) specification. The format of
the modification record (M) is as follows. The object program with relocation by
Modification records is also shown here.
Modification record
col 1: M
col 2-7: relocation address
col 8-9: length (halfbyte)
col 10: flag (+/-)
col 11-17: segment name
E.g M^000007^05
Pass the address – modification information to the relocatable loader
Beginning address of the program is to be added to a field that begins at addr
ox000007 and is 5 bytes in length
Relocation Bit:
In the case of use of relocation bit, each instruction is associated with one
relocation bit and, these relocation bits in a Text record is gathered into bit masks.
The relocation bit method is used for simple machines.
Relocation bit is
o 0: no modification is necessary, and
o 1: modification is needed.
This is specified in the columns 10-12 of text record (T), the format of text record,
along with relocation bits is as follows.
Text record
col 1: T
col 2-7: starting address
col 8-9: length (byte)
col 10-12: relocation bits
col 13-72: object code
Twelve-bit mask is used in each Text record (col:10-12 – relocation bits), since
each text record contains less than 12 words, unused words are set to 0, and, any
value that is to be modified during relocation must coincide with one of these 3-
byte segments.
For absolute loader, there are no relocation bits column 10-69 contains object
code.
The object program with relocation by bit mask is as shown below.
Observe FFC - means all ten words are to be modified and, E00 - means first three
records are to be modified.
Program Linking:
The Goal of program linking is to resolve the problems with external references
(EXTREF) and external definitions (EXTDEF) from different control sections.
EXTDEF (external definition) - The EXTDEF statement in a control section names
symbols, called external symbols, that are defined in this (present) control section and
may be used by other sections. ex: EXTDEF BUFFER, BUFFEND, LENGTH EXTDEF
LISTA, ENDA
EXTREF (external reference) - The EXTREF statement names symbols used in this
(present) control section and are defined elsewhere.
ex: EXTREF RDREC, WRREC
EXTREF LISTB, ENDB, LISTC, ENDC
How to implement EXTDEF and EXTREF
The assembler must include information in the object program that will cause the
loader to insert proper values where they are required – in the form of Define record (D)
and, Refer record(R).
Define record: The format of the Define record (D) along with examples is as shown
here.
Col. 1 D
Col. 2-7 Name of external symbol defined in this control section
Col. 8-13 Relative address within this control section (hexadecimal)
Col.14-73 Repeat information in Col. 2-13 for other external symbols
Example records
D LISTA 000040 ENDA 000054
D LISTB 000060 ENDB 000070
Refer record: The format of the Refer record (R) along with examples is as shown here.
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
Example records
R LISTB ENDB LISTC ENDC
R LISTA ENDA LISTC ENDC
R LISTA ENDA LISTB ENDB
Here are the three programs named as PROGA, PROGB and PROGC, which are separately
assembled and each of which consists of a single control section. LISTA, ENDA in PROGA,
LISTB, ENDB in PROGB and LISTC, ENDC in PROGC are external definitions in each of the
control sections. Similarly LISTB, ENDB, LISTC, ENDC in PROGA, LISTA, ENDA, LISTC,
ENDC in PROGB, and LISTA, ENDA, LISTB, ENDB in PROGC, are external references.
Program Logic for Pass 2: Pass 2 of linking loader perform the actual loading, relocation, and
linking. It uses modification record and lookup the symbol in ESTAB to obtain its addres. Finally
it uses end record of a main program to obtain transfer address, which is a starting address needed
for the execution of the program. The pass 2 process Text record and Modification record
7. Write notes in MS-DOS Linker. (Nov/Dec 2006)
MS-DOS Linker This explains some of the features of Microsoft MS-DOS linker, which
is a linker for Pentium and other x86 systems. Most MS-DOS compilers and assemblers (MASM)
produce object modules, and they are stored in .OBJ files. MS-DOS LINK is a linkage editor that
combines one or more object modules to produce a complete executable program - .EXE file; this
file is later executed for results.
The following table illustrates the typical MS-DOS object module
» THEADER similar to Header record in SIC/XE
» MODEND similar to End record in SIC/XE
» TYPDEF data type
» PUBDEF similar to Define record in SIC/XE
» EXTDEF similar to Reference record in SIC/XE
» LNAMES contain a list of segments and class names
» SEGDEF segment define
» GRPDEF specify how segments are grouped
» LEDATA similar to Text Record in SIC/XE
» LIDATA specify repeated instructions
» FIXUPP similar to Modification record in SIC/XE
THEADR specifies the name of the object module. MODEND specifies the end of the
module. PUBDEF contains list of the external symbols (called public names). EXTDEF contains
list of external symbols referred in this module, but defined elsewhere. TYPDEF the data types
are defined here. SEGDEF describes segments in the object module ( includes name, length, and
alignment). GRPDEF includes how segments are combined into groups. LNAMES contains all
segment and class names. LEDATA contains translated instructions and data. LIDATA has above
in repeating pattern. Finally, FIXUPP is used to resolve external references.
Suppose that the SIC assembler language is changed to include a new form of the
RESB statement, such as
RESB n‘c’
which reserves n bytes of memory and initializes all of these bytes to the character
‘c’. For example
BUFFER RESB 4096‘ ’
This feature could be implemented by simply generating the required number of
bytes in Text records. However, this could lead to a large increase in the size of
the object program.
Pass 1
» compute a starting address for each segment in the program
– segment from different object modules that have the same segment
name and class are combined
– segments with the same class, but different names are concatenated
– a segment’s starting address is updated as these combinations and
concatenations are performed
Pass 2
» extract the translated instructions from the object modules
» build an image of the executable program in memory
» write it to the executable (.EXE) file
8. Write short notes on Bootstrap loader.
When a computer is first turned on or restarted, a special type of absolute
loader must be executed (stored in ROM on a PC).
The bootstrap loader loads the first program to be run by the computer –
usually the operating system, from the boot disk (e.g., a hard disk or a floppy
disk)
It then jumps to the just loaded program to execute it.
Normally, the just loaded program is very small (e.g., a disk sector’s size, 512
bytes) and is a loader itself.
The just loaded loader will continue to load another larger loader and jump to
it.
This process repeats another the entire large operating system is loaded.
The algorithm for the bootstrap loader is as follows
Begin
X=0x80 (the address of the next memory location to be loaded
Loop
A←GETC (and convert it from the ASCII character code to the value of
the hexadecimal digit)
save the value in the high-order 4 bits of S
A←GETC
combine the value to form one byte A← (A+S)
store the value (in A) to the address in register X
X←X+1
End
It uses a subroutine GETC, which is
GETC A←read one character
if A=0x04 then jump to 0x80
if A<48 then GETC
A ← A-48 (0x30)
if A<10 then return
A ←A-7 return
9. Write short notes on absolute loader.
Characteristics of absolute loader:
o No linking and relocation needed
o Records in object program perform
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
o End record: Transfer control to the address specified in the End record
Algorithm for absolute loader:
Begin
read Header record
verify program name and length
read first Text record
while record type is not ‘E’ do
begin
{if object code is in character form, convert into internal representation}
move object code to specified location in memory
read next object program record
end
jump to address specified in End record
end
Advantage
o Simple and efficient
Disadvantage
o the need for programmer to specify the actual address difficult to use
subroutine libraries
UNIT IV
MACRO PROCESSORS
Stmt 1
Stmt 2
.
. Macro body
.
Stmt n
MEND
A Macro call leads to Macro expansion. A macro is called by specifying the macro
name in the mnemonic field of an assembly statement. The macro call has the syntax
<Macro name> [actual parameters]
During macro expansion the macro call statement is replaced by a sequence of
assembly statements given in the body of the macro with the arguments of the call
substituted for the parameters in the macro prototype.
3. List the statements present in a macro definition. (Nov/Dec 2005)
The structure of macro definition is
Macro name MACRO Parameters
Two assembler directives (MACRO and MEND) are used in macro
definitions.
The first MACRO statement identifies the beginning of macro definition.
Symbol in the label field is the name of the macro.
Entries in the operand field identify the parameters of the macro
instruction.
The MEND assembler directive marks the end of the macro definition.
4. Define Macro call / Macro invocation statement.
A Macro call leads to Macro expansion. A macro is called by specifying
the macro name in the mnemonic field of an assembly statement. The macro call
has the syntax
<Macro name> [actual parameters]
Eg: RDBUFF F1, BUFFER, LENGTH
During macro expansion the macro call statement is replaced by a sequence of
assembly statements given in the body of the macro with the arguments of the call
substituted for the parameters in the macro prototype.
5. Give the difference between macro invocation and subroutine call?
Macro:
The statements that form the expansion of the macro are generated
each time the macro is invoked.
The generated assembly code size is increased due to duplication of
macro statements during expansion.
Occupies more space in memory.
Sequential execution of statements
Subroutine:
Statements in a subroutine appears only once regardless of how many
times the subroutine is called
Occupies less space in memory.
Incurs more cost due to context switching
6. Compare one pass and two pass macro processor.
Two-pass macro processor
Pass1: process all macro definitions
Pass2: expand all macro invocation statements
Problem
Does not allow nested macro definitions
One-pass macro processor
Every macro must be defined before it is called
One-pass processor can alternate between macrodefinition and
macro expansion
Nested macro definitions are allowed
7. What is a nested macro call? How is it expanded? (Nov/Dec 2005)
Macro call within another macro definition is called nested macro call. In
the expansion of the macro, the ARGTAB is filled with the macro parameters. If
you encounter a nested macro call, the nested macro is expanded by replacing the
previous contents of ARGTAB by new macro parameters. Whenever the nested
macro encounters a MEND stmt, all the macro expansions are abruptly
terminated.
To overcome this, if the language supports recursion, the compiler will
save the return address otherwise use the stack to store the return address.
8. What is the necessity of a Macro? (May/June 2006)
A macro represents a commonly used group of statements in the source
programming language. Macroinstructions allow the programmer to write a
shorthand version of a program.
9. Write the significance of concatenation operator.
Macro processors allow parameters to be concatenated with other
characters. The macro processor uses concatenation operator ‘ ->’ to represent the
symbol.
For eg, the following macro does the addition of 5 numbers
SUM MACRO &ID
LDA X&ID->1
LDA X&ID->2
LDA X&ID->3
LDA X&ID->4
LDA X&ID->5
MEND
10. How do macro processors avoid the problem of longer jumps spanning
several instructions?
To avoid the problem of longer jumps spanning several
instructions, macro processor allows the generation of unique labels within
macros.
The labels within macro begins with $ and is replaced by $XX where XX
is a two character alphanumeric counter of the no of macro instructions expanded.
For 3 invocations, the labels generated will be AA, AB, AC
11. What is meant by macro time variable?
A symbol that begin with ‘&’ and that is not a macro parameter is assumed
to be macro time variable. Macro time variable often called set statement or set
symbol is used to store working values during the macro expansion.
12. How does Macro affect program development? (May/June 2006)
The object program obtained from source program has the repeated
programming statement because macro substituted the code where it is called instead
of dumping to location.
Conditional statements
5. State and explain the algorithm for one pass macro processor.
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.
Restriction
The definition of a macro must appear in the source program before any
statements that invoke that macro.
This restriction does not create any real inconvenience.
The design considered is for one-pass assembler. The data structures required are:
DEFTAB (Definition Table)
Stores the macro definition including macro prototype and macro body
Comment lines are omitted.
References to the macro instruction parameters are converted to a positional
notation for efficiency in substituting arguments.
Pointers to the beginning and the end of the macro definition (DEFTAB)
NAMTAB (Name Table)
Stores macro names
Serves as an index to DEFTAB
ARGTAB (Argument Table)
Stores the arguments according to their positions in the argument list.
As the macro is expanded the arguments from the Argument table are
substituted for the corresponding parameters in the macro body.
The figure below shows the different data structures described and their
relationship
Algorithm:
6. Explain the functions of two pass macro processor.
Two-pass macro processor
o Two-pass macro processor
o Pass1: process all macro definitions
o Pass2: expand all macro invocation statements
o Problem
Does not allow nested macro definitions
o Nested macro definitions
o The body of a macro contains definitions of other macros
Because all macros would have to be defined during the
first pass before any macro invocations were expanded
o Solution
One-pass macro processor
Text editors - Overview of the Editing Process - User Interface – Editor Structure. -
Interactive debugging systems - Debugging functions and capabilities – Relationship
withother parts of the system – User-Interface Criteria.
PART A:
1. What is an interactive editor?
An interactive editor is a computer program that allows a user to create and
revise a target document.
2. What is filtering?
Traveling specifies where the area of interest is, filtering controls the
selection of what is to be viewed and manipulated there. Filtering extracts the
relevant subset of target document at the point of interest, such as the next screen
full of text or the next statement.
3. What is the purpose of formatting?
Formatting determines how the result of the filtering will be seen as a visible
representation on a display screen or other device.
4. What is a placeholder? (Nov/Dec 2005)
A placeholder is a term, sign or some other thing which generally stands in the
place of content which is unknown or not identified. The placeholder concept is
represented by free variables and bound variables.
5. What is a command language processor?
The command language processor accepts input from the user’s input device and
analyses the tokens and syntactic structures of the commands. They may also invoke
semantic routines directly. In a text editor they perform the functions such as editing and
viewing.
6. What are the roles of a dialog manager? (Nov/Dec 2005)
Sentence generation from concept representation concerning the dialog
context.
Topic identification for spoken dialog understanding
The dialog manager in the interface has roles of determining the surface
sentence of the output message taking account of the dialog context.
7. What is the important of user interface? (May/June 2006)
It is interface where great deal of information can be displayed
Information can be changed easily and quickly
With menus and full screen editors, the user has far less information to
enter and remember
8. What is a window?
The viewing buffer is passed to the display component which produces a
display by mapping the buffer to a rectangular subset of the screen usually called a
window.
9. What are the various functions of a debugger? (May/June 2006)
Break points
Gaits
Tracing
Trace back
10. What is a terminal control database?
Instead of having explicitly terminal control sequences in display routine,
these editors simply call terminal independent library routines. These library routines
use the terminal control database to look up the appropriate control sequences for a
particular terminal.
11. What is an interactive debugging system?
An interactive debugging system provides programmers with facilities that
aid in testing and debugging of programs.
12. What are editor paging routines?
Editor page routines are one that read one or more logical portions of a document
into memory as needed. Such portions are termed as pages.
13. Write the tasks accomplished by the document editing process. (Nov/Dec
2006)
There are four tasks.
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 approximately
14. What are gaits?
The programmer can define conditional expressions that are continually
evaluated during the debugging session. Program execution is suspended if any of
these conditions become true. Given a good graphical representation of the
program process, it may be even useful to run the program at various speeds,
called gaits.
15. What do you mean by tracing? (Nov/Dec 2006)
Tracing is a function provided by a debugging system that can be used to track
the flow of execution at different levels of details, procedures, branch, individual
instructions and so on.
16. What are the input devices and how are they divided?
Input devices are used to enter elements of text being edited, to enter
commands to designate editable elements.
Input devices are divided into three categories.
Text devices
Button devices
Locator devices
Voice input devices
17. What is the purpose of voice input device?
It is a type of input device. It translates spoken words to their textual
equivalents.
18. What are the main features that highlight the relationship of the debugger
with other parts of the system?
A debugger
Must communicate and co-operate with other parts of OS such as
interactive sub systems
Must support debugging at any instance during the runtime
Must be consistent with the security and integrity of the system
Must be subject to normal authorization mechanisms and leave audit trials
Must co-ordinate its activities with the present generation compilers and
interpreters and as well as future language compilers
19. What must be the features of command language?
It must be flexible, clear, logical and simple syntax
Must contain very few parameters
Must contain default for parameters
20. How the mapping of view buffer to a window is done? (May/June 2006)
The mapping of view buffer to a window is done with two components.
They are
Viewing component formulates as ideal view
Display component maps to the physical output device.
PART B:
1. With neat block diagram, explain the different components of an editor
structure. (Nov/Dec 2005)
Editing Editing
component buffer
Editing
filter
Traveling Main
component memory
input Command
language Viewing
processor Viewing Viewing filter
component buffer
Paging
Routines
Output
devices Display File
component system
Control
Data
Typical Editor Structure
The command Language Processor
Editing Component
Traveling Component
Viewing Component
Display Component
Editing Filter
Editing Buffer
Viewing Filter
Viewing Buffer
2. Discuss about an interactive debugging system. (Nov/Dec 2005)
Debugging Functions and Capabilities
Relationship with Other Parts of the System
3. Explain the various types of user interfaces. (May/June 2006)
The Screen-editor
line editors
Input Devices :
a. Text devices
b. Button devices
c. Locator devices
Output devices
Interaction Language
a. The typing oriented or text command-oriented method
b. Menu oriented interfaces
c. Function key interfaces :
4. Discuss the nature of the user interface for an interactive debugger.
(May/June 2006)
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. 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.
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
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…
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,
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.
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.
Display of source code: 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.
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.
5. Explain in detail about the editing process.
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 arts 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 task:
1) Select the part of the target document to be viewed and manipulated
2) Determine how to format this view on-line and how to display it.
3) Specify and execute operations that modify the target document.
4) 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 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.Manuscript oriented
editors operate on elements such as single characters,words,lines,sentences,and
paragraphs;Program-oriented editors operates on elements such as identifiers,key
words and statements