flat assembler
Message board for the users of flat assembler.

Index > Linux > [Question] CRLF in read line

Author
Thread Post new topic Reply to topic
ramc



Joined: 08 Jul 2008
Posts: 1
Location: Colombia
ramc 24 Aug 2008, 18:50
Hi everybody, my question is about console input with carry return and line feed. For example:

I read a line with:
Code:
  mov eax, 3
  mov ebx, 0
  mov ecx, str
  mov edx, 0x100
  int 0x80    

But if I will like print the read text and the CRLF, do I need create a new string with 0D and 0A? and print or Do I can add somehow the CRLF to str?

Thanks for your answers and sorry for my english.

I hope you understand my question.
Post 24 Aug 2008, 18:50
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 24 Aug 2008, 22:12
In linux, it is just 0xA, no 0xD. You can either add it to end of buffer (careful with overflows), or print string and then print the 0xA character.
Post 24 Aug 2008, 22:12
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Endre



Joined: 29 Dec 2003
Posts: 215
Location: Budapest, Hungary
Endre 28 Aug 2008, 14:32
vid is right. syscall "read" returns character count read in eax. So you might have to add something like this:

Code:
mov word [str + eax], 0x000d    


0x0d for new line and 0x00 for string end (note byte order!)
of course you have to ensure that you don't over-index str. For instance you may set edx to max_str_length - 2 before invoking "read".
Post 28 Aug 2008, 14:32
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.