CS609 Assignment No. 1 Solution and Discussion

Semester: Fall 2019

CS609: System Programming
Graded
Assignment No. 01 Total Marks: 20

Due Date: Nov 11, 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
• BIOS data area.
• TSR program
• Calling interrupt functions

For any assignment related query, contact at

Problem Statement:
You are required to write a C program using interrupt 21H to print 3 string arrays i.e “Virtual University of Pakistan”, your own Student Name and father name. Your program should intercept the timer interrupt to call a function name “ScrollLock” to switch on the ScrollLock on the keyboard when the timer interrupt 8h occurs.
Instructions:

  1. Declare 3 character strings st1,st2,st3 having Values, Virtual University of Pakistan, your own Student Name and Father Name respectively.
  2. In this program, you will implement interrupt 21H to print the character string values on the top.
  3. Place service number 0x09 in AH register and String in DX to print strings.
  4. You should save interrupt 8H vector in a pointer to vector variable name old through getvect() instruction.
  5. Call any new function called i.e ScrollLock( ) through setvect instruction.
  6. Use keep() function to make this program TSR.

Note: Your assignment file should be a single Word file (.doc or .docx)

Solution:

//Header Files
#include<stdio.H>
#include<BIOS.H>
#include<DOS.H>
#include<conio.H>
void interrupt (*old)(); //To store current interrupt
void interrupt ScrollLock();  //NewInt prototype
char far *scr=(char far*)0x00400017;
char str1[80]={“Virtual University of Pakistan$”}  
char str2[80]={“Muhammad Saeed $”}
char str3[80]={“Saeed Akhtar$”}

void main()
{
clrscr();
_AH=0x09;         //Service Number
  _DX=(unsigned int)st1;      // Register for output.
  geninterrupt(0x21);
  _DX=(unsigned int)st2;      // Register for output.
  geninterrupt(0x21);
  _DX=(unsigned int)st3;      // Register for output.
  geninterrupt(0x21);
old=getvect(0x08); // Keep vector of current INT
setvect(0x08,ScrollLock); //setting to new INT
keep(0,1000);
}
void interrupt ScrollLock()
{ 
 *scr=16;
(*old)();
}

Solution:

//Header Files
#include<stdio.H>
#include<BIOS.H>
#include<DOS.H>
#include<conio.H>
void interrupt (*old)(); //To store current interrupt
void interrupt ScrollLock();  //NewInt prototype
char far *scr=(char far*)0x00400017;
char str1[80]={“Virtual University of Pakistan$”}  
char str2[80]={“Muhammad Saeed $”}
char str3[80]={“Saeed Akhtar$”}

void main()
{
clrscr();
_AH=0x09;         //Service Number
  _DX=(unsigned int)st1;      // Register for output.
  geninterrupt(0x21);
  _DX=(unsigned int)st2;      // Register for output.
  geninterrupt(0x21);
  _DX=(unsigned int)st3;      // Register for output.
  geninterrupt(0x21);
old=getvect(0x08); // Keep vector of current INT
setvect(0x08,ScrollLock); //setting to new INT
keep(0,1000);
}
void interrupt ScrollLock()
{ 
 *scr=16;
(*old)();
}

CS609 Assignment 1 Solution Idea!..

#include<BIOS.H>
#include<DOS.H>
char st1[80] ={"Virtual University of Pakistan$"};
char st2[80] ={"Washi Ali$"};
char st2[80] ={"Tufail$"};
void interrupt (*oldint65)( );
void interrupt newint65( );
void main()
{
oldint65 = getvect(0x65);
setvect(0x65, newint65);
keep(0, 1000);
}
void interrupt newint65( )
{
switch (_AH)
{
case 0:
_AH = 0x09;
_DX = (unsigned int) st1;
geninterrupt (0x21);
break;
case 1:
_AH = 0x09;
_DX = (unsigned int) st2;
geninterrupt (0x21);
break;
case 2:
_AH = 0x09;
_DX = (unsigned int) st3;
geninterrupt (0x21);
break;
}
}
}```

CS609 assignment #1 solution
Please check handout example on pg #26.

04 - TSR programs and Interrupts