ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Thank you. I didn't saw result message in terminal because there is no '\n' in the message text. Program works. With .string I have 18 in RAX result (do you mean it?). Where did you found the error code description?
error codes are negative of errno. Positive in %rax means it worked, returning the number of characters written.
The errno values are (eventually - includes that include includes, that include includes...) in:
/usr/include/asm-generic/errno-base.h
/usr/include/asm-generic/errno.h
man 2 write, gives explanation of the various returns that sys_write may give.
Thank you. I didn't saw result message in terminal because there is no '\n' in the message text.
I spotted this immediately. Standard output is buffered, and typically only flushed when you output a line feed. The writes (EDITING TO CLARIFY: as in the actual display of characters on the screen) happen during flushes.
libc's stdout FILE stream is certainly buffered, so you might need to fflush(stdout) in some C programs, but for a asm program making a direct call of the write(2) syscall writing to the tty on FD 1, I believe the write is unbuffered and therefore you don't need to flush/fsync. (someone please correct me if I'm wrong here).
You usually only use fsync() when you need to be sure something has gotten to disk before continuing, such as writing data to disk files, and even then you normally only do it when your program needs to periodically checkpoint or when you're done with the file and are about to close the FD.
If you are learning assembler just for fun, then maybe do it for old computers, like the c64, spectrum and co.
Why? Because, at least in my opinion, at this current point in time it is incredibly unlikely for you to do things faster than the established compilers for C, C++ etc when it comes to the PC.
This is also true for the C64 et al, yes, people have been hacking these things for 40+ years now, but you get to play with awesome things like sid chips, vic chips, actual limitations to gauge your skill in making things lightweight against, and you also have more or less a faster product cycle.
I wish I could have posted this without bumping. I could have private messaged you, yes, but I also think that assembler is really not very much needed these days, as in, highly diminishing returns, and I think that anyone should be at least somewhat aware of this.
Even arduinos and co are mostly programmed with C, etc, these days.
My post is not intended to rain on your parade or anything, but, on the offchance that you're just chasing that assembler feeling, why not go with something that has, at least, again, in my opinion, a more fun yield.
Plus, it can still be lucrative! The "8bit-guy" made a C64 game recently and I think it sold rather well. I doubt a program, or game written in assembler has that kind of marketability on the PC these days.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.