0% found this document useful (0 votes)
148 views

SS Question Bankss

The document contains questions and answers related to system software topics like SIC/XE architecture, assembler directives, and assembly language programming. Specifically, it discusses features like registers, instruction formats, addressing modes, the purpose of assembler directives, symbol tables, and functions of the assembler. The questions are part of a question bank for a subject on system software.

Uploaded by

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

SS Question Bankss

The document contains questions and answers related to system software topics like SIC/XE architecture, assembler directives, and assembly language programming. Specifically, it discusses features like registers, instruction formats, addressing modes, the purpose of assembler directives, symbol tables, and functions of the assembler. The questions are part of a question bank for a subject on system software.

Uploaded by

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

WWW.VIDYARTHIPLUS.

COM

SUDHARSAN ENGINEERING COLLEGE,


Sathiyamangalam-

Subject : SYSTEM SOFTWARE Subject Code : CS 2304

Academic Year : 2013 - 2014 Semester : V

Name of the Faculty :C.VENNILA Question Bank

Part – A
Unit – 1

1.A.1. What is use of SVC instruction in SIC.


Executing Supervisor call instruction( SVC) generates an interrupt that can be used
for Communication with the operating system.

1.A.2. What are the additional registers provided in SIC/XE then SIC
Mnemonic Number Special Use
B 3 Base register, used for addressing
S 4 General working register, no special Use
T 5 General working register , no special use
F 6 Floating-point accumulator(48 bits)

1.A.3. What is the purpose of test device instruction?


The test device (TD) instruction tests whether the addressed device is ready to send
or receive a byte of data.

1. A.4. How is a floating point value represented using exponent in SIC?


There is a floating point hardware on the standard version of SIC. 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 numbe represented is
f * 2 (e – 1024)

1. A.5. Define upward compatibility in systems.


An object of a lower version of machine will also execute properly on higher version of a
Machine. This property is called as upward compatibility in systems.
(e.g) An object program for the standard SIC machine will also execute properly on a
SIC/XE system.

1. A.6 Distinguish between direct addressing and indirect addressing.


Mode Indication Target address calculation Example
Direct X=0 TA = address LDA TEN
Indexed X=1 TA = address + (x) BUFFER,X
(x)->contents of register x.
WWW.VIDYARTHIPLUS.COM

1. A.7. What is the need for a modification record?


Modification record is needed as part of the object program that command the loader to
perform relocation at the time of loading, by adding the beginning address of the program
to the address field specified.

1. A.8 Draw the instruction formats of SIC computer.


All machine instructions on the standard version of SIC have the 24-bit format as follows

8 1 15

Opcode
X Address

Format 1 (1 byte)

8
Opcode

Format 2 (2 bytes)
8 4 4
OP R1 R2

R1 – register 1
R2 – register 2

Format 3 (3 bytes)
6 1 1 1 1 1 1 12
OP N i x b p e disp

n,i,x,p,b, p – flags used to have different addressing modes.


e = 0 – format 3
disp – displacement to calculate the relative values.

Format 4 ( 4 bytes)
6 1 1 1 1 1 1 12
OP N i x b p e address
WWW.VIDYARTHIPLUS.COM

e=1
address – Target address

1. A.9 What are the different registers used in SIC?


A 0 Accumulator, used for arithmetic operations
X 1 Index register used for addressing.
L 2 Linkage register, the JSUB instruction stores the
return address in this register.

PC 8 Program counter, contains the address of the next


instruction to be fetched for execution.
SW 9 Status word, contains a variety of information
including a Condition code(CC)

1.A.10. What is base relative addressing?


The target address is calculated as
TA=(B) + disp
Where (B) – content of base register and
disp - displacement
Base relative also sets the flags b=1 and p=0. The instruction that uses base relative
addressing is format 3 (3 byte) instruction.

1. A.11 Define system software


It consists of variety of programs that supports the operation of the computer. This
software makes it possible for the user to focus on the other problems to be solved with
out needing to know how the machine works internally.
Eg: operating system, assembler, loader.

1. A.12 write the abbreviation for the following:


(a)SIC b)XE C) CISC D)RISC
 Complex Instruction Set Computers
 Reduced Instruction Set Computer
 Simplified Instructional Computer
 Simplified Instructional Computer extra expensive

1.A.13 Write any two assembler directives used by SIC/XE.


START: Specify name and starting address for the program.
• END : Indicate the end of the source program and specify the first executable
instruction in the program.
• BYTE: Generate character or hexadecimal constant, occupying as many bytes as
needed to represent the constant.
WWW.VIDYARTHIPLUS.COM

• WORD: Generate one- word integer constant.


• RESB: Reserve the indicated number of bytes for a data area.
• RESW: Reserve the indicated number of words for a data area.

1.A.14 Write a SIC code to copy an 11 byte character string to another.

Part – A Unit – 2

2.A.1 .Define multiprogramming


Interleaving of CPU & IO operation is called multiprogramming. In other words load and
run several programs at the same time. This kind of sharing of the machine between programs
is called multiprogramming.

2.A.2 What is a program block


» 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
» Example: Figure 2.11
» Each program block may actually contain several separate segments of the
source program

2.A.3 What is the need for an assembler directive?


These are the statements that are not translated into machine instructions, but they
provide instructions to assembler itself.
example : START,END,BYTE,WORD,RESW and RESB.

2.A.4 What is the true of LOCCTR(Location Counter)?


WWW.VIDYARTHIPLUS.COM

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 statement. After each source
statement 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 to be associated with that label.
2.A.5. Consider the following sequence
W EQU Y
Y EQU Z
Z RESW 1
Is a two pass assembler can resolve such a sequence of definition? Justify your answer.
No. The symbol Y cannot be assigned a value when it is encountered during the first pass
because Z has not yet been defined. As a result, X cannot be evaluated during the second
pass. This means that any assembler that makes only two sequential passes over the source
program cannot resolve such a sequence of definitions.

2.A.6. What is the data structure used to organize the symbol table and operation code table
in a simple assembler? Why it is preferred?
Hash function base data structures are used to organize the symbol table. Hash
function used to perform well with non-random keys. Division of the entire key by a prime
table length gives good results.

2.A.7. Can an assembler have a single pass? What are the advantages and limitations?
Single Pass Assembler
A single pass assembler scans the program only once and creates the equivalent binary
program. The assembler substitute all of the symbolic instruction with machine code in one
pass.
Advantages
Every source statement needs to be processed once.
Disadvantages
We cannot use any forward reference in our program.

2.A.8. What are the functions of EXTREF and LTORG assembler directives.
When the assembler encounters a LTORG statements, it creates a literal pool that
contains all of the literal operands used since the previous LTORG. This literal
pool is placed in the object program at the location where the LTORG directive
was encountered

2.A.9. What is a symbol table? How is it useful.


The symbol table is an internal, dynamic table that is generated, maintained,
and use by the assembler. Each entry in the table contains the definition of a
symbol and has fields for the name, value, and type of the symbol. Some symbol
tables contain other information about the symbols. The symbol table starts
WWW.VIDYARTHIPLUS.COM

empty, labels and entered into it as their definitions are found in the source, and the
table is also searched frequently to find the values and types of symbols whose
names are known.

2.A.10. How are jump instructions assembled?


Jump instructions
– do not change flags.
Unconditional jumps
Jump
• near – the target label is in the same segment than the
jump
• far – jump to another code segment
Direct jump

2.A.11 Distingush between assembler and interpreter


Assembler is a software which converts assembly language program into machine language
program.
Compiler is a set of program which converts the whole high level language program
to machine language program.
Interpreter is a set of programs which converts high level language program to
machine language program line by line.

2.A.12. What do you mean by literal


It is convenient for the programmer to be able to write the value of a constant
operand as a part of the instruction that uses it. This avoids having to define the
constant elsewhere in the program and make up a label for it.

2.A.13 What is program relocation?


Program relocation is the process of modifying the addresses sued in the
address sensitive instructions of the program such that the program can execute
correctly from a designated area of the memory.

2.A.14 How literal differs from immediate operand?


Literal is a constant that is written as a part of the instruction. It
avoids storing a constant in the memory and using a label for it in
the instruction.the assembler generates the specified value as a constant at some other
memory locatin.the address of the generated constant is used as the target address for the
machine instruction.
Part – A Unit – 3
3.A.1 . What is a Bootstrap loader
A small program written and stored in the ROM initially loads the operating
WWW.VIDYARTHIPLUS.COM

system from secondary storage to main memory. The operating system then takes
the overall control. This program which is responsible for booting up the system
is called bootstrap loader

3.A.2 What is the use of linkage editor?


The binder which performs the linking function and produces adequate
information about allocation and relocation and writes this information along with
the program code in a file is called linkage editor. If frequent execution of the
program is needed then linkage editor is used. This is because although the
program is repeatedly executed the linking is done only once. And this helps in
effective utilization of memory.
3.A.3 What is function of MS-DOS LINK?
It is a linkage editor that combines one or more object modules to produce a
complete executable program. It can also combine the translated programs with other
modules from object code libraries.

3.A.4. What is the function of a linkage editor


The linkage editor produces a liked version of the program. Such a linked
version is also called as load module or executable image. This load module is
generally written in file or library for later execution.

3.A.5 What are the advantages of dynamic linking


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

3.A.6. What is the function of pass 2 of a loader


Pass 2 of loader extracts the translated instructions and data from the object modules ,
and builds an image of the executable program. It performs the actual loading, relocating and
linking of the program.
3.A.7 What is the meant by relocation? How does the assembler pass on this information to
the loader
Program relocation is the method of loading the object code in a different location specified

in the object program.Assembler passes this information about the program relocation to the
loader through modification record as pert of object program.
3.A.8 What is a boot strap loader?
A small program written and stored in the ROM initially loads the operating
system from secondary storage to main memory. The operating system then takes
the overall control. This program which is responsible for booting up the system
WWW.VIDYARTHIPLUS.COM

is called bootstrap loader

3.A.9 . Mention the use of FIXUPP records


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.

3.A.10 . . What are the functions of loader and linker


Linker links the subprograms or procedures of an object file, if a file sum.obj is input for
linker then the output file will be sum.exe. Loader is a part of an operating system which
loads the exe module from secondary memory into main memory and transfers the control of
execution to the starting of exe program.
3.A.11 .Define relocation
Program relocation is the method of loading the object code in a different location specified
in the object program.
Assembler passes this information about the program relocation to the loader through
modification record as pert of object program.
3.A.12 Define boot strap loader?
Refer : 3.A.8

3.A.13 Give the algorithm for absolute loader.


Begin
Read Header record
Verify program name and length
Read first text record
While record type != ‘E’ do
Begin
Moved object code to specified location in memory
Read next object program record
End
Jump to address specified in End record

Part – A
Unit – 4
WWW.VIDYARTHIPLUS.COM

4.A.1 . List the statements present in a macro definition


Two assembler directives (MACRO and MEND ) are used in macro
definitions.
 The first MACRO statement identifies the beginning of a 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.A.2. What is a nested macro call? How is it expanded


Macro call within another macro definition is called nested macro call, otherwise called as
recursive macro call.
In the expansion of 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 ARGRAB by new macro parameters. Whenever the nested macro encounters a
MEND statement, all the macro expansions are abruptly terminated.
To overcome this problem, if the language supports recursion, the compiler will save
the return address otherwise use the stack to store the return address.
4.A.3 What is the nacessity of a Macro?
A macro represents a commonly used group of statements in the source programming
language. Macro instruction allow the programmer to write a shorthand version of a program.
4.A.4. How do macros affect program development?
The object program obtained from source program has the repeated programming statement
because macro substituted the code where its called instead of dumping to location.
4.A.5. What is the use of DEFTAB (Definition table) NAMTAB (Name table) and ARGTAB
(Argument table) in macro processor?
DEFTAB – the macro definitions are stored in a definition table ie it contains a
macro prototype and the statements that make up the macro body.
NAMTAB – it is used to store the macro names and it contains two pointers
for each macro instruction which indicate the starting and end
location of macro definition in DEFTAB.it also serves as an index
to DEFTAB
ARGTAB – it is used to store the arguments during the expansion of macro
invocations.
WWW.VIDYARTHIPLUS.COM

4.A.6. What is the purpose of conditional compilation statement in ANSI C preprocessor?


These statements can be used to be sure that a macro is defined atleast once.
Eg. #ifndef Buffer-size
#define Buffer-size 1024
#endif
the # will be processed only if buffer-size has not already been defined.
4.A.7. For a small code fragment to be used respectively in the program, how is it decided
whether to implement it using a subprogram or macro
4.A.8 . How are local labels handed in macro processing?
The local variables are called as set symbols that begin with character &. These variables are
initialized to 0. The values of local variable can be modified with SET statement

4.A.9 How are MACROS defined?


MACROS are defined using two assembler directives MACRO and MEND. The statements
inside these directives called as MACRO body that is defined with the macro name. The
structure of macro definition is
Macroname MACRO Parameters
Statement 1
Statement 2
. Macro Body
.
Statement A
MEND
4.A.10. What are positional parameters? How do they differform keyword parameters?
Positional parameters are the one that are supplied with MACRO directive in the macro
definition. Here the parameters and arguments ( given in macro call ) were associated, with
each other according to their positions in the macro prototype and the macro invocation
statement.
In keyword parameter, the argument value is written with a keyword that names the
corresponding parameter. Arguments may be any order here.
Eg. Positional Argument
WWW.VIDYARTHIPLUS.COM

STRG DATA1,DATA2, DATA3


GENER ,, DIRECT,,,,3

Keyword Argument
STRG a3 = DATA1 , a2= DATA2, a1= DATA3
GENER TYPE = DIRECT, CHANNEL = 3.
4.A.11. Write any two basic macroprocessor functions
Recognize the macro definition.
2. Save the definition.
3. Recognize the call

4.A.12. Briefly write about MASM macr processor


The object program from MASM may be in several different formats, to allow easy and
efficient execution of the program in a variety of operating environments. MASM can also
produce an instruction timing listing that shows the number of clock cycles required to
execute each machine instruction.

4.A.13 What are the data structures used by macro Processor?


DEFTAB – the macro definitions are stored in a definition table ie it contains a
macro prototype and the statements that make up the macro body.
NAMTAB – it is used to store the macro names and it contains two pointers
for each macro instruction which indicate the starting and end
location of macro definition in DEFTAB.it also serves as an index
to DEFTAB
ARGTAB – it is used to store the arguments during the expansion of macro
invocation
4.A.14 What is the Advantage of keyword macro parameters?
The advantage of the keyword parameters is that you can specify a defualt value in the macro
definition.

Part – A Unit – 5

5.A.1. What is a place holder


WWW.VIDYARTHIPLUS.COM

One who holds an office or place, especially:


a. One who acts as a deputy or proxy.
b. One who holds an appointed office in a government.
2. In a mathematical or logical expression, a symbol that may be replaced by the name of any
element of a set.
3. In the decimal form of a number, a digit that is not significant

5.A.2 What are the roles of a dialog manager?

A dialog manager (DM) is a component of a dialog system (DS), responsible for the state
and flow of the conversation. Usually:

 The input to the DM is the human utterance, usually converted to some system-
specific semantic representation by the Natural Language Understanding (NLU)
component. For example, in a flight-planning dialog system, the input may look like
"ORDER(from=TA,to=JER,date=2012-01-01)".
 The DM usually maintains some state variables, such as the dialog history, the latest
unanswered question, etc., depending on the system.
 The output of the DM is a list of instructions to other parts of the dialog system,
usually in a semantic representation, for example "TELL(flight-num=123,flight-
time=12:34)". This semantic representation is usually converted to human language
by the Natural Language Generation (NLG) component

5.A.3. What is the important of user interface?


User interface is one, which allows the user to communicate with the system in order to
perform certain tasks. User interface is generally designed in a computer to make it easier to
use.

5.A.4. What are various functions of a debugger


Functions are tracing, trace back, unit test and execution sequencing.

5.A.5. What are the tasks performed by document editing process?


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.
WWW.VIDYARTHIPLUS.COM

4. Update the view appropriately.


5.A.6. How the mapping of view buffer to a window is done

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.

5.A.7. What are the main functions accomplished by a typical debugger?

 Break points
 Gaits
 Tracing
 Trace back

5.A.8 List down the user interface criteria.


User interface is one, which allows the user to communicate with the system in order to
perform certain tasks. User interface is generally designed in a computer to make it easier to
use.

1. Visibility of system status. Users should always know where they are and what's
going on.
2. Real world - system match. The system should mirror the real world of the user as
much as possible. Use language, concepts, etc. that are familiar to the user. Order the
processes/screens in a way that is meaningful and logical to the user.
3. Control and freedom. Don't "trap" the user. Support clearly marked exit, undo, and
redo functions. Don't force them into a long linear sequence of operations with no
escape.
4. Consistency and standards. Use objects and phrases consistently. Follow platform
conventions. Here is a checklist of specific items to watch for.
5. Recognition not recall. Provide visual objects, actions, and options (e.g. cue cards) to
assist the user for navigation and input activities. Don't expect they will memorize
commands.
6. Flexibility and efficiency of use. Accelerators (unseen by novice users) can speed up
interaction for expert users. Allow users to customize frequent actions whenever
possible.
7. Aesthetic and minimalist design. Visibility of rarely needed information should be
avoided. The more information that appears on the screen, the less visible each unit of
information becomes.
8. Online help and additional documentation. Though a well designed system can be
used without documentation and help, supplemental information may still be
necessary. Keep this information tied to user tasks, support easy to use search
functions, and don't make this section too large.
WWW.VIDYARTHIPLUS.COM

9. Effective error handling. Assist users to recognize, diagnose, and recover from
errors. Don't just tell them there's an error, suggest corrective action whenever
possible.
10. Error prevention. A design that prevents errors from occurring is better than a good
error message.

5.A.9. Write the tasks accomplished by the document editing process


The following 4 tasks are performed in the editing process
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.

5.A.10. What do you mean by tracing

 Tracing (law), a process by which a one demonstrates the ownership of property, with
the intent to be awarded a claim based on this information
 Tracing (criminology), a subject concerning setting up traces of occurrence of objects
generated from trace evidence left at crime scenes
 Tracing (as with a gun or camera), tracking an object, as with the use of tracer
ammunition
 Tracing in art, copying an object or drawing, especially with the use of translucent
tracing paper

5.A.11. .Define text editor


A text editor is a computer program that lets a user enter, change, store, and usually
printtext (characters and numbers, each encoded by the computer and its input and output
devices, arranged to have meaning to users or to other programs).

5.A.12. What do you mean by 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)
5.A.13 What are the tasks involved in document editing process?

5.A.14 What is the use of tracing?


Activities or tasks are the fundamental blocks of sub-processes. They usually consist of steps
of how to perform tasks. For example, you might have to document the tasks that an
employee does on a daily basis. The tasks may involve a series of steps. In order to
successfully capture the activity or task, you will have to interview employees. Get them to
show you what they do, as opposed to telling you. This last recommendation is important
WWW.VIDYARTHIPLUS.COM

because you can miss out on the computer-related tasks they perform. Get them to provide
you screenshots of the applications they use.

Part – B Unit – 1
1.B.1 Explain in detail the architecture of a SIC machine and SIC/XE machine

1.2.1 SIC Machine Architecture


We discuss here the SIC machine architecture with respect to its Memory and Registers,
Data Formats, Instruction Formats, Addressing Modes, Instruction Set, Input and Output

Memory
There are 215 bytes in the computer memory, that is 32,768 bytes , It uses Little Endian
format to store the numbers, 3 consecutive bytes form a word , each location in memory contains 8-
bit bytes.

Registers
There are five registers, each 24 bits in length. Their mnemonic, number and use are given in
the following table.

Mnemonic Number Use

A 0 Accumulator; used for arithmetic operations

X 1 Index register; used for addressing

L 2 Linkage register; JSUB

PC 8 Program counter

SW 9 Status word, including CC

Data Formats
Integers are stored as 24-bit binary numbers , 2’s complement representation is used for
negative values, characters are stored using their 8-bit ASCII codes, No floating-point hardware on
the standard version of SIC.

Instruction Formats

Opcode(8) x Address (15)


WWW.VIDYARTHIPLUS.COM

All machine instructions on the standard version of SIC have the 24-bit format as shown
above

Addressing Modes

Mode Indication Target address calculation

Direct x=0 TA = address

Indexed x=1 TA = address + (x)

There are two addressing modes available, which are as shown in the above table.
Parentheses are used to indicate the contents of a register or a memory location.

Instruction Set

SIC provides, load and store instructions (LDA, LDX, STA, STX, etc.). Integer arithmetic
operations: (ADD, SUB, MUL, DIV, etc.). All arithmetic operations involve register A and a word in
memory, with the result being left in the register. Two instructions are provided for subroutine
linkage. COMP compares the value in register A with a word in memory, this instruction sets a
condition code CC to indicate the result. There are conditional jump instructions: (JLT, JEQ, JGT),
these instructions test the setting of CC and jump accordingly. JSUB jumps to the subroutine placing
the return address in register L, RSUB returns by jumping to the address contained in register L.

Input and Output


Input and Output are performed by transferring 1 byte at a time to or from the rightmost 8
bits of register A (accumulator). The Test Device (TD) instruction tests whether the addressed device
is ready to send or receive a byte of data. Read Data (RD), Write Data (WD) are used for reading or
writing the data.

Data movement and Storage Definition


LDA, STA, LDL, STL, LDX, STX ( A- Accumulator, L – Linkage Register, X – Index Register), all
uses 3-byte word. LDCH, STCH associated with characters uses 1-byte. There are no memory-
memory move instructions.

Storage definitions are

 WORD - ONE-WORD CONSTANT


 RESW - ONE-WORD VARIABLE
WWW.VIDYARTHIPLUS.COM

 BYTE - ONE-BYTE CONSTANT


 RESB - ONE-BYTE VARIABLE
Example Programs (SIC)

2. Write in detail about SIC / XE Architecture.

Memory
Maximum memory available on a SIC/XE system is 1 Megabyte (220 bytes)

Registers
Additional B, S, T, and F registers are provided by SIC/XE, in addition to the registers of SIC

Mnemonic Number Special use

B 3 Base register

S 4 General working register

T 5 General working register

F 6 Floating-point accumulator (48 bits)

Floating-point data type


There is a 48-bit floating-point data type, F*2(e-1024)

1 11 36

S exponent fraction

Instruction Formats
The new set of instruction formats fro SIC/XE machine architecture are as follows. Format 1
(1 byte): contains only operation code (straight from table). Format 2 (2 bytes): first eight bits for
operation code, next four for register 1 and following four for register 2. The numbers for the
registers go according to the numbers indicated at the registers section (ie, register T is replaced by
hex 5, F is replaced by hex 6). Format 3 (3 bytes): First 6 bits contain operation code, next 6 bits

contain flags, last 12 bits contain displacement for the address of the operand. Operation code uses
only 6 bits, thus the second hex digit will be affected by the values of the first two flags (n and i). The
WWW.VIDYARTHIPLUS.COM

flags, in order, are: n, i, x, b, p, and e. Its functionality is explained in the next section. The last flag e
indicates the instruction format (0 for 3 and 1 for 4). Format 4 (4 bytes): same as format 3 with an
extra 2 hex digits (8 bits) for addresses that require more than 12 bits to be represented.

Format 1 (1 byte)

Op

Format 2 (2 bytes)

8 4 4

Op r1 r2

Formats 1 and 2 are instructions do not reference memory at all

Format 3 (3 bytes)

6 1 1 1 1 1 1 12

Op N i x B p e disp

Format 4 (4 bytes)

6 1 1 1 1 1 1 20

Op n i x B p e address

Addressing modes & Flag Bits


Five possible addressing modes plus the combinations are as follows.

Direct (x, b, and p all set to 0): operand address goes as it is. n and i are both set to the same
value, either 0 or 1. While in general that value is 1, if set to 0 for format 3 we can assume that the
rest of the flags (x, b, p, and e) are used as a part of the address of the operand, to make the format
compatible to the SIC format
WWW.VIDYARTHIPLUS.COM

Relative (either b or p equal to 1 and the other one to 0): the address of the operand should
be added to the current value stored at the B register (if b = 1) or to the value stored at the PC
register (if p = 1)

Immediate (i = 1, n = 0): The operand value is already enclosed on the instruction (ie. lies on
the last 12/20 bits of the instruction)

Indirect (i = 0, n = 1): The operand value points to an address that holds the address for the
operand value.

Indexed (x = 1): value to be added to the value stored at the register x to obtain real address
of the operand. This can be combined with any of the previous modes except immediate.

The various flag bits used in the above formats have the following meanings

e - e = 0 means format 3, e = 1 means format 4

Bits x,b,p: Used to calculate the target address using relative, direct, and indexed addressing Modes

Bits i and n: Says, how to use the target address b and p - both set to 0, disp field from format 3
instruction is taken to be the target address. For a format 4 bits b and p are normally set to 0, 20 bit
address is the target address

x - x is set to 1, X register value is added for target address calculation

i=1, n=0 Immediate addressing, TA: TA is used as the operand value, no memory reference

i=0, n=1 Indirect addressing, ((TA)): The word at the TA is fetched. Value of TA is taken as the
address of the operand value i=0, n=0 or i=1, n=1 Simple addressing, (TA):TA is taken as the address
of the operand value

Two new relative addressing modes are available for use with instructions assembled using
format 3.

Mode Indication Target address calculation

TA=(B)+ disp
Base relative b=1,p=0
(0disp 4095)

Program-counter TA=(PC)+ disp


b=0,p=1
relative (-2048disp 2047)
WWW.VIDYARTHIPLUS.COM

Instruction Set
SIC/XE provides all of the instructions that are available on the standard version. In addition
we have, Instructions to load and store the new registers LDB, STB, etc, Floating-point arithmetic
operations, ADDF, SUBF, MULF, DIVF, Register move instruction : RMO, Register-to-register
arithmetic operations, ADDR, SUBR, MULR, DIVR and, Supervisor call instruction : SVC.

Input and Output


There are I/O channels that can be used to perform input and output while the CPU is
executing other instructions. Allows overlap of computing and I/O, resulting in more efficient system
operation. The instructions SIO, TIO, and HIO are used to start, test and halt the operation of I/O
channels.

Example Programs (SIC/XE)


Example 1 (Simple data and character movement operation)

LDA #5

STA ALPHA

LDA #90

STCH C1 .

ALPHA RESW 1

C1 RESB 1

1. Explain about the SIC architecture

2. Write in detail about SIC / XE Architecture.


WWW.VIDYARTHIPLUS.COM

n sets

1.B.2 Write short notes on:


(i) Data formate and instruction formats.
Data Formats
Integers are stored as 24-bit binary numbers , 2’s complement representation is used for
negative values, characters are stored using their 8-bit ASCII codes, No floating-point
hardware on the standard version of SIC.

Instruction x Address
Formats (15)
Opcode(8)
(ii) I/O programming.
Input and Output
Input and Output are performed by transferring 1 byte at a time to or from the rightmost 8 bits
of register A (accumulator). The Test Device (TD) instruction tests 3

whether the addressed device is ready to send or receive a byte of data. Read Data (RD),
Write Data (WD) are used for reading or writing the data.

1.B.3 (i) With a neat diagram<explain the machine architecture of SIC and SIC/XE.
REFER 1.B.1
1.B.4 (b) Write short notes on:
(i) Data and instruction formats.
(ii) Addressing modes of SIC/XE.

REFER 1.B.1

1.B.5 a) (i) Explain the SIC machine architecture.


REFER 1.B.1

1.B.6 (i) Write a sequence of instructions for SIC to nset


VAL 1= VAL 2+INCR-2
VAL 3= VAL 4_INCR-2
Illustrate how the same calculation could ce performed on SIC/XE
LDS INCR
LDA ALPHA
ADD S,A
SUB #1
STA BEETA
WWW.VIDYARTHIPLUS.COM

………….
…………..
ALPHA RESW 1
BEETA RESW 1
INCR RESW 1
1.B.7 (b) (i) Explain the SIC/XE machine architecture.
(ii) The variable V1,V2 and V3 are assumed as an array of 100 words each. Write a
sequence of instructions for SIC to add together the corresponding elements of V1,V2 and
store in V3
1.B.8 ). (1). With instruction formats, explain the instruction set of SIC / XE.
(2). Highlight the salient features of SIC / XE machine architecture.
REFER 1.B.1
1.B.9 (b)Describe the following in VAX architecture
3.1 VAX Architecture
Memory - The VAX memory consists of 8-bit bytes. All addresses used are byte addresses.
Two consecutive bytes form a word, Four bytes form a longword, eight bytes form a
quadword, sixteen bytes form a octaword. All VAX programs operate in a virtual address
space of 232 bytes , One half is called system space, other half process space.

Registers – There are 16 general purpose registers (GPRs) , 32 bits each, named as R0 to
R15, PC (R15), SP (R14), Frame Pointer FP ( R13), Argument Pointer AP (R12) ,Others
available for general use. There is a Process status longword (PSL) – for flags.
Data Formats - Integers are stored as binary numbers in byte, word, longword, quadword,
octaword. 2’s complement notation is used for storing negative numbers. Characters are
stored as 8-bit ASCII codes. Four different floating-point data formats are also available.
Instruction Formats - VAX architecture uses variable-length instruction formats – op code 1
or 2 bytes, maximum of 6 operand specifiers depending on type of instruction. Tabak –
Advanced Microprocessors (2nd edition) McGraw-Hill, 1995, gives more information.
Addressing Modes - VAX provides a large number of addressing modes. They are Register
mode, register deferred mode, autoincrement, autodecrement, base relative, program-counter
relative, indexed, indirect, and immediate.
Instruction Set – Instructions are symmetric with respect to data type - Uses prefix – type of
operation, suffix – type of operands, a modifier – number of operands. For example, ADDW2
- add, word length, 2 operands, MULL3 - multiply, longwords, 3 operands CVTCL -
conversion from word to longword. VAX also provides instructions to load and store multiple
registers

Input and Output - Uses I/O device controllers. Device control registers are mapped to
separate I/O space. Software routines and memory management routines are used for
input/output operations.

1.B.10 (a) (i) Generate the object for the following SIC source program.
Label Operation Operand Opcode
SUM START 1000
FIRST LDX ZERO 04
WWW.VIDYARTHIPLUS.COM

LDA ZERO 00
LOOP ADD TABLE,X 18
TIX COUNT 2C
JLT LOOP 38
STA TOTAL OC
RSUB 4C
TABLE RESW 3000
COUNT RESW 1
ZERO WORD 0
TOTAL RESW 1
END FIRST

1.B.11 (ii) Discuss the SIC/XE architecture, explaining in detail the addressing modes and
the instruction formats.
REFER 1.B.1

1.B.12 (b)Generate the object code for the following SIC/XE source program.
Label Operation Operand Opcode
SUM START 0
FIRST LDX #0 04
LDA #0 00
+LDB #TABLE2 68
LOOP ADD TABLE,X 18
ADD TABLE2,X 18

TIX COUNT 2C
JLT LOOP 38
+STA TOTAL 0C
STA @TOTAL
RSUB 4C
COUNT RESW 1
TABLE RESW 3000
TABLE2 RESW 3000
TOTAL RESW 1
END FIRST

1.B.13 a(i) Write and explain the sequence of code in SIC and SIC/XE to read 200 byte
record from the device ‘F1’ using subroutine.
LDT #200
LDX #0
CLOOP TD INDEV
JEQ CLOOP
RD INDEV
WWW.VIDYARTHIPLUS.COM

STCH RECORD, X
TIXR T
JLT CLOOP
.
.
INDEV BYTE X ‘F5’
RECORD RESB 200

(ii) Write a sequence of code in SIC to implement the following expression.

BETA<- ALPHA+ INCR – 1


DELTA <- GAMMA+INCR – 1
ANS:
LDS INCR
LDA ALPHA
ADD S,A
SUB #1
STA BEETA
………….
…………..
ALPHA RESW 1
BEETA RESW 1
INCR RESW 1
1.B.14 Compare SIC and SIC\ XE architectures with respect to memory, Instruction formats,
addressing modes and data formats.
REFER 1.B.1

Part – B Unit – 2

2.B.1 State and explain the PASS I algorithm of an assembler.


Pass-1

Pass-2

of data areas for assigning the address values.


he symbols in the symbol table(generate the symbol table)
WWW.VIDYARTHIPLUS.COM

2.B.2 With an example,explain the concept of program relocation


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.
WWW.VIDYARTHIPLUS.COM

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.

2.B.3 ) (i) Explain the necessary of one pass and multi pass assemblers.
Restriction on EQU and ORG
no forward reference, since symbols’ value can’t be defined during the first
pass
Example
Use link list to keep track of whose value depend on an undefined symbol
(ii) Explain about implementation of one pass assembler.
Main Problem
forward reference
data items
labels on instructions
Two types of one-pass assembler
load-and-go
produces object code directly in memory for immediate execution the
other produces usual kind of object code for later execution

2.B.4 b) Explain the various machine dependent features of assembler.

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 212 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
WWW.VIDYARTHIPLUS.COM

• 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

1. 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.

2. 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.

2. 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:
WWW.VIDYARTHIPLUS.COM

3. 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
WWW.VIDYARTHIPLUS.COM

::

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 LDA 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.

4. Immediate Addressing Mode


WWW.VIDYARTHIPLUS.COM

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:

5. 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:
WWW.VIDYARTHIPLUS.COM

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.

3.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
WWW.VIDYARTHIPLUS.COM

object program that has the information necessary to perform this kind of modification is
called the relocatable program.

3.2.5 Control Sections:

A control section is a part of the program that maintains its identity after assembly;
each control section can be loaded and relocated independently of the others. Different
control sections are most often used for subroutines or other logical subdivisions. The
programmer can assemble, load, and manipulate each of these control sections separately.

Because of this, there should be some means for linking control sections together. For
example, instructions in one control section may refer to the data or instructions of other
control sections. Since control sections are independently loaded and relocated, the assembler
is unable to process these references in the usual way. Such references between different
control sections are called external references.

The assembler generates the information about each of the external references that
will allow the loader to perform the required linking. When a program is written using
multiple control sections, the beginning of each of the control section is indicated by an
assembler directive

– assembler directive: CSECT


The syntax

secname CSECT

– separate location counter for each control section

Control sections differ from program blocks in that they are handled separately by the
assembler. Symbols that are defined in one control section may not be used directly another

control section; they must be identified as external reference for the loader to handle. The
external references are indicated by two assembler directives:

EXTDEF (external Definition):

It is the statement in a control section, names symbols that are defined in this section
but may be used by other control sections. Control section names do not need to be named in
the EXTREF as they are automatically considered as external symbols.
WWW.VIDYARTHIPLUS.COM

EXTREF (external Reference):

It names symbols that are used in this section but are defined in some other control
section.

The order in which these symbols are listed is not significant. The assembler must include
proper information about the external references in the object program that will cause the
loader to insert the proper value where they are required.

Handling External Reference

Case 1

15 0003 CLOOP +JSUB RDREC 4B100000

 The operand RDREC is an external reference.


o The assembler has no idea where RDREC is
o inserts an address of zero
o can only use extended format to provide enough room (that is, relative
addressing for external reference is invalid)
 The assembler generates information for each external reference that will allow the
loader to perform the required linking.

Case 2

190 0028 MAXLEN WORD BUFEND-BUFFER 000000

 There are two external references in the expression, BUFEND and BUFFER.
 The assembler inserts a value of zero
 passes information to the loader
 Add to this data area the address of BUFEND
 Subtract from this data area the address of BUFFER

Case 3

On line 107, BUFEND and BUFFER are defined in the same control section and the
expression can be calculated immediately.

107 1000 MAXLEN EQU BUFEND-BUFFER


WWW.VIDYARTHIPLUS.COM

2.B.5 (b) Explain in detail about the machine independent features of assembler.

Consider the following example


It is convenient to write the value of a constant
operand as a part of instruction

:
LDA FIVE
:
FIVE WORD 5
:
:
LDA =X’0
Implementation of Literals
Pass 1
Build LITTAB with literal name, operand value and length,
leaving the address unassigned
When LTORG or END statement is encountered, assign an address
to each literal not yet assigned an address
The location counter is updated to reflect the
number of bytes occupied by each literal
Pass 2
Search LITTAB for each literal operand encountered
Generate data values usingBYTE or WORD statements
Generate Modification record for literalsthat represent an address
in the program

-Defining Statements

Assembler directive EQU


Allowsthe programmer to define symbols and specify their values
Syntax: symbol EQU value
To improve the program readability, avoid using magic numbers,
make it easier to find and change constant values
Replace
+LDT #4096
with
MAXLEN EQU 4096
+LDT #MAXLEN
Define mnemonic namesfor registers
A EQU 0 RMO A,X
X EQU 1
Expression is allowed
MAXLEN EQU BUFEND-BUFFER
WWW.VIDYARTHIPLUS.COM

The assemblers allow “the use of expressions as


operand”
The assembler evaluatesthe expressions and produces a single
operand address or value
Expressions consist of
Operator
+,-,*,/ (division is usually defined to produce an
integer result)
Individual terms
Constants
User-defined symbols
Special terms, e.g., *, the current value of LOCCTR

Examples
MAXLEN EQU BUFEND-BUFFER
STAB RESB (6+3+2)*MAXENTRIES

Allow the generated machine instructions and


data to appear in the object program in a
different order
Separating blocksforstoring code, data,stack, and
larger data block
Program blocks v.s. Control sections
Program blocks
Segments of code that are rearranged
within a single object program unit
Controlsections
Segments of code that are translated into
independent object program units

Control sections
can be loaded and relocated independently ofthe other
controlsections
are most often used forsubroutines or otherlogical
subdivisions of a program
the programmer can assemble, load, and manipulate each
ofthese controlsectionsseparately
because ofthis, there should be some meansforlinking
controlsectionstogether
WWW.VIDYARTHIPLUS.COM

assembler directive: CSECT


secname CSECT
separate location counter for each controlsection

2.B.6 Discuss the detailed design of pass 1 of a two-pass assembler. Mention clearly the
formatsof the data structures used.Include all the assembler directives that need to be
processed in pass 1 in your design
 Pass 1 - define symbols (assign addresses)
o Assign addresses to all statements in the program
o Save the values assigned to all labels for use in Pass 2
o Process some assembler directives

2.B.7 Discuss the detailed design of pass 2 of a two-pass assembler. Mention clearly the
formats of of the data structures used.Indicate the inputs taken from pass 1 and the outputs
generated by pass 2.
 Pass 2 - assemble instructions and generate object program
Assemble instructions
o Generate data values defined by BYTE, WORD, etc.
o Process the assembler directives not done in Pass 1
o Write the object program and the assembly listing

Source
program

Intermediat Object
Pass 1 Pass 2
e
codes
OPTAB SYMTAB file SYMTAB

2.B.8 ) Discuss in detail the assembler design options.


-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:
WWW.VIDYARTHIPLUS.COM

 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
-pass Assembler
 For a two pass assembler, forward references in symbol definition are not allowed:
ALPHA EQU BETA

BETA EQU DELTA

DELTA RESW 1

o Symbol definition must be completed in pass 1.


 Prohibiting forward references in symbol definition is not a serious inconvenience.
o Forward references tend to create difficulty for a person reading the program.

2.B.9. Explain machine dependent assemblerfeatures in details.

2.B.10 Explain the concept of program relocation


Program relocation
 Principles.
o The load address of an object program is unknown at assembly time if the
system implements the multiprogramming feature.
o The assembler generates addresses relative to zero in the object program.
o At load time, relocation is performed by adding the load address to the relative
addresses.
o Operands of instructions that use direct addressing must be relocated, and the
assembler provides the relocation information in the object program.
Operands of instructions that use relative addressing do not need to be relocated
Program Relocation
WWW.VIDYARTHIPLUS.COM

 The larger main memory of SIC/XE


o Several programs can be loaded and run at the same time.
o This kind of sharing of the machine between programs
o is called multiprogramming
 To take full advantage
 Load programs into memory wherever there is room
 Not specifying a fixed address at assembly time
 Called program relocation

2.B.11 With syntax, explain the usage of different symbol defining statements in an
Assembler.

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 This statement defines the given symbol

(i.e., entering in the SYMTAB) and assigning to it the value specified. The value can be a
constant or an expression involving constants and any other symbol which is already defined.
One common usage is to define symbolic names that can be used to improve readability in
place of numeric values. For example
+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. If the maximum length is changed
from 4096 to 1024, it is difficult to change if it is mentioned as an immediate value wherever
required in the instructions. We have to scan the whole program and make changes wherever
4096 is used. If we mention this value in the instruction through the symbol defined by EQU,
we may not have to search the whole program but change only the value of MAXLENGTH
in the EQU statement (only once
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

2.B.12 1) What are the different types of expressions supported by an Assembler ?Expalin
with examples
EXPRESSIONS:
WWW.VIDYARTHIPLUS.COM

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 *
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
Assembler Directive USE:
USE [blockname]

(2). Descripe the design of One Pass Assembler.


 One-pass assemblers are used when
o it is necessary or desirable to avoid a second pass over the source program
o the external storage for the intermediate file between two passes is slow or is
inconvenient to use

 Main problem: forward references to both data and instructions


 One simple way to eliminate this problem: require that all areas be defined before
they are referenced.
o It is possible, although inconvenient, to do so for data items.
o Forward jump to instruction items cannot be easily eliminated.

2.B.13 (a) How forward references are handled by multi pass assembler? Illustrate with an
example.
Multi-Pass Assemblers
• Prohibiting forward references in symbol definition:
– This restriction is not a serious inconvenience.
– Forward references tend to create difficulty for a person reading the program.

• Allowing forward references


– To provide more flexibility
– Solution:
• A multi-pass assembler that can make as many passes as are needed to
process the definitions of symbols.
WWW.VIDYARTHIPLUS.COM

• 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:
ALPHA EQU BETA
BETA EQU DELTA
DELTA RESW 1
• Reason: symbol definition must be completed in pass 1.
• Motivation for using a multi-pass assembler
– DELTA can be defined in pass 1
– BETA can be defined in pass 2
– ALPHA can be defined in pass 3

Implementation
• A symbol table is used
– to store symbol definitions that involve forward references
– to indicate which symbols are dependant on the values of others
– to facilitate symbol evaluation
• For a forward reference in symbol definition, we store in the SYMTAB:
– the symbol name
– the defining expression
– the number of undefined symbols in the defining expression
– the undefined symbol (marked with a flag *) associated with a list of symbols
depend on this undefined symbol.
• When a symbol is defined, we can recursively evaluate the symbol expressions
depending on the newly defined symbol.

2.B.14 (b) (i) How an assembler calculates displacement for PC – relative and Base relative
addressing modes?
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.
WWW.VIDYARTHIPLUS.COM

LDB #LENGTH (instruction)


BASE LENGTH (directive)
:

NOBASE

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

(ii) Describe the data structures used by an assembler.


Data Structures:
Operation Code Table (OPTAB)
Symbol Table (SYMTAB)
Location Counter(LOCCTR

Part – B Unit – 3
3.B.1 With examples, explain the machine independent features of a loader.

o Automatic Library Search for handling external


references
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.
o Loader Options
n Common options that can be selected at the time of loading and linking
Standard system library, subprogram library
o Automatic library search (Automatic library call)
The programmer does not need to take any action beyond mentioning the subroutine
names as external references

o Linking loaders that support automatic library search:


Must keep track of external symbols that are referred to, but not defined, in the
primary input to the loader.
Many loaders have a special command language that is used to specify options a
separate input file to the loader that contain
control statements
WWW.VIDYARTHIPLUS.COM

Control statements embedded in the primary input stream between object programs
Control statements are included in the source program, and the assembler or compiler
retains these commands as a part of the object program

3.B.2 With diagrams, explain how loading and calling of a subroutine is done using dynamic
linking.
 Dynamic Linking refers to postponing the linking function until execution time.
o 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)
 Allow several executing programs to share one copy of a subroutine or library
 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
WWW.VIDYARTHIPLUS.COM

3.B.3 Discuss the basis loader functions and design relocatable loader.
The most fundamental functions of a loader:
Bringing an object program into memory and starting its execution

3.B.4 Explain in detail how linkage editors are implemented in various machines.
Differentiate linkage editors with linkage loaders.
o 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
o A simple relocating loader can be used to load the linked version of
program into memory
 The loading can be accomplished in one pass with no external
symbol table required

 A linkage editor
o Resolution of external references and library searching are only
performed once
o In the linked version of programs
 All external references are resolved, and relocation is indicated
by some mechanism such as modification records or a bit mask
o External references is often retained in the linked program
 To allow subsequent relinking of the program to replace control
sections, modify external references, etc.
WWW.VIDYARTHIPLUS.COM

Linking Loader vs. Linkage Editor


 Linking loader
o Searches libraries and resolves external references every time the program is
executed.
o Avoid the writing and reading the linked program.
 Linkage editor
o Resolution of external reference and library searching are only performed once

3.B.5 ) Explain the design of relocating loader with an example


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)

3.B.6 Write short notes on :


(i) Linkage editor.
a. 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
b. A simple relocating loader can be used to load the linked version
of program into memory
i. The loading can be accomplished in one pass with no
external symbol table required
ii. Dynamic linking
Advantages
 Load the routines when they are needed, the time
 and memory space will be saved.
WWW.VIDYARTHIPLUS.COM

 Avoid the necessity of loading the entire library for each execution
o i.e. load the routines only when they are needed
 Allow several executing programs to share one copy of a subroutine or library
(Dynamic Link Library, DLL)

3.B.7 Discuss the detailed design of a linking and relocating loader.


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)

3.B.8 Expalin the different machine independent loader features in detail.

REFER 3.B.1

3.B.9 (1) With a neat flow diagram, explain the working of Linkage editors .

1. nkage editors can perform many useful functions besides simply preparing an object
program for execution.
2. This can also be used to build packages of subroutines or other control sections that
are generally used together.
3. This can be useful when dealing with subroutine library than support high-level
programming languages in a typical implementation of FORTRAN, for example,
there are a large number of subroutines that are used to handle formatted input and
output.
4. These include routines to read and write data blocks, to block and deadlock records.
There are a large number of cross references between these subprograms because of
WWW.VIDYARTHIPLUS.COM

their closely related functions. However, it is desirable that they remain as separate
control sections for reasons of program modularity and maintainability.

1. If a program using formatted I/O were linked in the usual way, all of the cross-
references between these library subroutines would have to be processed

individually. Exactly the same set of cross references would need to be processed for
almost every FORTRAN program linked. This represents a substantial amount of
overhead. The linkage editor would be used to combine the appropriate subroutines
into a packages with a command sequence like:
WWW.VIDYARTHIPLUS.COM

INCLUDE READER (FTNLIB)

INCLUDE WRITER (FTNLIB)

INCLUDE BLOCK (FTNLIB)

INCLUDE DEBLOCK (FTNLIB)

INCLUDE ENCODE (FTNLIB)

INCLUDE DECODE (FTNLIB)


.
.
.
SAVE FTN10 (SUBLIB)

2. The linked module named FTN10 could be indexed in the directory of SUBLIB
under the same names as the original subroutines. Thus a search of SUBLIB before
FTNLIB would retrieve FTN10 instead of the separate routines. Since FTN10 already
has all of the cross-references between subroutine resolved, these linkage would not
be reprocessed when each user’s program is linked. The result would be a much more
efficient linkage editor operation for each program and a considerable overall savings
for the system.

3. Linkage editors often allow the user to specify that external references are not to be
resolved by automatic library search. Suppose, for example, that 100 FORTRAN
programs using the I/O routines described above were to be stored on a library. If all
external references, were resolved, this would mean that a total of 100 copies of
FTN10 would be stored. If library space were an important resource, this might be
highly undesirable.

2.4.Using commands the user would specify that no library search be performed during
linkage editing. Thus only the external references between user-written routines
would be resolved. A linking loader could then be used to combine the linked user
routines with FTN10 at execution time. Because this process involves two separate
linking operations, it would require slightly more over head, however, it would result
in large savings in library space.
WWW.VIDYARTHIPLUS.COM

3.B.10 Write notes on MS-DOS Linker.


MS-DOS Assemblers and Compilers
-DOS LINK
-DOS Object modules

3.B.11 Describe machine dependent loader features in detail.

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.

3.4.1 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.

3.4.2 Methods for specifying relocation

Use of modification record and, use of relocation bit, are the methods available for
specifying relocation. In the case of modification record, a modification record M is used in
the object program to specify any relocation. In the case of use of relocation bit, each
instruction is associated with one relocation bit and, these relocation bits in a Text record is
gathered into bit masks.
WWW.VIDYARTHIPLUS.COM

Modification records are used in complex machines and is 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

HCOPY 000000 001077

T000000 1D17202D69202D48101036…4B105D3F2FEC032010

T00001D130F20160100030F200D4B10105D3E2003454F46

T001035 1DB410B400B44075101000…33200857C003B850

T0010531D3B2FEA1340004F0000F1..53C003DF2008B850

T00070073B2FEF4F000005

M00000705+COPY

M00001405+COPY

M00002705+COPY

E000000

The relocation bit method is used for simple machines. Relocation bit is 0: no
modification is necessary, and is 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
WWW.VIDYARTHIPLUS.COM

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.

HCOPY 000000 00107A

T0000001EFFC140033481039000036280030300015…3C0003  …

T00001E15E000C00364810610800334C0000…000003000000

T0010391EFFC040030000030…30103FD8105D280030...

T0010570A 8001000364C0000F1001000

T00106119FE0040030E01079…508039DC10792C0036...

E000000

3.5 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.
WWW.VIDYARTHIPLUS.COM

ex: EXTDEF BUFFER, BUFFEND, LENGTH

3.B.12 Describe machine Independent loader features in detail.


Automatic Library Search

3.B.13 (a) Why linking loader requires 2 passes to complete loading? Explain the operations
of linking loader.
 Dynamic Linking refers to postponing the linking function until execution time.
o 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)
 Allow several executing programs to share one copy of a subroutine or library
 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

3.B.14 (i) Differentiate between linkage editor and inking loader

Linkage editor
Linking before loading
Dynamic linking
Linking at the execution time

Bootstrap loader
Replacement of subroutines in the linked program
For example:
INCLUDE PLANNER(PROGLIB)
DELETE PROJECT {DELETE from existing PLANNER}
INCLUDE PROJECT(NEWLIB) {INCLUDE new version}
REPLACE PLANNER(PROGLIB)
Construction of a package for subroutines generally used
together
There are a large number of cross-references between these subroutines
due to their closely related functions.

For example (P.155) :


INCLUDE READR(FTNLIB)
INCLUDE WRITER(FTNLIB)
:
WWW.VIDYARTHIPLUS.COM

SAVE FTNIO(SUBLIB)
Specification of external references not to be
resolved by automatic library search
Can avoid multiple storage of common librariesin
programs.
Need a linking loaderto combine the common libraries
at execution time.
(II) Describe the various record types in MS-DOS linker.

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. LINK can also combine the translated
programs with other modules from object code libraries.

1. MS-DOS compilers and assemblers produce object modules(.OBJ).


2. Each .OBJ contains a binary image of the translated instructions and data of the
program.

3. MS-DOS LINK is a linkage editor that combines one-or more modules to produce a
complete executable program (.exe).

4. MS-DOS object
module.

Description
Record Types
THEADR Translator header similar to header record in
SIC/XE
TYPDEF Type definitions of external symbols
PUBDEF Public Definitions of external symbols
defined in object module.
EXTDEF Information about the data and external
name.
LNAMES List of all the segments and class names
used in the program.
SEGDEF Describes the segments in the object module,
including name, length, alignment.
GRPDEF Grouping of Segments.
LEDATA Similar to Text record (SIC/XE) contain
translated instruction and data from the
source program
LIDATA Translated Instruction and data that occur
In repeated pattern
FIXUPP Resolve external references, contains
relocation and linking information and must
immediately follow the LEDATA or LIDATA
record to which it applies
MODEND End of object module.
WWW.VIDYARTHIPLUS.COM

Link performs its processing in two passes.


Pass 1:
Computes a starting address for each segment in the program.

(i) Segments are placed in the same order as given in SEGDEF records.

(ii) Segments from different object modules that have the same segment name and class are
combined.

(iii) Segments with the same class, but different names are concatenated.

(iv) Segments starting address is updated as these combinations and concatenation are
performed.
Pass 2:
Extracts the translated instructions from the object modules.
(i) Process each LEDATA and LIDATA record along with FIXUPP
(ii) Relocation operation’s that involve the starting address of the segment are added to a
table of Segment Fixupps.
(iii) Build an image of the executable program in memory.
(iv) Write it to the executable (.EXE.) file.
(v) This file includes a header that contains table of fixupps,information about memory
requirements .

Part – B Unit – 4

4.B.1 (i) State and explain the algorithm for one pass macro processor.
What are the different data structures used by a macro processor? Explain.
One-Pass Macro Processor:
-pass macro processor that alternate between macro definition and macro
expansion in a recursive way is able to handle recursive macro definition.

o The definition of a macro must appear in the source program before any
statements that invoke that macro.
o This restriction does not create any real inconvenience.

The design considered is for one-pass assembler. The data structures required
are:

o Stores the macro definition including macro prototype and macro body
o Comment lines are omitted.
o References to the macro instruction parameters are converted to a positional
notation for efficiency in substituting arguments.

o Stores macro names


WWW.VIDYARTHIPLUS.COM

o Serves as an index to DEFTAB


inters to the beginning and the end of the macro definition (DEFTAB)

o Stores the arguments according to their positions in the argument list.


o As the macro is expanded the arguments from the Argument table are
substituted for the corresponding parameters in the macro body.
o The figure below shows the different data structures described and their
relationship.

4.B.2 (b) Explain in brief about


(i) 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.
(ii) MASM Macro processor.

4.B.3 Explain the various machine independent macro processor features, in detail.
Concatenation of Macro parameters

4.B.4 Discuss the various design options of a MASM macro processor

macro

4.B.5 Explain with an example how macro processor allows the invocation of macro with in
macro.
l Macro invocations within macros
WWW.VIDYARTHIPLUS.COM

» process macro invocation during expansion time


l Recursive macro expansion
» Problems:
– ARGTAB
– EXPANDING
» Solution
– Recursive call
– While loop with stack

4.B.6 Discuss the macro processing features of ANSI C programming language.


 In the ANSI C language, definitions and invocations of macros are handled by a
preprocessor, which is generally not integrated with the rest of the compiler
 #define ABSDIFF(X,Y) X>Y ? X-Y : Y-X
 #define DISPLAY(EXPR) printf(#EXPR”=%d\n”,EXPR)
 Macro in ANSI C may contain definitions or invocations of other macros
 DISPLAY(ABSDIFF(3,8))ABSDIFF(3,8)=5
 The ANSI C preprocessor also provides conditional compilation statements
 #ifndef BUFFER_SIZE
#define BUFFER_SIZE 1024
#endif
WWW.VIDYARTHIPLUS.COM

4.B.7 Explain the various machine independent featuresof macro processor in detail
Concatenation of Macro parameters
 Most macro processors allow parameters to concatenated with other character strings
 If similar processing is to be performed on each series of variables, the programmer
might want to incorporate this processing in to a macro instruction
 The body of the macro definition might contain a statement like “LDA X&ID1” in
which the parameter &ID is concatenated after the character string X and before the
character string 1
 If the macro definition contained both &ID and &ID1 as parameters, the situation
would be ambiguous
 Most macro processors deal with this problem by providing a special concatenation
operator (e.g. )
 LDA X&ID1

 Relative addressing in a source statement may be acceptable for short jumps such as
“JEQ *-3*
 For longer jumps spanning several instructions, such notation is very inconvenient,
error-prone and difficult to read
 Allow the creation of special types of labels
 Each symbol beginning with $ has been modified by replacing $ with $xx, where xx
is a two character alphanumeric counter of the number of macro instructions
expanded
 For the first macro expansions, xx will have the value AA
 For succeeding macro expansions, xx will be set to AB, AC, etc

 Most macro processors can modify the sequence of statements generated for a macro
expansion, depending on the arguments supplied in the macro invocation
 The IF statement evaluates a Boolean expression that is its operand
 If the value of this expression is TRUE, the statements following the IF are generated
until an ELSE is encountered
 Otherwise, these statements are skipped, and the statements following the ELSE are
generated
 The ENDIF statement terminates the conditional expression that was begun by the IF
statement
WWW.VIDYARTHIPLUS.COM

 Positional parameter: parameters and arguments were associated with each other
according to their positions in the macro prototype and the macro invocation
statement
 Keyword parameters: each argument value is written with a keyword that named the
corresponding parameter
 Each parameter name is followed by an equal sign, which identifies a keyword
parameter
 The parameter is assumed to have the default value if its name does not appear in the
macro invocation statement

4.B.8 Discuss the algorithm for a one – pass macro processor.


WWW.VIDYARTHIPLUS.COM
WWW.VIDYARTHIPLUS.COM

4.B.9 Write notes on (i) conditional macro expansion, (ii) ANSI C macro processing.
 Pre-concatenation
o LDA X&ID1
 Post-concatenation
o LDA X&ID1
 Example: Figure 4.6

4.B.10 Discuss in brief about the different data structures used by a macro processor.
 Data Structures
o MACRO DEFINITION TABLE (DEFTAB)
 Macro prototype
 States that make up the macro body
 Reference to parameters are converted to a positional notation.
WWW.VIDYARTHIPLUS.COM

o MACRO NAME TABLE (NAMTAB)


 Role: an index to DEFTAB
 Pointers to the beginning and end of the definition in DEFTAB
o MACRO ARGUMENT TABLE (ARGTAB)
 Used during the expansion
 Invocation  Arguments are stored in ARGTAB according to their
position

4.B.11 What is the need for concatenation of macro parameters ? Explain


REFER 4.B.7

4.B.12 Write notes on the following :


(1). Conditional macro expression (8)
Conditional Macro Expansion
There are applications of macro processors that are not related to assemblers or assembler
programming.
Conditional assembly depends on parameters provides
MACRO &COND
……..
IF (&COND NE ‘’)
part I
ELSE
part II
WWW.VIDYARTHIPLUS.COM

ENDIF
………
ENDM
Part I is expanded if condition part is true, otherwise part II is expanded. Compare operators:
NE, EQ, LE, GT.

4.B.13 Explain the features of machine independent maxcro processor in details.


Concatenation of Macro parameters
Generation of unique labels

REFER 4.B.7
4.B.14 Describe the following in detail:
(i)Conditional macro expansion
(ii) MASM macro processor
(iii) ANSI C macro language

4.B.15 With an example program, explain the process of conditional macro expansion.

REFER 4.B.7

4.B.16 Explain the concatenation of macro parameters and handling of lables by macro
processor with examples.
Most macro processor allows parameters to be concatenated with other character strings.
Suppose that a program contains a series of variables named by the symbols XA1, XA2,
XA3,…, another series of variables named XB1, XB2, XB3,…, etc. If similar processing is to
be performed on each series of labels, the programmer might put this as a macro instruction.
The parameter to such a macro instruction could specify the series of variables to be operated
on (A, B, etc.). The macro processor would use this parameter to construct the symbols
required in the macro expansion (XA1, Xb1, etc.).
Suppose that the parameter to such a macro instruction is named &ID. The body of the macro
definition might contain other marco
WWW.VIDYARTHIPLUS.COM

Part – B Unit – 5

5.B.1 (i) With aneat block diagrm,explain the different components of an editor structure.
.

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
Most Text editors have a structure similar to that shown above.

The command Language Processor It accepts input from the user‟s input devices,
and analyzes the tokens and syntactic structure of the commands. It functions much
WWW.VIDYARTHIPLUS.COM

like the lexical and syntactic phases of a compiler. The command language processor
may invoke the semantic routines directly. In a text editor, these semantic routines
perform functions such as editing and viewing. The semantic routines involve
traveling, editing, viewing and display functions. Editing operations are always
specified by the user and display operations are specified implicitly by the
other three categories of operations. Traveling and viewing operations may be
invoked either explicitly by the user or implicitly by the editing operations
Editing Component In editing a document, the start of the area to be edited is
determined by the current editing pointer maintained by the editing component, which
is the collection of modules dealing with editing tasks. The current editing pointer can
be set or reset explicitly by the user using travelling commands, such as next
paragraph and next screen, or implicitly as a side effect of the previous editing
operation such as delete paragraph.

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

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

Display Component

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

Editing Filter

Filtering consists of the selection of contiguous characters beginning at the current


point.The editing filter filters the document to generate a new editing buffer based on
the current editing pointer as well as on the editing filter parameters

Editing Buffer

It contains the subset of the document filtered by the editing filter based on the editing
pointer and editing filter parameters
WWW.VIDYARTHIPLUS.COM

Viewing Filter

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

Viewing Buffer
It contains the subset of the document filtered by the viewing filter based on the
viewing pointer and viewing filter parameters. E.g. The user of a certain editor might
travel to line 75,and after viewing it, decide to change all occurrences of “ugly
duckling” to “swan” in lines 1 through 50 of the file by using a change command such
as [1,50] c/ugly duckling/swan/ As a part of the editing command there is implicit
travel to the first line of the file

(iii)How are user interface useful? Explain

The user of an interactive editor is presented with a conceptual model of the


editing system. The model is an abstract framework on which the editor and the world
on which the operations are based. The line editors simulated the world of the
keypunch they allowed operations on numbered sequence of 80-character card image
lines.
The Screen-editors define a world in which a document is represented as a
quarter-plane of text lines, unbounded both down and to the right. The user sees,
through a cutout, only a rectangular subset of this plane on a multi line display
terminal.

The cutout can be moved left or right, and up or down, to display other portions of the
document. 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. Input devices are categorized
as: 1)Text devices 2) Button devices 3) Locator devices

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.
2) Button or Choice devices generate an interrupt or set a system flag, usually causing
an invocation of an associated application program. Also special function keys are
also available on the key board. Alternatively, buttons can be simulated in software by
displaying text strings or symbols on the screen. The user chooses a string or symbol
instead of pressing a button.
3) Locator devices: They are two-dimensional analog-to-digital converters that
position a cursor symbol on the screen by observing the user‟s movement of the
device. The most common such devices are the mouse and the tablet.

The Data Tablet is a flat, rectangular, electromagnetically sensitive panel. Either the
WWW.VIDYARTHIPLUS.COM

ballpoint pen like stylus or a puck, a small device similar to a mouse is moved over
the surface. The tablet returns to a system program the co-ordinates of the position on
the data tablet at which the stylus or puck is currently located. The program can then
map these data-tablet coordinates to screen coordinates and move the cursor to the
corresponding screen position. Text devices with arrow (Cursor) keys can be used to
simulate locator devices. Each of these keys shows an arrow that point up, down, left
or right. Pressing an arrow key typically generates an appropriate character sequence;
the program interprets this sequence and moves the cursor in the direction of the
arrow on the key pressed.

VOICE-INPUT DEVICES: which translate spoken words to their textual equivalents,


may prove to be the text input devices of the future. Voice recognizers are currently
available for command input on some systems.
OUTPUT DEVICES The output devices let the user view the elements being edited
and the result of the editing operations.
-printing terminals
that generated output on paper.

CRT screen essentially to simulate the hard-copy teletypewriter.


‟s advanced CRT terminals use hardware assistance for such features as
moving the cursor, inserting and deleting characters and lines, and scrolling lines and
pages.
th high
resolution displays; support multiple proportionally spaced character fonts to produce
realistic facsimiles of hard copy documents.

5.B.2 Discuss in detail about an interactive debugging system


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

Debugging Functions and Capabilities


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
programSetting 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
WWW.VIDYARTHIPLUS.COM

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 How functions are
provided
To provide these functions, a debugger should consider the language in which the
program being debugged is written
A single debugger – many programming languages – language independent
The debugger - a specific programming language – language dependent
The debugger must be sensitive to the specific language being debugged
The context being used has many different effects on the debugging interaction
The statements are different depending on the language
Cobol - MOVE 6.5 TO X
Fortran - X = 6.5
C - X = 6.5
Examples of assignment statements
What about optimized code ?
It is also important that a debugging system be able to deal with optimized code
Many optimizations like
- invariant expressions can be removed from loops
- separate loops can be combined into a single loop
- redundant expression may be eliminated
- elimination of unnecessary branch instructions

Leads to rearrangement of segments of code in the program All these optimizations create
problems for the debugger, and should be handled carefully
Relationship with Other Parts of the System
WWW.VIDYARTHIPLUS.COM

The important requirement for an interactive debugger is that it always be available Must
appear as part of the run-time environment and an integral part of the system When an
error is discovered, immediate debugging must be possible
The debugger must communicate and cooperate with other operating system components
such as interactive subsystems
Debugging is more important at production time than it is at application-development
time 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
5.B.3 ) Explain any two system software tools highlighting their advantages and
disadvantages.

Types of Text Editors

Depending on how editing is performed, and the type of output that can be generated, editors
can be broadly classified as -

1. Line Editors - During original creation lines of text are recognised and delimited by
end-of-line markers, and during subsequent revision, the line must be explicitly
specified by line number or by some pattern context. eg. edlin editor in early MS-
DOS systems.
2. Stream Editors - The idea here is similar to line editor, but the entire text is treated as
a single stream of characters. Hence the location for revision cannot be specified
using line numbers. Locations for revision are either specified by explicit positioning
or by using pattern context. eg. sed in Unix/Linux.

Line editors and stream editors are suitable for text-only documents.

3. Screen Editors - These allow the document to be viewed and operated upon as a two
dimensional plane, of which a portion may be displayed at a time. Any portion may
be specified for display and location for revision can be specified anywhere within the
displayed portion. eg. vi, emacs, etc.
4. Word Processors - Provides additional features to basic screen editors. Usually
support non-textual contents and choice of fonts, style, etc.
5. Structure Editors - These are editors for specific types of documents, so that the editor
recognises the structure/syntax of the document being prepared and helps in
maintaining that structure/syntax.
WWW.VIDYARTHIPLUS.COM

Salient Aspects of Text Editor

A text editor has to cover the following main aspects related to document creation, storage
and revision -

1. Interactive user interface


2. Appropriate format for storing the document in file in secondary storage
3. Efficient transfer of information between the user interface and the file in secondary
storage

 Text editors

 Debugging systems
5.B.4 ) What are the various criteria of 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 Screen-editors define a world in which a document is represented as a quarter-plane
of text lines.unbounded both down and to the right. The user sees ,through a cutout ,only
a rectangular subset of this planeon a multi line display terminal. The cutout can be move
left or right ,and up or down ,to display other portions of the document.
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.
The interactive debugging system should be user friendly. The facilities of
debugging system should be organized into few basic categories of functions which
should closely reflect common user tasks.
Full – screen displays and windowing systems
-screen display and windowing
systems.
The advantage of such interface is that the information can be should displayed and
changed easily and quickly.
Menus:

remember
menus without having to retrace an entire
hierarchy.
-screen terminal device is not available, user should have an equivalent
action in a linear debugging language by providing commands.
Command language:
a clear, logical, simple syntax. Parameters
names
WWW.VIDYARTHIPLUS.COM

should be consistent across set of commands

Parameters should automatically be checked for errors for type and range values.
ided for parameters.

special characters.
On Line HELP facility
-line HELP facility that should provide
help for all options of menu

5.B.5 (i) Explain the various types of user interfaces.

Types

Direct manipulation interface is the name of a general class of user interfaces that allow users

to manipulate objects presented to them, using actions that correspond at least loosely to the

physical world.

Currently (as of 2009) the following types of user interface are the most common:

 Graphical user interfaces (GUI) accept input via devices such as a computer keyboard

and mouse and provide articulated graphical output on the computer monitor. There are at

least two different principles widely used in GUI design: Object-oriented user

interfaces (OOUIs) and application oriented interfaces[verification needed].

 Web-based user interfaces or web user interfaces (WUI) that accept input and provide

output by generating web pages which are transmitted via the Internet and viewed by the

user using a web browser program. Newer implementations

utilize Java, JavaScript, AJAX, Adobe Flex, Microsoft .NET, or similar technologies to

provide real-time control in a separate program, eliminating the need to refresh a


WWW.VIDYARTHIPLUS.COM

traditional HTML based web browser. Administrative web interfaces for web-servers,

servers and networked computers are often called control panels.

 Touchscreens are displays that accept input by touch of fingers or a stylus. Used in a

growing amount of mobile devices and many types of point of sale, industrial processes

and machines, self-service machines etc.

User interfaces that are common in various fields outside desktop computing:

 Command line interfaces, where the user provides the input by typing a command

string with the computer keyboard and the system provides output by printing text on the

computer monitor. Used by programmers and system administrators, in engineering and

scientific environments, and by technically advanced personal computer users.

 Touch user interface are graphical user interfaces using a touchpad or touchscreen

display as a combined input and output device. They supplement or replace other forms

of output with haptic feedback methods. Used in computerized simulators etc.

An important consideration of a document is its layout to a human reader. For this it is


essential to present a document in a rectangular form, on the monitor screen (terminal) or via
a printer (as an output of the interactive process). Further since a document can potentially be
very large and since in a computer terminal can display only a limited size of a document at a
time, hence it is necessary for a text editor to display only a portion (page) of a large
document that cannot be displayed in entireity at once.

The process of creating and revising a document in a computer is called editing. For
interactive editing a text editor displays a document on the terminal and accepts various types
of input from the user through different types of input devices, viz., keyboard, mouse, data-
tablet (flat, rectangular, elctromagnetically sensitive panel over which a ball-point-pen-like
stylus is moved and the coordinates of the stylus is sent to the system).

Initially the text editor may display the starting portion of the document. During editing the
user may give inputs to bring other portions to the display. Besides the displayed page, there
WWW.VIDYARTHIPLUS.COM

is the notion of a point within the page, indicated by an easily distinguishable symbol called
the cursor, where the next insertion, deletion or modification will be effective. An editor
provides various mechanisms (left-right-up-down keys, page-up, page-down keys, mouse
pointer, commands, etc.) for the cursor to be moved throughout the document. If the user
requires it to be moved outside of the displayed page, the editor displays the new portion that
would contain the cursor. Many editors also allows the user to select (and deselect) portions
of the document whose attributes can be modified as a whole (like change of font, delete,
etc.)

The most basic action by a user in creating or revising a document is to type in the text
through the keyboard and, possibly, delete already typed portions. Most text editors support
many other features in order to reduce the work of the user as well as to produce a higher
quality documents. Commonly found features include cut-paste, pattern-search (and
substitute), font-change, working with multiple documents at the same time, etc.

Many text editors allows pictures and other non-text information to be included in a
document. Such editors provide mechanisms to either create/modify such information or
embed such objects inside the document.

The output of an editing process, i.e., the document, can be either saved as file(s) in the
secondary storage or sent to some destination in the network, such as a printer or some
remote host.

(ii) Discuss the nature of the user interface for an interactive debugger.
REFER 5.B.2,,5.B.4
5.B.6 ) (i) Explain the structure of a text editor.
(ii) Explain the important functions of an interative debugging system.
REFER 5.B.2
5.B.7 (a) Discuss clearly the design of the Functional components of a text editor.
REFER 5.B.1
5.B.8 List down the options provided by any debugger that you have used. Discuss briefly the
possible design of this debugger.
REFER 5.B2
5.B.9 With a neat diagram, explain the structure of an editor.
REFER 5.B.1
5.B.10 Discuss in detail about the various issues related to an interative debugging system .
REFER 5.B.2
5.B.11 Explain the editor structure with neat diagram
REFER 5.B.1
5.B.12 Discuss interactive debugging systems in detail.
REFER 5.B.2
5.B.13 Discuss functions and capabilities of an interactive debugging system.
REFER5.B2
WWW.VIDYARTHIPLUS.COM

5.B.14 Describe the structure of a text and discuss some of the system related issues.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy