C language function Daquan (k start)

Source: Internet
Author: User
Tags continue count int size

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;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.