How Write a TSR (Terminate and Stay Resident) program, by using interrupt 65H in C

Vu Old Solved Programming Based Assignments Codes are Available in this Section.
Post Reply
User avatar
ALI RAZA
★★★★★★★★★★★★★
★★★★★★★★★★★★★
Posts: 177
Joined: Fri Dec 22, 2017 8:10 am
Location: Lahore
Has thanked: 6 times
Been thanked: 7 times
Contact:
Status: Offline

How Write a TSR (Terminate and Stay Resident) program, by using interrupt 65H in C

Post by ALI RAZA » Tue Jan 15, 2019 1:26 pm

Write a TSR (Terminate and Stay Resident) program, by using interrupt 65H, that will print course code i.e. CS609 when 0 is pressed by the user from keyboard, course name i.e. System Programming when 1 is pressed by the user and print Virtual University of Pakistan when 2 is pressed from Keyboard.
Detailed Instructions:
In this program, you will implement interrupt 65H which is currently not used by operating system.
Interrupt 65H function must check for Service Number – if service number is 0, course code will be printed and if service number is 1, full name of the course will be displayed. In order to implement this, place service number in AH register. Interrupt 65H will check its value and will perform relevant function.
Course Code or course name must be printed at the beginning of monitor text memory area, 0xb8000000
Calculate Attribute Byte for both course code and course name according to the following criteria:
Text blinking: No
Background color: White
Foreground color: Black
Bold text: No
Visit this link: https://ascii.cl/ for complete ASCII table. This table is also available in the Downloads section of LMS.
Use keep() function to make this program TSR.
After writing interrupt 65H, write a test function which will take input from user (for example: Enter 0 for printing course code, 1 for printing Name of course and 2 for printing Virtual University of Pakistan), place relevant service number in AH register, and generate interrupt function. You may use switch statement for this.
Your assignment file should be a single Word file (.doc or .docx) containing:
Complete interrupt function (both services must be implemented)
Test function to generate interrupt as given in instruction # 7
You can use Consolas font for enhancing readability of the code in Word file.
Note:
You should NOT use interrupt 21/09H to display Student ID or Name. It must be displayed only by accessing monitor text memory area.
Best of Luck!
Problem Solution:

Code: Select all

 



// Implementing interrupt 65H
#include<BIOS.H>
#include<DOS.H>

unsigned int far *scr = (unsigned int far *) 0xb8000000;
void interrupt (*oldint65)();
void interrupt newint65();

void main() {
	
	oldint65 = getvect(0x65);
	setvect(0x65, newint65);
	keep(0, 1000);
}
void interrupt newint65() {

	if((_AH) == 0) { // Printing Course Code. Attribute Byte is 01110000 or 70H
		(*scr) = 0x7043;         // C
        	(*(scr + 1)) = 0x7053;   // S
        	(*(scr + 2)) = 0x7036;   // 6
        	(*(scr + 3)) = 0x7030;   // 0
        	(*(scr + 4)) = 0x7039;   // 9

	  	outportb(0x20, 0x20); // sending EOI to PIC
	  	return;
	}
	else {
		if((_AH) == 1) { // Printing Course Name
			(*scr) = 0x7053;         // S
        		(*(scr + 1)) = 0x7079;   // y
        		(*(scr + 2)) = 0x7073;   // s
        		(*(scr + 3)) = 0x7074;   // t
        		(*(scr + 4)) = 0x7065;   // e
        		(*(scr + 5)) = 0x706D;   // m
        		(*(scr + 6)) = 0x7020;   // Space
                  (*(scr + 7)) = 0x7050;   // P
                  (*(scr + 8)) = 0x7072;   // r
                  (*(scr + 9)) = 0x706F;   // o
                  (*(scr + 10)) = 0x7067;   // g
                  (*(scr + 11)) = 0x7072;   // r
                  (*(scr + 12)) = 0x7061;   // a
                  (*(scr + 13)) = 0x706D;   // m
                  (*(scr + 14)) = 0x706D;   // m
                  (*(scr + 15)) = 0x7069;   // i
                  (*(scr + 16)) = 0x706E;   // n
                  (*(scr + 17)) = 0x7067;   // g

			outportb(0x20, 0x20); // sending EOI to PIC
	  		return;
		}
	}
else {
		if((_AH) == 2) { // Printing Virtual University
			(*scr) = 0x7056;         // V
        		(*(scr + 1)) = 0x7069;   // i
        		(*(scr + 2)) = 0x7072;   // r
        		(*(scr + 3)) = 0x7074;   // t
        		(*(scr + 4)) = 0x7075;   // u
        		(*(scr + 5)) = 0x7061;   // a
        		(*(scr + 6)) = 0x706C;   // l
                  (*(scr + 7)) = 0x7020;   // Space
                  (*(scr + 8)) = 0x7055;   // U
                  (*(scr + 9)) = 0x706E;   // n
                  (*(scr + 10)) = 0x7069;   // i
                  (*(scr + 11)) = 0x7076;   // v
                  (*(scr + 12)) = 0x7065;   // e
                  (*(scr + 13)) = 0x7072;   // r
                  (*(scr + 14)) = 0x7073;   // s
                  (*(scr + 15)) = 0x7069;   // i
                  (*(scr + 16)) = 0x7074;   // t
                  (*(scr + 17)) = 0x7079;   // y

			outportb(0x20, 0x20); // sending EOI to PIC
	  		return;
		}
	}

}


// Test function to take user input and generate interrupt
#include<BIOS.H>
#include<DOS.H>
#include<stdio.h>

void main() {

	int i;

   	printf( "Enter 0 for printing Student ID or 1 for printing Student name :");
   	scanf ("%d", &i);

	switch(i) {
		
		case 0:
		_AH = 0;
		geninterrupt(0x65);
		break;

		case 1:
		_AH = 1;
		geninterrupt(0x65);
		break;

            case 2:
		_AH = 2;
		geninterrupt(0x65);
		break;

		default:
		printf("You have entered an invalid number. Exiting the program...");
	}
}
	
	 



Post Reply

Last 10 Members Who Visited This Topic

User avatar ALI RAZA (2)

  • Similar Topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 1 guest