Cs2308 SS Lab Manual

download Cs2308 SS Lab Manual

of 69

Transcript of Cs2308 SS Lab Manual

  • 8/11/2019 Cs2308 SS Lab Manual

    1/69

    CS2308 SYSTEM SOFTWARE LAB

    Prepared By,

    R.Uma,

    Lecturer, CSE

  • 8/11/2019 Cs2308 SS Lab Manual

    2/69

    CS2308 SYSTEM SOFTWARE LAB L T PC

    0 0 3 2(Using C)1. Implement a symbol table with functions to create, insert, modify, search, and display.

    2. Implement pass one of a two pass assembler.3. Implement pass two of a two pass assembler.4. Implement a single pass assembler.5. Implement a two pass macro processor6. Implement a single pass macro processor.7. Implement an absolute loader.. Implement a relocating loader.!. Implement pass one of a direct"lin#ing loader.1$. Implement pass two of a direct"lin#ing loader.11. Implement a simple te%t editor with features li#e insertion & deletion of a character, word, and sentence.12. Implement a symbol table with suitable hashing

    '(or loader e%ercises, output the snap shot of the main memory as it would be, after theloading has ta#en place)

    TOTAL=45 PERIODS

    R!"i#$n% &'# %*+ '& 30 s%",n%s

    Ds*#i-%i'n '& E!"i-$n% . /"n%i% R!"i#,

    1. *ardware + entium - es#tops " 3$ /os.

    2. 0oftware + urbo - '(reely download) " ultiuser

  • 8/11/2019 Cs2308 SS Lab Manual

    3/69

    LIST OF EXPERIMENTS

    S.NO TITLE PAGE NO

    1 I$-1$n% s$'1 %1 i%+&"n*%i'ns %' *#% ins#% $',i&s#*+ n, ,is-1

    I$-1$n% -ss 'n '& %' -ssss$1#

    ! I$-1$n% -ss %' '& %' -ssss$1#

    " I$-1$n% sing1 -ss ss$1#

    # I$-1$n% %' -ss $*#'-#'*ss'#

    $ I$-1$n% sing1 -ss $*#'-#'*ss'#

    % I$-1$n% n s'1"% 1',#

    & I$-1$n% #1'*%ing 1',#

    ' I$-1$n% -ss 'n '& ,i#*%.1ining 1',#

    1( I$-1$n% -ss %' '& ,i#*%.1ining 1',#

    11 I$-1$n% si$-1 %6% ,i%'# i%+&%"#s 1i ins#%i'n 7 ,1%i'n '& *+#*%# '#, n, sn%n*

    1 I$-1$n% s$'1 %1 i%+s"i%1 +s+ing

  • 8/11/2019 Cs2308 SS Lab Manual

    4/69

    EXPT NO 1

    Implement a symbol table wt! "#n$tons to $%eate& nse%t& mo'"y& sea%$!& an' 'splay(

    AIM )

    To write a C program to implement Symbol Table

    A*+r-tm )

    1. Start the program for performing insert, display, delete, search and modify option

    in symbol table

    2. Define the structure of the Symbol Table3. Enter the choice for performing the operations in the symbol Table

    . !f the entered choice is 1, search the symbol table for the symbol to be inserted. !f

    the symbol is already present, it displays "Duplicate Symbol#. Else, insert thesymbol and the corresponding address in the symbol table.

    $. !f the entered choice is 2, the symbols present in the symbol table are displayed.

    %. !f the entered choice is 3, the symbol to be deleted is searched in the symbol

    table. !f it is not found in the symbol table it displays "&abel 'ot found#. Else, thesymbol is deleted.

    (. !f the entered choice is $, the symbol to be modified is searched in the symbol

    table. The label or address or both can be modified.

    Surce Cde pr+ram -/ c -mp*eme/t 0ym* ta*e

    ) include *stdio.h+) include *conio.h+

    ) include *alloc.h+) include *string.h+

    ) define null

    int si-e/

    0oid insert/0oid del/

    int searchchar lab4/

    0oid modify/0oid display/

    struct symbtab

    5char label14/

    int addr/

    struct symtab 6ne7t/

    8/struct symbtab 6first,6last/

    0oid main

  • 8/11/2019 Cs2308 SS Lab Manual

    5/69

    5int op/

    int y/

    char la14/clrscr/

    do5printf9:nS;& T?=&E !

  • 8/11/2019 Cs2308 SS Lab Manual

    6/69

    case %breaG/

    8

    8whileop*%/

    getch/80oid insert

    5

    int n/

    char l14/printf9Enter the label 9/

    scanf9s9,l/

    nsearchl/ifn1

    5

    printf9The label already e7ists. Duplicate cant be inserted:n9/8

    else

    5

    struct symbtab 6p/pmallocsi-eofstruct symbtab/

    strcpypH+label,l/

    printf9Enter the address 9/scanf9d9,FpH+addr/

    pH+ne7tnull/

    ifsi-e

    5firstp/

    lastp/8

    else

    5

    lastH+ne7tp/lastp/

    8

    si-eII/8

    8

    0oid display5

    int i/

    struct symbtab 6p/

    pfirst/printf9&?=E&:t?DDAESS:n9/

    fori/i*si-e/iII

  • 8/11/2019 Cs2308 SS Lab Manual

    7/69

    5printf9s:td:n9,pH+label,pH+addr/

    ppH+ne7t/

    88

    int searchchar lab45int i,flag/

    struct symbtab 6p/

    pfirst/

    fori/i*si-e/iII5

    ifstrcmppH+label,lab

    5flag1/

    8

    ppH+ne7t/8

    return flag/

    8

    0oid modify5

    char l14,nl14/

    int add, choice, i, s/struct symbtab 6p/

    pfirst/

    printf9Jhat do you want to modifyK:n9/

    printf91. >nly the label:n9/printf92. >nly the address of a particular label:n9/

    printf93. =oth the label and address:n9/printf9Enter your choice 9/

    scanf9d9,Fchoice/

    switchchoice

    5case 1

    printf9Enter the old label:n9/

    scanf9s9,l/printf9Enter the new label:n9/

    scanf9s9,nl/

    ssearchl/ifs

    5

    printf9'> such label9/

    8else

    5

  • 8/11/2019 Cs2308 SS Lab Manual

    8/69

    fori/i*si-e/iII5

    ifstrcmppH+label,l

    5strcpypH+label,nl/

    8ppH+ne7t/8

    8

    breaG/

    case 2printf9Enter the label whose address is to modified:n9/

    scanf9s9,l/

    printf9Enter the new address:n9/scanf9d9,Fadd/

    ssearchl/

    ifs5

    printf9'> such label9/

    8

    else5

    fori/i*si-e/iII

    5ifstrcmppH+label,l

    5

    pH+addradd/

    8ppH+ne7t/

    88

    breaG/

    case 3

    printf9Enter the old label 9/scanf9s9,l/

    printf9Enter the new label 9/

    scanf9s9,nl/printf9Enter the new address 9/

    scanf9d9,Fadd/

    ssearchl/ifs

    5

    printf9'> such label9/

    8else

    5

  • 8/11/2019 Cs2308 SS Lab Manual

    9/69

    fori/i*si-e/iII5

    ifstrcmppH+label,l

    5strcpypH+label,nl/

    pH+addradd/8ppH+ne7t/

    8

    8

    breaG/8

    8

    0oid del5

    int a/

    char l14/struct symbtab 6p,6L/

    pfirst/

    printf9Enter the label to be deleted:n9/

    scanf9s9,l/asearchl/

    ifa

    5printf9&abel not found:n9/

    8

    else

    5ifstrcmpfirstH+label,l

    5firstfirstH+ne7t/

    8

    else ifstrcmplastH+label,l

    5LpH+ne7t/

    whilestrcmpLH+label,lM

    5ppH+ne7t/

    LLH+ne7t/

    8pH+ne7tnull/

    lastp/

    8

    else5

    LpH+ne7t/

  • 8/11/2019 Cs2308 SS Lab Manual

    10/69

    whilestrcmpLH+label,lM5

    ppH+ne7t/

    LLH+ne7t/8

    pH+ne7tLH+ne7t/8si-eHH/

    8

    8

    RESULT) Thus a symbol table is implemented in C .

  • 8/11/2019 Cs2308 SS Lab Manual

    11/69

    EXPT NO

    I$-1$n% -ss 'n '& %' -ss ss$1#

    AIM

    To implement pass one of a two pass assembler.

    ALGORIT2M

    1. >pen the files fp1 and fp in read mode and fp2 and fp3 in write mode

    2.Aead the source program3. !f the opcode read in the source program is ST?AT, the 0ariable location

    counter is initiali-ed with the operand 0alue.

    . Else the location counter is initiali-ed to .$. The source program is read line by line until the reach of opcode E'D.

    %. ChecG whether the opcode read is present in the operation code table.

    (. !f the opcode is present, then the location counter is incremented by 3.

    N. !f the opcode read is J>AD, the location counter is incremented by3.O. !f the opcode read is AESJ, the operand 0alue is multiplied by 3 and then the

    location

    counter is incremented.1. !f the opcode read is AES=, the location counter 0alue is incremented by

    operand 0alue.

    11. !f the opcode read is =;TE, the location counter is auto incremented.

    The length of the source program is found using the location counter 0alue.

    Surce Cde pr+ram -/ c pa00 /e 3 a t4 pa00 a00em*er.

    ) include *stdio.h+

    ) include *conio.h+

    ) include *string.h+0oid main

    5

    char opcode14,mnemonic34,operand14,label14,code14/int locctr,start,length/

    !&E 6fp1,6fp2,6fp3,6fp/

    clrscr/fp1fopen9input.dat9,9r9/

    fp2fopen9symtab.dat9,9w9/

    fp3fopen9out.dat9,9w9/

    fpfopen9optab.dat9,9r9/fscanffp1,9sss9,label,opcode,operand/

    ifstrcmpopcode,9ST?AT9

  • 8/11/2019 Cs2308 SS Lab Manual

    12/69

    5startatoioperand/

    locctrstart/

    fprintffp3,9:ts:ts:ts:n9,label,opcode,operand/fscanffp1,9sss9,label,opcode,operand/

    8elselocctr/

    whilestrcmpopcode,9E'D9M

    5

    fprintffp3,9d:t9,locctr/ifstrcmplabel,9669M

    fprintffp2,9s:td:n9,label,locctr/

    rewindfp/fscanffp,9s9,code/

    whilestrcmpcode,9E'D9M

    5ifstrcmpopcode,code

    5

    locctrI3/

    breaG/8

    fscanffp,9s9,code/

    8ifstrcmpopcode,9J>AD9

    locctrI3/

    else ifstrcmpopcode,9AESJ9

    locctrI36atoioperand/else ifstrcmpopcode,9AES=9

    locctrIatoioperand/else ifstrcmpopcode,9=;TE9

    IIlocctr/

    fprintffp3,9s:ts:ts:n9,label,opcode,operand/

    fscanffp1,9sss9,label,opcode,operand/8

    fprintffp3,9d:ts:ts:t:s:n9,locctr,label,opcode,operand/

    lengthlocctrHstart/printf9The length of the program is d9,length/

    fclosefp1/

    fclosefp2/fclosefp3/

    fclosefp/

    getch/

    8

  • 8/11/2019 Cs2308 SS Lab Manual

    13/69

    INPUT FILES

    INPUT.5AT

    66 ST?AT 266 &D? !PE66 ST? ?&@B?

    66 &DCB CB?AQ

    66 STCB C1

    ?&@B? AESJ 1!PE J>AD $

    CB?AQ =;TE CRQR

    C1 AES= 166 E'D 66

    OPTAB.5AT

    ST?AT

    &D?ST?

    &DCB

    STCBE'D

    >T@T !&ES

    >T.D?T

    66 ST?AT 2

    2 66 &D? !PE23 66 ST? ?&@B?

    2% 66 &DCB CB?AQ

    2O 66 STCB C1212 ?&@B? AESJ 1

    21$ !PE J>AD $

    21N CB?AQ =;TE CRQR21O C1 AES= 1

    22 66 E'D 66

  • 8/11/2019 Cs2308 SS Lab Manual

    14/69

    S;'E of a two pass

    assembler

  • 8/11/2019 Cs2308 SS Lab Manual

    15/69

    EXPT NO !

    I$-1$n% -ss %' '& %' -ss ss$1#

    AIM )

    To implement pass two of a two pass assembler.

    ALGORIT2M )

    1. Start the program

    2. !nitiali-e all the 0ariables3. >pen a file by name

    fp1fopen9assmlist.dat9,9w9/

    fp2fopen9symtab.dat9,9r9/fp3fopen9intermediate.dat9,9r9/

    fpfopen9optab.dat9,9r9/

    . Aead the content of the file$. !f opcode is =;TE

    ifstrcmpopcode,9=;TE9

    Te/

    fprintffp1,9d:ts:ts:ts:t9,address,label,opcode,operand/Else if opcode is J>AD

    else ifstrcmpopcode,9J>AD9

    te/

    fprintffp1,9d:ts:ts:ts:ts:n9,address,label,opcode,operand,a/

    Else perform

    else ifstrcmpopcode,9AES=9strcmpopcode,9AESJ9

    fprintffp1,9d:ts:ts:ts:n9,address,label,opcode,operand/if it is not math anything

    elsefprintffp1,9d:ts:ts:ts:td:n9,address,label,opcode,operand,code/

    %. inally terminate the of pass two of pass two assembler

    Surce cde pr+ram -/ c pa00 t4 3 pa00 t4 a00em*er

    )include*stdio.h+

    )include*conio.h+)include*string.h+

    )include*stdlib.h+

    0oid main5

    char a14,ad14,label14,opcode14,operand14,mnemonic14,symbol14/

    int i,address,code,add,len,actuallen/

    !&E 6fp1,6fp2,6fp3,6fp/clrscr/

    fp1fopen9assmlist.dat9,9w9/

  • 8/11/2019 Cs2308 SS Lab Manual

    16/69

    fp2fopen9symtab.dat9,9r9/fp3fopen9intermediate.dat9,9r9/

    fpfopen9optab.dat9,9r9/

    fscanffp3,9sss9,label,opcode,operand/ifstrcmpopcode,9ST?AT9

    5fprintffp1,9:ts:ts:ts:n9,label,opcode,operand/fscanffp3,9dsss9,Faddress,label,opcode,operand/

    8

    whilestrcmpopcode,9E'D9M

    5ifstrcmpopcode,9=;TE9

    5

    fprintffp1,9d:ts:ts:ts:t9,address,label,opcode,operand/lenstrlenoperand/

    actuallenlenH3/

    fori2/i*actuallenI2/iII5

    itoaoperandi4,ad,1%/

    fprintffp1,9s9,ad/

    8fprintffp1,9:n9/

    8

    else ifstrcmpopcode,9J>AD95

    lenstrlenoperand/

    itoaatoioperand,a,1/

    fprintffp1,9d:ts:ts:ts:ts:n9,address,label,opcode,operand,a/8

    else ifstrcmpopcode,9AES=9strcmpopcode,9AESJ95

    fprintffp1,9d:ts:ts:ts:n9,address,label,opcode,operand/

    8

    else5

    rewindfp/

    fscanffp,9sd9,mnemonic,Fcode/whilestrcmpopcode,mnemonicM

    fscanffp,9sd9,mnemonic,Fcode/

    ifstrcmpoperand,96695

    fprintffp1,9d:ts:ts:ts:td:n9,address,label,opcode,operand,code/

    8

    else5

    rewindfp2/

  • 8/11/2019 Cs2308 SS Lab Manual

    17/69

    fscanffp2,9sd9,symbol,Fadd/whilestrcmpoperand,symbolM

    5

    fscanffp2,9sd9,symbol,Fadd/8

    fprintffp1,9d:ts:ts:ts:tdd:n9,address,label,opcode,operand,code,add/88

    fscanffp3,9dsss9,Faddress,label,opcode,operand/

    8

    fprintffp1,9d:ts:ts:ts:n9,address,label,opcode,operand/printf9inished9/

    fclosefp1/

    fclosefp2/fclosefp3/

    fclosefp/

    getch/8

    INPUT FILES

    INTERME5IATE.5AT

    66 ST?AT 2

    2 66 &D? !PE23 66 ST? ?&@B?

    2% 66 &DCB CB?AQ

    2O 66 STCB C1

    212 ?&@B? AESJ 121$ !PE J>AD $

    21N CB?AQ =;TE CUE>U21O C1 AES= 1

    22 66 E'D 66

    >@T?=.D?T&D? 33

    ST?

    &DCB $3STCB $(

    E'D 6

    S;

  • 8/11/2019 Cs2308 SS Lab Manual

    18/69

    >T@T !&E ?SSAD $ $

    21N CB?AQ =;TE CUE>U $f%

    21O C1 AES= 122 66 E'D 66

    RESULT)

    Thus pass two of a two pass assembler was implemented in -

  • 8/11/2019 Cs2308 SS Lab Manual

    19/69

    EXPT NO "

    I$-1$n% sing1 -ss ss$1#

    AIM

    To implement a single pass assembler.

    ALGORIT2M

    Surce cde pr+ram -/ c60-/+*e pa00 a00em*er

    )include*stdio.h+)include*conio.h+

    )include*string.h+

    )include*stdlib.h+struct st

    5

    char op2$4/

    int nb/char code34/

    8s/

    0oid main

    5int i,lc,h/

    char g14,c14/!&E 6fp1,6fp2,6fp3/

    clrscr/

    fp1fopen9pgm.dat9,9r9/

    fp3fopen9oneoutput.dat9,9w9/fprintffp3,9lc:topcode:tobVcode:n9/

    lc72/

    whileMfeoffp15

    fgetsg,3$,fp1/whilegi4MU:nU5

    ifgi4+U?U FF gi4*UQU

    5ch4gi4/

    hII/

    8

  • 8/11/2019 Cs2308 SS Lab Manual

    20/69

    iII/8

    ch4U:U/

    fp2fopen9opcode.dat9,9r9/whileMfeoffp2

    5fscanffp2,9sds9,s.op,Fs.nb,s.code/ifstrcmpc,s.op

    5

    fprintffp3,97:ts9,lc/

    switchs.nb5

    case 1

    fprintffp3,9:ts:n9,s.code/breaG/

    case 2

    fprintffp3,9:ts:tcc9,s.code,giH24,giH14/fprintffp3,9:n9/

    breaG/

    case 3

    fprintffp3,9:ts:tcc:tcc9,s.code,giH24,giH14,giH4,giH34/fprintffp3,9:n9/

    breaG/

    8lclcIs.nb/

    breaG/

    8

    8fclosefp2/

    i/h/

    88

    INPUT FILES)

    pcde.dat

    MO7AB 1 %&

    A55B 1 &1

    M7IA "

    STA ! !

    2LT 1 %$

  • 8/11/2019 Cs2308 SS Lab Manual

    21/69

    p+m.dat

    M7I A,($

    A55 B

    STA #((

    2LT

    RESULT)

    Thus a single pass assembler was implemented in C.

  • 8/11/2019 Cs2308 SS Lab Manual

    22/69

    EXPT NO #

    I$-1$n% %' -ss $*#' -#'*ss'#

    AIM)

    To Implement a two pass macro processor

    ALGORIT2M)

  • 8/11/2019 Cs2308 SS Lab Manual

    23/69

    Surce cde pr+ram -/ c6two pass ma$%o p%o$esso%

    #include#include#include

    #include//------------------------------------------Header Filesstructmnt{charname[20];intmdtinde;int!"ipFla;$mnt[%0];//-------------------------structmdt{intsrno;charinst[20];$mdt[%0];

    //-------------------------structala{intinde;charar[20];$ala[%0];//-------------------------intmntc&mdtc&alac;//-----------------------------------------------------

  • 8/11/2019 Cs2308 SS Lab Manual

    24/69

    char'replace(str)char'str& char'ori& char'rep*{ staticchar+u,,er[0]; char'p;

    if))p 1 strstr)str& ori*** // s 3ori3 e4en in 3str35 { returnstr; $

    strncpy)+u,,er& str& p-str*; // 6opy characters ,rom 3str3 start to3ori3 st7 +u,,er[p-str] 1 3803; sprint,)+u,,er9)p-str*&:ss:&rep&p9strlen)ori**;

    if))p 1 strstr)+u,,er& ori*** // s 3ori3 e4en in 3+u,,er35 return+u,,er; else replace(str)+u,,er&ori&rep*;$

    //--------------------------------------------------------------voiddisp=)*{inti; print,):8nnde8trument:*; print,):8n------------------:*;for)i10;i

  • 8/11/2019 Cs2308 SS Lab Manual

    25/69

    do{ do{ //----> @o !eperate ut @o"en ch 1 ,etc)src*; //----> ch G 6urrent ointer to"en[i] 1 ch; i99; $while)ch1DF II isspace)ch**; to"en[i-%] 1 3803; //----> as" 6urrent ch //-------------------------------------------- //-------------------------------------------- //-------------------------------------------- if)strcmp)to"en&:macro:** //--> 6hec" For :macro: { do{ //--> acro Jame ch% 1 ,etc)src*; to"en%[A] 1 ch%; A99; $while)ch%1DF II isspace)ch%**; to"en%[A-%] 1 3803; //----------------------------------- strcpy)mnt[mntc].name&to"en%*;

    mnt[mntc].mdtinde 1 mdtc; mntc99; //------------------------------------- //, no arameter i.e = is Dmpty //------------------------------------- if)ch%1138n3* { mnt[mntc-%].!"ipFla 1 %; oto id; $ //------------------------------------- //6reate = //------------------------------------- do{ //= 6ontent ch% 1 ,etc)src*; if)ch%113I3* ,la1%; if)ch%113&3KKch%1138n3* { to"en%["]13803; ,la10; ala[alac].inde 1 alac; strcpy)ala[alac].ar&to"en%*; alac99; "10; $ if),la11%*

    to"en%["99] 1 ch%; $while)ch%1DF II ch%138n3*; //----------------------------------------- idG ,la1%; A10; do { line[0]13803;

  • 8/11/2019 Cs2308 SS Lab Manual

    26/69

    do{ //?@ ch% 1 ,etc)src*; line[A99]1ch%; $ while)ch%1DF II ch%138n3*; line[A-%]13803;

    for)l 1 0 ;l

  • 8/11/2019 Cs2308 SS Lab Manual

    27/69

    $while)ch1DF*;$//----------------------------------------------------------------voidpass2)*{charch;intcounter10;intstart(inde;charch%&ch2&pch; //comment 4alidationintlen&,la10&s,la10;inti 1 0&A10&"10&l10;charto"en[%0];charto"en%[%0];chartemp[B]&temp%[B];chartline[C0];charline[C0];charrepl[%0];

    F=D 'src;alac 1 0;

    strcpy)temp&:#:*;

    src 1 ,open):op.c:&:r:*;

    do

    { do{ //For !eperate @o"en ch 1 ,etc)src*; to"en[i] 1 ch; i99; $while)ch1DF II isspace)ch**; to"en[i-%] 1 3803; //-------------------------------------------- for)A10;A

  • 8/11/2019 Cs2308 SS Lab Manual

    28/69

    //----------------------------------------- JetG " 1 counter; do { strcpy)line&mdt[start(inde].inst*; if)strcmp)line&:mend:** break; for)l10;l

  • 8/11/2019 Cs2308 SS Lab Manual

    29/69

    //-----------------------------------voidmain)*{clrscr)*;pass%)*;print,):8n---------------------------:*;print,):8nnput roram G :*;print,):8n---------------------------8n:*;disp)*;print,):8n---------------------------:*;print,):8n6ontent o, = G :*;print,):8n---------------------------8n:*;disp=)*;print,):8n---------------------------:*;print,):8n6ontent o, ?@ G :*;print,):8n---------------------------8n:*;disp?@)*;print,):8n----------------------------8n:*;pass2)*;

    etch)*;$

    RESULT)

    Thus a two pass macroprocessor was implemented in C

  • 8/11/2019 Cs2308 SS Lab Manual

    30/69

    EXPT NO $ I$-1$n% sing1 -ss $*#' -#'*ss'#

    AIM

    To implement a single pass macro processor

    ALGORIT2M

    1.Start the macro processor program2. !nclude the necessary header files and 0ariable

    3. >pen the three files

    f1macin.dat with read pri0ilegef2macout.dat with write pri0ilege

    f3 deftab.dat with write pri0ilege

    . Wet the 0ariable form f1 file macin.dat for label,opcode,operand$. Aead the 0ariable until the opcode is not is eLual to -ero

    Then checG if the opcode is eLual to

  • 8/11/2019 Cs2308 SS Lab Manual

    31/69

    char lab14/char opc14/

    char oper14/

    8d14/0oid main

    5char label14,opcode14,operand14,newlabel14,newoperand14/char macroname14/

    int i,lines/

    !&E 6f1,6f2,6f3/

    clrscr/f1fopen9macin.dat9,9r9/

    f2fopen9macout.dat9,9w9/

    f3fopen9deftab.dat9,9w9/fscanff1,9sss9,label,opcode,operand/

    whilestrcmpopcode,9E'D9M

    5ifstrcmpopcode,9

  • 8/11/2019 Cs2308 SS Lab Manual

    32/69

    fclosef1/fclosef2/

    fclosef3/

    printf9!'!SBED9/getch/

    8

    !'@T !&E

  • 8/11/2019 Cs2308 SS Lab Manual

    33/69

    RESULT)

    Thus a single pass macroprocessor was implemented in C.

  • 8/11/2019 Cs2308 SS Lab Manual

    34/69

    EXPT NO %

    I$-1$n% n s'1"% 1',#

    AIM)

    To implement an absolute loader.

    ALGORIT2M)

    1. Start the program

    2. ?ssign the reLuired 0ariable3. >pen the files

    fp1fopen9input.dat9,9r9/

    fp2fopen9output.dat9,9w9/

    . Aead the content$. sing while loop perform the loop until character is not eLual to E

    4-*e80trcmp8-/put,9E9:;

  • 8/11/2019 Cs2308 SS Lab Manual

    35/69

    Surce cde pr+ram -/ c per3rm-/+ A0*uter Lader

    ) include *stdio.h+

    ) include *conio.h+) include *string.h+

    0oid main5char input14/

    int start,length,address/

    !&E 6fp1,6fp2/

    clrscr/fp1fopen9input.dat9,9r9/

    fp2fopen9output.dat9,9w9/

    fscanffp1,9s9,input/whilestrcmpinput,9E9M

    5

    ifstrcmpinput,9B95

    fscanffp1,9d9,Fstart/

    fscanffp1,9d9,Flength/

    fscanffp1,9s9,input/8

    else ifstrcmpinput,9T9

    5fscanffp1,9d9,Faddress/

    fscanffp1,9s9,input/

    fprintffp2,9d:tcc:n9,address,input4,input14/

    fprintffp2,9d:tcc:n9,addressI1,input24,input34/fprintffp2,9d:tcc:n9,addressI2,input4,input$4/

    addressI3/fscanffp1,9s9,input/

    8

    else

    5fprintffp2,9d:tcc:n9,address,input4,input14/

    fprintffp2,9d:tcc:n9,addressI1,input24,input34/

    fprintffp2,9d:tcc:n9,addressI2,input4,input$4/addressI3/

    fscanffp1,9s9,input/

    88

    fclosefp1/

    fclosefp2/

    printf9!'!SBED9/getch/

    8

  • 8/11/2019 Cs2308 SS Lab Manual

    36/69

    !'@T !&E!'@T.D?T

    B 1 232

    T 1 1233 N33O 123%T 2 2ON3 23 2N23 321$

    EOUTPUT FILE

    >[email protected]?T

    1 1

    11 2

    12 3313 N

    1 3

    1$ 3O1% 1

    1( 2

    1N 3%2 2O

    21 N3

    22

    23 232

    2$

    2% 2N2( 2

    2N 3

    2O 3

    21 2211 1$

    RESULT)

    Thus an absolute loader was implemented in C.

  • 8/11/2019 Cs2308 SS Lab Manual

    37/69

    EXPT NO &

    I$-1$n% #1'*%ing 1',#

    AIM

    To implement a relocating loader.

    ALGORIT2M

    1. Start the program2. !nclude the necessary header file and 0ariable

    3. >pen the two file for

    fp1 relinput.dat and gi0e readfp2 reloutput.dat and gi0e write

    . Aead the content

    $. sing while loop perform the loop until character is not eLual to E

    4-*e80trcmp8-/put,9E9:;

  • 8/11/2019 Cs2308 SS Lab Manual

    38/69

    int start,inp,len,i,address,opcode,addr,actualadd/!&E 6fp1,6fp2/

    clrscr/

    printf9Enter the actual starting address 9/scanf9d9,Fstart/

    fp1fopen9relinput.dat9,9r9/fp2fopen9reloutput.dat9,9w9/fscanffp1,9s9,input/

    whilestrcmpinput,9E9M

    5

    ifstrcmpinput,9B95

    fscanffp1,9s9,add/

    fscanffp1,9s9,length/fscanffp1,9s9,input/

    8

    ifstrcmpinput,9T95

    fscanffp1,9d9,Faddress/

    fscanffp1,9s9,bitmasG/

    addressIstart/lenstrlenbitmasG/

    fori/i*len/iII

    5fscanffp1,9d9,Fopcode/

    fscanffp1,9d9,Faddr/

    relocbitbitmasGi4/

    ifrelocbitUUactualaddaddr/

    elseactualaddaddrIstart/

    fprintffp2,9d:tdd:n9,address,opcode,actualadd/

    addressI3/

    8fscanffp1,9s9,input/

    8

    8fclosefp1/

    fclosefp2/

    printf9!'!SBED9/getch/

    8

    !'@T AE&!'@T.D?TB 1 2

    T 1 111 1 133 N 13O O 1((% O2 1(%$ $( 1(%$

  • 8/11/2019 Cs2308 SS Lab Manual

    39/69

    T 211 1111 23 1N3N 3 1O(O NO 1% %% 1NO OO 1((E 1

    >T@T Enter the actual starting address

    AE&>[email protected]?T 133

    3 N3O

    % O1((%

    O O21(%$12 $((%$

    $11 23N3N

    $1 3O(O$1( NO%

    $2 %%NO

    $23 OO1((

    AES&T Thus a relocating loader was implemented in C.

  • 8/11/2019 Cs2308 SS Lab Manual

    40/69

    EXPT NO '

    I$-1$n% -ss 'n '& ,i#*%.1ining 1',#

    AIM

    To implement pass one of a direct"lin#ing loader.

    OB=ECTI7ES

    1. Start the program for linGing loader

    2. ?ssign the necessary 0ariable and the header 0ariable3. >pen the two file

    . !n fp1 for linG input file for read pri0ilege

    $. ?nd fp2 for load map file for write pri0ilege%. Aead the character until the input is not eLual to E'D

    (. ?nd the checG the character in if condition input is B then

    N. Wet the name from fp1

    O. Copy the name between csnamename1. ?nd e7tsym66

    11. Else if the character is D

    12. Then get the input 0ariable

    13. !n these if condition perform the while loop the read character until the inputis not eLual to A

    The copy csnmae661. ?nd e7tsyminput

    1$. Then add address addIcsaddr

    1%. ?nd length is eLual to -ero

    1(. ?nd perform the operation see the Source code1N. inally terminate the program

    Surce cde -/ c pr+ram per3rm-/+ pa00e0 /e *-/>-/+ *ader

    ) include *stdio.h+) include *conio.h+) include *string.h+

    ) define

  • 8/11/2019 Cs2308 SS Lab Manual

    41/69

    int address/int length/

    8es

  • 8/11/2019 Cs2308 SS Lab Manual

    42/69

  • 8/11/2019 Cs2308 SS Lab Manual

    43/69

    < $ % H&!ST?< $ % I@A>WC

    E

    E'D

    OUTPUT)

    Enter the location where the program has to be loaded $

    &>?D

  • 8/11/2019 Cs2308 SS Lab Manual

    44/69

    EXPT NO 1(

    I$-1$n% -ss %' '& ,i#*%.1ining 1',#

    AIM

    To implement pass two of a direct"lin#ing loader.

    RESULT)

  • 8/11/2019 Cs2308 SS Lab Manual

    45/69

  • 8/11/2019 Cs2308 SS Lab Manual

    46/69

    cur7where7/curywherey/

    te7tcolor12/

    te7tbacGgroundO/goto7y3$,1/

    cout**9:n9/cout**9)))))))))))))))))))))))))))))))))))))))))))))):n9/cout**9:n9/

    cout**9:t:tTEZT ED!T>A:n9/

    cout**9)))))))))))))))))))))))))))))))))))))))))))))):n9/

    cout**9:n Type your te7t and then press ESC Gey:n9/goto7y1,$/

    cprintf92d2d9,cury,cur7/

    goto7ycur7,cury/8

    0oid main5

    char ch,c/

    ofstream outfile/

    ifstream infile/clrscr/

    curpos/

    cur7where7/curywherey/

    whilecM2(

    5

    cgetch/switchc

    5case N [[down arrow

    goto7ycur7,curyI1/

    breaG/

    case (( [[right sidegoto7ycur7I1,cury/

    breaG/

    case (2 [[up arrowgoto7ycur7,curyH1/

    breaG/

    case ($ [[left sidegoto7ycur7H1,cury/

    breaG/

    case 32 [[space

    printf9 9/buffcountII4U U/

    breaG/

  • 8/11/2019 Cs2308 SS Lab Manual

    47/69

    case 13 [[new linegoto7y1,curyI1/

    buffcountII4U:nU/

    breaG/default

    te7tcolor13/ifc+%$ FF c*122 c+N FF c*$(cprintf9c9,c/

    breaG/

    8

    buffcountII4c/curpos/

    8

    cprintf9:n:nDo you want to sa0eK y[n9/scanf9c9,Fc/

    ifcUyUcU;U

    5cprintf9:n:nEnter the file name with e7tension in N characters only9/

    scanf9s9,filename/

    outfile.openfilename,iosout/

    outfile**buff/outfile.close/

    cout**9:nDo you want to openK y[n :n9/

    chgetch/ifchUyUchU;U

    5

    cprintf9:n:nEnter the file name to open9/

    scanf9s9,filename/infile.openfilename,iosin/

    infile.getbuff,count,U6U/goto7yO,1/

    printf9s9,buff/

    getch/

    infile.close/8

    8

    8

    RESULT)

    Thus a Te7t editor was implemented in C

  • 8/11/2019 Cs2308 SS Lab Manual

    48/69

  • 8/11/2019 Cs2308 SS Lab Manual

    49/69

  • 8/11/2019 Cs2308 SS Lab Manual

    50/69

    whilecMU/U

    5

    strcpy0al,9 9/

    cgetcfp/

    i/

    do

    5

    0ariII4c/

    cgetcfp/

    8whileisalphac/

    0ari4U:U/

    ifcUU

    5

    i/

    cgetcfp/

    strcpyin,9 9

    do

    5

    iniII4c/cgetcfp/

    Gatoiin/

    si-esi-e6G/

    8

    else

    5

    strcpyin,U1U/

    si-e2/

    8

    ifcUU

    cgetcfp/

    i/

  • 8/11/2019 Cs2308 SS Lab Manual

    51/69

    do

    5

    0aliII4c/

    cgetcfp/

    8whilecMU,UFFcMU/U

    0ali4U:U/

    8

    printf9:ns:t:ts:ts:t:ts:td=ytes:td9,temp,0ar,0al,in,si-e,add/

    addaddIsi-e/

    8

    8

    8

    else

    cgetcfp/

    8

    getch/

    8

    RESULT)

    Tu0 te 0ym* ta*e 4a0 +e/erated u0-/+ C.

  • 8/11/2019 Cs2308 SS Lab Manual

    52/69

    VIVA VOCE QUESTIONS WITH ANSWERS

    INTRODUCTION

    1. Define system software.It consists of variety of programs that supports the operation of thecomputer. Thissoftware makes it possible for the user to focus on the other problems tobe solved with outneeding to know how the machine works internally.

    Eg: operating system, assembler, loader.2. i!e some a""#i$ations of o"eratin% system.

    to make the computer easier to use

    to manage the resources in computer

    process management

    data and memory management to provide security to the user.Operating system acts as an interface between the user and the systemEg:windows,linux,unix,dos&. Define $om"i#er an' inter"reter.ompiler is a set of program which converts the whole high level

    language programto machine language program.Interpreter is a set of programs which converts high level languageprogram to machinelanguage program line by line.(. Define #oa'er.!oader is a set of program that loads the machine language translated bythe translator

  • 8/11/2019 Cs2308 SS Lab Manual

    53/69

  • 8/11/2019 Cs2308 SS Lab Manual

    54/69

    9ere the Target address is calculatedusing the formulaTarget address 5 )isplacement 3 6'7'Abase register9ere the target address is calculated using the

    formulaTarget address 5 )isplacement 3 6?7?Aprogram counter)isplacement lies between + to 2+0 )isplacement lies between >*+2- to*+2*(ADD -:imme'iate; to R :in'ire$t;9ere / is the immediate data and the next value is indirect data. ie, theregister containsthe address of the operand. 9ere the address of the operand is and itscorresponding valueis .

    / 3 6$7 5 /3 67 5 /3 5(112. 7o##owin% is a memory $onfi%ration8A''ress Va#e Re%ister R( 4 -) /- 2W*at is t*e res#t of t*e fo##owin% statement,SU9 (:'ire$t; to R :'ire$t;9ere one operand is in the address location 2%direct addressing& and thenext operandis in the register %register direct&.

    The resultant value is 0 >/ 51.1&. W*at is t*e name of A an' 6 re%ister in SIC ma$*ine an' a#sos"e$ify its se.#AaccumulatorBsed for arithmetic operation. i.e., in the case of arithmetic operationsone operand isin the accumulator, and other operand may be an immediate value,register operand ormemory content. The operation given in the instruction is performed andthe result is storedin the accumulator register.!Alinkage registerIt is used to store the return address in the case of Cump to subroutine%D4B'&instructions.1(. W*at are t*e instr$tion formats se' in SICE ar$*ite$tre,i!e any oneformat.ormat ( %( byte&, ormat * %* bytes&, ormat 1 %1 bytes& ormat 2%2bytes&

  • 8/11/2019 Cs2308 SS Lab Manual

    55/69

    ormat *:- 2 2O?O)E $( $*1). Consi'er t*e instr$tions in SIC E "ro%rammin%15 1555 6ENTH RESW (

    **25

  • 8/11/2019 Cs2308 SS Lab Manual

    56/69

    'ET# $E4F (OGE $E4F (21. Write t*e se?en$e of instr$tions to "erform t*e o"eration9ETA @ A6HAB)sin% SICE instr$tions.

    *1!)# #!?9##)) am"#e.

    These are the statements that are not translated into machineinstructions, but theyprovide instructions to assembler itself.example 4T#$T,EG),'NTE,FO$),$E4F and $E4'.&. W*at are forwar' referen$es,It is a reference to a label that is defined later in a program.onsider the statement(+ (+++ 4T! $ET#)$. . . .. . . .-+ (+1/ $ET#)$ $E4F (The first instruction contains a forward reference $ET#)$. If we attemptto translatethe program line by line, we will unable to process the statement in line(+because we do notknow the address that will be assigned to $ET#)$ .The address isassigned later%in line -+&in the program.(. W*at are t*e t*ree 'ifferent re$or's se' in o0e$t "ro%ram,

  • 8/11/2019 Cs2308 SS Lab Manual

    57/69

  • 8/11/2019 Cs2308 SS Lab Manual

    58/69

    time is known as relocatable program.4. Differentiate a0so#te e>"ression an' re#ati!e e>"ression.If the result of the expression is an absolute value %constant& then it isknown asabsolute expression.

    Eg: 'BEG) > 'BE$*If the result of the expression is relative to the beginning of the programthen it isknown as relative expression. label on instructions and data areas andreferences to thelocation counter values are relative terms.Eg: 'BEG) 3 'BE$15. Write t*e ste"s re?ire' to trans#ate t*e sor$e "ro%ram too0e$t "ro%ram.

    onvert mnemonic operation codes to their machine languageeMuivalents.

    onvert symbolic operands to their eMuivalent machine addresses 'uild the machine instruction in the proper format.

    onvert the data constants specified in the source program into theirinternal machinerepresentation Frite the obCect program and assembly listing.11. W*at is t*e se of t*e !aria0#e 6OCCTR :#o$ation $onter; inassem0#er,This variable is used to assign addresses to the symbols. !OT$ isinitialied to thebeginning address specified in the 4T#$T statement. #fter each source

    statement isprocessed the length of the assembled instruction or data area to begenerated is added to!OT$ and hence whenever we reach a label in the source program thecurrent value of!OT$ gives the address associated with the label.12. Define #oa' an' %o assem0#er.One pass assembler that generates their obCect code in memory forimmediateexecution is known as load and go assembler. 9ere no obCect programmeris written out and

    hence no need for loader.1&. W*at are t*e two 'ifferent ty"es of m" statements se' in+AS+ assem0#er,

    Gear Cump# near Cump is a Cump to a target in the same segment and it isassembled by using a currentcode segment 4.

    ar Cump

  • 8/11/2019 Cs2308 SS Lab Manual

    59/69

    # far Cump is a Cump to a target in a different code segment and it isassembled by usingdifferent segment registers .1(. W*at is t*e se of 0ase re%ister ta0#e in AI assem0#er,# base register table is used to remember which of the general purpose

    registers arecurrently available as base registers and also the base addresses theycontain.*/.B4IGH statement causes entry to the table and .)$O? statementremoves thecorresponding table entry.1). Differentiate t*e assem0#er 'ire$ti!es RESW an' RES9.$E4F >It reserves the indicated number of words for data area.Eg: (+ (++1 T9$EE $E4F (In this instruction one word area %1 bytes& is reserved for the symbolT9$EE. If the

    memory is byte addressable then the address assigned for the nextsymbol is (++/.$E4' >It reserves the indicated number of bytes for data area.Eg: (+ (++- IG?BT $E4' (In this instruction one byte area is reserved for the symbol IG?BT .9encethe addressassigned for the next symbol is (++0.1-. Define mo'ifi$ation re$or' an' %i!e its format.This record contains the information about the modification in the obCectcode duringprogram relocation. the general format is

    ol ( "ol *A 4tarting location of the address field to be modified relative to thebeginningof the programol -A0 length of the address field to be modified in half bytes.1/. Write 'own t*e "ass nm0ers :ASS 1 ASS 2; of t*efo##owin% a$ti!ities t*at o$$rin a two "ass assem0#er8a. O0e$t $o'e %eneration0. 6itera#s a''e' to #itera# ta0#e$. 6istin% "rinte''. A''ress #o$ation of #o$a# sym0o#s

    #nswer:a. ObCect code generation A ?#44 *b. !iterals added to literal table > ?#44 (c. !isting printed > ?#44*d. #ddress location of local symbols > ?#44(13. W*at is meant 0y ma$*ine in'e"en'ent assem0#er featres,The assembler features that do not depend upon the machinearchitecture are known

  • 8/11/2019 Cs2308 SS Lab Manual

    60/69

    as machine independent assembler features.*Eg: program blocks, !iterals.14. How t*e re%ister to re%ister instr$tions are trans#ate' inassem0#er,

    In the case of register to register instructions the operand field containsthe registername. )uring the translation first the obCect code is converted into itscorresponding machinelanguage eMuivalent with the help of O?T#'. Then the 4N"T#' issearched for thenumeric eMuivalent of register and that value is inserted into the operandfield.Eg: (* (+1/ $)$E !E#$ @ '2(+'2Amacine eMuivalent of the opcode !E#$(+Anumeric eMuivalent of the register @.25. W*at is meant 0y e>terna# referen$es,

    #ssembler program can be divided into many sections known as controlsections andeach control section can be loaded and relocated independently of theothers. If theinstruction in one control section need to refer instruction or data inanother control section.the assembler is unable to process these references in normal way. 4uchreferences betweencontrol are called external references.21. Define $ontro# se$tion.# control section is a part of the program that maintains its identity after

    assemblyeach control section can be loaded and relocated independently of theothers.ontrol sections are most often used for subroutines. The maCor benefit ofusingcontrol sections is to increase flexibility.22. W*at is t*e 'ifferen$e 0etween t*e assem0#er 'ire$ti!eETRE7 an' ETDE7.E@T)E names external symbols that are defined in a particular controlsectionand may be used in other sections.E@T$E names external symbols that are referred in a particular controlsection anddefined in another control section.2&. i!e t*e %enera# format of 'efine re$or'.This record gives information about external symbols that are defined in aparticularcontrol section. The format isol ( )ol *A name of external symbol defined in this control section

  • 8/11/2019 Cs2308 SS Lab Manual

    61/69

    ol -A(1 relative address of the symbol with in this control sectionol (2A1 name and relative address for other external symbols.2(. i!e t*e se of assem0#er 'ire$ti!e CSECT an' USE*-4ET A used to divide the program into many control sections

    B4E > used to divide the program in to many blocks called program blocks2). W*at is t*e se of t*e assem0#er 'ire$ti!e START,The assembler directive 4T#$T gives the name and starting address ofthe program.The format is?G 4T#$T (+++9ere?G > Game of the program(+++ A 4tarting address of the program.

    6OADERS AND 6INERS

    1. W*at are t*e 0asi$ fn$tions of #oa'ers, !oading > brings the obCect program into memory for execution

    $elocation > modifies the obCect program so that it can be loaded at anaddressdifferent from the location originally specified !inking > combines two or more separate obCect programs and alsosupplies theinformation needed to reference them.2. Define a0so#te #oa'er.The loader, which is used only for loading, is known as absolute loader.e.g. 'ootstrap loader

    &. W*at is meant 0y 0ootstra" #oa'er,This is a special type of absolute loader which loads the first program tobe run by thecomputer. %usually an operating system&(. W*at are re#ati!e :re#o$ati!e; #oa'ers,!oaders that allow for program relocation are called relocating%relocative& loaders.). W*at is t*e se of mo'ifi$ation re$or',"odification record is used for program relocation. Each modificationrecordspecifies the starting address and the length of the field whose value is to

    be altered and alsodescribes the modification to be performed.-. W*at are t*e 2 'ifferent te$*ni?es se' for re#o$ation,*0"odification record method and relocation bit method./. Define Re#o$ation 0it met*o'.If the relocation bit corresponding to a word of obCect code is set to (, theprogram=s

  • 8/11/2019 Cs2308 SS Lab Manual

    62/69

    starting address is to be added to this word when the program isrelocated. 'it value +indicates no modification is reMuired.3. Define 0it masF.The relocation bits are gathered together following the length indicator in

    each textrecord and which is called as bit mask. or e.g. the bit mask%((((((((((++& specifiesthat the first (+ words of obCect code are to be modified during relocation.4. W*at is t*e nee' of ESTA9,It is used to store the name and address of the each external symbol. Italso indicatesin which control section the symbol is defined.15. W*at is t*e se of t*e !aria0#e ROADDR,It gives the beginning address in memory where the linked program is tobe loaded.The starting address is obtained from the operating system.

    11. Write t*e two "asses of a #inFin% #oa'er.?ass(: assigns address to all external symbols?ass*: it performs actual loading, relocation and linking.12. Define atomati$ #i0rary sear$*.In many linking loaders the subroutines called by the program beingloaded areautomatically fetched from the library, linked with the main program andloaded. This featureis referred to as automatic library search.1&. 6ist t*e #oa'er o"tions INC6UDE GDE6ETE.The general format of IG!B)E is

    IG!B)E programQname %library name&This command direct the loader to read the designated obCect programfrom a library and treatit as the primary loader input.The general format of )E!ETE command is)E!ETE sectAnameIt instructs the loader to delete the named control sections from the setsof programs loaded.1(. i!e t*e fn$tions of t*e #inFin% #oa'er.1+The linking loader performs the process of linking and relocation. Itincludes theoperation of automatic library search and the linked programs are directlyloaded into thememory.1). i!e t*e 'ifferen$e 0etween #inFin% #oa'er an' #inFa%ee'itors.6inFin% #oa'er 6inFa%e e'itorThe relocation and linking is performedeach time the program is loaded

  • 8/11/2019 Cs2308 SS Lab Manual

    63/69

    It produces a linked version of a programand which is written in a file for laterexecution9ere the loading can be accomplished in asingle pass

    Two passes are reMuired1-. Define 'ynami$ #inFin%.If the subroutine is loaded and linked to the program during its first call%run time&,then it is called as dynamic loading or dynamic linking.1/. Write t*e a'!anta%e of 'ynami$ #inFin%.

    It has the ability to load the routine only when they are needed.

    The dynamic linking avoids the loading of entire library for eachexecution.13. W*at is meant 0y stati$ e>e$ta0#e an' 'ynami$ e>e$ta0#e,In static executable, all external symbols are bound and ready to run. Indynamicexecutables some symbols are bound at run time.14. W*at is s*are' an' "ri!ate 'ata,The data divided among processing element is called shared data. If thedata is notshared among processing elements then it is called private data.25. Write t*e a0so#te #oa'er a#%orit*m.9e%in$ead 9eader record8erify program name and length$ead first text recordFhile record type R5 ;E= do

    'egin"oved obCect code to specified location in memory$ead next obCect program recordEndDump to address specified in End record1(

    +ACRO ROCESSORS

    1. Define ma$ro "ro$essor."acro processor is system software that replaces each macroinstructionwith thecorresponding group of source language statements. This is also called asexpanding ofmacros.2. W*at 'o ma$ro e>"ansion statements mean,These statements give the name of the macroinstruction being invokedand thearguments to be used in expanding the macros. These statements arealso known as macro

  • 8/11/2019 Cs2308 SS Lab Manual

    64/69

    call.&. W*at are t*e 'ire$ti!es se' in ma$ro 'efinition,"#$O A it identifies the beginning of the macro definition"EG) A it marks the end of the macro definition(. W*at are t*e 'ata str$tres se' in ma$ro "ro$essor,

    )ET#' > the macro definitions are stored in a definition table i.e. itcontains amacro prototype and the statements that make up the macro body.G#"T#' > it is used to store the macro names and it contains twopointers for eachmacro instruction which indicate the starting and end location of macrodefinition in)ET#'. it also serves as an index to )ET#'#$HT#' > it is used to store the arguments during the expansion of macroinvocations.). Define $on'itiona# ma$ro e>"ansion.If the macro is expanded depends upon some conditions in macro

    definition%depending on the arguments supplied in the macro expansion& then it iscalled as conditionalmacro expansion.-. W*at is t*e se of ma$ro time !aria0#e,"acro time variable can be used to store working values during the macroexpansion.#ny symbol that begins with the character and then is not a macroinstruction parameter isassumed to be a macro time variable./. W*at are t*e statements se' for $on'itiona# ma$ro

    e>"ansion,IAE!4EAEG)I statementF9I!EAEG)F statement3. W*at is meant 0y "ositiona# "arameters,1*If the parameters and arguments were associated with each otheraccording to theirpositions in the macro prototype and the macro invocation statement,then these parameters inmacro definitions are called as positional parameters.4. Consi'er t*e ma$ro 'efinition='efine DIS6A :ER; rintf :ER @ 'JnKL ER;

    E>"an' t*e ma$ro instr$tion DIS6A :ANS;#ns.: ?rintf %SE@?$ 5 dUnV, #G4&15. W*at are Fnown as neste' ma$ro $a##,The statement, in which a macro calls on another macro, is called nestedmacro call.In the nested macro call, the call is done by outer macro and the macrocalled is the innermacro.

  • 8/11/2019 Cs2308 SS Lab Manual

    65/69

    11. How t*e ma$ro is "ro$esse' sin% two "asses,?ass(: processing of definitions?ass *:actualAmacro expansion.12. i!e t*e a'!anta%e of #ine 0y #ine "ro$essors.

    It avoids the extra pass over the source program during assembling.

    It may use some of the utility that can be used by language translatorsso that can beloaded once.1&. W*at is meant 0y #ine 0y #ine "ro$essor,This macro processor reads the source program statements, process thestatements andthen the output lines are passed to the language translators as they aregenerated, insteadof being written in an expanded file.1(. i!e t*e a'!anta%es of %enera#e$te',

    The execution of nested macro call follows the !IO rule. In case of nestedmacrocalls the expansion of the latest macro call is completed first.14. +ention t*e tasFs in!o#!e' in ma$ro e>"ansion.

    identify the macro calls in the program

    the values of formal parameters are identified maintain the values of expansion time variables declared in a macro

    expansion time control flow is organied

  • 8/11/2019 Cs2308 SS Lab Manual

    66/69

    determining the values of seMuencing symbols

    expansion of a model statement is performed25. How to 'esi%n t*e "ass str$tre of a ma$ro assem0#er,To design the structure of macroAassembler, the functions of macropreprocessor and

    the conventional assembler are merged. #fter merging, the functions arestructured intopasses of the macro assembler.

    TET EDITORS

    1. Define intera$ti!e e'itor,#n interactive editor is a computer program that allows a user to createand revise atarget document. The term document includes obCects such as computerprograms, text,eMuations, tables, diagrams, line art, and photographs any thing that onemight find on aprinted page.2. W*at are t*e tasFs "erforme' in t*e e'itin% "ro$ess,2 tasks 4elect the part of the target document to be viewed and manipulated.

    )etermine how to format this view onAline and how to display it.

    4pecify and execute operations that modify the target document.

    Bpdate the view appropriately.12&. W*at are t*e t*ree $ate%ories of e'itorMs 'e!i$es,

    Text deviceX 4tring devices

    'utton deviceXhoice devices !ocator device(. W*at is t*e fn$tion "erforme' in e'itin% "*ase,In the actual editing phase, the target document is created or altered witha set ofoperations such as insert, delete, replace, move and copy.). Define 6o$ator 'e!i$e,!ocator devices are twoAdimensional analogAtoAdigital converters thatposition acursor symbol on the screen by observing the user=s movement of thedevice. The most

    common such devices for editing applications are the mouse and the datatablet.-. W*at is t*e fn$tion "erforme' in !oi$e in"t 'e!i$e,8oiceAinput devices, which translate spoken words to their textualeMuivalents, mayprove to be the text input devices of the future. 8oice recogniers arecurrently available forcommand input on some systems.

  • 8/11/2019 Cs2308 SS Lab Manual

    67/69

    /. W*at are $a##e' toFens,The lexical analyer tracks the source program one character at a time bymaking thesource program into seMuence of atomic units is called tokens.3. Name some of ty"i$a# toFens.

    Identifiers, keywords, constants, operators and punctuation symbols suchas commasand parentheses are typical tokens.4. W*at is meant 0y #e>eme,The character that forms a token is said to be a lexeme.15. +ention t*e main 'isa'!anta%e of inter"reter.The main disadvantage of interpreter is that the execution time ofinterpreted programis slower than that of a corresponding compiled obCect program.11. W*at is meant 0y $o'e o"timiation,The code optimiation is designed to improve the intermediate code,which helps the

    obCect program to run faster and takes less space.12. W*at is error *an'#er,The error handler is used to check if there is an error in the program. Ifany error, itshould warn the programmer by instructions to proceed from phase tophase.11&. Name some of te>t e'itors.

    line editors

    stream editors

    screen editors

    word processors structure editors1(. W*at for 'e0% monitors are se',)ebug monitors are used in obtaining information for localiation oferrors.1). +ention t*e featres of wor' "ro$essors.

    moving text from one place to another

    merging of text

    searching word replacement1-. W*at are t*e "*ases in "erformin% e'itin% "ro$ess,

    Traveling phase iltering phase

    ormatting phase

    Editing phase1/. Define tra!e#in% "*ase.The phase specifies the region of interest. Traveling is achieved usingoperationssuch as next screenful, bottom, find pattern.

  • 8/11/2019 Cs2308 SS Lab Manual

    68/69

    13. 7i#terin% "*ase.The selection of what is to be viewed and manipulated in given byfiltering.14. E'itin% "*aseIn this phase, the target document is altered with the set of operations

    such as insert,delete, replace, move and copy.25. Define ser interfa$e,Bser interface is one, which allows the user to communicate with thesystem in orderto perform certain tasks. Bser interface is generally designed in acomputer to make it easierto use.21. Define in"t 'e!i$e,1/Input device is an electromechanical device, which accepts data from theoutside

    world and translates them into a form, which the computer can interpret.**.)efine output devicesOutput devices the user to view the elements being edited and the resultsof the editingoperations.2&. W*at are t*e met*o's in Intera$tion #an%a%e of a te>te'itor,

    Typing >oriented or text command oriented method

    unction key interfaces menu oriented method2(. Define intera$ti!e 'e0%%in% systems.

    #n interactive debugging system provides programmers with facilitiesthat aid in thetesting and debugging of programs.

    )ebugging functions and capabilities

    $elationship with other parts of the system

    Bser interface criteria.2). Define e'itor str$tre.The command language processor accepts input from the users inputdevices andanalyes the tokens and syntactic structure of the commands.2-. i!e t*e $om"onents of e'itor str$tre

    2 components Editing component

    Traveling component

    8iewing component

    )isplay component2/. W*at are t*e 0asi$ ty"es of $om"tin% en!ironments se' ine'itorMs fn$tions,Editor=s function in three basic types of computing environments

  • 8/11/2019 Cs2308 SS Lab Manual

    69/69

    i. Time sharing ii. 4tandAalone iii. )istributed