KeyB typeahead buffer in BIOS

S

Sree

Hello Friends,

i was trying to read the Keyboard typeahead buffer from BIOS
according to its address.
But i'm not able to get the data.
Please tell me how to do so.

void main()
{
char far *p=(char* far)(0x0040001E);
int i=0;
clrscr();

for(i=0;i<32;i++)
printf("\n%4d %c",(*(p+i)),*(p+i));
getch();
}

i tried using a "near" pointer too. But not working!
 
V

Vladimir Oka

Sree opined:
Hello Friends,

i was trying to read the Keyboard typeahead buffer from BIOS
according to its address.
But i'm not able to get the data.
Please tell me how to do so.

You're missing at least some #include files:

/* for `printf()` */
#include <stdio.h>

and (I may be wrong here):

/* for non-Standard stuff */
#include said:
void main()

This should be:

int main(void)

or

int main(int argc, char *argv[])
{
char far *p=(char* far)(0x0040001E);
int i=0;

No need to initialise here, as you do it below anyway.
clrscr();

Why does everybody seem to want to clear the screen for no good reason
whatsoever?
for(i=0;i<32;i++)
printf("\n%4d %c",(*(p+i)),*(p+i));

You need to terminate `printf()` with a '\n' (or do a `fflush(stdout)`)
if you want to be sure anything (on the last line) is displayed.

There's a perfectly standard `getchar()` for this (it may require you
to press ENTER as well, though).
}

i tried using a "near" pointer too. But not working!

What exactly is not working?

The above shouldn't compile at all (see my comments), but I guess you
just did not get the numbers you expected.

Anyway, your question is system specific (DOS I believe), an here we
discuss only standard C, so you're much better off asking elsewhere.

comp.os.msdos.programming

may be a good starting place.


--
if (argc > 1 && strcmp(argv[1], "-advice") == 0) {
printf("Don't Panic!\n");
exit(42);
}
(Arnold Robbins in the LJ of February '95, describing RCS)

<http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>
 
R

Rod Pemberton

Sree said:
Hello Friends,

i was trying to read the Keyboard typeahead buffer from BIOS
according to its address.
But i'm not able to get the data.
Please tell me how to do so.

void main()
{
char far *p=(char* far)(0x0040001E);
int i=0;
clrscr();

for(i=0;i<32;i++)
printf("\n%4d %c",(*(p+i)),*(p+i));
getch();
}

i tried using a "near" pointer too. But not working!

My references indicate the keyboard buffer is at segment:eek:ffset 0040h:001Eh.
This is a 20bit address representation. The segment is shifted four bits:
0x0040<<4=0x0400 and added to the offset 0x001E. The physical address is
0x0000041E. However, you probably want to look for a macro which creates
the proper address for you called MK_FP.

p=MK_FP(0x0040,0x001E);


Rod Pemberton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top