69
DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF INFORMATION TECHNOLOGY CS2304 SYSTEM SOFTWARE UNIT -I Part – A ! D"#$%" S&'t"( S)#t*ar" (M – 12, N – 11) System software consists of a variety of programs that support the operation of the computer. This software makes it possi!e for the user to focus on the other pro!ems to e so!ve" without nee"ing to know how the machine works interna!!y. #$amp!e% &perating System, 'ssem!er an" oa"er. 2! Wr$t " t+" # % t$)% ' )# t +" T" 't D" .$" $%'t rt $)% ) # SIC!  (M 12) The Test evice (T) instruction, tests whether the a""resse" "evice is rea"y to sen" or receive a yte of "ata. The con"ition co"e is set to in"icate the resu!t of this test. Setting of * means the "evice is rea"y to sen" or receive an" + means the "evice is not rea"y. 3! D$## "r" %t$at" a''"(/"r #r)( $%t "r1r "t"r! A''"(/"r I%t"r1r"t"r 1. 'n assem !e r ca n e cons i"ere" a specia! ty pe of compi! er, whi ch on! y tra ns! ates 'ssem!y !angua ge to machine co"e. 2. 'sse m!er s pro"uc e an oect co"e, which might have to  e !inke" using !inker programs in or"er to run on a machine. 3. 'n assem!er wi!! typica!!y "o a one to one trans!ation,  ut this is not true for most interpreters. -ecause 'ssem!y !a ngu age has a one to one ma ppi ng wi th machine co"e, an assem!er may e use" for pro"ucing co"e tha t run s ver y eff icient! y for occasi ons in whi ch  performance is very important (for e.g. graphics engines, eme" "e" systems wi th !i mi te" har"ware resour ces compar e" to a pers ona! computer !ike mi cr owaves, washing machines,etc.). 1. nterpreters are too!s that e$ecute instruction written in some !anguage. 2. Most int er pr et ers can comp!ete the e$ecution of a program y themse!ves. /. nterpreters are use" when we nee" hig h por tai! ity . 0or e$a mp! e, the same ava yte co"e can e run on "i ff er ent p! at forms y using the appr opri at e in te rp re ter ( M). 1

CS2304-System Software With Answers (2)

Embed Size (px)

Citation preview

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 1/69

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

DEPARTMENT OF INFORMATION TECHNOLOGY

CS2304 SYSTEM SOFTWARE

UNIT -I

Part – A

! D"#$%" – S&'t"( S)#t*ar" (M – 12, N – 11)

System software consists of a variety of programs that support the operation of the

computer. This software makes it possi!e for the user to focus on the other pro!ems to e

so!ve" without nee"ing to know how the machine works interna!!y.

#$amp!e% &perating System, 'ssem!er an" oa"er.

2! Wr$t" t+" #%t$)%' )# t+" T"'t D".$" $%'trt$)% )# SIC!   (M – 12)

The Test evice (T) instruction, tests whether the a""resse" "evice is rea"y to

sen" or receive a yte of "ata. The con"ition co"e is set to in"icate the resu!t of this test.

Setting of * means the "evice is rea"y to sen" or receive an" + means the "evice is not

rea"y.

3! D$##"r"%t$at" a''"(/"r #r)( $%t"r1r"t"r!

A''"(/"r I%t"r1r"t"r

1. 'n assem!er can e consi"ere" a specia! type of

compi!er, which on!y trans!ates 'ssem!y !anguage to

machine co"e.2. 'ssem!ers pro"uce an oect co"e, which might have to

 e !inke" using !inker programs in or"er to run on a

machine.

3. 'n assem!er wi!! typica!!y "o a one to one trans!ation,

 ut this is not true for most interpreters. -ecause

'ssem!y !anguage has a one to one mapping with

machine co"e, an assem!er may e use" for pro"ucing

co"e that runs very efficient!y for occasions in which

 performance is very important (for e.g. graphics engines,

eme""e" systems with !imite" har"ware resources

compare" to a persona! computer !ike microwaves,

washing machines,etc.).

1. nterpreters are too!s that e$ecute

instruction written in some

!anguage.2. Most interpreters can comp!ete the

e$ecution of a program y

themse!ves.

/. nterpreters are use" when we nee"

high portai!ity. 0or e$amp!e, the

same ava yte co"e can e run on

"ifferent p!atforms y using the

appropriate interpreter (M).

1

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 2/69

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 3/69

System Software 'pp!ication Software

1. ' system software runs the system

2. ' system software are programs that

run H contro! the har"ware units of

the system

/. System programs are written using

"!!, e$e fi!es for win"ows H rpm

fi!es for !inu$ etc

<. 8e canIt create app!ications using

system software

1. 'pp!ication system runs over the

system software.

2. 'pp!ication software "oesnIt.

/. 'pp!ication software are "eve!ope"

on the asis these fi!es or y using

"ifferent !anguage fi!es.

<. 'pp!ication software are specia!!y

ma"e to create app!ications for users.

0! W+at ar" t+" %a("' )# A, 6 a%7 L r"$'t"r' $% SIC<

The ', 5, an" register in S3 are

'4 'ccumu!ator, which is use" for arithmetic operations5 – n"e$ 7egister, which is use" for a""ressing

– inkage register, which is use" for SJ- instruction

! H)* $' t+" tar"t a77r"'' aat"7 $% 7$r"t a%7 $%7$r"t a77r"'' ()7" )# SIC?6E

ar+$t"tr"<  ( – 1B)

n "irect a""ressing mo"e, the target a""ress is ca!cu!ate" using the formu!a%

  T'+"isp(format /) or a""ress(format <)

8e wi!! get the a""ress of the instruction "irect!y from there we have to get the

operan".

  n in"irect a""ressing mo"e, the target a""ress is ca!cu!ate" using the formu!a%

T'+("isp) or (a""ress)

8e wi!! get the a""ress of the instruction that stores the a""ress of the operan". 8e

have to fetch the operan" from the a""ress specifie" in the ca!cu!ate" target a""ress.

2! L$'t )t t+" t&1"' )# r"$'t"r' '"7 $% SIC!

The register use" in S3 are tau!ate" as fo!!ows%

Mnemonic Numer Specia! Jse' B 'ccumu!ator, use" for arithmetic operations

5 1 n"e$ register, use" for a""ressing

2 inkage register, use" in SJ- instruction

F3 > Frogram counter, stores the a""ress of ne$t

instruction to e e$ecute"

S8 K Status 8or", inc!u"ing con"ition co"e, which is use"

3

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 4/69

for testing a "evice.

3! W+at $' t+" '$@" )# ("()r& $% SIC a%7 SIC?6E (a+$%"'<

  n S3,

i. The memory is 1 megayte(21?) ytes.

ii. / consecutive ytes forming a wor"

iii. > 4 it ytes

  n S395#

i. The memory is /2,AG>(22B) ytes.

ii. / consecutive ytes forming a wor"

iii. > 4 it ytes

4! Wr$t" a%& t*) a''"(/"r 7$r"t$."' '"7 /& SIC?6E!  (M –1/)

These are the statements that are not trans!ate" into machine instructions, ut they

 provi"e instructions to assem!er itse!f.

The assem!er "irective use" y S395# are as fo!!ows%

ST'7T, #N, -LT#, 8&7, 7#S8 an" 7#S-

8! Wr$t" a SIC C)7" t) )1& a% /&t" +arat"r 'tr$% t) a%)t+"r!  (M – 1/)

  The S3 co"e to copy an 11 yte character string to another is asfo!!ows%

5 #7& 99 nitia!!y $ to eroM&#3D 3D ST71, 5 5 99 specifying in"e$ingST3D ST72, 5 99ncrements 5 an" compares with 11

T5 ###NT M&#3D..ST71 -LT# 3 OT#ST ST7NP= 99String constantST72 7#S- 11#7& 8&7 B

  ###N 8&7 11

4

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 5/69

Part -

! E1a$% $% 7"ta$, .ar$)' r"$'t"r' )# SIC. (1A)(M – 12)7egisters%

There are five registers, each 2< its in !ength. Their mnemonic, numer an" use are given

in the fo!!owing ta!e.

Mnemonic Numer Jse

' B 'ccumu!atorQ use" for arithmetic operations

5 1 n"e$ registerQ use" for a""ressing

2 inkage registerQ SJ-

F3 > Frogram counter  

S8 K Status wor", inc!u"ing 33

1. 'ccumu!ator%  'ccumu!ator is the register which is use" for arithmetic operations

  #g. 3&MF ',S  The aove instruction compares the contents of register '(accumu!ator) H

S(register)2. n"e$ 7egister%

n"e$ register use" for a""ress purpose.  #g. ' -#T' ,5The aove instruction a""s the va!ue in -#T' an" 5 register.

/. inkage 7egister%

inkage register is use" to store the return a""ress for SJ- an" 7SJ-suroutines.<. Frogram 3ounter 

Frogram counter is use" to store the a""ress of the ne$t instruction to ee$ecute".

?. Status 8or"%Status 8or" contains a variety of information, inc!u"ing a con"ition co"e.

This con"ition co"e is use" to whether a "evice is sen"9receive "ata. 3o"e R

:*: means rea"y, ;+: means not rea"y.

 

2! E1a$% $% 7"ta$, SIC (a+$%" ar+$t"tr"!  (1A)(N – 11, – 1B)  S3 Machine 'rchitecture%

Memory%

There are 21? ytes in the computer memory, that is /2,GA> ytes, t uses itt!e #n"ian

format to store the numers, / consecutive ytes form a wor" , each !ocation in memory contains

>4it ytes.

5

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 6/69

7egisters%

There are five registers, each 2< its in !ength. Their mnemonic, numer an" use are given

in the fo!!owing ta!e.

Mnemonic Numer Jse

' B 'ccumu!atorQ use" for arithmetic operations

5 1 n"e$ registerQ use" for a""ressing

2 inkage registerQ SJ-

F3 > Frogram counter  

S8 K Status wor", inc!u"ing 33

ata 0ormats%

ntegers are store" as 2<4it inary numers, 2=s comp!ement representation is use" for

negative va!ues, characters are store" using their >4it 'S3 co"es, No f!oating4point har"ware onthe stan"ar" version of S3.

nstruction 0ormats%

&pco"e(>) $ '""ress (1?)

'!! machine instructions on the stan"ar" version of S3 have the 2<4it format as shown

aove.'""ressing Mo"es%

M)7" I%7$at$)% Tar"t a77r"'' aat$)%

irect $ + B T' + a""ress

n"e$e" $ + 1 T' + a""ress E ($)

There are two a""ressing mo"es avai!a!e, which are as shown in the aove ta!e.

Farentheses are use" to in"icate the contents of a register or a memory !ocation.

nstruction Set%

S3 provi"es, !oa" an" store instructions (', 5, ST', ST5, etc.). nteger arithmetic

operations% (', SJ-, MJ, , etc.). '!! arithmetic operations invo!ve register ' an" a wor"

in memory, with the resu!t eing !eft in the register. Two instructions are provi"e" for suroutine

!inkage. 3&MF compares the va!ue in register ' with a wor" in memory, this instruction sets a

6

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 7/69

con"ition co"e 33 to in"icate the resu!t. There are con"itiona! ump instructions% (T, #, PT),

these instructions test the setting of 33 an" ump accor"ing!y. SJ- umps to the suroutine

 p!acing the return a""ress in register , 7SJ- returns y umping to the a""ress containe" in

register .

nput an" &utput%

nput an" &utput are performe" y transferring 1 yte at a time to or from the rightmost > its of register ' (accumu!ator). The Test evice (T) instruction tests whether the a""resse"

"evice is rea"y to sen" or receive a yte of "ata. 7ea" ata (7), 8rite ata (8) are use" for

rea"ing or writing the "ata.

ata movement an" Storage efinition%

', ST', , ST, 5, ST5 ( '4 'ccumu!ator, – inkage 7egister, 5 – n"e$

7egister), a!! uses /4yte wor". 3D, ST3D associate" with characters uses 14yte. There are no

memory4memory move instructions.

Storage "efinitions are

• 8&7 4 &N#48&7 3&NST'NT

• 7#S8 4 &N#48&7 '7'-#

• -LT# 4 &N#4-LT# 3&NST'NT

• 7#S- 4 &N#4-LT# '7'-#

#$amp!e Frograms (S3)

Ea(1" 9S$(1" 7ata a%7 +arat"r ()."("%t )1"rat$)%5

  ' 0#

  ST' 'FD'

  3D 3D'7

  ST3D 31

.

'FD' 7#S8 1

0# 8&7 ?

3D'7 -LT# 3==

31 7#S- 1

7

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 8/69

3! E1a$% $% 7"ta$, t+" .ar$)' t&1"' )# a77r"''$% ()7"' a%7 $%'trt$)% #)r(at' )#

SIC?6E (a+$%"!   (1A)( – 1B)

'""ressing mo"es%

Mo"e n"ication Target a""ress ca!cu!ation &peran"

-ase re!ative +1, p+B T'+(-)E"isp (B*+"isp*+<BK?) (T')

F34re!ative +B, p+1 T'+(F3)E"isp (42B<>*+"isp*+2B<G) (T')

irect +B, p+B T'+"isp (format /) or a""ress (format <) (T')

n"e$e" $+1 T'+T'E(5) (T')

8e can use the target a""ress for fin"ing the operan" using the fo!!owing a""ressing%

Mo"e n"ication &peran" va!ue

mme"iate a""ressing i+1, n+B T'

in"irect a""ressing i+B, n+1 ((T'))simp!e a""ressing i+B, n+B S3 instruction (a!! en" with BB)

i+1, n+1 S395# instruction

'""ressing mo"es%

a. -ase re!ative (n+1, i+1, +1, p+B)

 . Frogram4counter re!ative (n+1, i+1, +B, p+1)

c. irect (n+1, i+1, +B, p+B)

". mme"iate (n+B, i+1, $+B)e. n"irect (n+1, i+B, $+B)

f. n"e$ing (oth n H i + B or 1, $+1)

g. #$ten"e" (e+1 for format <, e+B for format /)

D$r"t ($, , an" p a!! set to B)% operan" a""ress goes as it is. n an" i are oth set to the

same va!ue, either B or 1. 8hi!e in genera! that va!ue is 1, if set to B for format / we can

assume that the rest of the f!ags ($, , p, an" e) are use"as a part of the a""ress of the

operan", to make the format compati!e to the S3 format

R"at$." (either or p e6ua! to 1 an" the other one to B)% the a""ress of the operan"

shou!" e a""e" to the current va!ue store" at the - register (if + 1) or to the va!ue store"

at the F3 register (if p + 1)

8

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 9/69

I(("7$at" (i + 1, n + B)% The operan" va!ue is a!rea"y enc!ose" on the instruction (ie.

!ies on the !ast 1292B its of the instruction)

I%7$r"t (i + B, n + 1)% The operan" va!ue points to an a""ress that ho!"s the a""ress for

the operan" va!ue.

I%7""7 ($ + 1)% va!ue to e a""e" to the va!ue store" at the register $ to otain rea!

a""ress of the operan". This can e comine" with any of the previous mo"es e$ceptimme"iate.

nstruction 0ormats%

a. new registers% -, ST-, etc.

 . f!oating4point arithmetic% '0, SJ-0, MJ0, 0

c. register move% 7M&

". register4register arithmetic% '7, SJ-7, MJ7, 7 

e. supervisor ca!!% S3

 nput9output

f. S&, T&, D&% start, test, ha!t the operation of 9& "evice

Ea(1" 9S$(1" 7ata a%7 +arat"r ()."("%t )1"rat$)%5

  ' ?

  ST' 'FD'

  ' KB

  ST3D 31

.

  .

'FD' 7#S8 1

31 7#S- 1

Ea(1" 29Ar$t+("t$ )1"rat$)%'5

S N37

' 'FD'

  ' S,'

  SJ- 1

  ST' -##T'

  UUUU.

  UUUU..

'FD' 7#S8 1

9

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 10/69

-#T' 7#S8 1

N37 7#S8 1

Ea(1" 39L))1$% a%7 I%7"$% )1"rat$)%5

  T 11

  5 B % 5 + B

 M&#3D 3D ST71, 5 % &' ' 07&M ST71  ST3D ST72, 5 % ST&7# ' T& ST72

T57 T % ' 1 T& 5, T#ST (T)

T M&#3D

  UUU.

  UUU.

  UUU

  ST71 -LT# 3 OD#& 8&7=

  ST72 7#S- 11

4! C)(1ar" SIC *$t+ SIC?6E *$t+ 1r)ra(($% "a(1"' a%7 *$t+ r"'1"t t) ("()r&,

$%'trt$)% #)r(at', a77r"''$% ()7"' a%7 7ata #)r(at'!  (1A)(M – 1/)  S3 Machine 'rchitecture%

Memory%

There are 21? ytes in the computer memory, that is /2,GA> ytes, t uses itt!e #n"ian

format to store the numers, / consecutive ytes form a wor" , each !ocation in memory contains

>4it ytes.

7egisters%

There are five registers, each 2< its in !ength. Their mnemonic, numer an" use are given

in the fo!!owing ta!e.

Mnemonic Numer Jse

' B 'ccumu!atorQ use" for arithmetic operations

5 1 n"e$ registerQ use" for a""ressing

2 inkage registerQ SJ-

F3 > Frogram counter  

S8 K Status wor", inc!u"ing 33

ata 0ormats%

10

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 11/69

ntegers are store" as 2<4it inary numers, 2=s comp!ement representation is use" for

negative va!ues, characters are store" using their >4it 'S3 co"es, No f!oating4point har"ware on

the stan"ar" version of S3.

nstruction 0ormats%

&pco"e(>) $ '""ress (1?)

'!! machine instructions on the stan"ar" version of S3 have the 2<4it format as shown

aove.'""ressing Mo"es%

M)7" I%7$at$)% Tar"t a77r"'' aat$)%

irect $ + B T' + a""ress

n"e$e" $ + 1 T' + a""ress E ($)

There are two a""ressing mo"es avai!a!e, which are as shown in the aove ta!e.

Farentheses are use" to in"icate the contents of a register or a memory !ocation.

nstruction Set%

S3 provi"es, !oa" an" store instructions (', 5, ST', ST5, etc.). nteger arithmetic

operations% (', SJ-, MJ, , etc.). '!! arithmetic operations invo!ve register ' an" a wor"

in memory, with the resu!t eing !eft in the register. Two instructions are provi"e" for suroutine

!inkage. 3&MF compares the va!ue in register ' with a wor" in memory, this instruction sets a

con"ition co"e 33 to in"icate the resu!t. There are con"itiona! ump instructions% (T, #, PT),

these instructions test the setting of 33 an" ump accor"ing!y. SJ- umps to the suroutine

 p!acing the return a""ress in register , 7SJ- returns y umping to the a""ress containe" in

register .

nput an" &utput%

nput an" &utput are performe" y transferring 1 yte at a time to or from the rightmost >

 its of register ' (accumu!ator). The Test evice (T) instruction tests whether the a""resse"

"evice is rea"y to sen" or receive a yte of "ata. 7ea" ata (7), 8rite ata (8) are use" for

rea"ing or writing the "ata.

ata movement an" Storage efinition%

11

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 12/69

', ST', , ST, 5, ST5 ( '4 'ccumu!ator, – inkage 7egister, 5 – n"e$

7egister), a!! uses /4yte wor". 3D, ST3D associate" with characters uses 14yte. There are no

memory4memory move instructions.

Storage "efinitions are

• 8&7 4 &N#48&7 3&NST'NT

• 7#S8 4 &N#48&7 '7'-#

• -LT# 4 &N#4-LT# 3&NST'NT

• 7#S- 4 &N#4-LT# '7'-#

#$amp!e Frograms (S3)

Ea(1" 9S$(1" 7ata a%7 +arat"r ()."("%t )1"rat$)%5

  ' 0#

  ST' 'FD'

  3D 3D'7  ST3D 31

.

'FD' 7#S8 1

0# 8&7 ?

3D'7 -LT# 3==

31 7#S- 1

S395# Machine 'rchitecture%

'""ressing mo"es%

Mo"e n"ication Target a""ress ca!cu!ation &peran"

-ase re!ative +1, p+B T'+(-)E"isp (B*+"isp*+<BK?) (T')

F34re!ative +B, p+1 T'+(F3)E"isp (42B<>*+"isp*+2B<G) (T')

irect +B, p+B T'+"isp (format /) or a""ress (format <) (T')

n"e$e" $+1 T'+T'E(5) (T')

8e can use the target a""ress for fin"ing the operan" using the fo!!owing a""ressing%

Mo"e n"ication &peran" va!ue

mme"iate a""ressing i+1, n+B T'

in"irect a""ressing i+B, n+1 ((T'))

simp!e a""ressing i+B, n+B S3 instruction (a!! en" with BB)

i+1, n+1 S395# instruction

12

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 13/69

'""ressing mo"es%

a. -ase re!ative (n+1, i+1, +1, p+B)

 . Frogram4counter re!ative (n+1, i+1, +B, p+1)

c. irect (n+1, i+1, +B, p+B)

". mme"iate (n+B, i+1, $+B)

e. n"irect (n+1, i+B, $+B)

f. n"e$ing (oth n H i + B or 1, $+1)

g. #$ten"e" (e+1 for format <, e+B for format /)

D$r"t ($, , an" p a!! set to B)% operan" a""ress goes as it is. n an" i are oth set to the

same va!ue, either B or 1. 8hi!e in genera! that va!ue is 1, if set to B for format / we can

assume that the rest of the f!ags ($, , p, an" e) are use"as a part of the a""ress of the

operan", to make the format compati!e to the S3 format

R"at$." (either or p e6ua! to 1 an" the other one to B)% the a""ress of the operan"

shou!" e a""e" to the current va!ue store" at the - register (if + 1) or to the va!ue store"

at the F3 register (if p + 1)

I(("7$at" (i + 1, n + B)% The operan" va!ue is a!rea"y enc!ose" on the instruction (ie.

!ies on the !ast 1292B its of the instruction)

I%7$r"t (i + B, n + 1)% The operan" va!ue points to an a""ress that ho!"s the a""ress for

the operan" va!ue.

I%7""7 ($ + 1)% va!ue to e a""e" to the va!ue store" at the register $ to otain rea!

a""ress of the operan". This can e comine" with any of the previous mo"es e$cept

imme"iate.

nstruction 0ormats%

a. new registers% -, ST-, etc.

 . f!oating4point arithmetic% '0, SJ-0, MJ0, 0

c. register move% 7M&

". register4register arithmetic% '7, SJ-7, MJ7, 7 

e. supervisor ca!!% S3

 nput9output

f. S&, T&, D&% start, test, ha!t the operation of 9& "evice

Ea(1" 9S$(1" 7ata a%7 +arat"r ()."("%t )1"rat$)%5

13

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 14/69

  ' ?

  ST' 'FD'

  ' KB

  ST3D 31

.

  .'FD' 7#S8 1

31 7#S- 1

Ea(1" 29Ar$t+("t$ )1"rat$)%'5

S N37

' 'FD'

  ' S,'

  SJ- 1

  ST' -##T'

  UUUU.

  UUUU..

'FD' 7#S8 1

-#T' 7#S8 1

N37 7#S8 1

Ea(1" 39L))1$% a%7 I%7"$% )1"rat$)%5

  T 11

  5 B % 5 + B

 M&#3D 3D ST71, 5 % &' ' 07&M ST71

  ST3D ST72, 5 % ST&7# ' T& ST72

T57 T % ' 1 T& 5, T#ST (T)

T M&#3D

  UUU.

  UUU.

  UUU

  ST71 -LT# 3 OD#& 8&7=

  ST72 7#S- 11

8! E1a$% $% 7"ta$, t+" '"B"%" )# )7" $% SIC a%7 SIC?6E t) r"a7 200 /&t" r")r7

#r)( t+" 7".$" F '$% '/r)t$%"!  (1B)(M – 1/)

14

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 15/69

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 16/69

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 17/69

8! W+at $' ("a%t /& a $t"ra<  (N – 11)

n itera!s, the va!ue of constants operan" as a part of the instructions, itse!f.

This avoi"s having to "efine the constant e!sewhere in the  progr am.

The itera!s are i"entifie" with prefi$ O+=. 8hich is fo!!owe" y the specification

of the itera! va!ue.0or #g,

' + 3 O#&0=

:! W+at $' r"-)ata/" 1r)ra(<   (M – 11)

'n oect program that contains the information necessary to perform re6uire"

mo"ification in the oect co"e "epen"s on the starting !ocation of the program "uring !oa"

time is known as re!ocata!e program.

;! D$##"r"%t$at" a/')t" "1r"''$)% #r)( r"at$." "1r"''$)%!   (M – 11)

'so!ute #$pression 7e!ative #$pression

1. f the resu!t of the e$pression is an

aso!ute va!ue (constant) then it is known

as aso!ute e$pression.

2. #$amp!e.% -J0#N – -J00#7 

1. f the resu!t of the e$pression is

re!ative to the eginning of the

 program, then it is known as re!ative

e$pression. ae! on instructions

an" "ata areas an" references to the

!ocation counter va!ues are re!ative

terms.

2. #$amp!e.% -J0#N E -J00#7 

=! H)* $t"ra 7$##"r' #r)( $(("7$at" )1"ra%7<  (M – 1/)

Vitera!sV are character se6uences that se!f4i"entify their va!ue, e.g, 1G an" VacV.

mme"iate operan"s are ways of eme""ing !itera! va!ues "irect!y into machine

instructions. 8hen the !itera! va!ue wonIt fit, an" you nee" it, you have to put it somewhere

e!se (e.g, in a 3) an" refer to it using the a""ress of that somewhere e!se (usua!!y a !ae!),

an" you can often "o that y writing the name of the !ae! in the p!ace where an imme"iate

va!ue is a!!owe" in an instruction.

>! W+at $' t+" '" )# t+" .ar$a/" LOCCTR 9)at$)% )%t"r5 $% a''"(/"r<  ( – 1B)

The varia!e &33T7 use" to assign a""resses to the symo!s. &33T7 is

initia!ie" to the eginning a""ress specifie" in the ST'7T statement. 'fter each source

statement is processe", the !ength of the assem!e" instruction or "ata area to e generate"

17

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 18/69

is a""e" to &33T7 an" hence whenever we reach a !ae! in the source program the

current va!ue of &33T7 gives the a""ress associate" with the !ae!.

0! W+at ar" t+" '"' )# t+" a''"(/"r 7$r"t$."' START, CSECT a%7 USE<  ( – 1B)

The use of the assem!er "irectives are !iste" e!ow%

ST'7T% Specifies name an" starting a""ress of the progr am

3S#3T% "entifies the start or continuation of a contro! section.' )%tr) '"t$)% (3S#3T), is ;a !ock of co"ing that can e re!ocate"

(in"epen"ent of other co"ing) without a!tering the operating !ogic of the

 program.:

JS#% Jse" to "ivi"e the program in to many !ocks ca!!e" program !ocks

! W+at $' 1r)ra( r")at$)%<

Frogram re!ocation is the process which mo"ifies the oect program so that it can e

!oa"e" at an a""ress "ifferent from the !ocation origina!!y specifie".

2! W+at $' a $t"ra 1))<

'!! of the !itera! operan"s use" in a program are gathere" together into one or more

!itera! poo!s. Norma!!y, !itera!s are p!ace" into a poo! at the en" of the program. The

assem!y !isting of a program containing !itera!s usua!!y inc!u"es a !isting of this !itera!

 poo!, which shows the assigne" a""resses an" generate" "ata va!ues.

3! W+at $' t+" '" )# t+" '&(/) 7"#$%$% 'tat"("%t' EU a%7 ORG<

The use of symo! "efining statements #J an" &7P are%

(i)O#J=4it a!!ows the programmer to "efine symo!s an" specify their va!ues"irect!y. The genera! format is

symo! EU va!ue

(ii) O&7P=4it is use" to in"irect!y assign va!ues to symo!s. 8hen this statement is

encountere" the assem!er resets its !ocation counter to the specifie" va!ue.

  The genera! format is

ORG va!ue

  n the aove two statements, va!ue is a constant or an e$pression invo!ving constants

an" previous!y "efine" symo!s

4! W+at ar" t+" t+r"" 7$##"r"%t r")r7' '"7 $% )/"t 1r)ra(<

The three "ifferent recor"s use" in oect program are,

18

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 19/69

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 20/69

Part -

! E1a$% $% 7"ta$, t+" 1r$%$1"' )# 1r)ra( r")at$)%!   (1A)(M – 12)

Sometimes it is re6uire" to !oa" an" run severa! programs at the same time. The

system must e a!e to !oa" these programs wherever there is p!ace in the memory.

Therefore the e$act starting is not known unti! the !oa" time.

'so!ute Frogram

n this the a""ress is mentione" "uring assem!ing itse!f. This is ca!!e" 'so!ute

assem!y. 3onsi"er the instruction%

?? 1B1- ' TD7## BB1B2

This statement says that the register ' is !oa"e" with the va!ue store" at !ocation

1B2. Suppose it is "eci"e" to !oa" an" e$ecute the program at !ocation 2BBB instea" of

!ocation 1BBB. Then at a""ress 1B2 the re6uire" va!ue which nee"s to e !oa"e" in the

register ' is no more avai!a!e. The a""ress a!so gets change" re!ative to the

"isp!acement of the program. Dence we nee" to make some changes in the a""ress

 portion of the instruction so that we can !oa" an" e$ecute the program at !ocation 2BBB.

'part from the instruction which wi!! un"ergo a change in their operan" a""ress va!ue as

the program !oa" a""ress changes. There e$ist some parts in the program which wi!!

remain same regar"!ess of where the program is eing !oa"e".

Since assem!er wi!! not know actua! !ocation where the program wi!! get !oa"e", it

cannot make the necessary changes in the a""resses use" in the program. Dowever, the

assem!er i"entifies for the !oa"er those parts of the program which nee" mo"ification.

'n oect program that has the information necessary to perform this kin" of

mo"ification is ca!!e" the re!ocata!e program.

Frogram 7e!ocation%

'so!ute program, starting a""ress 1BBB  e.g. ?? 1B1- ' TD7## BB1B27e!ocate the program to 2BBB

e.g. ?? 1B1- ' TD7## BB2B2#ach 'so!ute a""ress shou!" e mo"ifie"

#$cept for aso!ute a""ress, the rest of the instructions nee" not e mo"ifie" not amemory a""ress (imme"iate a""ressing) F34re!ative, -ase4re!ativeThe on!y parts of the program that re6uire mo"ification at !oa" that time are those

specify "irect a""resses7e!ocata!e Frogram Mo"ification recor"3o! 1 M

20

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 21/69

3o! 24G Starting !ocation of the a""ress fie!" to e mo"ifie", re!ative to the eginning ofthe program

  3o! >4K !ength of the a""ress fie!" to e mo"ifie", in ha!f ytes

2! E1a$% $% 7"ta$, t+" a''"(/"r 7"'$% )1t$)%'!  (1A)(N – 11)

  A''"(/"r D"'$% O1t$)%'

1. &ne4pass assem!ers

2. Mu!ti4pass assem!ers

/. Two4pass assem!er with over!ay structure

1. &ne4Fass 'ssem!ers%Main pro!em%

i. forwar" referencesii. "ata items

iii. !ae!s on instructionsSo!ution%

i. "ata items% re6uire a!! such areas e "efine" efore they arereference"

ii. !ae!s on instructions% no goo" so!ution

2. Mu!ti4Fass 'ssem!ersi. 7estriction on #J an" &7P

a. no forwar" reference, since symo!s= va!uecan=t e "efine""uring the first pass

i. #$amp!ea. Jse !ink !ist to keep track of whose va!ue "epen" on an un"efine"symo!

/. Two4Fass 'ssem!er with &ver!ay Structure

 For small memory

1. pass 1 an" pass 2 are never re6uire" at the same time

2. three segments

a. root% "river program an" share" ta!es an" suroutines

 . pass 1

c. pass 2

/. tree structure

<. over!ay program

3! E1a$% $% 7"ta$, t+" (a+$%" 7"1"%7"%t a''"(/"r #"atr"'!  (1A)(N – 11)

Machine4epen"ent 0eatures%

1. nstruction formats an" a""ressing mo"es

2. Frogram re!ocation

1. nstruction formats an" '""ressing Mo"es

21

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 22/69

The instruction formats "epen" on the memory organiation an" the sie of

the memory. n S3 machine the memory is yte a""ressa!e. 8or" sie is / ytes.

So the sie of the memory is 212 ytes. 'ccor"ing!y it supports on!y one

instruction format. t has on!y two registers% register ' an" n"e$ register. Therefore

the a""ressing mo"es supporte" y this architecture are "irect, in"irect, an"

in"e$e". 8hereas the memory of a S395# machine is 22B ytes (1 M-). Thissupports four "ifferent types of instruction types, they are%

i. 1 yte instruction

ii. 2 yte instruction

iii. / yte instruction

iv. < yte instruction

W nstructions can e%

 – nstructions invo!ving register to register

 – nstructions with one operan" in memory, the other in 'ccumu!ator

(Sing!e operan" instruction)

 – #$ten"e" instruction format

W '""ressing Mo"es are%

 – n"e$ '""ressing(S3)% &pco"e m, $

 – n"irect '""ressing% &pco"e Xm

 – F34re!ative% &pco"e m

 – -ase re!ative% &pco"e m

 – mme"iate a""ressing% &pco"e c

2. Frogram 7e!ocation%

'so!ute program, starting a""ress 1BBB  e.g. ?? 1B1- ' TD7## BB1B27e!ocate the program to 2BBB

e.g. ?? 1B1- ' TD7## BB2B2

#ach 'so!ute a""ress shou!" e mo"ifie" 

#$cept for aso!ute a""ress, the rest of the instructions nee" not e mo"ifie" not amemory a""ress (imme"iate a""ressing) F34re!ative, -ase4re!ativeThe on!y parts of the program that re6uire mo"ification at !oa" that time are thosespecify "irect a""resses

7e!ocata!e Frogram%

22

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 23/69

  Mo"ification recor" 3o! 1 M3o! 24G Starting !ocation of the a""ress fie!" to e mo"ifie", re!ative to the eginning of the program

  3o! >4K !ength of the a""ress fie!" to e mo"ifie", in ha!f ytes

4. W+at ar" t+" /a'$ #%t$)%' )# a% a''"(/"r< E1a$% $% 7"ta$, t+" t*)-1a''

a''"(/"r a)r$t+( *$t+ a% "a(1"!   (1A)( –  1B)

The asic assem!er functions are%

i. Trans!ating mnemonic !anguage co"e to its e6uiva!ent oect co"e.

ii. 'ssigning machine a""resses to symo!ic !ae!s.

Source program 4Y 'ssem!er 4Y &ect 3o"e

 

The "esign of assem!er can e to perform the fo!!owing%

i. Scanning (tokeniing)

ii. Farsing (va!i"ating the instructions)

iii. 3reating the symo! ta!e

iv. 7eso!ving the forwar" references

v. 3onverting into the machine !anguage

The "esign of assem!er in other wor"s%

i. 3onvert mnemonic operation co"es to their machine !anguage e6uiva!ents

ii. 3onvert symo!ic operan"s to their e6uiva!ent machine a""resses

iii. eci"e the proper instruction format 3onvert the "ata constants to interna!

machine representations

iv. 8rite the oect program an" the assem!y !isting

So for the "esign of the assem!er we nee" to concentrate on the machine architecture

of the S395# machine. 8e nee" to i"entify the a!gorithms an" the various "ata structuresto e use". 'ccor"ing to the aove re6uire" steps for assem!ing the assem!er a!so has to

han"!e assem!er "irectives, these "o not generate the oect co"e ut "irects the

assem!er to perform certain operation. These "irectives are%

W S3 'ssem!er irective%

 – ST'7T% Specify name H starting a""ress.

23

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 24/69

 – #N% #n" of the program, specify the first e$ecution instruction.

 – -LT#, 8&7, 7#S-, 7#S8

 – #n" of recor"% a nu!! char(BB) 1?

  #n" of fi!e% a ero !ength recor"

The assem!er "esign can e "one%

i. Sing!e pass assem!erii. Mu!ti4pass assem!er 

8! W+at $' #)r*ar7 r"#"r"%"< E1a$% $% 7"ta$, t+" )%" 1a'' a''"(/"r *$t+ a%

"a(1"! (1A)( – 1B)

0orwar" 7eference means, the symo!s in the program may e referre" efore

that is "efine". 0or

#g.

  ' -

- -LT# 1B

Dere - va!ue is referre" efore it is "ef ine".

&ne4Fass 'ssem!er

The main pro!em in "esigning the assem!er using sing!e pass was to reso!ve forwar"

references. 8e can avoi" to some e$tent the forwar" references y%

i. #!iminating forwar" reference to "ata items, y "efining a!! the storage

reservation statements at the eginning of the program rather at the en".

ii. Jnfortunate!y, forwar" reference to !ae!s on the instructions cannot e

avoi"e". (forwar" umping)

iii. To provi"e some provision for han"!ing forwar" references y prohiiting

forwar" references to "ata items.

There are two types of one4pass assem!ers%

i. &ne that pro"uces oect co"e "irect!y in memory for imme"iate e$ecution

(oa"4an"4go assem!ers).

ii. The other type pro"uces the usua! kin" of oect co"e for !ater e$ecution.

oa"4an"4go assem!er generates their oect co"e in memory for imme"iate

24

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 25/69

e$ecution.

a. No oect program is written out, no !oa"er is nee"e".

 . t is usefu! in a system with fre6uent program "eve!opment an" testing

c. The efficiency of the assem!y process is an important consi"eration.

". Frograms are re4assem!e" near!y every time they are runQ efficiency of the

assem!y process is an important consi"eration.

25

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 26/69

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

DEPARTMENT OF INFORMATION TECHNOLOGY

CS2304 SYSTEM SOFTWARE

UNIT -III

Part – A

! W+at ar" t+" a7.a%ta"' )# 7&%a($ $%$%<   (M – 12)

f the suroutine is !oa"e" an" !inke" to the program "uring its first ca!!

(run time),then it is ca!!e" as "ynamic !oa"ing or "ynamic !inking.

 The various a"vantages of "ynamic !inking are%

  (i) t has the ai!ity to !oa" the routine on!y when they are nee"e"

  (ii)The "ynamic !inking avoi"s the !oa"ing of entire !irary for each e$ecution

2! W+at $' /))t'tra1 )a7"r<   (M – 12)

This is a specia! type of aso!ute !oa"er which !oa"s the first program to e run y

the computer usua!!y an operating system.

3! W+at ar" t+" #%t$)%' )# )a7"r a%7 $%"r<  (N – 11)

  The various functions of !oa"er an" !inker are%

L)a7$% – rings the oect program into memory for e$ecution

R")at$)% – mo"ifies the oect program so that it can e !oa"e" at an a""ress

"ifferent from the !ocation origina!!y specifie"

L$%$% – comines two or more separate oect programs an" a!so supp!ies the

information nee"e" to reference them.

4! W+at ar" t+" #%t$)%' )# a% $%$% )a7"r<

The !inking !oa"er performs the process of !inking an" re!ocation. t inc!u"es the

operation of automatic !irary search an" the !inke" programs are "irect!y !oa"e" into the

memory.

8! G$." t+" a)r$t+( )# a% a/')t" )a7"r! (M – 1/)

-egin

7ea" Dea"er recor"

erify program name an" !ength

7ea" first te$t recor"

8hi!e recor" type Z+ O#= "o

-egin

26

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 27/69

Move" oect co"e to specifie" !ocation in memory

7ea" ne$t oect program recor"

#n"

ump to a""ress specifie" in #n" recor"

#n"

:! D"#$%" – R")at$)% (N – 11)The process of storing programs in some other memory !ocation an" e$ecuting from

that !ocation is ca!!e" re!ocation.

The two "ifferent techni6ues of re!ocation are %

(i) Mo"ification recor" metho"

(ii) 7e!ocation it metho".

;! W+at $' ("a%t /& 7&%a($ )a7$%<   (M – 11)

The process of !oa"ing the program at runtime is ca!!e" "ynamic !oa"ing.

nstea" of !oa"ing the program at compi!e time, we wi!! !oa" the program at runtime.

=! D$##"r"%t$at" $%a" "7$t)r' #r)( $%$% )a7"r'. (M –11)

L$%$% )a7"r L$%a" "7$t)r

1. The re!ocation an" !inking is

 performe" each time the program is

!oa"e".

2. Dere the !oa"ing can e

accomp!ishe" in two passes arere6uire".

1. t pro"uces a !inke" version of a

 program an"which is written in a fi!e for

!ater e$ecution.

2. Dere the !oa"ing can e accomp!ishe"

in a sing!e pass is re6uire".

>! W+at $' ("a%t /& 7&%a($ $%$%<  ( – 1B HM – 1/)

f the suroutine is !oa"e" an" !inke" to the program "uring its first ca!!

  (run time),then it is ca!!e" as "ynamic !oa"ing or "ynamic !inking.

The various a"vantages of "ynamic !inking are%

  (i) t has the ai!ity to !oa" the routine on!y when they are nee"e"

  (ii)The "ynamic !inking avoi"s the !oa"ing of entire !irary for each e$ecution

0! Wr$t" t+" #%t$)%' )# t*) 1a''"' )# a $%$% )a7"r!

The functions of two passes of a !inking !oa"er are%

27

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 28/69

Pa'' assigns a""ress to a!! e$terna! symo!s

Pa''2 performs actua! !oa"ing, re!ocation an" !inking

! D"#$%" – At)(at$ L$/rar& S"ar+

n many !inking !oa"ers, the suroutines ca!!e" y the program eing !oa"e" are

automatica!!y fetche" from the !irary, !inke" with the main program an" !oa"e".This

feature is referre" to as automatic !irary search.

2! W+at $' t+" '" )# ESTA<

#ST'- is use" to store the name an" a""ress of each e$terna! symo!. t a!so

in"icates, in which contro! section the symo! is "efine".

3! W+at ar" t+" #%t$)%' )# a )a7"r<   ( – 1B)

  The various functions of !oa"er an" !inker are%

i. L)a7$% – rings the oect program into memory for e$ecution

ii. R")at$)% – mo"ifies the oect program so that it can e !oa"e" at an a""ress"ifferent from the !ocation origina!!y specifie"

4! D"#$%" – $t Ma' 

The re!ocation its are gathere" together fo!!owing the !ength in"icator in each te$t

recor" an" which is ca!!e" as it mask. 0or #$amp!e.% the it mask 003(1111111111BB)

specifies that the first 1B wor"s of oect co"e are to e mo"ifie" "uring re!ocation.

15. L$'t )t t+" '" )# )a7"r )1t$)%' INCLUDE a%7 DELETE!

  The genera! format of N3J# is

N3J#   program name (!irary name)

This comman" "irects the !oa"er to rea" the "esignate" oect program from a

!irary an" treat it as the primary !oa"er input.

  The genera! format of ##T# comman" is

##T# 3sect4name

t instructs the !oa"er to "e!ete the name" contro! sections from the sets of programs

!oa"e".

28

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 29/69

Part –

! D"'r$/" $% 7"ta$, (a+$%" 7"1"%7"%t )a7"r #"atr"'!   (1A)(N – 11)

Ma+$%"-D"1"%7"%t L)a7"r F"atr"'

'so!ute !oa"er is simp!e an" efficient, ut the scheme has potentia!

"isa"vantages &ne of the most "isa"vantage is the programmer has to specify the actua!

starting a""ress, from where the program to e !oa"e". This "oes not create "ifficu!ty, if

one program to run, ut not for severa! programs. 0urther it is "ifficu!t to use suroutine

!iraries efficient!y.

This nee"s the "esign an" imp!ementation of a more comp!e$ !oa"er. The !oa"er

must provi"e program re!ocation an" !inking, as we!! as simp!e !oa"ing functions.

7e!ocation

The concept of program re!ocation is, the e$ecution of the oect program using

any part of the avai!a!e an" sufficient memory. The oect program is !oa"e" into

memory wherever there is room for it. The actua! starting a""ress of the oect program

is not known unti! !oa" time. 7e!ocation provi"es the efficient sharing of the machine

with !arger memory an" when severa! in"epen"ent programs are to e run together. t

a!so supports the use of suroutine !iraries efficient!y. oa"ers that a!!ow for program

re!ocation are ca!!e" re!ocating !oa"ers or re!ative !oa"ers.

Metho"s for specifying re!ocation

Jse of mo"ification recor" an", use of re!ocation it, are the metho"s avai!a!e

for specifying re!ocation. n the case of mo"ification recor", a mo"ification recor" M is

use" in the oect program to specify any re!ocation. n the case of use of re!ocation it,

each instruction is associate" with one re!ocation it an", these re!ocation its in a Te$t

recor" is gathere" into it masks.

Mo"ification recor"s are use" in comp!e$ machines an" is a!so ca!!e" 7e!ocation

an" inkage irectory (7) specification. The format of the mo"ification recor" (M) is

as fo!!ows. The oect program with re!ocation y Mo"ification recor"s is a!so shown

here.Mo"ification recor"

co! 1% M

co! 24G% re!ocation a""ress

co! >4K% !ength (ha!fyte)

co! 1B% f!ag (E94)

29

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 30/69

co! 1141G% segment name

D 3&FL BBBBBB BB1BGG

T BBBBBB 1 1G2B2 AK2B2 <>1B1B/AU<-1B? /020#3 B/2B1B <A

T BBBB1 1/ B02B1A B1BBB/ B02BB <-1B1B? /#2BB/ <?<0<A

T BB1B/? 1 -<1B -<BB -<<B G?1B1BBB U //2BB> ?G3BB/ ->?BT BB1B?/ 1 /-20#' 1/<BBB <0BBBB 01...?/3BB/ 02BB> ->?B

T BBBGB BG /-20#0 <0BBBB B?

M BBBBBG B?E3&FL

M BBBB1< B?E3&FL

M BBBB2G B?E3&FL

# BBBBBB

The re!ocation it metho" is use" for simp!e machines. 7e!ocation it is B% no

mo"ification is necessary, an" is 1% mo"ification is nee"e". This is specifie" in the

co!umns 1B412 of te$t recor" (T), the format of te$t recor", a!ong with re!ocation its is

as fo!!ows.

Te$t recor"

co! 1% T

co! 24G% starting a""ress

co! >4K% !ength (yte)

co! 1B412% re!ocation its

co! 1/4G2% oect co"e

Twe!ve4it mask is use" in each Te$t recor" (co!%1B412 – re!ocation its), since

each te$t recor" contains !ess than 12 wor"s, unuse" wor"s are set to B, an", any va!ue

that is to e mo"ifie" "uring re!ocation must coinci"e with one of these /4yte segments.

0or aso!ute !oa"er, there are no re!ocation its co!umn 1B4AK contains oect co"e. The

oect program with re!ocation y it mask is as shown e!ow. &serve 003 4 means a!!

ten wor"s are to e mo"ifie" an", #BB 4 means first three recor"s are to e mo"ifie".

D 3&FL BBBBBB BB1BG'

T BBBBBB 1# 003 1<BB// <>1B/K BBBB/A 2>BB/B /BBB1?U/3BBB/ U

30

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 31/69

T BBBB1#1? #BB B3BB/A <>1BA1 B>BB// <3BBBBUBBBBB/ BBBBBB

T BB1B/K 1# 003 B<BB/B BBBB/B U/B1B/0 >1B? 2>BB/B...

T BB1B?G B' >BB 1BBB/A <3BBBB 01 BB1BBB

T BB1BA1 1K 0#B B<BB/B #B1BGK U ?B>B/K 31BGK 23BB/A ...

# BBBBBB

F7&P7'M N[NP

The Poa! of program !inking is to reso!ve the pro!ems with e$terna! references

(#5T7#0) an" e$terna! "efinitions (#5T#0) from "ifferent contro! sections.

#5T#0 (e$terna! "efinition) 4 The #5T#0 statement in a contro! section

names symo!s, ca!!e" e$terna! symo!s, that are "efine" in this (present) contro! section

an" may e use" y other sections.

e$% #5T#0 -J00#7, -J00#N, #NPTD

#5T#0 ST', #N'

#5T7#0 (e$terna! reference) 4 The #5T7#0 statement names symo!s use"

in this (present) contro! section an" are "efine" e!sewhere.

e$% #5T7#0 77#3, 877#3

#5T7#0 ST-, #N-, ST3, #N3

2!  E1a$% t+" #))*$%% ( – 1B)

9a5 A''"(/"r-a%7-) )a7"r   (B>)

3haracteristic%

The oect co"e is store" in memory after assem!y the oect co"e

is store" in memory after assem!y sing!e JMF instruction

'"vantage%

Simp!e, "eve!oping environment

  isa"vantage%

8henever the assem!y program is to e e$ecute", it has to e

assem!e" again programs have to e co"e" in the same !anguage

9/5 A/')t" )a7"r   (B>)

The operation of aso!ute !oa"er is very simp!e. The oect co"e is

!oa"e" to specifie" !ocations in the memory. 't the en" the !oa"er umps to the

specifie" a""ress to egin e$ecution of the !oa"e" program. The a"vantage of

31

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 32/69

aso!ute !oa"er is simp!e an" efficient. -ut the "isa"vantages are, the nee" for

 programmer to specify the actua! a""ress, an", "ifficu!t to

use suroutine !iraries.

The a!gorithm for this type of !oa"er is given here. The oect program

an", the oect program !oa"e" into memory y the aso!ute !oa"er are a!so

shown. #ach yte of assem!e" co"e is given using its he$a"ecima!representation in character form. #asy to rea" y human eings. #ach yte of

oect co"e is store" as a sing!e yte. Most machine store oect programs in a

 inary form, an" we must e sure that our fi!e an" "evice conventions "o not

cause some of the program ytes to e interprete" as contro! characters.

Samp!e 3o"e %

 -egin

rea" Dea"er recor"

verify program name an" !ength

rea" first Te$t recor"

whi!e recor" type is *Y O#= "o

 egin

\

if oect co"e is in character form, convert into interna!

representation

  ]

move oect co"e to specifie" !ocation in memory

rea" ne$t oect program recor"

en"

 ump to a""ress specifie" in #n" recor"

en"

3. E1a$% t+" #))*$%% ( – 1B)

9a5 R")at$% )a7"r  

(B>)

i. Motivation

a. #fficient sharing of the machine with !arger memory an"

  when severa! in"epen"ent programs are to e run together 

32

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 33/69

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 34/69

e$amp!e to un"erstan" the concept. arious segments a!ong with their memory

re6uirements is as shown e!ow.

4!  E1a$% t+" #))*$%

9a5 ))t'tra1 L)a7"r. (B>)

Piven an i"!e computer with no program in memory,how "o we get things starte"^

i. 8ith the machine empty an" i"!e, there is no nee" for  program re!ocationa. Some ear!y computers re6uire" the operator to enter into

memory the oect co"e for an aso!ute !oa"er, usingswitches on the computer conso!e

 . &ne some computer, an aso!ute !oa"er program is permanent!y resi"ent in a 7&M

c. ' ui!t4in har"ware function that rea"s a fi$e"4!ength recor"form some "evice into memory at a fi$e" !ocation

34

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 35/69

Samp!e program%

  -egin

  5+B$>B (the a""ress of the ne$t memory !ocation to e !oa"e"

  oop

'4YP#T3 (an" convert it from the 'S3 character co"e to

the va!ue of the he$a"ecima! "igit)save the va!ue in the high 4 or"er < its of S or"er < its of S

 '4YP#T3

 comine the va!ue to form one yte '*4('ES)

 store the va!ue (in ') to the a""ress in register 5

 5*45E1

  #n"

9/5 L$%a" "7$t)r   (B>)

inkage #"itor%

The e$ecution of any program nee"s four asic functiona!ities an"

those are a!!ocation, re!ocation, !inking an" !oa"ing. 's we have a!so seen in

"irect !inking !oa"er for e$ecution of any program each time these four

functiona!ities nee" to e performe". -ut performing a!! these functiona!ities

each time is time an" space consuming task. Moreover if the program contains

many suroutines or functions an" the program nee"s to e e$ecute"

repeate"!y then this activity ecomes annoying!y comp!e$ .#ach time for

e$ecution of a program, the a!!ocation, re!ocation !inking an" 4!oa"ing nee"s

to e "one. Now "oing these activities each time increases the time an" space

comp!e$ity.

'ctua!!y, there is no nee" to re"o a!! these four activities each time.

nstea", if the resu!ts of some of these activities are store" in a fi!e then that

fi!e can e use" y other activities. 'n" performing a!!ocation, re!ocation,

!inking an" !oa"ing can e avoi"e" each time. The i"ea is to separate out these

activities in separate groups. Thus "ivi"ing the essentia! four functions in

groups re"uces the overa!! time comp!e$ity of !oa"ing process. The program

which performs a!!ocation, re!ocation an" !inking is ca!!e" in"er. The in"er

 performs re!ocation, creates !inke" e$ecuta!e te$t an" stores this te$t in a fi!e

in some systematic manner. Such kin" of mo"u!e prepare" y the in"er

35

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 36/69

e$ecution is ca!!e" !oa" mo"u!e. This !oa" mo"u!e can then e actua!!y !oa"e"

in the main memory y the !oa"er. This !oa"er is a!so ca!!e" as mo"u!e !oa"er.

f the in"er can pro"uce the e$act rep!ica of e$ecuta!e co"e in the !oa"

mo"u!e then the mo"u!e !oa"er simp!y !oa"s this fi!e into the main

memory which u!timate!y re"uces the overa!! time comp!e$ity. -ut in this

 process the in"er shou!" knew the current positions of the main memory.#ven though the in"er knew the main memory !ocations this is not the

on!y thing which is sufficient. n mu!tiprogramming environment, the

region of main memory avai!a!e for !oa"ing the program is "eci"e" y

the host operating system.

 The in"er shou!" a!so know which memory area is a!!ocate" to the !oa"ing

 program an" it shou!" mo"ify the re!ocation information accor"ing!y. The

 in"er which performs the !inking function an" pro"uces a"e6uate

information aout a!!ocation an" re!ocation an" writes this information a!ong

with the program co"e in the fi!e is ca!!e" !inkage e"itor. The mo"u!e !oa"er

then accepts this ri!e as input, rea"s the information store" in an" ase" on

this information aout a!!ocation an" re!ocation it performs the task of !oa"ing

in the main memory. #ven though the program is repeate"!y e$ecute" the

!inking is "one on!y once. Moreover, the f!e$ii!ity of a!!ocation an"

re!ocation he!ps efficient uti!iation of the main memory.

8! E1a$% $% 7"ta$, t+" #"atr"' )# (a+$%" $%7"1"%7"%t )a7"r. (1A)

The features of machine in"epen"ent !oa"ers are%

i. 'utomatic irary Search

i. Many !inking !oa"ers can automatica!!y incorporate routines from a

suprogram !irary into the program eing !oa"e"

ii. ' stan"ar" !irary &ther !iraries may e specifie" y contro! statements or

 y parameters to the !oa"er. '!so ca!!e" automatic library call in some

systems

iii. inking !oa"ers that support automatic !irary search must keep track of

e$terna! symo!s that are referre" to , ut not "efine", in the primary input

to the !oa"er 

iv. 't the en" of Fass 1, the symo!s in #ST'- that remain un"efine"

represente" unresolved e$terna! references

36

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 37/69

v. Then, the !oa"er searches the !irary or !iraries specifie" for routines that

contain the "efinitions of these symo!s.

vi. Note that the suroutines fetche" from a !irary in this way may themse!ves

contain e$terna! references.

vii. t is therefore necessary to repeat the !irary search process unti! a!!

reference are reso!ve".ii. oa"er &ptions

i. Many !oa"ers a!!ow the user to specify options that mo"ify the stan"ar"

 processing

ii. Many !oa"ers have a specia! comman" !anguage

iii. ' separate input fi!e to !oa"er eme""e" in the primary input stream

iv. n source program

v. #$amp!es of comman" !anguage

  a. N3J# program4name(!irary4name)

irect the !oa"er to rea" the "esignate" oect program from a

!irary an" treat it as if it were part of the primary !oa"er input

 . ##T# cs"ect4name

nstruct the !oa"er to "e!ete the name" contro! section(s) from the

set of programs eing !oa"e"

c. 3D'NP# name1, name2

3ause the e$terna! symo! name1 to e change" to name2 wherever it

appears in the oect programs

INCLUDE READ9UTLI5

INCLUDE WRITE9UTLI5

DELETE RDREC, WRREC

CHANGE RDREC, READ

CHANGE WRREC, WRITE

vi. #$amp!es of comman" !anguage

a. -7'7L ML-

.'utomatic inc!usion of !irary routines to satisfy e$terna!

  7eferences Searche" efore the stan"ar" !iraries

 . N&3' ST#, F&T, 3&77#

  #$terna! references are to remain

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

37

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 38/69

DEPARTMENT OF INFORMATION TECHNOLOGY

CS2304 SYSTEM SOFTWARE

UNIT -IJ

Part – A

! D$##"r"%t$at" (ar) #r)( '/r)t$%"!   (M – 12)Macro Suroutine

1.  Macros can on!y e use" in the

 program the are "efine" in an" on!y after

the "efinition are e$pan"e" at

compi!ation 9 generation.

2. ' M'37& is more or !ess an

areviation for some !ines of co"e that

are use" more than once or twice.

1. Suroutines (0&7M) can e ca!!e"

from oth the program the are "efine" in

an" other programs

2. ' 0&7M is a !oca! suroutine (which

can e ca!!e" e$terna!). ' 0JN3T&N is

(more or !ess) a suroutine that is ca!!e"

e$terna!.

2! H)* ar" t+" %"'t"7 (ar) a' ar" ""t"7<  (M – 12, – 1B)

The e$ecution of neste" macro ca!! fo!!ows the 0& ru!e. n case of neste" macro

ca!!s the e$pansion of the !atest macro ca!! is comp!ete" first fo!!owe" y the previous

"ec!are" macro.

3! Wr$t" a%& t*) /a'$ (ar)1r)"'')r #%t$)%'! (N – 11)

The two asic macro processor functions are

1. Macro efinition – efining Macros with M'37& an" M#N.

2. Macro nvocation an" e$pansion – 3a!!ing an" e$pan"ing the macros

with proper "efinition

4! W+at $' a (ar)<

' macro represents a common!y use" group of statements in the source

 programming !anguage.

#$pan"ing a macros inc!u"es rep!acing each macro instruction with the

correspon"ing group of source !anguage statements8! H)* 7)"' t+" (ar) 1r)"'')r +"1 t+" 1r)ra(("r<

Macro processor is system software that rep!aces each macroinstruction with the

correspon"ing group of source !anguage statements. This is a!so ca!!e" as e$pan"ing of

macros. Macro processor is use" for the e$pansion of macro. -y using macro processor we

can easi!y re"uce memory space an" time y non4reputation of co"e.

:! Wr$t" t+" #%t$)%' )# MASM (ar)1r)"'')r!  (N – 11)

38

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 39/69

The two asic macro processor functions are

1. Macro efinition – efining Macros with M'37& an" M#N.

2. Macro nvocation an" e$pansion – 3a!!ing an" e$pan"ing the macros

with proper "efinition

  The on!y "ifference etween M'SM macro processor an" norma! macro processor !ies

in the nature of the con"itiona! macro e$pansion. M'SM ca!!s these as con"itiona!assem!y statements.

;! L$'t )t t+" 7ata 'trtr"' '"7 /& (ar) 1r)"'')r. (M – 11, M – 1/)

The various "ata structures use" in macro processor are %

(i) DEFTA – the macro "efinitions are store" in a "efinition ta!e i.e., it contains a macro

 prototypean" the statements that make up the macro o"y.

(ii) NAMTA – it is use" to store the macro names an" it contains two pointers for each

macroinstruction which in"icate the starting an" en" !ocation of macro "efinition in

#0T'-. t a!so serves asan in"e$ to #0T'-

(iii)  ARGTA  – it is use" to store the arguments "uring the e$pansion of macro

invocations

=! W+at $' a (ar)-t$(" .ar$a/"<   (M – 11)

Macro time varia!e can e use" to store working va!ues "uring the macro

e$pansion. 'ny symo! that egins with the character H an" then is not a macro instruction

 parameter is assume" to e a macro time varia!e.

>! W+at ar" t+" ta'' $%.)."7 $% (ar) "1a%'$)%. ( – 1B)The various tasks invo!ve" in macro e$pansion are%

(i) i"entify the macro ca!!s in the program

(ii) the va!ues of forma! parameters are i"entifie"

(iii) maintain the va!ues of e$pansion time varia!es "ec!are" in a macro

(iv) e$pansion time contro! f!ow is organie"

(v) "etermining the va!ues of se6uencing symo!s

(vi) e$pansion of a mo"e! statement is performe"

0! W+at $' t+" 1r1)'" )# t+" ARGTA<

'7PT'- ('rgument Ta!e)

i. Stores the arguments accor"ing to their positions in the argument !ist.

39

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 40/69

ii. 's the macro is e$pan"e" the arguments from the 'rgument ta!e are

sustitute" for the correspon"ing parameters in the macro o"y

  '7PT'-

01

-J00#7 

#NPTD

! W+at $' t+" a7.a%ta" )# "&*)r7 (ar) 1ara("t"r'<  (M – 1/)

'"vantages of [eywor" macro parameters

i. #ach argument va!ue is written with a keywor" that names the correspon"ing

 parameter.

ii. 'rguments may appear in any or"er.

P#N#7 ,, 7#3T, , , , , , /

P#N#7 TLF#+7#3T, 3D'NN#+/

P#N#7 3D'NN#+/, TLF#+7#3T

 parameter+argument

2! W+at $' ("a%t /& )%7$t$)%a (ar) "1a%'$)%<

f the macro is e$pan"e" "epen"s upon some con"itions in macro "efinition

("epen"ing on the arguments supp!ie" in the macro e$pansion), then it is ca!!e" as

con"itiona! macro e$pansion.

The statements use" for con"itiona! macro e$pansion are%

  (i) 0–#S#–#N0 statement

  (ii) 8D#–#N8 statement

3! W+at ar" t+" at$.$t$"' )# t+" (ar) 1r)"''$%<

The activities of macro processing are %

i) Macro "efinition – "efining the macro statements with M'37&

an" M#N

ii) Macro nvocation an" e$pansion – invocation of macro an"

rep!acing with appropriate macro statements.

4! W+at $' t+" )$ /"+$%7 t+" t*) - 1a'' (ar) 1r)"'')r<

The !ogic ehin" a two4pass macro processor is%

i. Fass 1%

'!! macro "efinitions are processe"

40

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 41/69

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 42/69

ii. Peneration of Jni6ue ae!s

iii. 3on"itiona! Macro #$pansion

iv. [eywor" Macro Farameters

  3oncatenation of Macro Farameters%

Most macro processors a!!ow parameters to e concatenate" with other character

stringsi. The nee" of a specia! catenation operator 

a. ' 5H1

 . ' 5H

ii. The catenation operator 

a. ' 5H→1

  Peneration of Jni6ue ae!s%

t is in genera! not possi!e for the o"y of a macro instruction to contain !ae!s of

the usua! kin"

i. ea"ing to the use of re!ative a""ressing at the source statement !eve!

a. &n!y e accepta!e for short umps

ii. '!!owing the creation of specia! types of !ae!s within macro instructions

3on"itiona! Macro #$pansion%

Most macro processors can mo"ify the se6uence of statements generate" for a

macro e$pansion, "epen"ing on the arguments supp!ie" in the macro invocation.

Most macro processors can mo"ify the se6uence of statements generate" for a

macro e$pansion, "epen"ing on the arguments supp!ie" in the macro invocation

There are app!ications of macro processors that are not re!ate" to assem!ers or

assem!er programming.

3on"itiona! assem!y "epen"s on parameters provi"es

M'37& H3&N

UU..

0 (H3&N N# O=) part

#S#

 part

#N0

UUU

42

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 43/69

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 44/69

Macro processor "irective

i. 0, #S#, #N0

ii. S#T

Macro4time varia!e (set symo!)

8D#4#N8

See 0igure

/5MASM (ar) 1r)"'')r

i. The macro processor of M'SM is integrate" with Fass 1 of the assem!er 

ii. M'SM generates the uni6ue names of !oca! !ae!s in the form ^^n, where n

is a he$a"ecima! numer in the range BBBB to 0000

iii. .#77% signa!s to M'SM that an error has een "etecte"

iv. #5TM% "irects M'SM to terminate the e$pansion of the macro

v. H% is a concatenation operator 

44

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 45/69

vi. QQ is a macro comment, serves on!y as "ocumentation for the macro

"efinition

vii. Q is an or"inary assem!er !anguage comment, inc!u"e" as part of the macro

e$pansion

viii. 7F% sets the macro4time varia!e to a se6uence of va!ues specifie" in *UY

i$. The statements etween the T7F an" the matching #NM are generate"once for each va!ue of the varia!e

$. #$amp!es of M'SM Macro an" 3on"itiona! Statements%

95 ANSI C (ar) a%a"

i. n the 'NS 3 !anguage, "efinitions an" invocations of macros are han"!e"

 y a preprocessor, which is genera!!y not integrate" with the rest of the

compi!er 

ii. "efine '-S00(5,L) 5YL ̂ 54L % L45

iii. "efine SF'L(#5F7) printf(#5F7:+_"Rn:,#5F7)

iv. Macro in 'NS 3 may contain "efinitions or invocations of other macros

v. SF'L('-S00(/,>))à'-S00(/,>)+?

45

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 46/69

vi. The 'NS 3 preprocessor a!so provi"es con"itiona! compi!ation

statements

ifn"ef -J00#7`S#

"efine -J00#7`S# 1B2<

en"if

vii. Jse of Macros instea" of functions%

Macro is more efficient than functions as the amount of computation

re6uire"

s !ess than the overhea" of ca!!ing a function.

viii. #$amp!e%

"efine '-S00 (5,L) ((5) Y (L) ^ (5) – (L) % (L) – (5))

an" the macro invocation statement

  '-S00 (E1, 4?)

wou!" resu!t in macro e$pansion statement

  ((E1) Y ( – ?) ^ (E1) – ( – ?) % ( – ?) – ( E 1))

  n this macro "efinition, the macro processor simp!y makes string

sustitutions,

without consi"ering the synta$ of the 3 !anguage.

 

's a resu!t, the macro nvocation statement

'-S00 (< E 1, > – A) wou!" resu!t in

  < E 1 Y > – A ^ < E 1– > – A % > – A – < E 1

which gives a une$pecte" resu!t.

3! E1a$% $% 7"ta$, t+" (ar) 1r)"'')r a)r$t+( a%7 7ata 'trtr"'!  (1A)( – 1B)

&ne4Fass Macro Frocessor%

' one4pass macro processor that a!ternate etween macro definition an" macro

e$pansion in a recursive way is a!e to han"!e recursive macro "efinition.7estriction

i. The "efinition of a macro must appear in the source program efore any statements

that invoke that macro.

ii. This restriction "oes not create any rea! inconvenience.

46

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 47/69

The "esign consi"ere" is for one4pass assem!er. The "ata structures re6uire" are%

1. #0T'- (efinition Ta!e)

i. Stores the macro "efinition inc!u"ing macro prototype an" macro body

ii. 3omment !ines are omitte".

iii. 7eferences to the macro instruction parameters are converte" to a

 positiona! notation for efficiency in sustituting arguments.

2. N'MT'- (Name Ta!e)

i. Stores macro names

ii. Serves as an in"e$ to #0T'-

iii. Fointers to the eginning an" the en" of the macro "efinition (#0T'-)

/. '7PT'- ('rgument Ta!e)

i. Stores the arguments accor"ing to their positions in the argument !ist.

ii. 's the macro is e$pan"e" the arguments from the 'rgument ta!e are

sustitute" for the correspon"ing parameters in the macro o"y.

The figure e!ow shows the "ifferent "ata structures "escrie" an" their re!ationship.

47

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 48/69

4! E1a$% $% 7"ta$, t+" #))*$% (a+$%" $%7"1"%7"%t (ar) #"atr"'. (1A)( – 1B)9a5 C)%at"%at$)% )# (ar) 1ara("t"r'   (?)

Most macro processors a!!ow parameters to

 e concatenate" with other character strings

 – The nee" of a specia! catenation operator 

W ' 5H1

W ' 5H

 – The catenation operator 

W ' 5H4Y1

H is the starting character of the macro instructionQ ut the en" of the parameter

is not marke". So in the case of H1, the macro processor cou!" "e"uce themeaning that was inten"e". f the macro "efinition contains contain H an"

H1 as parameters, the situation wou!" e unavoi"a!y amiguous.

Most of the macro processors "ea! with this pro!em y provi"ing a

specia! concatenation operator. n the S3 macro !anguage, this operator is the

character

48

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 49/69

Thus the statement ' 5H1 can e written as

  ' 5H

 

9/5 G"%"rat$)% )# %$B" a/"'   (?)

's "iscusse" it is not possi!e to use !ae!s for the instructions in the

macro "efinition, since every e$pansion of macro wou!" inc!u"e the !ae!

repeate"!y which is not a!!owe" y the assem!er. This in turn forces us to use

re!ative a""ressing in the ump instructions. nstea" we can use the techni6ue of

generating uni6ue !ae!s for every macro invocation an" e$pansion. uring

macro e$pansion each wi!! e rep!ace" with 55, where $$ is a two4character

a!phanumeric counter of the numer of macro

instructions e$pansion.

49

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 50/69

0or e$amp!e,

55 + '', '-, '3U

This a!!ows 12KA macro e$pansions in a sing!e program.

The fo!!owing program shows the macro "efinition with !ae!s to the instruction.

50

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 51/69

The fo!!owing figure shows the macro invocation an" e$pansion first time.

f the macro is invoke" secon" time the !ae!s may e e$pan"e" as'-&&F '-#5T.

95 C)%7$t$)%a (ar) "1a%'$)%   (A)

There are app!ications of macro processors that are not re!ate" toassem!ers or assem!er programming.

3on"itiona! assem!y "epen"s on parameters provi"esM'37& H3&N

UU..0 (H3&N N# O=)

 part #S#

 part #N0

UUUU#NM

Fart is e$pan"e" if con"ition part is true, otherwise part is e$pan"e". 3ompare operators% N#, #, #, PT.

Macro4Time aria!es%Macro4time varia!es (often ca!!e" as S#T Symo!) can

51

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 52/69

 e use" to store working va!ues "uring the macro e$pansion.'ny symo! that egins with symo! H an" not a macroinstruction parameter is consi"ere" as macro4time varia!e. '!!such varia!es are initia!ie" to ero.

8! E1a$% $% 7"ta$, t+" (ar) 1r)"'')r 7"'$% )1t$)%'!   (1A)

7ecursive Macro Frocessor%

52

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 53/69

53

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 54/69

Penera! Furpose Macro Frocessor%

Macro Frocessing 8ithin anguage Trans!ators

54

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 55/69

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 56/69

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

DEPARTMENT OF INFORMATION TECHNOLOGY

CS2304 SYSTEM SOFTWARE

UNIT -J

Part – A

! W+at ar" t+" t&1"' )# )(1t$% "%.$r)%("%t' '"7 $% "7$t)r #%t$)%'<

#"itor functions in three types of computing environments. They are

  (i) Time sharing

  (ii) Stan"4a!one

  (iii) istriute"

2! I7"%t$#& t+" '" )# )((a%7 a%a" 1r)"'')r!   (M – 12)

The uses of comman" !anguage processor are%

i. The comman" !anguage processor invokes the routines "irect!y which

 performs the functions !ike e"iting an" viewing.

ii. t pro"uces an interme"iate representation, which a!!ows the e"itor to provi"e

a variety of user4interaction !anguages with a sing!e set of semantic routines

that are "riven from a common interme"iate representation.

3! D"#$%" –T"t E7$t)r   (N – 11)

Te$t e"itor is a software that can compose a string, or mo"ify an e$isting one. Two

common types of e"itors%

i. ine e"itors% !ines of te$t are numere" automatica!!y, an" mo"ifie" y

giving the numer of the !ine as part of the e"iting comman"

ii. Screen e"itors% te$t is "isp!aye" on the screen, an" the cursor can e move"

to where the changes are going to e ma"e.

4! W+at $' ("a%t /& 7"/"r<   (N – 11)

' "eugger is a computer program that is use" to test an" "eug other programs.

8hen the program crashes, the "eugger shows the position in the origina! co"e if itis a source4!eve! "eugger or symo!ic "eugger, common!y seen in integrate"

"eve!opment environments(#s)

i. Typica!!y, "euggers a!so offer more sophisticate" functions such as running a

 program in the fo!!owing manner

ii. Step y step (sing!e4stepping)

56

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 57/69

iii. Stopping (reaking) (pausing the program to e$amine the current state) at some

kin" of event y means of reakpoint, an" tracking the va!ues of some varia!es.

iv. Some "euggers have the ai!ity to mo"ify the state of the program whi!e it is

running, rather than mere!y to oserve it.

8! W+at $' a% $%t"rat$." "7$t)r<

'n interactive e"itor is a computer program that a!!ows a user to create an" revise atarget "ocument. The term "ocument inc!u"es oects such as computer programs, te$t,

e6uations, ta!es, "iagrams, !ine art, an" photographs anything that one might fin" on a

 printe" page.

:! W+at ar" t+" 1+a'"' $% 1"r#)r($% "7$t$% 1r)"''<

  The various phases of the e"iting process are%

(i) Trave!ing phase

(ii) 0i!tering phase

(iii) 0ormatting phase

(iv) #"iting phase

Trave!ing phase specifies the region of interest. Trave!ing is achieve" using

operations such as ne$t screen, ottom, fin" pattern.0i!tering phase is use" for se!ection

of what is to e viewe" an" manipu!ate" in given y fi!tering.n the e"iting phase, the

target "ocument is a!tere" with the set of operations such as insert, "e!ete, rep!ace, move

an" copy.

;! Wr$t" t+" )(1)%"%t' )# "7$t)r 'trtr"!

The four components of e"itor structure are%

(i) #"iting component

(ii) Trave!ing component

(iii) iewing component

(iv) isp!ay component

=! W+at ar" t+" ta'' $%.)."7 $% 7)("%t "7$t$% 1r)"''<  (M – 1/)

The various tasks performe" in the e"iting process are %

(i) Se!ect the part of the target "ocument to e viewe" an" manipu!ate"

(ii) etermine how to format this view on4!ine an" how to "isp!ay it

(iii) Specify an" e$ecute operations that mo"ify the target "ocument

(iv)Jp"ate the view appropriate!y

57

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 58/69

>! W+at $' t+" #%t$)% )# a )((a%7 a%a" 1r)"'')r<   (M – 11)

The function of a comman" !anguage processor is%

t accepts the input from the user=s input "evices, an" ana!yes the tokens

an" syntactic structure of the comman"s. t pro"uces an interme"iate representation of

the e"iting operations, which a!!ows the e"itor to provi"e a variety of user4interaction

!anguages with a sing!e set of semantic routines that are "riven from a commoninterme"iate representation.

0! D"#$%" – Tra$%   (M – 11, M – 1/)

Tracing is use" to track the f!ow of e$ecution an" "ata mo"ifications. The contro!

f!ow can e trace" at "ifferent !eve!s of "etai! – proce"ure, ranch, in"ivi"ua! instruction,

an" so on. Trace ack can show the path y which the current statement in the program was

reache" t can a!so show which statements have mo"ifie" a given varia!e or parameter

The statements are "isp!aye" rather than as he$a"ecima! "isp!acements

! W+at $' a% "rr)r +a%7"r<  ( – 1B)

The error han"!er is use" to check if there is an error in the program. f any error, it

shou!" warn the programmer y instructions to procee" from phase to phase.

2! W+at ar" t+" t*) #%7a("%ta t&1"' )# "7$t)r'<

#"itor is software that can compose a string, or mo"ify an e$isting one. Two

common types of e"itors%

iii. ine e"itors% !ines of te$t are numere" automatica!!y, an" mo"ifie" y

giving the numer of the !ine as part of the e"iting comman"

iv. Screen e"itors% te$t is "isp!aye" on the screen, an" the cursor can e move"

to where the changes are going to e ma"e

3! D"#$%" – I%t"rat$." D"/$% S&'t"('

'n interactive "eugging system provi"es programmers with faci!ities that ai" in the

testing an" "eugging of programs.

(i) eugging functions an" capai!ities

(ii) 7e!ationship with other parts of the system

(iii) Jser interface criteria.

4! M"%t$)% t+" #"atr"' )# *)r7 1r)"'')r'!   ( – 1B)

The various features of wor" processors%

(i) moving te$t from one p!ace to another 

(ii) merging of te$t

58

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 59/69

(iii) searching

(iv) wor" rep!acement

8! Na(" ')(" )# t+" t"t "7$t)r'!

The various types of te$t e"itors are%

(i) !ine e"itors

(ii) stream e"itors(iii) screen e"itors

(iv) wor" processors

(v) structure e"itors

Part –

! E1a$% $% 7"ta$, t+" "7$t)r 'trtr" *$t+ %"at 7$ara(. (1A)(N – 11)

 Te$t #"itors%

 #"itor  is a software that can compose a string, or mo"ify an e$isting one.

Two common types of e"itors%

i. ine e"itors% !ines of te$t are numere" automatica!!y, an" mo"ifie"

 y giving the numer of the !ine as part of the e"iting comman"

ii. Screen e"itors% te$t is "isp!aye" on the screen, an" the cursor can e

move" to where the changes are going to e ma"e.

The typica! structure of e"itor is shown e!ow%

59

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 60/69

The fo!!owing are the components of e"itor%

60

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 61/69

2! E1a$% $% 7"ta$, $%t"rat$." 7"/$% '&'t"('!   1A)(N – 11)

'n interactive "eugging system provi"es programmers with faci!ities that ai" in

testing an" "eugging of programs interactive!y Many such systems are avai!a!e "uringthese "ays &ur "iscussion is roa" in scope, giving the overview of interactive "eugging

systems – not specific to any particu!ar e$isting system.

eugging 0unctions an" 3apai!ities

&ne important re6uirement of any S is the oservation an" contro! of the f!ow of

 program e$ecution Setting reak points – e$ecution is suspen"e", use "eugging

comman"s to ana!ye the progress of the program, rbsumb e$ecution of the program

Setting some con"itiona! e$pressions, eva!uate" "uring the "eugging session, program

e$ecution is suspen"e", when con"itions are met, ana!ysis is ma"e, !ater e$ecution is

resume"

eugging system

 ' eugging system shou!" a!so provi"e functions such as tracing an" traceack

Tracing can e use" to track the f!ow of e$ecution !ogic an" "ata mo"ifications.

The contro! f!ow can e trace" at "ifferent !eve!s of "etai! – proce"ure, ranch,

in"ivi"ua! instruction, an" so on.

Traceack

Traceack can show the path y which the current statement in the program was

reache" t can a!so show which statements have mo"ifie" a given varia!e or parameter

The statements are "isp!aye" rather than as he$a"ecima! "isp!acements

Frogram4isp!ay capai!ities 

' "eugger shou!" have goo" program4"isp!ay capai!ities Frogram eing

"eugge" shou!" e "isp!aye" comp!ete!y with statement numers The program may e

"isp!aye" as origina!!y written or 8ith macro e$pansion [eeping track of any changes

ma"e to the programs "uring the "eugging session Support for symo!ica!!y "isp!aying or

mo"ifying the contents of any of the varia!es an" constants in the program 7esume

e$ecution – after these changes

Dow functions are provi"e" 

61

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 62/69

To provi"e these functions, a "eugger shou!" consi"er the !anguage in which the

 program eing "eugge" is written ' sing!e "eugger – many programming !anguages –

!anguage in"epen"ent The "eugger 4 a specific programming !anguage – !anguage

"epen"ent The "eugger must e sensitive to the specific !anguage eing "eugge" The

conte$t eing use" has many "ifferent effects on the "eugging interaction The statements

are "ifferent "epen"ing on the !anguage 3oo! 4 M&# A.? T& 5

0ortran 4 5 + A.?

 3 4 5 + A.?

#$amp!es of assignment statements

The con"ition that 5 e une6ua! to may e e$presse" as

 3oo! 4 0 5 N&T #J' T&

0ortran 4 0 ( 5.N#.)

3 4 0 ( 5 *Y )

The notation use" to specify certain "eugging functions varies accor"ing to the

!anguage of the program eing "eugge" Sometimes the !anguage trans!ator itse!f has

"eugger interface mo"u!es that can respon" to the re6uest for "eugging y the user The

source co"e may e "isp!aye" y the "eugger in the stan"ar" form or as specifie" y the

user or trans!ator 

3! Wr$t" '+)rt %)t"' )% t+" #))*$% (1A)( – 1B)

$! I%t"rat$." 7"/$% '&'t"('   (B>)

$$! T"t "7$t)r'   (B>)

 

nteractive "eugging systems%

'n interactive "eugging system provi"es programmers with faci!ities that ai" in

testing an" "eugging of programs interactive!y Many such systems are avai!a!e "uring

these "ays &ur "iscussion is roa" in scope, giving the overview of interactive "eugging

systems – not specific to any particu!ar e$isting system.

eugging 0unctions an" 3apai!ities

&ne important re6uirement of any S is the oservation an" contro! of the f!ow of

 program e$ecution Setting reak points – e$ecution is suspen"e", use "eugging

comman"s to ana!ye the progress of the program, rbsumb e$ecution of the program

Setting some con"itiona! e$pressions, eva!uate" "uring the "eugging session, program

62

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 63/69

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 64/69

The notation use" to specify certain "eugging functions varies accor"ing to the

!anguage of the program eing "eugge" Sometimes the !anguage trans!ator itse!f has

"eugger interface mo"u!es that can respon" to the re6uest for "eugging y the user The

source co"e may e "isp!aye" y the "eugger in the stan"ar" form or as specifie" y the

user or trans!ator 

ii.Te$t e"itors%#"itor   is a software that can compose a string, or mo"ify an e$isting

one.Two common types of e"itors%

i. ine e"itors% !ines of te$t are numere" automatica!!y, an" mo"ifie" y giving

the numer of the !ine as part of the e"iting comman"

ii. Screen e"itors% te$t is "isp!aye" on the screen, an" the cursor can e move" to

where the changes are going to e ma"e.

3omman" !anguage%

i. te$t comman"s

ii. function keys

iii. menus

1.1. #$amp!e ine #"itor %

-asic comman"s%

 4 #"it # *fi!enameY

4 isp!ay *!ine noY or *!ine no 1Y 4 *!ine no2Y (eg. L 00 or L 00-30)

4 nsert *!ine noY (eg. I 20 inserts !ines after !ine 2B)

4 e!ete *!ine noY or *!ine no 1Y 4 *!ine no 2Y (eg. D 00 or D 00-28)

4 Save S

3omman" Frocessing %

1. f fi!e sie is sma!!er than memory uffer %

4 The entire fi!e can e kept in memory.

4 ine is compose" into !ine uffer, which wi!! e han"!e" y the uffer

manager. t puts the !ine into memory uffer.4 ou!y !inke" !ists are use"

The "isa"vantage of this metho" is, it !eaves unuse" space in the memory

"ue to the "e!etions. To avoi" this, if a !ock of !ines is "e!ete", the e"itor may keep

track of these spaces an" reuse them if necessary. This metho" is ca!!e" ar/a"

)"t$)%.

64

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 65/69

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 66/69

 Some e$amp!e

#c!ipse PNJ

eugger '' F!atform eugger

-M 7ationa! Furify

TJ7-& eugger

isua! Stu"io eugger 8! E1a$% t+" .ar$)' ')#t*ar" t))'!   (1A)

The software too!s are

$! nteractive "eugging system

$$!Te$t e"itor 

 $! I%t"rat$." 7"/$% '&'t"('

'n interactive "eugging system provi"es programmers with faci!ities that ai" in

testing an" "eugging of programs interactive!y Many such systems are avai!a!e "uring

these "ays &ur "iscussion is roa" in scope, giving the overview of interactive "eugging

systems – not specific to any particu!ar e$isting system.

eugging 0unctions an" 3apai!ities

&ne important re6uirement of any S is the oservation an" contro! of the f!ow of

 program e$ecution Setting reak points – e$ecution is suspen"e", use "eugging

comman"s to ana!ye the progress of the program, rbsumb e$ecution of the program Setting

some con"itiona! e$pressions, eva!uate" "uring the "eugging session, program e$ecution

is suspen"e", when con"itions are met, ana!ysis is ma"e, !ater e$ecution is resume"

eugging system

  ' eugging system shou!" a!so provi"e functions such as tracing an" traceack

Tracing can e use" to track the f!ow of e$ecution !ogic an" "ata mo"ifications.

The contro! f!ow can e trace" at "ifferent !eve!s of "etai! – proce"ure, ranch,

in"ivi"ua! instruction, an" so on.

Traceack

Traceack can show the path y which the current statement in the program was

reache" t can a!so show which statements have mo"ifie" a given varia!e or parameter

The statements are "isp!aye" rather than as he$a"ecima! "isp!acements

Frogram4isp!ay capai!ities 

' "eugger shou!" have goo" program4"isp!ay capai!ities Frogram eing "eugge"

shou!" e "isp!aye" comp!ete!y with statement numers The program may e "isp!aye" as

66

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 67/69

origina!!y written or 8ith macro e$pansion [eeping track of any changes ma"e to the

 programs "uring the "eugging session Support for symo!ica!!y "isp!aying or mo"ifying

the contents of any of the varia!es an" constants in the program 7esume e$ecution – after

these changes

Dow functions are provi"e" 

To provi"e these functions, a "eugger shou!" consi"er the !anguage in which the program eing "eugge" is written ' sing!e "eugger – many programming !anguages –

!anguage in"epen"ent The "eugger 4 a specific programming !anguage – !anguage

"epen"ent The "eugger must e sensitive to the specific !anguage eing "eugge" The

conte$t eing use" has many "ifferent effects on the "eugging interaction The statements

are "ifferent "epen"ing on the !anguage

 3oo! 4 M&# A.? T& 5

0ortran 4 5 + A.?

 3 4 5 + A.?

#$amp!es of assignment statements

The con"ition that 5 e une6ua! to may e e$presse" as

 3oo! 4 0 5 N&T #J' T&

0ortran 4 0 ( 5.N#.)

3 4 0 ( 5 *Y )

The notation use" to specify certain "eugging functions varies accor"ing to the

!anguage of the program eing "eugge" Sometimes the !anguage trans!ator itse!f has

"eugger interface mo"u!es that can respon" to the re6uest for "eugging y the user The

source co"e may e "isp!aye" y the "eugger in the stan"ar" form or as specifie" y the

user or trans!ator 

ii. T"t "7$t)r'   (B>)

#"itor   is a software that can compose a string, or mo"ify an e$isting one. Two

common types of e"itors%

a. ine e"itors% !ines of te$t are numere" automatica!!y, an" mo"ifie" y

giving the numer of the !ine as part of the e"iting comman"

 . Screen e"itors% te$t is "isp!aye" on the screen, an" the cursor can e move"

to where the changes are going to e ma"e.

3omman" !anguage%

i. te$t comman"s

67

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 68/69

ii. function keys

iii. menus

1.1. #$amp!e ine #"itor %

-asic comman"s%

 4 #"it # *fi!enameY

4 isp!ay *!ine noY or *!ine no 1Y 4 *!ine no2Y (eg. L 00 or L 00-30)4 nsert *!ine noY (eg. I 20 inserts !ines after !ine 2B)

4 e!ete *!ine noY or *!ine no 1Y 4 *!ine no 2Y (eg. D 00 or D 00-28) 4 Save S

3omman" Frocessing %

1. f fi!e sie is sma!!er than memory uffer %

4 The entire fi!e can e kept in memory.

4 ine is compose" into !ine uffer, which wi!! e han"!e" y the uffer

manager. t puts the !ine into memory uffer.

4 ou!y !inke" !ists are use"

The "isa"vantage of this metho" is, it !eaves unuse" space in the memory "ue to the

"e!etions. To avoi" this, if a !ock of !ines is "e!ete", the e"itor may keep track of these

spaces an" reuse them if necessary. This metho" is ca!!e" ar/a" )"t$)%.

8riting the te$t onto a fi!e%

Te$t is taken from memory character y character in the or"er "efine" y the forwar"

!inks, accumu!ate" in a fi$e" !ength recor" an" written to "isk. ines are separate" y a

carriage return an" an #&0 marker appears at the en" of the te$t.

 oa"ing a fi!e in memory%

The recor"s of the fi!e are rea" into a uffer. The e"itor "etects carriage returns, p!aces the

!ines in memory an" fi!!s in the !ink fie!"s. This process removes a!! unuse" spaces "ue to

"e!etions.

 2. f fi!e sie is !arger than memory uffer

4 Farts of the fi!e are move" into the memory to work on. 7est of the fi!e is kept on "isk.

4 f the re6uire" !ine is a!rea"y in memory, no e$tra processing is necessary. 4 f the

re6uire" !ine is on "isk,

4 write the segments in the memory uffer onto "isk

68

8/12/2019 CS2304-System Software With Answers (2)

http://slidepdf.com/reader/full/cs2304-system-software-with-answers-2 69/69

4 rea" a !ock of segments which inc!u"e the re6uire" !ine, from "isk an" p!ace them in the

memory. t is etter to choose the !ock of segments in a way that the !ine to e accesse"

wi!! e in the mi""!e of them.