flat assembler
Message board for the users of flat assembler.

Index > Linux > How can I get char by char input with libc?

Author
Thread Post new topic Reply to topic
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 07 Apr 2010, 03:47
I don't want to use getchar because I want the function to accept one char and immediately return.
This is as far as I've got
Code:
 ..invalid_mode:
         push   [_stdin]
         call   [fgetc]
         add    esp,sizeof_pntr
         push   [_stdout]
         push   eax
         call   [fputc]
         pop    eax
         add    esp,sizeof_pntr
         cmp    al,-1 ; Anything other than -1 here causes an infinite loop
         jne    ..invalid_mode  
    

but it closes without waiting for input. It would also be useful to have a function that will accept the enter key and return 0xD or 0xA, is there one that does that?
Post 07 Apr 2010, 03:47
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 07 Apr 2010, 09:17
use read() or fread()
Post 07 Apr 2010, 09:17
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 08 Apr 2010, 03:52
Is there a way to do it in Fasmlib? Example?
Post 08 Apr 2010, 03:52
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 08 Apr 2010, 18:21
Hmm... I think I had stdin.read.byte or stdin.read.char (which was just a wrapper for generic stream.read.byte called with stream=stdin, which was wrapper for stream.read called with size=1).

Unfortunatelly I don't have copy of FASMLIB on this machine, so you won't get your example. But it should be easy enough to do yourself, in either libc or FASMLIB (note that I don't plan to do any further development on FASMLIB, so I don't really encourage people to use it anymore).
Post 08 Apr 2010, 18:21
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 08 Apr 2010, 21:21
vid wrote:

note that I don't plan to do any further development on FASMLIB

Sad to here that, from what I've read, it had potential to be really useful. I should warn you, as of ~1am last night, your wikipedia page on it was a day away from being deleted.
Post 08 Apr 2010, 21:21
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 09 Apr 2010, 08:37
Quote:
Sad to here that, from what I've read, it had potential to be really useful.

It solved some problems with using libc in assembly (also some general problems of libc), but IMO it wasn't that much. It was just somewhat more convenient than libc.

Quote:
I should warn you, as of ~1am last night, your wikipedia page on it was a day away from being deleted.

Not that I would give a damn, but I wonder why? Not enough relevance?
Post 09 Apr 2010, 08:37
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20630
Location: In your JS exploiting you and your system
revolution 09 Apr 2010, 10:37
vid wrote:
Not that I would give a damn, but I wonder why? Not enough relevance?
Well it seems to have been saved for now. But, vid, you gave NO references at all. From what I have seen at WP, without references people get nervous about it and are keen to delete.
Post 09 Apr 2010, 10:37
View user's profile Send private message Visit poster's website Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 09 Apr 2010, 19:22
It said it was being deleted for a conflict of interest, claiming that vid wrote it all. You could give a link to your flatassembler.net hosted site as a reference.
Post 09 Apr 2010, 19:22
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20630
Location: In your JS exploiting you and your system
revolution 09 Apr 2010, 22:52
Tyler wrote:
It said it was being deleted for a conflict of interest, claiming that vid wrote it all. You could give a link to your flatassembler.net hosted site as a reference.
A link like that would just prove the conflict of interest. But anyhow it doesn't now matter since the storm has passed.
Post 09 Apr 2010, 22:52
View user's profile Send private message Visit poster's website Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 15 May 2010, 11:12
Post 15 May 2010, 11:12
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.