Function Name: Kbhit
function: Check the key that is currently pressed
Usage: int kbhit (void);
program Example:
#include
int main(void)
{
cprintf("Press any key to continue:");
while (!kbhit()) /* do nothing */ ;
cprintf("\r\nA key was pressed...\r\n");
return 0;
}
Function Name: Keep
Function: Exit and continue to reside
Usage: void Keep (int status, int size);
program Example:
/***note:
This is a interrupt service routine. You
Can not compile it with Test
Stack Overflow turned on and get an
Executable file which would operate
correctly. Due to the nature of this
Function The formula used to compute
The number of paragraphs may is not
Necessarily work in all cases. Use with
care! Terminate Stay resident (TSR)
Programs are complex and no other support
For the them is provided. Refer to the
MS-DOS Technical documentation
For more information. */
#include
/* The clock tick interrupt * *
#define INTR 0x1c
/* screen attribute (blue on grey) *
#define ATTR 0x7900
/* Reduce heaplength and stacklength
To make a smaller program in memory * *
extern unsigned _heaplen = 1024;
extern unsigned _stklen = 512;
void Interrupt (*oldhandler) (void);
void interrupt handler (void)
{
unsigned int (far *screen) [80];
static int count;
/* For a color screens the video memory
is at b800:0000. For a monochrome
System Use b000:000 * *
Screen = MK_FP (0xb800,0);
/* Increase the counter and keep it
Within 0 to 9 * *
count++;
Count%= 10;
/* Put the "number on the" screen * * *
SCREEN[0][79] = count + ' 0 ' + ATTR;
/* Call the old interrupt handler * *
Oldhandler ();
}
int main (void)
{
/* Get the "address" of the current clock
Tick Interrupt * *
Oldhandler = Getvect (INTR);
/* Install the new interrupt handler * *
Setvect (INTR, handler);
/* _PSP is the starting address of the
Program in memory. The top of the stack
Is the "End of" program. Using _ss and
_SP Together we can get the end of the
Stack. Want to allow a bit of
Saftey Insure that enough room
is being allocated ie:
(_ss + (_sp + safety Space)/16)-_PSP)
*/
Keep (0, (_ss + (_SP/16)-_PSP));
return 0;
}