Recent Topics


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


  • Cyberian's

    ed68798f-18fe-4f13-97a5-5a6035004af5-image.png
    Semester: Spring 2019
    CS609: System Programming
    Graded
    Assignment No. 02
    Total Marks: 20

    Due Date: May 29, 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 write C program which will act like screen saver. Your program should display multiple characters i.e AAAAAAAAAA…… on whole screen then if 5 seconds elapses and no key is pressed then then the screen characters should be stored in an array and screen should be cleared with blanks. After that if any character from keyboard is pressed then it should recover the same characters i.e AAAAAAA…. on whole screen.
    Instructions:

    1. You should include all related header files first of all then declare interrupt pointer to hold Timer and Key i.e
      void interrupt (*oldTimer)(void);
      void interrupt (*oldKey)(void);
    2. Similarly, give prototype for new functions of newtimer() and newKey(); i.e
      void interrupt newTimer();
      void interrupt newKey();
    3. Declare a far pointer i.e *scr to hold far address =0xB8000000 and declare char array of 4000 i.e char charscr[4000];
    4. Store current vector values of INT 8 and 9 through getvect in oldTimer and oldKey.
    5. Set newTimer and newKey fuctions through setvect.
    6. In newTimer() function, give logic to wait for 5 seconds i.e t>=90 and store the screen characters i.e AAAAA… of all screen in char array of charscr[i] through loop. After that blank space should be displayed by setting keyboard status with black background i.e no character on screen i.e
      *(scr+i)=ox20;
      *(scr+i+1)=ox07;
    7. When any key is pressed from the keyboard, newKey() function should be called and all the screen characters i.e AAAAA … should again be recovered on whole screen using loop.
    8. *(scr+i)=charscr[i]

    Note: Your assignment file should be a single Word file (.doc or .docx).
    Sample Code:
    #include<stdio.h>
    #include<conio.h>
    #include<DOS.H>
    #include<BIOS.H>
    void interrupt (*oldTimer)(void);
    void interrupt (*oldKey)(void);
    void interrupt newTimer();
    void interrupt newKey();
    char far *scr=(char far *)0xB8000000;
    int i, t=0,m=0;
    char charscr[4000];
    void main()
    {
    clrscr();
    for(i=0;i<4000;i++)
    *(scr+i)=….
    oldTimer=……….
    oldKey=………….
    setvect(8,newTimer);
    setvect(9,newKey);
    getch();

    }
    void interrupt newTimer()
    {
    t++;
    if ((t>=91) && (m==0))
    {
    for(i=0;i<4000;i++)
    charscr[i]=…………
    for(i=0;i<4000;i+=2)
    {
    *(scr+i)=………;
    *(scr+i+1)=……………;
    }
    t=0;m=1;
    }
    (*oldTimer)();
    }

    void interrupt newKey()
    {

    if (m==1)
    {
    for(w=0;w<4000;w++)
    ……………………
    ……………
    }

    (*oldKey)();
    }

    Best of Luck!

    Spring 2019_CS609_2.docx



  • @zaasmi

    CS609
    Correct Solution:
    
    
    #include<conio.h>
    #include<BIOS.H>
    #include<stdio.h>
    #include<DOS.H>
    void interrupt (*oldTimer)(void); // To store current Timer vector
    void interrupt (*oldKey)(void);//  To store current KeyVector
    void interrupt newTimer();     //New Timer Function
    void interrupt newKey(); //New Key Function 
    char far *scr= (char far *)0xBS090200381; //Screen segment
    int i, t=0,m=0;
    char charscr[4000];       //Character Array
    void main()
    {
    	
        clrscr();
    for(i=0;i<4000;i++)
    *(scr+i)=0x41;  // Displaying A on whole screen
    oldTimer=getvect(8);
    oldKey=getvect(9);
    setvect(8,newTimer);
    setvect(9,newKey);
    getch();
    }
    void interrupt newTimer()
    {
    t++;
    if((t>=90) && (m==0))
    {
    	
    for(i=0;i<4000;i++)
    charscr[i]=*(scr+i);             //Storing all characters in array
     for(i=0;i<4000;i+=2)
      {
          *(scr+i)=0x20;            // Blank screen
          *(scr+i+1)=0x07;
       }
        t=0;
    m=1;
    }
    (*oldTimer)();
    }
     void interrupt newKey()
    {int w;
     if (m==1)
    {
    for(w=0;w<4000;w++)
        *(scr+w)=charscr[w];    // Recovering all characters on screen.
            m=0;}
       (*oldKey)(); 
       }
    
    
    
    

  • Cyberian's

    @moaaz 1:18: fatal error: conio.h: No such file or directory
    compilation terminated.



  • #include<conio.h>
    #include<BIOS.H>
               #include<stdio.h>
    #inlcude<DOS.H>
    void interrupt (*oldTimer)(*void); // To store current Timer vector
    void interrupt (*oldKey)(void);//  To store current KeyVector
    void interrupt newTimer();     //New Timer Function
    void interrupt newKey(); New Key Function 
    char far *scr= (char far *)0xB8000000; Screen segment
    int in, t=0,m=0;
    char scharscr[4000];       //Character Array
    void main()
    {
        clrscr();
    for(i=0;i<4000;i++)
    *(scr+i)=0x42;  // Displaying B on whole screen
    oldTimer=getvect(8);
    oldKey=getvect(9);
    setvect(8,newTimer);
    setvect(9,newKey);
    getch();
    }
    void interrupt newTimer();
    {
    t++;
    if((t>=90) && (m==0))
    {
    for(i=0;i<4000;i++)
    charscr[i]=*(scr+i);             //Storing all characters in array
     for(i=0;i<4000;i+=2)
      {
          *(scr+i)=0x20;            // Blank screen
          *(scr+i+1)=0x07;
       }
        t=0;
    m=1;
    }
    (*oldTimer)();
    }
     void interrupt newKey()
    {int w;
     if (m==1)
    {
    for(w=0;w<4000;w++)
        *(scr+w)=charscr[w];    // Recovering all characters on screen.
            m=0;}
       (*oldKey)(); }
    

Log in to reply
 

  • Tech News

    Tech News posts from individual members

  • Virtual University

    Virtual University Assignment Discussion and Solution, Quiz Discussion and Solution, GDB discussion and Solution, Solved Mid Term Past Paper, Solved Final Term Past Paper

  • DigiSkills

    E-Commerce Management, SEO (Search Engine Optimisation), Digital Marketing, Freelancing,

Online Users

Use "cyberian" Promo Code Get 20% off

| |