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?

;********************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

Recommended Answers

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/forum.php?thread_name=814462.63171.qm%40web65510.mail.ac4.yahoo.com&forum_name=hla-stdlib-talk

Nathan.

Jump to Post

All 2 Replies

Thanks, that is exactly what I needed

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.