I would like to know if it's possible to write a function for C++ using 32bit inline asm in order to get unbuffered input. I was able to use 16 bit asm on my dos compiler, but using the same call locks up all of my win32 compilers such as Code Warrior, VC6, and Dev C

My 16 bit code was something like

unsigned short GETCH(void)
unsigned short raw;

mov ah,0x10
mov raw,ax
int 0x16

return raw;

From there I would process the scan code to do what task that I needed. I cannot get unbuffered input at all using standard c++. Could someone explain why this code won't work with 32 bit compilers or possibly provide a snippit of inline code that I could use with the aforementioned compilers.

The apps are all console.

Posted on 2003-01-27 23:58:47 by pseudocoder
Check out the following of Win32 APIs:

If you have to use DOS interrupt, either you can use VWIN32 VxD (but I don't know if it supports keyboard interrupt.) or you have to code it in old 16-bit way.
Posted on 2003-01-28 00:09:29 by Starless
That should read 1 character from console in AL (ebx holds handle for STDIN):

invoke GetConsoleMode ebx, addr oldstate
invoke SetConsoleMode ebx, 0
push 0
mov edx, esp
push 0
mov ecx, esp
invoke ReadConsole ebx, ecx, 1, edx, 0
invoke SetConsoleMode ebx, oldstate
pop ecx
pop edx
and eax,eax
jz @F
movzx eax,cl
Posted on 2003-01-28 05:10:17 by japheth
Thanks to you both for the feedback. I'll give the info a try.
Posted on 2003-01-28 13:45:13 by pseudocoder