Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help Language is C. write a Terminate and Stay Resident program that will

ID: 3618389 • Letter: P

Question

Please help Language is C.
write a Terminate and Stay Resident program that will display yourName and VU ID (ABC, xC0xxxxxxxx) in the centre of the blankscreen after 5 seconds (only if no operation is performed for 5sec) and whenever Alt+Ctrl+Q is pressed your program should restorethe previous screen (i.e. screen before displaying your id andname). Please help Language is C.
write a Terminate and Stay Resident program that will display yourName and VU ID (ABC, xC0xxxxxxxx) in the centre of the blankscreen after 5 seconds (only if no operation is performed for 5sec) and whenever Alt+Ctrl+Q is pressed your program should restorethe previous screen (i.e. screen before displaying your id andname).

Explanation / Answer


"Don't forget to change your ID in code" #include <dos.h>
#include <conio.h>

void interrupt (*oldTimer)(void);
void interrupt (*oldKey)(void);
void interrupt newTimer ( );
void interrupt newKey ( );
void clearScreen(void);
void printInfo(int);

char far *scr = (char far* ) 0xB8000000; //Address of videomemory.
char far *kbd = (char far* ) 0x00400017; //Keyboard statusbyte.

int i, t = 0, m = 0;

char charscr [4000];


void main( )
{

oldTimer = getvect(8); //Save the old timer routine in oldTimer(interrupt function pointer)
oldKey = getvect (9); //Save the old keyboard routine in oldKey(interrupt function pointer)

setvect (8,newTimer); //Replace the functionality of orginalroutine with new one.
setvect (9,newKey);

keep(0,1000); //Making this program TSR

getch();
getch();

}

//This function will be invoked after every 1/18.2 th ofsecond.
void interrupt newTimer ( )
{
t++;
if((t >= 91) && (m == 0))
{
for (i =0; i < 4000; i ++)
{
charscr [i] = *(scr + i); //Save the original screen into charscr[]array
}
m=1;
}

if (t >= 91 && m == 1) //Check if 5 seconds havepassed.
{
clearScreen();
printInfo(1990);
}


(*oldTimer) ( );
}


void clearScreen()
{
int i;

// Write the spaces with withe back color in whole screen

for (i =0; i <=4000; i +=2)
{

*(scr + i) = 0x20; //ASCII code of space key
*(scr + i + 1) = 0x70; //Means white fore colr and black backcolor

}

}



void printInfo(int i)
{

*(scr + i) = 0x41;
*(scr + i + 1) = 0x70;
i+=2;

*(scr + i) = 0x42;
*(scr + i + 1) = 0x70;
i+=2;

*(scr + i) = 0x43;
*(scr + i + 1) = 0x70;
i+=2;

*(scr + i) = 0x28;
*(scr + i + 1) = 0x70;
i+=2;

*(scr + i) = 0x42; // ASCII code of 'B'
*(scr + i + 1) = 0x70; // Means Black fore colr and White backcolor
i+=2;


*(scr + i) = 0x43; // ASCII code of 'C'
*(scr + i + 1) = 0x70;
i+=2;


*(scr + i) = 0x30; // ASCII code of '0'
*(scr + i + 1) = 0x70;
i+=2;


*(scr + i) = 0x30;
*(scr + i + 1) = 0x70;
i+=2;


*(scr + i) = 0x30;
*(scr + i + 1) = 0x70;
i+=2;


*(scr + i) = 0x30;
*(scr + i + 1) = 0x70;
i+=2;

*(scr + i) = 0x30;
*(scr + i + 1) = 0x70;
i+=2;


*(scr + i) = 0x30;
*(scr + i + 1) = 0x70;
i+=2;


*(scr + i) = 0x30;
*(scr + i + 1) = 0x70;
i+=2;


*(scr + i) = 0x30;
*(scr + i + 1) = 0x70;
i+=2;

*(scr + i) = 0x30;
*(scr + i + 1) = 0x70;


}

void interrupt newKey ( )
{
int w;

if (inportb(0x60)==0x10 && m==1 && (((*kbd)&12)==12 ))
{

for (w =0; w < 4000; w ++)
{
//Restoring the original screen
*(scr + w) = charscr [w]; // Whenever Alt+Ctrl+Q is pressedoriginal screen will be restored

}
m = 0;
t = 0;
}
(*oldKey) ( );

}