• C

Keyboard buffer

How can I feed an ascii code in the keyboard buffer
using Turbo-C (MS-DOS) platform ?
The software should interpret as if the keyboard has
been pressed
pan_kajAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kamareyCommented:
Use function int peek(address,offset) to get values from memory.

40:001a,2-bytes. Addr of keyboard buffer head (keystroke at that addr is next).
40:001c,2-bytes. Address of keyboard buffer tail.
40:001e,32-bytes. Keyboard buffer.  BIOS stores keystrokes here (head and tail point to addresses from 041eH to 043dH inclusive).

But i didn't tested if it work.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nadtCommented:
This solution is in assembly language.  It is assumed that as you are asking question in C you are familiar with assembly.

mov ah,3fh; {function 3fh of dos interrupt}
mov bx,0;{handle for standard input}
mov cx,80h;{Maximum bytes to read}
mov dx,seg buffer;{DS:DX Buffer address}
mov ds,dx;
mov dx,offset buffer;
int 21h;

what essentially u're doin' in this is that opening the console as a file.  Embed this code in C as some function.
Don't forget to add _asm before you write the declarations.
nadt
0
pan_kajAuthor Commented:
The answer proposed by kamarey is very cryptic and I am
unable to understand it.

I will appreciate a function which accepts an ASCII char as an
input and puts it in keyboard buffer something like given below:

void put_kb_buffer(char a)
{




   return;
}

Will somebody help ?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.