System Software: Components and Language Processing

undefined
 
UNIT-1
Introduction to
System
Programming
 
 Introduction: Components of System
Software, Language Processing
Activities, Fundamentals of Language
Processing
Assemblers: Elements of Assembly
Language Programming, A simple
Assembly Scheme, Pass structure of
Assemblers, Design of Two Pass
Assembler, Single pass assembler
Macro Processor: Macro Definition and
call, Macro Expansion, Nested Macro
Calls and definition,Advanced Macro
Facilities, Design of Macro Processor
 
 
 
 
Introduction:
Components of System Software,
 Language Processing Activities,
Fundamentals of Language Processing
 
Unit-1
 
Basic
 
Software
Types of software
Application software-
Word, Excel
 etc.
System Software- 
Compiler, Assembler,O.S.,
Linker 
etc.
 
Unit-1
 
Sytem Programming
 
Application Software
 
Develop using Programming Lang. and Tools
Application software 
interact
 with systems
software;
systems software then directs computer hardware
to perform 
the necessary tasks
 
 
Unit-1
 
Sytem Programming
 
System Software
 
Needed for program development.
Controls operations of computer hardware
Definition: 
System Software Consist of a 
variety
of program
 that support the operation of a
computer.
 
Unit-1
 
Sytem Programming
 
Language processing Model
 
Source Program
C,C++,java etc
 
Target Assembly Program
 
Relocatable M/c Code
 
Lib+ relocatable obj file
 
Executable M/c Code
 
Components of System Software,
 
Example:
Assembler
Compiler
Macro processor
Loader
Linker
Interpreter
Operating System
Debugger
Text editor
 
 
Unit-1
 
Sytem Programming
 
Programming Languages: Terminology
 
Language translator
Systems software that converts a programmer’s
source code into its equivalent in machine language
Source code
High-level program code written by the programmer
Object code
Another name for machine language code
 
Assembler
 
A Translator
 
 
 
 
 
Assembler make 
two passes 
over the assembly file
First Pass
: reads each line and 
records labels 
in a
symbol table.
Second Pass 
: use info in symbol table to produce
actual machine code for each line.
 
 
Unit-1
 
Assembler…
 
Assembly lang. a 
symbolic representation 
of machine
language.
 uses a 
mnemonic
 to represent each low-level machine
instruction or operation.
 Assemblers with different 
syntax
 for a particular 
CPU
 or
instruction set architecture
.
Example
:- An instruction 
to add memory data to
     a register
   
x86
-family processor:  
add eax,[ebx],
    whereas this would be written 
addl (%ebx),%eax
    
in the 
AT&T syntax
 used by the 
GNU Assembler
.
 
Unit-1
 
Compiler
 
Once the target program is generated, the user
can execute the program.
 
Unit-1
 
Compiler…
 
Early compilers were written in assembly language.
A compiler verifies code syntax,
generates efficient object code,
performs run-time organization,
and 
formats the output 
according to 
assembler
and 
linker
 conventions
 
Unit-1
 
Macro Processor
 
It allows the programmer to write 
shorthand version 
of a
program .
Macro allows a 
sequence of source language 
code to be
defined once and then referred to by name each time it is to
be referred.
Each time this name Occurs in a program, the sequence of
codes is substituted at that point.
 
Unit-1
 
Copy code -- Example
Source
STRG 
 
MACRO
  
STA
 
DATA1
  
STB
 
DATA2
  
STX
 
DATA3
  
MEND
 
.
STRG
 
.
STRG
 
.
 
.
Expanded source
 
.
 
.
 
.
  
STA
 
DATA1
  
STB
 
DATA2
  
STX
 
DATA3
 
.
  
STA
 
DATA1
  
STB
 
DATA2
  
STX
 
DATA3
 
.
 
{
 
{
 
Unit-1
 
Loader and Linker
 
A program which 
accepts object program 
and
prepares them for 
execution.
4 main functions:
i.
Allocation
 
of space in main memory for the
programs.
ii.
Linking 
of object modules with each other.
iii.
Adjust all address dependent locations.
iv.
Physically 
loading
 the machine instructions and
data into the main memory.
 
Unit-1
 
Interpreter
 
A 
Interpreter
 reads the source code 
one
instruction
 or 
line
 at a  this line
 
into
 
machine
code 
or 
some intermediate form
 and 
executes
it.
 
Statement
execution
 
Fig.: Interpreter
 
Unit-1
 
Operating System- 
Interface between users and
the hardware of a computer system.
 
Debugger-  
helps to detect error in the program.
 
Text editor- 
used to create and modify the
program.
 
Unit-1
 
Language Processing Activities
 
 
It 
Involves
 
translation
 of a program written in a high
level language 
into
 machine code
 
It can be divided into two groups:
1.
Program generation activities
2.
Program execution activities
 
 
Unit-1
 
Language Processing Activities..
 
Unit-1
 
1.Program generation activities
 
 
 
 
 
 
 
The program generator is a software which 
accepts
 the
specification of program 
to be generated 
And
 
generates
a program in 
target
 programming lang.
 
 
 
 
 
 
Unit-1
 
Sytem Programming
 
1.Program generation activities…
 
Sytem Programming
 
Fig.: Specification and Execution gap
 
 Execution gap is 
bridged
 by the 
compiler 
or
 interpreter
.
The program generator 
bridges
 the gap between application
domain & Programming lang. (PL)domain
 
 
Unit-1
 
1.Program generation activities…
 
Example- A Screen handling Program.
 
Employee name:
Address:
 
 
Married:
Age                                                Sex
 
Sytem Programming
 
Unit-1
 
2.Program Execution activities
 
 
2 Models for Program Execution:
    1.Translation
    2.Interpretion
 
A program must be translated before it can be
executed.
The translated program may be saved in a file.The
saved program may be executed repeatedly.
 
 
 
 
 
 
Unit-1
 
1.Program Translation
 
 
Sytem Programming
 
Fig.: Program Translation Model
 
Unit-1
 
Program Interpretation
 
Sytem Programming
 
Unit-1
 
Fundamental of Language
Processing
 
 
Language Processing=Analysis of SP + Synthesis of TP
 
 
 
 
 
 
 
System Programming
 
Unit-1
 
Fig.: Phases of language of language processing
 
Sp=source prog.
TP=target program
 
Analysis Phase
 
Three components:
          
 1. 
Lexical rules -
the formation of valid lexical units in the
source language.
Example:
percent_profit = (profit * 100) / cost_price;
                     identifies =, * and / operators,
                      100 as constant,
                       and the remaining strings as identifiers.
 
          2. Syntax rules 
the formation of valid statements in the source
language.
Example :
 percent_profit as the 
left hand side 
and (profit * 100) /
cost_price as the expression on the 
right hand side.
 
System Programming
 
Unit-1
 
Analysis Phase…
 
3. Semantic rules -
associate meaning with valid
statements of the language.
  example:  
 
percent_profit = (profit * 100) / cost_price;
 Semantic analysis :
 assignment
 of profit X 100 / cost_price to percent_profit
 
Sytem Programming
 
Unit-1
 
Synthesis Phase
 
 It performs two main activities:
1.
      Creation of data structures in the target program
(
memory allocation
)
2.
      Generation of target code (
code generation
)
 
 Example
 
 
MOVER AREG, PROFIT
 
 
MULT AREG, 100
 
 
DIV
 
 
AREG, COST_PRICE
 
 
MOVEM AREG, PERCENT_PROFIT
 
 
 
 
PERCENT_PROFIT DW 1
 
 
PROFIT DW 1
 
 
COST_PRICE DW 1
 
Sytem Programming
 
Unit-1
 
 
 
Assemblers:
Elements of Assembly Language Programming,
A simple Assembly Scheme,
 Pass structure of Assemblers,
Design of Two Pass Assembler,
Single pass assembler
 
Unit-1
 
Assembler
 
A Translator
 
 
 
 
 
Assembler make 
two passes 
over the assembly file
First Pass
: reads each line and 
records labels 
in a
symbol table.
Second Pass 
: use info in symbol table to produce
actual machine code for each line.
 
 
Unit-1
 
Assembler…
 
The translated program contains 3 kinds of entities:
1.
Relative entities- 
address of instructions and
variables.
2.
Absolute entities- 
operation code , numeric and
string constant and fixed addresses.
3.
The object program- 
addresses are relative
       symbols are defined externally
 
Sytem Programming
 
Unit-1
 
Assembler…
 
Assembly lang. a symbolic representation of machine
language.
 uses a 
mnemonic
 to represent each low-level machine
instruction or operation.
 Assemblers with different 
syntax
 for a particular 
CPU
 or
instruction set architecture
.
Example
:- An instruction 
to add memory data to
     a register
   
x86
-family processor:  
add eax,[ebx],
    whereas this would be written 
addl (%ebx),%eax
    
in the 
AT&T syntax
 used by the 
GNU Assembler
.
 
Unit-1
 
Assembler
 
Elements
 of assembly language programs:
A.
Basic features
B.
Statement format
C.
Operation code
 
Sytem Programming
 
Unit-1
 
A.Basic features
 
Sytem Programming
 
  Assembly lang. Provides 3 basic features:
1. Mnemonic Operation Codes(Opcodes)
   Ex: MOVER or MOVEM
 
2. Symbolic Operand:
Ex: DS – Declare as storage
     DC – Declare as Constant
 
3. Data Declaration:
Ex: X DC ‘-10.5’
 
Unit-1
 
B.Statement Format
 
Statement Format:
[Label]  <opcode>  <operand1> [ <operand2>..]
 
Label-Optional
Opcode-it contain 
symbolic
 operation code
Operand- Operand can also be a CPU register: AREG,
BREG,CREG.
Example-
LOOP :      MOVER AREG, ‘=5’
 
Unit-1
 
Machine Instruction Format
 
Sytem Programming
 
Fig.: Machine Instruction format for assembly lang.
 
 Sign is not part of the instruction
 
Reg.operand: AREG, BREG,CREG,DREG.
 
 Memory operand: Refers memory word using symbolic name
 
Unit-1
 
Machine supports 11 Different Operations
 
Unit-1
 
First
 operand is always a 
CPU register
Second
 operand is always a 
memory operand
 
 
Machine supports 11 Different Operations
 
Unit-1
 
Assembly language statements
 
 3 types of Statement in Assembly Language
1.
Imperative
2.
Declaration
3.
Assembler directives
 
Unit-1
 
1.Imperative  Statement
 
Executable statement
Indicates an 
action to be taken.
translates into a machine instruction.
class IS
Ex.:
1.
MOVER BREG, X
2.
STOP
3.
READ X
4.
PRINT Y
5.
BC NE,L1
 
Unit-1
 
2.Declaration statements
 
Reserves memory for variables
Initial value of a variable can also be specified.
 
[
label
]
   DS   
<
const specifying size of memory to  be reserved
>
[
label
]
   DC  
<
Initial value of variable
>
 
DS  
 declare storage,
DC 
 declare constant
Class
-DL
 
>
 
Unit-1
 
2.Declaration statements…
 
 
 
 
 
X
 
   DS
 
1
Y      DS     5
 
Unit-1
 
2.Declaration Statements…
 
ONE
 
DC
 
   ‘1’
 
 
 
 
 
Unit-1
 
MOT for declaration statements
 
Unit-1
 
3.Assembler Directive
 
Instructs the assembler 
to perform 
certain actions
during assembly of a program.
A 
directive
 is a 
direction for the assembler
A 
directive
 is also known as 
pseudo instruction
 
machine code 
machine code 
is 
is 
not generated 
not generated 
for AD.
for AD.
 
Unit-1
 
3.Assembler Directive…
 
START  <Constant>
It indicates that the 
first word 
of the m/c code
should be placed in the memory word with the
address 
<CONSTANT>
 
Unit-1
 
END  [<
OPERAND SPECIFICATION
>]
 
 
 
Optional, indicates address of the instruction
where the 
address of program should begin
.
By default, execution begins from the first
instruction.
It indicates the end of the source program.
Class
:AD
 
Unit-1
 
3.Assembler Directive…
 
Advanced Assembler Directives
 
These directive include:
1.
ORIGIN
2.
Symbol
3.
LTORG
 
 
ORIGIN
 
Useful when m/c code is not stored in consecutive memory
location.
ORIGIN <
address specification>
 
  
Operand
 or 
constant
 or 
expression
 containing an operand
 and a constant.
 
Sets LC to the address given by 
<address specification>
LC 
processing in a relative 
rather than absolute manner
 
 
ORGIN…..Example
 
EQU
 
Syntax:
<
symbol
>    EQU   <
address specification
>
Where,
<
address specification
> :
can be 
operand specification
 or a
constant
<
symbol
>: EQU 
Associates
 symbol 
with the 
<
address
specification
>
Ex.     
BACK  EQU  LOOP
The symbol 
BACK
 is set to the address of 
LOOP
 
LTORG
 
Permits a programmer to specify where literal should be placed.
If the LTORG statement not present, literal are present at the
END statement
At every LTORG Statement, 
memory is allocated 
to the literal
of the current pool of literals.
The 
pool contains all literal 
used in the program since the start
of the program or since the last LTORG statement.
 
Sytem Programming
 
MOT for Assemblers Directives
 
Unit-1
 
C.Mnemonic Opcode Table(MOT)…
 
Unit-1
 
Literal and Constant
 
A literal is an immediate operand
A literal is an operand with constant value.
   In the c-statement
   int z=5;
   x=y+5;
The constant value is ‘5’ known as literal.
Literal can not be change during program
execution
They are specified using immediate addressing.
 
Sytem Programming
 
Unit-1
 
Literal and Constant…
 
Literal in assembly language:
Assembly instruction for 8086 with immediate
operand
MOV AX  15  (8086 instruction)
 
But Hypothetical machine does 
not support
immediate operand.
 
 
Sytem Programming
 
Unit-1
 
Literal and Constant…
 
Handling a literal by our machine is as follows:
 
Sytem Programming
 
Unit-1
 
Forward Reference
 
It is reference to the entity which precedes its
declaration.
 
Examples
      x=y+5
     int x,y;
 
The compiler will 
not be able to generate the m/c
code
 for the statement “x=y+5” 
until
 it has been
declaration of two variables x & y
 
Sytem Programming
 
Unit-1
 
Forward Reference…
 
 
Sytem Programming
 
Unit-1
 
Types of Assembler
 
3 Types of Assemblers
1.
Load and Go-Assembler
2.
One-pass Assembler
3.
Two-pass Assembler
 
Sytem Programming
 
Unit-1
 
1.Load and Go-Assembler
 
Simplest form of assembler
It produces machine language as output which
are 
loaded directly 
in main memory and executed
The ability to 
design code 
and test the different
program components in parallel
 
Sytem Programming
 
Unit-1
 
2.One Pass Assembler
 
Normally , it does 
not allow 
forward referencing.
An assembler 
cannot generate m/c code 
for an
assembly instruction with FR.
Machine code is generated ,after the 
address of
variable 
used in the instruction is known.
Symbol table is used to record the address of the
variables.
 
Unit-1
 
One Pass Assembler with
 Forward Reference
 
FR can be tackled using  technique 
Backpatching
   
1. 
Operand field 
of instruction containing FR is left 
blank
 initially.
   2. A
 table 
of instruction containing forward reference is made
separately.
  
(<
Instruction address
>
 ,
<
Symbol making a forward reference
>)
 
This table can be used o fill-up address in incomplete instruction.
 
   An example of backpatching:
      Assign addresses to all statements in the program
 
Sytem Programming
 
Mnemonic Opcode Table(MOT)
 
Unit-1
 
Mnemonic Opcode Table(MOT)…
 
Unit-1
 
  
START    100
M
O
V
E
R
 
A
R
E
G
,
 
X
.
 
 
1
0
0
 
 
L
1
A
D
D
 
B
R
E
G
,
 
O
N
E
 
.
1
0
1
 
 
 
 
 
 
 
 
 
 
 
 
C
O
M
P
 
B
R
E
G
,
 
T
E
N
1
0
2
B
C
 
E
Q
,
 
L
A
S
T
1
0
3
A
D
D
 
A
R
E
G
,
O
N
E
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
0
4
B
C
 
A
N
Y
,
 
L
1
.
1
0
5
L
A
S
T
 
 
S
T
O
P
1
0
6
X
D
C
 
 
 
5
1
0
7
O
N
E
 
 
 
D
C
 
 
 
 
 
1
1
0
8
T
E
N
 
 
 
 
D
C
 
 
 
 
1
0
 
.
.
1
0
9
  
END
 
S
t
e
p
1
:
 
G
e
n
e
r
a
t
i
o
n
 
o
f
 
M
/
C
 
c
o
d
e
 
a
n
d
 
F
R
 
l
e
f
t
 
a
s
 
b
l
a
n
k
 
Sytem Programming
 
START    100
 
 
 
M
O
V
E
R
 
A
R
E
G
,
 
X
 
 
1
0
0
 
 
 
 
 
 
0
4
 
 
1
-
-
-
-
-
L
1
 
 
A
D
D
 
B
R
E
G
,
 
O
N
E
 
 
1
0
1
 
 
 
 
 
 
0
1
2
 
 
 
 
 
 
 
 
 
-
-
-
-
-
 
 
 
 
 
 
 
C
O
M
P
 
B
R
E
G
,
 
T
E
N
 
 
1
0
2
 
 
 
 
 
 
0
6
 
 
 
 
 
 
 
 
 
2
 
 
 
 
 
 
 
 
 
-
-
-
-
-
-
 
 
 
 
 
B
C
 
E
Q
,
 
L
A
S
T
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
0
3
 
 
 
 
 
 
0
7
 
 
 
 
 
 
 
 
 
 
1
 
 
 
 
 
 
 
 
 
-
-
-
-
-
 
 
 
 
 
A
D
D
 
A
R
E
G
,
O
N
E
 
 
 
 
 
 
 
 
 
1
0
4
 
 
 
 
 
 
0
1
 
 
 
 
 
 
 
 
 
 
1
 
 
 
 
 
 
 
 
 
-
-
-
-
-
 
 
 
 
 
B
C
 
A
N
Y
,
 
L
1
.
 
 
 
 
 
1
0
5
 
 
 
 
 
 
0
7
 
 
 
 
 
 
 
 
 
 
7
 
 
 
 
 
 
 
 
 
-
-
-
-
-
-
L
A
S
T
 
S
T
O
P
1
0
6
 
 
 
 
 
 
 
0
0
 
 
 
 
 
 
 
 
 
 
0
0
 
 
 
 
 
 
 
0
0
0
X
D
C
5
 
 
 
1
0
7
 
 
 
 
 
 
 
0
0
0
0
0
0
5
O
N
E
 
 
 
D
C
 
 
 
 
 
1
 
 
 
1
0
8
 
 
 
 
 
 
 
0
0
0
0
0
0
1
T
E
N
 
 
 
 
D
C
 
 
 
 
1
0
 
 
 
1
0
9
 
 
 
 
 
 
 
0
0
0
0
0
1
0
 
END
 
 
Backpatch list:
 
S
t
e
p
2
:
 
B
a
c
k
p
a
t
c
h
 
l
i
s
t
 
c
a
n
 
b
e
 
u
s
e
d
 
t
o
 
f
i
l
l
 
u
p
 
a
d
d
r
e
s
s
 
i
n
 
b
l
a
n
k
 
f
i
e
l
d
 
o
f
 
i
n
s
t
r
u
c
t
i
o
n
 
Sytem Programming
 
 
   START    100
 
   MOVER AREG, X………  
100      04
 
1
 
107
L1  ADD BREG, ONE ……… 
101      01
 
2         
108
       
COMP BREG, TEN……     
102      06         2         
 
109
 
     BC EQ, LAST
  
      
103      07          1         
106
 
     ADD AREG,ONE
 
      
104      01          1         
108
 
     BC ANY, L1………….     
105      07          7         
101
LAST STOP……………………
106       00          00     000
X
  
DC
 
‘5’………………   
107       00
 
00
 
005
ONE   DC     ‘1’………………   
108       00
 
00
 
001
TEN    DC    ‘10’
 
…………   
109       00
 
00
 
010
 
END
 
 
 
Machine Code Meaning
 
    100                 04                 1                   
107
 
Start 100 – is assembler directive,100 LC(location count) 0f first instruction
STOP –M/c opcode-00,absense of register,
 
108  X    DS     1   
: Memory is reserved but no code is generated.
 
3.Two Pass Assembler
 
Two passes(stages),
Pass I
1. 
Separate
 the symbols, mnemonic op-code and operand
fields.
      2. Determine the 
storage requirement 
for every assembly
language statement and update the location counter.
      3. 
Build
 the symbol table.
Pass II
Generate machine code.
 
Sytem Programming
 
Design of Two Pass Assembler
 
First pass has to fix address of variables ,
the second pass can generate the machine code.
 
Sytem Programming
PASS I
PASS II
 
Mnemonic    Opcode       length
 
Source
Program
Assembly
 
Target
Program
 
Symbol
Table
 
Fig.: Data Structures for the Assembler
 
Working of pass I
 
Data structures required:
MOT-use to search the opcode
Symbol table-use to search the symbol
Literal table
Pool table :  starting literal number of each pool.
 
Mnemonic Opcode Table(MOT)
 
Unit-1
 
Mnemonic Opcode Table(MOT)…
 
Unit-1
 
Mnemonic Opcode Table(MOT)…
 
Unit-1
 
Class Field Indicate
 
Sytem Programming
 
Symbol  Table
 
It contains:
1.
Name of variable or a label
2.
Its address
3.
Its size in number of words
4.
Example-
 
Sytem Programming
 
 Index
 
Literal Table
 
It contains:
1.
Value of the  literal
2.
Address of the memory location associated with
 the literal.
Example-
 
 
 
Sytem Programming
 
Index
 
POOL Table
 
This table contains the literal number of the 
starting
literal 
of each literal pool.
 
Sytem Programming
 
Index
 
Intermediate Code
 
Is equivalent representation of source program.
Pass-I of the assembler involve 
scanning of the source file.
Every opcode is searched in MOT
Every operand is searched in symbol table.
 
It helps in avoiding:
 1. Scanning of source file in PASS-II
 2. Searching MOT and ST in PASS-II
 
 
 
 
Sytem Programming
 
Format of Intermediate Code
 
Each Mnemonic opcode field is represented as:
 
(  
Statement class
     ,    
Machine code  
)
 
  
  
IS
  
            
MOT entry of opcode
  
 AD
  
 DL
Ex.:  MOVER  
 (IS,04)
  
LTORG  
  (AD, 05)
         START
(AD,01)
  
DC  
  (DL,02)
 
Operand
 
(   Operand Class,    
reference
  )
 
C: constant
   
for a symbol or
 
S:  symbol
    
literal , reference
 
L:  literal(varible)
   
field contains the
 
RG: register
   
index of the operand’s
 
CC:condition code
  
entry in the symbol
      
table or literal table
 
  
START    200
  
MOVER AREG, ‘=5’………….  
 
200
  
MOVEM AREG, X    …………
 
201
L1
 
MOVER BREG, ‘=2’………….
 
202
  
ORIGIN L1+3
  
 
LTORG                      …………
 
205
NEXT
 
ADD AREG, ‘= 1’       …………
 
206
  
SUB BREG,’=2’           …………
 
207
  
BC LT, BACK              ………….
 
208
  
LTORG
    
210, 211
BACK  EQU  L1
 
           ………… 
202
             ORIGIN NEXT+5         ………….211
  
MULT AREG,’=4’         …………
212
 
  
STOP……………………………
213
X
  
DS
 
‘5’……………………….
 
214
  
END 
    
215
202+3=205
 
Index
 
Index
 
 Index
 
  
START    200
  
………..
(AD,01)    (C,200)
  
MOVER AREG, ‘=5’…..
 
200 ….(IS,04)     (RG,01)    (L,0)
  
MOVEM AREG, X……
 
201….(IS,05)     (RG,01)    (S,0)
 L1
 
MOVER BREG, ‘=2’…..
 
202 ….(IS,04)     (RG,02)    (L,1)
  
ORIGIN L1+3
  
            
(AD,03)    (C,205)
  
 
LTORG 
  
205……(DL,02)
 
     (C,5)
     
206
 
……(DL,02)     (C,2)
NEXT
 
ADD AREG, ‘= 1’…….
 
207 ….(IS,01)     (RG,01)    (L,2)
  
SUB BREG,’=2’  ………
 
208 ….(IS,02)     (RG,02)    (L,3)
  
BC LT, BACK………….   
209 ….(IS,07)     (CC,02)    (S,3)
  
LTORG
 
………..
 
               
210,
 
……(DL,02) (C,1)
     
211
 
……(DL,02)
 
     (C,2)
  
BACK EQU L1
 
………..
 
202 
………..
(AD,01)    (C,202)
  
ORIGIN NEXT+5
 
         
………..
(AD,01)    (C,212)
  
MULT AREG,’=4’……..
 
212 ….(IS,03)     (RG,03)    (L,4)
 
  
STOP……………………
 
213 ….(IS,00)
X
  
DS
 
‘5’…………….
 
214 
……(DL,01)
 
     (C,1)
  
END 
   
         -------(AD,02)
     
215 ………(DL,02) (C,4)
 
 
A
s
s
e
m
b
l
y
 
P
r
o
g
r
a
m
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
L
C
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
I
n
t
e
r
m
e
d
i
a
t
e
 
C
o
d
e
 
 
       START    100
        MOVER AREG, ‘=5’
        ADD CREG, ‘= 1’
        A  DS ‘3’
L1
 
   MOVER AREG, B
        ADD AREG,C
       MOVEM AREG,D
       
LTORG
 
  EQU A+1
L2  PRINT D
      ORIGIN A-1
      SUB AREG,’=1’
     MULT CREG,B
      C DC ‘5’
      ORIGIN  L2+1
      STOP
      B DC 19
      END
 
 
 
  START    100
MOVER AREG, 
‘=5’
     ADD CREG, 
‘= 1’
    
A
 
DS
 
‘3’
  L1: MOVER AREG, B
        ADD AREG,C
        MOVEM AREG,D
   
LTORG
 
 
       (AD,01)  (C,100)
100
(IS,04) (RG,01) (L,0)
101
(IS,01) (RG,03) (L,1)
102
(DL,01) (C,3)
105
(IS,04) (RG,01) (S,2)
106
(IS,01) (RG,01) (S,3)
107
(IS,05) (RG,01) (S,4)
108 
(DL,02)(C,5)
109  
(DL,02)(C,1)
 
 
      D  
 
EQU A+1
  L2 PRINT D
      ORIGIN A-1
      SUB AREG,’=1’
      MULT CREG,B
     
C DC ‘5’
    ORIGIN  L2+1
     STOP
  
B
 
DC   19
     END
 
 
 
     (AD,04) (C,103)
110 
(IS,10) (S,4)
     (AD,03) (C,101)
101
(IS,02) (RG,01) (L,2)
102
(IS,03) (RG,03) (S,2)
103
(DL,02)(C,5)
    (AD,03) (C,111)
111
(IS,00)
112
(DL,02) (C,19)
(AD,02)
113
(DL,02) (C,1)
 
 (AD,01)  (C,100)
100 
(IS,04) (RG,01) (L,0)
101 
(IS,01) (RG,03) (L,1)
102 
(DL,01) (C,3)
105 
(IS,04) (RG,01) (S,2)
106 
(IS,01) (RG,01) (S,3)
107
(IS,05) (RG,01) (S,4)
108
109
 
 
100)
    
04
 
  01
 
108
 
101)  01    03
 
109
 
102)
 
105)    04
 
   01
 
112
 
106)    01
 
   01
 
103
 
107)    05
 
   01
 
103
 
108)    00
 
   00
 
005
 
109)    00
 
   00
 
001
 
 
  
(AD,04) (C,103)
110
 
(IS,10) (S,4)
  
(AD,03) (C,101
)
101
 
(IS,02)(RG,01) (L,2)
102
 
(IS,03) (RG,03) (S,2)
103
 
(DL,02)(C,5)
    
 
(AD,03) (C,111)
111
 
(IS,00)
112
 
(DL,02) (C,19)
  
(AD,02)
113
 
(DL,02) (C,1)
 
 
 
110)
 
10
 
00
 
103
 
 
101)
 
02
 
01
 
113
 
102)
 
03
 
03
 
112
 
103)
 
00
 
00
 
005
 
111)
 
00
 
00
 
000
 
112)
 
00
 
00
 
019
 
113)
 
00
 
00
 
001
 
Sytem Programming
 
Macro Processor:
Macro Definition and call,
Macro Expansion,
Nested Macro Calls and definition,
Advanced Macro Facilities,
Design of Macro Processor
 
Macro Processor
 
Macro allows a sequence of source language code to be
defined once and then referred to by name each time it is to
be referred.
Each time this name Occurs in a program, the sequence of
codes is substituted at that point.
It allows the programmer to write shorthand version of a program .
 
Unit-1
Slide Note
Embed
Share

Delve into the intricate world of system programming with an overview of system software components and language processing activities such as assemblers, macro processors, and application software development. Explore the role of system software in controlling computer hardware operations and the interactions between application and system software.

  • System Software
  • Language Processing
  • Assemblers
  • Application Software
  • System Programming

Uploaded on Jul 28, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. UNIT-1 Introduction to System Programming Introduction: Components of System Software, Language Activities, Fundamentals of Language Processing Assemblers: Elements Language Programming, Assembly Scheme, Pass structure of Assemblers, Design Assembler, Single pass assembler Macro Processor: Macro Definition and call, Macro Expansion, Nested Macro Calls and definition,Advanced Macro Facilities, Design of Macro Processor Processing of Assembly A simple of Two Pass

  2. Unit-1 Introduction: Components of System Software, Language ProcessingActivities, Fundamentals of Language Processing

  3. Unit-1 Basic Software Types of software Application software-Word, Excel etc. System Software- Compiler, Assembler,O.S., Linker etc. Operating and systems software Application software Users Hardware Sytem Programming

  4. Unit-1 Application Software Develop using Programming Lang. and Tools Application software interact with systems software; systems software then directs computer hardware to perform the necessary tasks Sytem Programming

  5. Unit-1 System Software Needed for program development. Controls operations of computer hardware Definition: System Software Consist of a variety of program that support the operation of a computer. Sytem Programming

  6. Language processing Model Source Program C,C++,java etc Compiler Target Assembly Program Assembler Relocatable M/c Code Loader/Link editor Lib+ relocatable obj file Executable M/c Code

  7. Unit-1 Components of System Software, Example: Assembler Compiler Macro processor Loader Linker Interpreter Operating System Debugger Text editor Sytem Programming

  8. Programming Languages: Terminology Language translator Systems software that converts a programmer s source code into its equivalent in machine language Source code High-level program code written by the programmer Object code Another name for machine language code

  9. Unit-1 Assembler A Translator Assembler Assembly Language Program Machine Language format or object file Fig.: Assembler Assembler make two passes over the assembly file First Pass: reads each line and records labels in a symbol table. Second Pass : use info in symbol table to produce actual machine code for each line.

  10. Unit-1 Assembler Assembly lang. a symbolic representation of machine language. uses a mnemonic to represent each low-level machine instruction or operation. Assemblers with different syntax for a particular CPU or instruction set architecture. Example:- An instruction to add memory data to a register x86-family processor: add eax,[ebx], whereas this would be written addl (%ebx),%eax in the AT&T syntax used by the GNU Assembler.

  11. Unit-1 Compiler Once the target program is generated, the user can execute the program. Error Messages Program in Source Language Target code(Program in machine code) Compiler Fig.: A Compiler

  12. Unit-1 Compiler Early compilers were written in assembly language. A compiler verifies code syntax, generates efficient object code, performs run-time organization, and formats the output according to assembler and linker conventions

  13. Unit-1 Macro Processor It allows the programmer to write shorthand version of a program . Macro allows a sequence of source language code to be defined once and then referred to by name each time it is to be referred. Each time this name Occurs in a program, the sequence of codes is substituted at that point.

  14. Unit-1 Copy code -- Example Source STRG . STRG . STRG . . Expanded source . . . . . { MACRO STA STB STX MEND DATA1 DATA2 DATA3 { STA STB STX DATA1 DATA2 DATA3 STA STB STX DATA1 DATA2 DATA3

  15. Unit-1 Loader and Linker A program which accepts object program and prepares them for execution. 4 main functions: Allocationof space in main memory for the programs. Linking of object modules with each other. Adjust all address dependent locations. Physically loading the machine instructions and data into the main memory. i. ii. iii. iv.

  16. Unit-1 Interpreter A Interpreter reads the source code one instruction or line at a this line into machine code or some intermediate form and executes it. Machine language statement Program statement Interpreter Statement execution Fig.: Interpreter

  17. Unit-1 Operating System- Interface between users and the hardware of a computer system. Debugger- helps to detect error in the program. Text editor- used to create and modify the program.

  18. Unit-1 Language Processing Activities It Involves translation of a program written in a high level language into machine code It can be divided into two groups: 1. Program generation activities 2. Program execution activities

  19. Unit-1 Language Processing Activities.. Program generation Language processing activities Using compiler Program execution Using interpreter

  20. Unit-1 1.Program generation activities Error Messages Program specification Program in target PL Program generator Fig.: Program generator The program generator is a software which accepts the specification of program to be generated Andgenerates a program in target programming lang. Sytem Programming

  21. Unit-1 1.Program generation activities Fig.: Specification and Execution gap Execution gap is bridged by the compiler or interpreter. The program generator bridges the gap between application domain & Programming lang. (PL)domain Sytem Programming

  22. Unit-1 1.Program generation activities Example- A Screen handling Program. Employee name: Address: Married: Age Sex Sytem Programming

  23. Unit-1 2.Program Execution activities 2 Models for Program Execution: 1.Translation 2.Interpretion A program must be translated before it can be executed. The translated program may be saved in a file.The saved program may be executed repeatedly.

  24. Unit-1 1.Program Translation Fig.: Program Translation Model Sytem Programming

  25. Unit-1 Program Interpretation Sytem Programming

  26. Unit-1 Fundamental of Language Processing Language Processing=Analysis of SP + Synthesis of TP Fig.: Phases of language of language processing Sp=source prog. TP=target program System Programming

  27. Unit-1 Analysis Phase Three components: 1. Lexical rules -the formation of valid lexical units in the source language. Example:percent_profit = (profit * 100) / cost_price; identifies =, * and / operators, 100 as constant, and the remaining strings as identifiers. 2. Syntax rules the formation of valid statements in the source language. Example : percent_profit as the left hand side and (profit * 100) / cost_price as the expression on the right hand side. System Programming

  28. Unit-1 Analysis Phase 3. Semantic rules -associate meaning with valid statements of the language. example: percent_profit = (profit * 100) / cost_price; Semantic analysis : assignment of profit X 100 / cost_price to percent_profit Sytem Programming

  29. Unit-1 Synthesis Phase It performs two main activities: 1. Creation of data structures in the target program (memory allocation) 2. Generation of target code (code generation) Example MOVER AREG, PROFIT MULT AREG, 100 DIV AREG, COST_PRICE MOVEM AREG, PERCENT_PROFIT PERCENT_PROFIT DW 1 PROFIT DW 1 COST_PRICE DW 1 Sytem Programming

  30. Unit-1 Assemblers: Elements of Assembly Language Programming, A simple Assembly Scheme, Pass structure of Assemblers, Design of Two Pass Assembler, Single pass assembler

  31. Unit-1 Assembler A Translator Assembler Assembly Language Program Machine Language format or object file Fig.: Assembler Assembler make two passes over the assembly file First Pass: reads each line and records labels in a symbol table. Second Pass : use info in symbol table to produce actual machine code for each line.

  32. Unit-1 Assembler The translated program contains 3 kinds of entities: 1. Relative entities- address of instructions and variables. 2. Absolute entities- operation code , numeric and string constant and fixed addresses. 3. The object program- addresses are relative symbols are defined externally Sytem Programming

  33. Unit-1 Assembler Assembly lang. a symbolic representation of machine language. uses a mnemonic to represent each low-level machine instruction or operation. Assemblers with different syntax for a particular CPU or instruction set architecture. Example:- An instruction to add memory data to a register x86-family processor: add eax,[ebx], whereas this would be written addl (%ebx),%eax in the AT&T syntax used by the GNU Assembler.

  34. Unit-1 Assembler Elements of assembly language programs: A. Basic features B. Statement format C. Operation code Sytem Programming

  35. Unit-1 A.Basic features Assembly lang. Provides 3 basic features: 1. Mnemonic Operation Codes(Opcodes) Ex: MOVER or MOVEM 2. Symbolic Operand: Ex: DS Declare as storage DC Declare as Constant 3. Data Declaration: Ex: X DC -10.5 Sytem Programming

  36. Unit-1 B.Statement Format Statement Format: [Label] <opcode> <operand1> [ <operand2>..] Label-Optional Opcode-it contain symbolic operation code Operand- Operand can also be a CPU register: AREG, BREG,CREG. Example- LOOP : MOVER AREG, =5

  37. Unit-1 Machine Instruction Format Memory operand(3) Sign Reg.operand(1) Opcode(2) Fig.: Machine Instruction format for assembly lang. Sign is not part of the instruction Reg.operand: AREG, BREG,CREG,DREG. Memory operand: Refers memory word using symbolic name Sytem Programming

  38. Unit-1 Machine supports 11 Different Operations Symbolic opcode STOP ADD SUB MULT MOVER MOVEM COMP Remark Stop Excecution Operand Oper1+Oper2 Operand Oper1- Oper2 Operand Oper1*Oper2 CPU Register Memory move Memory operand CPU register Set condition code Comparison instruction sets a condition code The condition code can be tested by BC Branch on condition Format for BC : BC <condition code spec.>, <Memory address> 1. LT-Less than 2. LE-Less or equal 3. EQ-Equal 4. GT-Greater than 5. GE-Greater or equal 6. ANY-Implies unconditional transfer of control BC

  39. Unit-1 Machine supports 11 Different Operations Symbolic opcode Remark Operand Oper1/Oper2 DIV Operand2 input value READ Output operand2 PRINT First operand is always a CPU register Second operand is always a memory operand

  40. Unit-1 Assembly language statements 3 types of Statement in Assembly Language 1. Imperative 2. Declaration 3. Assembler directives

  41. Unit-1 1.Imperative Statement Executable statement Indicates an action to be taken. translates into a machine instruction. class IS Ex.: 1. MOVER BREG, X 2. STOP 3. READ X 4. PRINT Y 5. BC NE,L1

  42. Unit-1 2.Declaration statements Reserves memory for variables Initial value of a variable can also be specified. [label] DS <const specifying size of memory to be reserved> [label] DC <Initial value of variable> DS declare storage, DC declare constant Class-DL >

  43. Unit-1 2.Declaration statements Reserve memory area of 1 word for variable X X DS Y DS 5 1

  44. Unit-1 2.Declaration Statements ONE DC 1 Reserve one word of memory for variable ONE Memory is initialized with 1

  45. Unit-1 MOT for declaration statements Mnemonic opcode Class Opcode DS DL 01 DC DL 02

  46. Unit-1 3.Assembler Directive Instructs the assembler to perform certain actions during assembly of a program. A directive is a direction for the assembler A directive is also known as pseudo instruction machine code is not generated for AD.

  47. Unit-1 3.Assembler Directive START <Constant> It indicates that the first word of the m/c code should be placed in the memory word with the address <CONSTANT>

  48. Unit-1 3.Assembler Directive END [<OPERAND SPECIFICATION>] Optional, indicates address of the instruction where the address of program should begin. By default, execution begins from the first instruction. It indicates the end of the source program. Class:AD

  49. Advanced Assembler Directives These directive include: 1. ORIGIN 2. Symbol 3. LTORG

  50. ORIGIN Useful when m/c code is not stored in consecutive memory location. ORIGIN <address specification> Operand or constant or expression containing an operand and a constant. Sets LC to the address given by <address specification> LC processing in a relative rather than absolute manner

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#