Spos Unit 1 Introduction Notes
Spos Unit 1 Introduction Notes
1.1 INTRODUCTION
System Software
• System software consists of a variety of programs that support the operation of a
computer.
• It is a set of programs to perform a variety of system functions as file editing, resource
management, I/O management and storage management.
• The characteristic in which system software differs from application software is machine
dependency.
• An application program is primarily concerned with the solution of some problem, using
the computer as a tool.
• System programs on the other hand are intended to support the operation and use of
the computer itself, rather than any particular application.
• For this reason, they are usually related to the architecture of the machine on which they
are run.
• For example, assemblers translate mnemonic instructions into machine code. The
instruction formats, addressing modes are of direct concern in assembler design.
• There are some aspects of system software that do not directly depend upon the type of
computing system being supported. These are known as machine-independent features.
• For example, the general design and logic of an assembler is basically the same on most
computers.
UNIT I | 1.1
Fig. 1.1
Compilers
• A compiler is a language program that translates programs written in any high-level
language into its equivalent machine language program.
• It bridges the semantic gap between a programming language domain and the execution
domain.
• Two aspects of compilation are :
1. Generate code to increment meaning of a source program in the execution domain.
2. Provide diagnostics for violation of programming language, semantics in a source
program.
• The program instructions are taken as a whole.
Fig. 1.2
UNIT I | 1.2
Fig. 1.3
Assemblers
• Programmers found it difficult to write or red programs in machine language. In a quest
for a convenient language, they began to use a mnemonic (symbol) for each machine
instructions which would subsequently be translated into machine language.
• Such a mnemonic language is called Assembly language.
• Programs known as Assemblers are written to automate the translation of assembly
language into machine language.
Fig. 1.4
• Translating mnemonic operation codes to their machine language equivalents.
• Assigning machine addresses to symbolic tables used by the programmers.
Loader
• A loader is a system software program that performs the loading function.
UNIT I | 1.3
Fig. 1.5
UNIT I | 1.5
(a)
(b)
Fig. 1.8 : Language processors
The interpreter is a language translator. This leads to many similarities between translators
and interpreters. From a practical viewpoint many differences also exist between translators
and interpreters. The absence of a target program implies the absence of an output interface
UNIT I | 1.6
UNIT I | 1.11
1.2 ASSEMBLERS
1.2.1 Introduction to Assembly languages
There are two main classes of programming languages : high level (e.g., C, Pascal) and low
level. Assembly Language is a low level programming language. Programmers code symbolic
instructions, each of which generates machine instructions.
An assembler is a program that accepts as input an assembly language program (source) and
produces its machine language equivalent (object code) along with the information for the
loader.
UNIT I | 1.13
UNIT I | 1.14
UNIT I | 1.15
UNIT I | 1.17
UNIT I | 1.18
UNIT I | 1.19
UNIT I | 1.20
UNIT I | 1.21
UNIT I | 1.22
UNIT I | 1.23
Fig. 1.15
Above Fig. 1.15 illustrates use of the symbol and mnemonics tables by the analysis and
synthesis phases. The symbol table is constructed during analysis and used during synthesis.
The tasks performed by analysis and synthesis phase are as follows :
Analysis Phase :
1. Isolates the label, mnemonic opcode, and operands fields of a statement.
UNIT I | 1.24
UNIT I | 1.25
UNIT I | 1.26
UNIT I | 1.27
Fig. 1.17
START 100
MOVER AREG, X 100 04 1 _ _ _
L1 ADD BREG, ONE 101 01 2 _ _ _
ADD CREG, TEN 102 06 3 _ _ _
STOP 103 00 0 000
X DC ‘5’ 104
ONE DC ‘1’ 105
TEN DC ‘10’ 106
UNIT I | 1.29
5. Literal Table
The literal table keep list of all the literals used in the program.
The table has the following format.
Literal Symbol Value Legth of Inst. Characteristics
UNIT I | 1.30
3. MOT : Indicates Symbolic mnemonic for each instruction and its length.
4. POT : Indicates Symbolic mnemonic and action to be taken for each Pseudo Opcode.
UNIT I | 1.31
UNIT I | 1.32
UNIT I | 1.33
UNIT I | 1.34
UNIT I | 1.35
UNIT I | 1.36
UNIT I | 1.37
UNIT I | 1.38
UNIT I | 1.40
UNIT I | 1.41
UNIT I | 1.42
UNIT I | 1.43
UNIT I | 1.44
UNIT I | 1.45
UNIT I | 1.46
UNIT I | 1.47
UNIT I | 1.48
UNIT I | 1.49
UNIT I | 1.50
UNIT I | 1.51
UNIT I | 1.52
UNIT I | 1.53
UNIT I | 1.55
UNIT I | 1.56
INCR A 3, Data
: :
: :
INCR :
: A 1, Data
: A 2, Data
data DC F’5’ A 3, Data
: data Dc F’5’
:
END
Fig. 1.21
UNIT I | 1.58
UNIT I | 1.59
UNIT I | 1.60
A3, &arg3 :
MEND :
: :
: :
: :
LOOP1 INCR data1, data2, data3 LOOP1 A1, data1
: A2, data2
: A3, data3
: :
: :
LOOP2 INCR data3, data2, data1 LOOP2 A1, data1
: A2, data2
: A3, data3
data1 DC F’5’ :
data1 DC F’6’ data1 DC F’5’
data1 DC F’7’ data1 DC F’6’
data1 DC F’7’
1.3.3.1 Two ways of Specifying Arguments to a Macro Call
(A) Positional Argument
Argument are matched with dummy arguments according to order in which they appear.
• INCR A,B,C
• ‘A’ replaces first dummy argument.
• ‘B’ replaces second dummy argument.
• ‘C’ replaces third dummy argument.
(B) Keyword Arguments
All the macro instruction definitions used positional parameters. Parameters and arguments
are matched according to their positions in the macro prototype and the macro invocation
statement. The programmer needs to be careful while specifying the arguments. If an
argument is to be omitted the macro invocation statement must contain a null argument
mentioned with two commas.
Positional parameters are suitable for the macro invocation. But if the macro invocation has
large number of parameters, and if only few of the values need to be used in a typical
UNIT I | 1.61
UNIT I | 1.62
UNIT I | 1.63
UNIT I | 1.64
UNIT I | 1.65
43 ENDIF
44 IF (&MAXLTH
EQ ‘ ‘)
45 +LDT #4096 SET MAX LENGTH = 4096
46 $AAEXIT ELSE
47 +LDT #&MAXLTH SET MAXIMUM RECORD LENGTH
48 ENDIF
50 $LOOP TD =X’&INDEV’ TEST INPUT DEVICE
55 JEQ $LOOP LOOP UNTIL READY
60 RD =X’&INDEV’ READ CHARACTER INTI REG A
63 IF (&EORCK EQ
1)
65 COMPR A, S TEST FOR END OF RECORD
70 JEQ $EXIT EXIT LOOP IF EOR
73 ENDIF
75 STCH &BUFADR, X STORE CHRACTHER IN BUFFER
80 TIXR T LOOP UNLESS MAXIMUM LENGTH
85 JLT $LOOP HAS BEEN REACHED
90 $EXIT SIX &RECLTH SAVE RECORD LENGTH
95 MEND
Above Program a gives the definition of the macro RDBUFF with the parameters &INDEV,
&BUFADR, &RECLTH, &EOR, &MAXLTH. According to the above program if &EOR has any
value, then &EORCK is set to 1 by using the directive SET, otherwise it retains its default value
0.
Use of Macro-Time Variable with EOF being Not Null
RDBUFF F31 BUF, RECL, 04, 2048
30 CLEAR X CLEAR LOOP COUNTER
35 CLEAR A
40 LDTH =X’04’ SET FOR CHARACTHER
42 RMO A, S
47 +LDT #2048 SET MAXIMUM RECORD LENGTH
UNIT I | 1.66
UNIT I | 1.67
UNIT I | 1.68
UNIT I | 1.69
UNIT I | 1.70
UNIT I | 1.71
UNIT I | 1.72
UNIT I | 1.73
UNIT I | 1.74
UNIT I | 1.77
12 MEND
Where SSTP : Sequencing Symbol Table Points
(E, 1) First Expansion Variable
(S, 1) First Sequency Symbol
#0, #1 : parameter
Expanded Code
START
+SUB AREG, B
+ MOVER AREG, = ‘0’
+ MOVERM AREG, B
+ MOVEM AREG, B+ 1
+ MULT AREG, = ‘5
B DS 4
END
Example 1.6 : Consider the following code segment and show the content of
(a) Macro name table
(b) Macro definition table
(c) Argument list any
1 MACRO
2 INCR &A, &B, & REG
3 MOVER ®, &A
4 ADDS &A, &B
5 MOVEM ®, &A
6 MEND
7 MACRO
8 ADDS &F, &S
9 MOVER AREG, &F
10 ADD AREG, &S
11 MOVEM AREG, &S
12 WRITE &S
13 MEND
UNIT I | 1.78
UNIT I | 1.79
UNIT I | 1.80
UNIT I | 1.81
UNIT I | 1.82
L 1, &Z
MEND
XYZ B1
SR 4, 4
ABC B1
D1 DC F’4’
B1 DC F’5’
END
Solution :
MNT
NAME MDTP
XYZ 0
ABC 4
DISPLAY 12
MDT
OPCODE RESB
0 XYZ &A
1 A 1, # 1
2 AR 2, 2
3 MEND
4 ABC &Z
5 SR 3, 3
6 MACRO
7 DISPLAY
8 XYZ B
9 MEND
10 L 1, #1
11 MEND
12 DISPLAY
13 XYZ B
UNIT I | 1.84
14 MEND
Expanded Code
START 100
SR 2, 2
USING *, 15
L 1, D1
+A 1, B1 ; xyz is expanded
+AR 2, 2
SR 4, 4
+SR 3, 3 ; ABC B1 is expanded
+L 1, B1
D1 DC F’4’
B1 DC F’5’
END
UNIT I | 1.85
Fig. 1.26
Algorithm :
begin {macro processor}
EXPANDING : = FALSE
while OPCODE ≠ ‘END’ do
begin
GETLINE
PROCESSLINE
end {while}
end {macro processor}
procedure PROCESSLINE
begin
search MNT for OPCODE
if found then
EXPAND
else if OPCODE = ‘MACRO’ then
UNIT I | 1.86
UNIT I | 1.88
UNIT I | 1.89
UNIT I | 1.90
UNIT I | 1.91
UNIT I | 1.92
UNIT I | 1.93
UNIT I | 1.94
UNIT I | 1.95
UNIT I | 1.96
UNIT I | 1.97
UNIT I | 1.99
UNIT I | 1.100
Ans. : The object program is a program written with the generated object codes for an
assembly language program.
UNIT I | 1.102
1. Header record
3. End record.
17. What are the functions performed by pass 1 of two pass assembler?
2. Save the values (addresses) assign to all labels for use in pass-2.
Ans. : 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. This avoids having to define the constant
elsewhere in the program and makeup a label for it. Such an operand is called a literal
because the value is stated “literally” in the instruction.
Ans. : For each literal used, literal table contains the literal name, the operand value and
length, and the address assigned to the operand when it is placed in the literal pool. All of
the literal operands used in a program are gathered together into one or more literal pools.
20. What do macro expansion statements mean? [May 2011, 2014 -3M]
Ans. : These statements give the name of the macroinstruction being invoked and the
arguments to be used in expanding the macros. These statements are also known as macro
call.
21. Mention the tasks involved in macro expansion. [May 2011, 2014 -3M]
24. What are the statements used for conditional macro expansion?
WHILE-ENDW statement
UNIT I | 1.104
UNIT I | 1.105
QUESTIONS
1. Write down the pass numbers either (Pass 1 or Pass 2) of the following activities that
occur in a 2-pass assembler.
(a) Object code generation
(b) Literals added to literal table
(c) Printing assembly listing
(d) Address resolution of local symbols
16. Explain with suitable example macro definition, call and expansion.
UNIT I | 1.106
41. What is the data structure used to organize the SYMTAB and OPCODE table in a simple
assembler? Why it is preferred?
UNIT I | 1.107
UNIT I | 1.108