I am prigramming in assembly Language, x86 in C++ and I need to know the getch equivalent in assembly language instead of C++ language as I dont want to use any function from the C++ programming language.
I found the code on the web but it saves the given value to a variable and created in C++. I want to use the function only to stop the program until any key is pressed. I dont have to use the entered key value in further programming.
This is an OS-specific question. For example if you’re using Linux, you can issue a
readsystem call like this:This is actually the more antiquated way to issue a syscall on x86 Linux, but it’s the one I know off the top of my head. There’s also
sysenterwhich is faster. And there is a shared library mapped into every process that abstracts the syscall interface based on what your hardware supports. (linux-gate.so.)As a matter of taste, I would argue against the approach of doing system calls from assembly language. It is much simpler to do it from C. Call into the assembly code (or produce inline assembly) for the stuff that absolutely needs to be in assembly language. But in general for most practical matters you will find it better not to waste your time talking to OS interfaces in assembly. (Unless it’s a learning exercise, in which case I’m all for it.)
Update: You mentioned as a comment to @Anders K. that you are writing something to put on the MBR. You should have mentioned this earlier in the question. One approach is to use a BIOS call: I believe the one you want is
int 16hwithah=0. Another would be to install a keyboard interrupt handler. Here’s what the BIOS call would look like: