I am trying to make a fully compatible getch() like function.
In Borland Turbo C++ and many other dos compilers, it is only dos compatible.
Why can't they make it more compatible?
However, it's entirely different between conio.h and curses.h.
Not even kbhit() is compatible with both unix and dos.
Does anyone know if such function exists?
If not, I have a piece of asm routine I made that is similar to getch().
Can someone help error check the asm code just in case I messed up somewhere?
I just don't know how to implement this into C.
Can anyone refer me to a very compatible getch() function or put the asm code into a union regs or something?
I've never done this before.
By the way, this is not my school assignment.
Maybe this is homework to some people but to me it is just personal curiousity (They don't even have CS/CIS courses in my school).
Here is the code:
Code:;asm LOOP: MOV AH, 01 ; triggers when key press is made INT 16H ; type JZ LOOP ; jump to "LOOP" if false ; otherwise: MOV AH, 0 ; retrieve value INT 16H ; type ; one problem: ; in C programming, a value is returned from a function. ; in this case, AL holds the ASCII value and AH holds the scan key value. ; how do I return the value from AL or AH? ; do I do something like this: "return AL;" at the end of function?