Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

System Software 2019

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

UNIT 1

Simplified Instructional Computer (SIC): Simplified Instructional Computer


(SIC) is a hypothetical computer that has hardware features which are often found
in real machines. There are two versions of this machine: SIC standard Model
SIC/XE(extra equipment or expensive) Object program for SIC can be properly
executed on SIX/XE which is known as upward compatability.
SIC Machine Architecture/Components –
Memory – Memory is byte addressable that is words are addressed by location of
their lowest numbered byte. There are 2^15 bytes in computer memory (1 byte = 8
bits) 3 consecutive byte = 1 word (24 bits = 1 word)
Registers –There are 5 registers in SIC. Every register has an address associated
with it known as register number. Size of each register is 4 bytes. On basis of
register size, integer size is dependent. I. A(Accumulator-0): It is used for
mathematical operations.
II. X(Index Register-1): It is used for addressing. III. L(Linkage Register-2): It
stores the return address of instruction in case of subroutines. IV. PC(Program
Counter-8): It holds the address of next instruction to be executed. V. SW(Status
Word-9): It contains the variety of information
Status Word Register:

Data Format – Integers are represented by 24 bit.Negative numbers are


represented in 2’s complement. Characters are represented by 8 bit ASCII value.
No floating point representation is available.
Instruction Format –All instructions in SIC have 24 bit format

Instruction Set – Load And Store Instructions: To move or store data from
accumulator to memory or vice-versa. For example LDA, STA, LDX, STX etc.
Comparison Instructions: Used to compare data in memory by contents in
accumulator. For example COMP data.
Arithmetic Instructions: Used to perform operations on accumulator and memory
and store result in accumulator. For example ADD, SUB, MUL, DIV
Conditional Jump: compare the contents of accumulator and memory and
performs task based on conditions. For example JLT, JEQ, JGT
Subroutine Linkage: Instructions related to subroutines. For example JSUB, RSUB
Input and Output –It is performed by transferring 1 byte at a time from or to
rightmost 8 bits of accumulator. Each device has 8 bit unique code.
There are 3 I/O instructions: Test Device (TD) tests whether device is ready or
not. Condition code in Status Word Register is used for this purpose. If cc is < then
device is ready otherwise device is busy. Read data(RD) reads a byte from device
and stores in register A. Write data(WD) writes a byte from register A to the
device.
SIC/XE Machine Architecture:
• Memory: Byte addressable, 3 consecutive bytes form a word 8-bit bytes 220
bytes in the computer memory
REGISTERS: More registers are provided by SIC/XE

Data format: 24-bit binary number for integer, 2_s complement for negative
values
48-bit floating-point data type The exponent is between 0 and 2047 f*2(e-1024)0:
set all bits to 0

Instruction formats:Relative addressing - format 3 (e=0) Extend the address to 20


bits - format 4 (e=1)‰Don’t refer memory at all - formats 1 and 2
A Simple SIC Assembler: The translation of source program to object code
requires us to accomplish the following functions: 1) Convert mnemonic operation
codes to their machinelanguage equivalents – e.g., translates STL to 14 2) Convert
symbolic operands to their equivalent machineaddresses – e.g., translate RETADR
to 1033
3) Build the machine instructions in the proper format; 4) Convert the data
constants specified in the source program into their internal machine
representations – e.g., translate EOF to 454F46 5) Write the object program and
the assembly listing. If we attempt to translate the program line by line, we will be
unable to process this statement because we do not know the address that will be
assigned to RETADR. Because of this, most assemblers make two passes over the
source program. The first pass scans the source program for label definitions and
assigns addresses. The second pass performs most of the actual translation.

Assembler Algorithm and Data Structures The simple assembler uses two major
internal data structures: the Operation Code Table (OPTAB) and the Symbol Table
(SYMTAB).Written by WWF 5 OPTAB must contain (at least) the mnemonic
operation code and its machine language equivalent. In more complex
assemblers, this table also contains information about instruction format and length.
During Pass 1, OPTAB is used to look up and validate operation codes in the
source program. In Pass 2, it is used to translate the operation codes to machine
language.

MACHINE DEPENDENT ASSEBLER FEATURE:


Instruction Formats and Addressing Modes : Key points of this subsection: the
translation of the source program, and the handling of different instruction formats
and different addressing modes. Note that the START statement (assembler
directive) specifies a beginning program address of 0. Translation of
register-to-register instructions (such as CLEAR – line 125, COMPR – line 150):
The assembler must simply convert the mnemonic operation code to machine
language (using OPTAB) and change each register mnemonic to its numeric
equivalent. Register-to-memory instructions: assembled using either
program-counter relative or base relative addressing; The assembler must, in either
case, calculate a displacement to be assembled as part of the object instruction.If
neither program-counter relative nor base relative addressing can be used (because
the displacements are too large), then the 4-byte extended instruction format (20-bit
displacement) must be used. Example:15 0006 CLOOP +JSUB RDREC 4B101036
Program Relocation: The program we considered in Section 2.1 is an example of
an absolute program (or absolute assembly). The program must be loaded at
address 1000 (specified at assembly time) in order to execute properly. Example:
55 101B LDA THREE 00102D. In the object program (Fig 2.3), this statement is
translated as 00102D, specifying that register A is to be loaded from memory
address 102D. Suppose we attempt to load and execute the program at address
2000 instead of address 1000.However, the assembler can identify for the loader
those parts of the object program that need modification. An object program
that contains the information necessary to perform this kind of modification is
called a relocatable program.
relative to the start of the program. (This is the reason we initialized the location
counter to 0 for the assembly.) 2) The assembler will also produce a command for
the loader, instructing it to add the beginning address of the program to the address
field in the JSUB instruction at load time
UNIT 2
Machine-Independent Assembler Features :
LITERALS:It is often convenient for the programmer to be able to write the value
of a constant operand as a part of the instruction that uses it. Note that a literal is
identified with the prefix =, which followed by a specification of the literal value.
Example: 45 001A ENDFIL LDA =C’EOF’ 032010 specifies a 3-byte operand
with value ‘EOF’.
Symbol-Defining Statements : The user-defined symbols in assembler language
programs appear as labels on instructions or data areas. The value of such a label is
the address assigned to the statement on which it appears. Most assemblers
provide an assembler directive that allows the programmer to define symbols and
specify their value. The assembler directive generally used is EQU. The general
form: symbol EQU value *This statement define the given symbol (enters it into
SYMBOL) and assigns to it the value specified.
Expressions: Most assemblers allow the use of expressions. Each such
expression must be evaluated by the assembler to produce a single operand address
or value. Expressions are classified as either absolute expressions or relative
expressions.Relative: means relative to the beginning of the program. Labels on
instructions and data areas, and references to the location counter value, are relative
terms. Absolute: means independent of program location. A constant is an absolute
term.
Program Blocks: Program blocks are referred to be segments of code that are
rearranged within a single object program unit, and control sections (appeared in
next subsection) to be segments that are translated into independent object program
units
Control Sections and Program Linking : A control section is a part of the
program that maintains its identity after assembly; each such control section can be
loaded and relocated independently of the others. Different control sections are
most often used for subroutines or other logical subdivisions of a program. Control
sections differ from program blocks in that they are handled separately by the
assembler.
One-Pass Assemblers The main problem in trying to assemble a program in one
pass involves forward references and forward jump . There are two main types of
one-pass assembler. One type produces object code directly in memory for
immediate execution the other type produces the usual kind of object program for
later execution.

The first forward reference occurred on line 15. Since the operand (RDREC) was
not yet defined, the instruction was assembled with no value assigned as the
operand address RDREC was then entered into SYMTAB as an undefined
symbol the address of the operand field of the instruction was inserted in a list
associated with RDREC
1) Forward references are entered into lists as before.
2) When the definition of a symbol is encountered, instructions that made forward
references to that symbol may no longer available in memory for modification. In
this case, the assembler must generate another Text record with the correct operand
address. 3) When the program is loaded, this address will be inserted into the
instruction by the action of the loader.
ALGORITHM:Assembler Pass 1:
begin read first input lineif OPCODE ='START' then begin save #[OPERAND]
as starting address initialize LOCCTR to starting address write line to
intermediate file read next input line end {if START} else initialize LOCCTR
to 0 while OCODE != 'END' do begin if this is not a comment line then
begin if there is a symbol in the LABEL field then begin search SYMTAB
for LABEL if found then set error flag (duplicate symbol) else insert
(LABEL,LOCCTR) into SYMTAB end {if symbol}
search OPTAB for OPCODE if found then add 3 {instruction length} to
LOCCTR else if OPCODE='WORD' then add 3 to LOCCTR else if OPCODE =
'RESW' then add 3 * #[OPERAND] to LOCCTR else if OPCODE = 'RESB' then
add #[OPERAND] to LOCCTR else if OPCODE = 'BYTE' then begin find
length of constant in bytes add length to LOCCTR end {if BYTE} else set
error flag (invalid operation code) end {if not a comment} write line to
intermediate file read next input line end {while not END} write last line to
intermediate file save (LOCCTR – starting address) as program length end {Pass
1}
Multi-Pass Assemblers: Consider the program sequence ALPHA EQU BETA
BETA EQU DELTA DELTA RESW 1 Note that any assembler that makes only
two sequential passes over the source program cannot resolve such a sequence of
definitions. The general solution is a multi-pass assembler that can
make as many passes as are needed to process the definitions of symbols.
PASS 2: begin read first input line (from intermediate file) if OPCODE
='START' then begin write listing line read next input line end {if START} write
Header record to object program initialize first Text record while OPCODE !=
'END' do begin if this is not a comment line then begin search OPTAB for
OPCODE if found then begin if there is a symbol in OPERAND field then begin
search SYMTAB for OPERAND if found then store symbol value as operand
address else begin store 0 as operand address set error flag (undefined symbol)
end end {if symbol} else store 0 as operand address assemble the object code
instruction end {if opcode found} else if OPCODE ='BYTE' or 'WORD' then
convert constant to object code if object code will not fit into the current Text
record then begin write Text record to object program initialize new Text record
end add object code to Text record end {if not comment} write listing line read
next input line end(while not END) write last Text record to object program
write End record to object write last listing line end{Pass 2}
UNIT 3
Design of an Absolute Loader : For a simple absolute loader, all functions are
accomplished in a single pass as follows: 1) The Header record of object programs
is checked to verify that the correct program has been presented for loading. 2) As
each Text record is read, the object code it contains is moved to the indicated
address in memory. 3) When the End record is encountered, the loader jumps to the
specified address to begin execution of the loaded program.

Therefore, to save space and execution time of loaders, most machines store object
programs in a binary form, with each byte of object code stored as a single byte in
the object program.
A Simple Bootstrap Loader: When a computer is first turned on or restarted,
special type of absolute loader, called a bootstrap loader, is executed. This
bootstrap loads the first program to be run by the computer – usually an operating
system. The object code from device F1 is always loaded into consecutive bytes
of memory, starting at address 80. The main loop of the bootstrap keeps the address
of the next memory location to be loaded in register X. After all of the object
code from device F1 has been loaded, the bootstrap jumps to address 80, which
begins the execution of the program that was loaded. Much of the work of the
bootstrap loader is performed by the subroutine GETC. GETC is used to read and
convert a pair of characters from device F1 representing 1 byte of object code to be
loaded. For example, two bytes =C“D8”Æ‘4438’H converting to one byte ‘D8’H.
The resulting byte is stored at the address currently in register X, using STCH
instruction that refers to location 0 using indexed addressing. The TIXR instruction
is then used to add 1 to the value X
Machine-Dependent Loader Features:
Relocation: Two methods for specifying relocation as part of the object program.
The first method: A Modification record is used to describe each part of the object
code that must be changed when the program is relocated. Most of the instructions
in this program use relative or immediate addressing. The only portions of the
assembled program that contain actual addresses are the extended format
instructions on lines 15, 35, and 65.
THE SECOND METHOD: There are no Modification records. The Text records
are the same as before except that there is a relocation bit associated with each
word of object code. Since all SIC instructions occupy one word, this means that
there is one relocation bit for each possible instruction. The relocation bits are
gathered together into a bit mask following the length indicator in each Text record.
Program Linking:For the first program (PROGA), (1) REF1 is simply a reference
to a label within the program. (2) It is assembled in the usual way as a PC relative
instruction. (3) No modification for relocation or linking is necessary.
In PROGB, the same operand refers to an external symbol. (1) The assembler uses
an extended-format instruction with address field set to 00000. (2) The object
program for PROGB (Fig 3.9) contains a Modification record instructing the loader
to add the value of the symbol LISTA to this address field when the program is
linked. reference marked REF2 is processed in a similar manner. REF3 is an
immediate operand whose value is to be the difference between ENDA and LISTA
(that is, the length of the list in bytes). In PROGA, the assembler has all of the
information necessary to compute this value.
Algorithm and Data Structures for a LinkingLoader: The algorithm for a
linking loader is considerably more complicated than the absolute loader algorithm
discussed A linking loader usually makes two passes over its input, just as an
assembler does. main data structure needed for our linking loader is an external
symbol table ESTAB.
ALGORITHM FOR ONE PASS LINKNG LOARDER:
The beginning load address for the linked program (PROGADDR) is obtained from
the OS. This becomes the starting address (CSADDR) for the first control section
in the input sequence. 2) The control section name from Header record is entered
into ESTAB, with value given by CSADDR. .
PASS2:
1) As each Text record is read, the object code is moved to the specified address 2)
When a Modification record is encountered, the symbol whose value is to be used
for modification is looked up in ESTAB.
3) This value is then added to or subtracted from the indicated location in memory.
4) The last step performed by the loader is usually the transferring of control to the
loaded program to begin execution.
UNIT 4
MACHINE INDEPENDENT MACRO PROCESSOR FEATURE:
CANCATENATION OF MACRO PARAMETERS: Concatenate parameters
with other character stings, for example: A program contains a set of series of
variables: XA1, XA2, XA3,… XB1, XB2, XB3,…
The programmer wants to write a macro to process each series of variables. The
programmer specifies the series of variables to be operated on (A, B, …). The
macro processor construct the symbols by concatenating X, (A, B, …) and
(1,2,3,…) in the macro expansion. Suppose such parameter is named &ID, the
macro body may contain a statement: LDA X&ID1, in which &ID is concatenated
after the string “X” and before the string “1”. → LDA XA1
(&ID=A) → LDA XB1 (&ID=B)
Ambiguity problem: E.g., X&ID1 may mean “X” + &ID + “1” “X” + &ID1
This problem occurs because the end of the parameter is not marked.
Solution to this ambiguity problem: Use a special concatenation operator “→” to
specify the end of the parameter X&ID →1
Example of Concatenation:

GENERATION OF UNIQUE LABELS:


Labels in the macro body may cause “duplicate labels” problem if the macro is
invocated and expanded multiple times. Use of relative addressing at the source
statement level is very inconvenient, error-prone, and difficult to read. It is highly
desirable to let the programmer use label in the macro body Labels used within the
macro body begin with $. let the macro processor generate unique labels for each
macro invocation and expansion. During macro expansion, the $ will be replaced
with $xx, where xx is a two-character alphanumeric counter of the number of
macro instructions expanded. XX=AA, AB, AC,…..
CONDITIONAL MACRO EXPANSION:
Arguments in macro invocation can be used to: Substitute the parameters in the
macro body without changing the sequence of statements expanded.
2. Modify the sequence of statements for conditional macro expansion.
This capability adds greatly to the power and flexibility of a macro language.
Macro-time conditional structure:IF-ELSE-ENDIF,WHILE-ENDW
Example of Conditional Macro Expansion: Two additional parameters used
in the example of conditional macro expansion (i) &EOR: specifies a hexadecimal
character code that marks the end of a record. (ii) &MAXLTH: specifies the
maximum length of a record.Macro-time variable (set symbol) can be used to
(i) store working values during the macro expansion (ii) store the evaluation
result of Boolean expression (iii)control the macro-time conditional structures
begins with “&” and that is not a macro instruction parameter be initialized to a
value of 0 be set by a macro processor directive, SET
Implementation of Conditional Macro Expansion:(IF-ELSE-ENDIF Structure)
A symbol table
(i) This table contains the values of all macro-time variables used.
(ii) Entries in this table are made or modified when SET statements are
processed.
(iii) This table is used to look up the current value of a macro-time variable
whenever it is required.
When an IF statement is encountered during the expansion of a macro,
the specified Boolean expression is evaluated. 1. TRUE
(a) the macro processor continues to process lines from DEFTAB until it
encounters the next ELSE or ENDIF statement.
(b) If ELSE is encountered, then skips to ENDIF 2. FALSE
the macro processor skips ahead in DEFTAB until it finds the next ELSE or
ENDLF statement
KEYWORD MACRO PARAMETER:
Positional parameters: Parameters and arguments are associated according to
their positions in the macro prototype and invocation.
If an argument is to be omitted, a null argument should be used to maintain the
proper order in macro invocation: For example: GENER ,,DIRECT,,,,,,3. It is
not suitable if a macro has a large number of parameters, and only a few of these
are given values in a typical invocation.
Keyword parameters:Each argument value is written with a keyword that names
the corresponding parameter. Arguments may appear in any order. Null arguments
no longer need to be used. For example: GENER
TYPE=DIRECT,CHANNEL=3. It is easier to read and much less error-prone than
the positional method.
ANSI MACRO LANGUAGE: In the ANSI C language, definitions and
invocations of macros are handled by a preprocessor. This preprocessor
is generally not integrated with the rest of compiler. Its operation is similar to the
macro processor we discussed before.
Two simple examples of ANSI C:
macro definitions: #define NULL 0 #define EOF (-1) After these definitions,
every occurrence of NULL will be replaced by 0, and every occurrence of EOF will
be replaced by (-1).ANSI C macros can also be defined with parameters. Consider,
for example, the macro definition #define ABSDIFF(X,Y) ((X) > (Y)) ? (X) – (Y) :
(Y) – (X)) For example, ABSDIFF (I+1, J-5) would be converted by the macro
processor into ((I+1) > (J-5) ? (I+1) – (J-5) : (J-5) – (I+1)).
The ANSI C preprocessor also provides conditional compilation statements. For
example, in the sequence #ifndef BUFFER_SIZE #define BUFFER_SIZE 1024
#endif the #define will be processed only if BUFFER_SIZE has not already been
defined.
Microsoft Macro Assembler:
The Microsoft Macro Assembler (MASM) is an assembler for the x86 family of
microprocessors, originally produced Microsoft MS-DOS operating system.
The features of MASM are listed below:
i It supported a wide variety of macro facilities and structured
programming idioms, including high-level constructions for looping, procedure
calls and alternation (therefore, MASM is an example of a high-level assembler).
ii. MASM is one of the few Microsoft development tools for which there was
no separate 16-bit and 32-bit version.
MASM can build very small high performance executable files that are well suited
where size and speed matter.
MASM32 has been designed to be familiar to programmers who have already
written API based code in Windows. The invoke syntax of MASM allows functions
to be called in much the same way as they are called in a high level compiler.
UNIT 5
Text Editors: An Interactive text editor has become an important part of almost
any computing environment. Text editor acts as a primary interface to the computer
for all type of “knowledge workers” as they compose, organize, study, and
manipulate computer-based information. A text editor allows you to edit a text file
(create, modify etc…). For example the Interactive text editors on Windows OS -
Notepad, WordPad, Microsoft Word, and text editors on UNIX OS - vi, emacs, jed,
pico.
Overview of the editing process:Document-editing process in an interactive
user-computer dialogue has four tasks
- Select the part of the target document to be viewed and manipulated
- Determine how to format this view on-line and how to display it
- Specify and execute operations that modify the target document
- Update the view appropriately
The above task involves traveling, filtering and formatting. Editing phase involves
– insert, delete, replace, move, copy, cut, paste, etc…
USER INTERFACE:The user interface is concerned with, the input devices, the
output devices and, the interaction language. The input devices are used to enter
elements of text being edited, to enter commands. The output devices, lets the user
view the elements being edited and the results of the editing operations and, the
interaction language provides communication with the editor.
Input Devices are divided into three categories, text devices, button devices and,
locator devices. Text Devices are keyboard. Button Devices are special function
keys, symbols on the screen. Locator Devices are mouse, data tablet. There are
voice input devices which translates spoken words to their textual equivalents.
Output Devices are Teletypewriters (first output devices), Glass teletypes (Cathode
ray tube (CRT) technology), Advanced CRT terminals, TFT Monitors (Wysiwyg)
and Printers (Hard-copy).
EDITOR STRUCTURE:

DEBUGGING FUNCTIONS:One important requirement of any IDS is the


observation and control of the flow of program execution. Setting break points –
execution is suspended, use debugging commands to analyze the progress of the
program, résumé execution of the program. Setting some conditional expressions,
evaluated during the debugging session, program execution is suspended, when
conditions are met, analysis is made, later execution is resumed.A Debugging
system should also provide functions such as tracing and traceback. Tracing can be
used to track the flow of execution logic and data modifications. The
control flow can be traced at different levels of detail – procedure, branch,
individual instruction, and so on… Traceback can show the path by which the
current statement in the program was reached. It can also show which statements
have modified a given variable or parameter. The statements are displayed rather
than as hexadecimal displacements
Relationship with Other Parts of the System: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.
User-Interface Criteria: Debugging systems should be simple in its organization
and familiar in its language, closely reflect common user tasks. The simple
organization contribute greatly to ease of training and ease of use. The user
interaction should make use of full-screen
displays and windowing-systems as much as possible. With menus and full-screen
editors, the user has far less information to enter and remember. There should be
complete functional equivalence between commands and menus – user where
unable to use full- screen IDSs may use commands. The command language should
have a clear, logical and
simple syntax; command formats should be as flexible as possible. Any good IDSs
should have an on-line HELP facility. HELP should be accessible from any state of
the debugging session

You might also like