| | |
Readin single character from keybard (linux/nasm)
Thread Solved |
I am attempting to write assembly code for linux using nasm. I have an include file containing io functions that was originally written for windows using masm and I am trying to convert it. I have on procedure that I am having problems with. The procedure is supposed to recieve on character of input from the keybard. The windows version only allow you to input one character. Once a key is pressed the program continues with out requireing you to press the enter key. The version I have modified does not do this. It requires you to press enter and when you do it acts as if it is reading two characters, I am assuming this is because it is reading the enter key as well as the character typed. This casues the program to exit and I get two prompts after it ends, as if I was at the prompt and just pressed enter. I am including the code below. Can anyone tell me how to remedy this?
Assembly Syntax (Toggle Plain Text)
;********************procedure to get char from keyboard******************* ;Given : variable to store to in esi ;Process : make linux system call to get character from keyboard. ;Returns : nothing ;Author : Jason T. Murphree ;************************************************************************ getChar: pushad ;save registers pushfd ;save flags mov eax, 3 ;sys_read(3) mov ebx, 0 ;stdin (0) mov ecx, esi ;string to store to mov edx, 1 ;number of bytes to read int 0x80 ;interupt for linux popfd ;restore flags popad ;restore registers ret ;return to calling procedure
You will need to tweak 'termios' to get non-buffered input to work. Read this thread for code and discussion of the issue:
http://sourceforge.net/mailarchive/f...la-stdlib-talk
Nathan.
http://sourceforge.net/mailarchive/f...la-stdlib-talk
Nathan.
while (CPU is present) {some assembly required}
![]() |
Other Threads in the Assembly Forum
- Previous Thread: Assembly Tutorial
- Next Thread: how to read from bootsecotr ??
| Thread Tools | Search this Thread |





