CS609: System Programming Graded Assignment No. 01 Solution and Discussion


  • Cyberian's Gold

    ![0_1557822319583_5fab6ed2-204d-438f-92b4-530de1925001-image.png](Uploading 100%)
    Semester: Spring 2019
    CS609: System Programming
    Graded
    Assignment No. 01
    Total Marks: 20

    Due Date: May 13, 2019

    Instructions:

    Please read the following instructions carefully before submitting assignment. It should be clear that your assignment will not get any credit if:

    ♣ The assignment is submitted after due date.
    ♣ The submitted assignment does not open or file is corrupt.
    ♣ You have not followed steps described in Detailed Instructions of the problem statement.
    ♣ Assignment is copied (partial or full) from any source (websites, forums, students, etc.) Strict action will be taken in this regard.

    Note: You have to upload only .doc or .docx file. Assignment in any other format (extension) will not be accepted and will be awarded with zero marks.

    Objectives:

    The objective of this assignment is to provide hands-on experience of System Programming concepts including:

    • How can interrupts be generated
    • What are Interrupts
    • Interrupt functions writing
    • TSR program
    • Calling interrupt functions

    For any assignment related query, contact at [email protected]

    Problem Statement:
    You are required to writ C program using interrupt 65H to print your own Student ID, Name or your Study Program depending upon the number input i.e 1,2,3 respectively. When the user enters 1 it will print your own Student ID, if 2 then print your own Name and finally, if the user enters 3, it will print your Study Program.
    Instructions:

    1. Declare 3 character strings st1,st2,st3 having Student ID, Name and Study Program
    2. You should save interrupt 65H vector in a pointer to vector variable name oldint65 through getvect instruction.
    3. Call any new function i.e newint65( ) through setvect instruction.
    4. Through printf instruction, show message “What you want to print: Press 1,2,3= ” i.e
      printf(“What you want to print: Press 1,2,3= ”);
    5. Then use scanf to take input input in an integer variable i.e scanf(“%d”, &i)
    6. In this program, you will implement interrupt 65H which is currently not used by operating system.
    7. Place service number in AH register. Interrupt 65H will check its value and will perform relevant function.
    8. Interrupt 65H function must check for Service Number using Switch Statement. In Case of Service Number 1, it should print Student ID i.e BC123456 and in case of Service Number is 2, it should print your own full name i.e Ali Ahmad. Similarly your study program i.e BS/MCS etc should be printed in case of number 3.
    9. Use keep() function to make this program TSR.

    Note: Your assignment solution will be in this Word file (.doc or .docx) containing code of C only as given in sample solution:

    Best of Luck!

    Sample Solution:

    //Header Files
    #include<stdio.H>
    #include<BIOS.H>
    #include<DOS.H>
    #include<conio.H>
    void interrupt (*oldint 65)(); //To store current interrupt
    char str1[80]={“BC123456$”}  // Write your own particulars
    char str2[80]={“Ali Ahmad$”}
    char str3[80]={“Degree Program:  BS$”}
    int i;
    void interrupt newint65(void);  //NewInt prototype
    void main()
    {
    // Keep vector of current INT
    //setting to newint65
     clrscr();
    printf(“What you want to print: Press 1,2,3=>”);
    scanf(“%d”,&i);
    _AH=i;
    getch();
    }
    void interrupt newint65()
    { 
    switch(i)
    {
      case 1:
               //Service Number
      // Register for output.
      break;
     }
     case 2:
       
       break;
     }
     case 3:
       
       break;
     }
     default:  {  }
    }
    

  • Cyberian's

    #include<stdio.h>
    #include<fcntl.h>
    #include<io.h>
    #include<DOS.h>
    void interrupt *newint65(void);
    int a = {"my id "};
    void interrupt newint65(void);
    printf("press 0 for student Id ",y)
    unsigned char far *scr=(unsigned char far*)0xb8000000;
    //corrected
    void main()
    {
    int i; //instruction added
    for (i=0;i<2000;i++) //corrected
    {
    *scr=0x20; //corrected
    *(scr+1)=0x07; //corrected
    scr=scr+2;
    }
    }
    void main()
    {
    oldint65 = getvect(0x65);
    setvect(0x65, newint65);
    geninterrupt (0x65);
    geninterrupt (0x65);
    geninterrupt (0x65);
    setvect(0x65, oldint65);
    }
    void interrupt(*newint65)( )
    {
    _AH = 0x09;
    _DX=(unsigned int)st;
    geninterrupt (0x21);
    }
    

  • Cyberian's

    #include<stdio.H>
    #include<BIOS.H>
    #include<DOS.H>
    #include<conio.H>
    char str1[80]={“bs012345678$”}
    char str2[80]={“your name$”}
    char str3[80]={“Degree Program: BSCS$”}
    void interrupt (*oldint 65)();
    void interrupt newint65(void);
    keep(0,1000);
    int i;
    void main()
    {
    oldint65 = getvect(0x65);
    setvect(0x65,newint65);
    clrscr;
    printf(“What you want to print: Press 1, 2 or 3: ”);
    scanf(“%d”,&i);
    _AH=i;
    geninterrupt(0x65);
    getch();
    }
    void interrupt newint65()
    {
    switch(i)
    case 1:
    _AH = 0x09;
    _DH = (unsigned int) st1;
    geninterrupt (0x21);
    break;
    case 2:
    _AH = 0x09;
    _DH = (unsigned int) st2;
    geninterrupt (0x21);
    break;
    case 3:
    _AH = 0x09;
    _DH = (unsigned int) st3;
    geninterrupt (0x21);
    break;
    default:
    printf(“You did not entered any valid option”);
    }
    

Log in to reply
 

    Recent Topics


  • 1
  • 4
  • 1
  • 3
  • 15
  • 2
  • 4
  • 2
|