Link to home
Start Free TrialLog in
Avatar of pan_kaj
pan_kaj

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of kamarey
kamarey

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nadt
nadt

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
Avatar of pan_kaj

ASKER

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 ?