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.
Even if you will never write a useful line of asm code, learning to code in asm with an OS, is a valuable skill that will improve the quality of your programming in languages like C++ as well as your skill at debugging.
Learning to code in asm without an OS would mostly be useful if you intend someday to write or significantly modify an OS. (I myself have done so, but don't expect to do so again).
Coding and debugging C++ is a more commonly useful skill than modifying an OS. So asm with an OS is more relevant knowledge than asm without an OS.
What johnsfine says is all true, but ignores that there are other architectures than X86 Linux. There are many architectures for which assembly is either the best or only choice, as well as other architectures which are easier to learn and experiment with. Many of these are supported with emulators such as Qemu, which further simplifies the process (overlooking a small amount of initial setup pain, maybe).
It think it bears emphasizing that there is a difference between learning a CPU instruction set, and learning assembly language programming. Much of the idiom of assembly language programming is transportable across CPUs. Even though the instruction sets may vary, the concepts are fairly consistent, and simply understanding how low level language constructs compare to relatively higher level languages is a valuable piece of knowledge.
I would tend to put more emphasis on interfacing assembly language to a high level language compiler, than to an OS. I say this as a matter of pragmatism, as well as a matter of academics. Being able to code a function/subroutine in assembler, and understanding the use of the interface to a high level language is not significantly unlike the interface to an OS. On many architectures, there is no OS, but there may well be a C compiler, or other compiler. It may also be useful to code in assembler for such things as optimization of code (I know GNU C is hard to beat, but not all compilers are GNU C), or to access hardware in ways not supported by a high level language.
I say all of this to suggest that MTK358 examine the real reason(s) for wanting to learn assembler coding, and base his choice of training architecture on his needs/wants, more than on what future there is in assembly language for Linux X86.
For example, the original PC keyboard had a microcontroller (I think I8039, don't remember already) and all the firmware was written in assembly. Probably still is - the keyboard remains remarkably the same - a few added keys don't count, key matrix is simply scanned.
Also, compilers are still either terrible or don't even try to use SSE. Even though there's a huge win *just by treating the SSE or MMX registers like really fast memory*.
I believe MMX can be ignored as an obsolete predecessor of SSE. But I never used MMX much even when it wasn't obsolete, so I'm not certain there aren't a few useful features one might still want despite having SSE to use instead.
In addition to being SIMD, SSE is also the better way to do ordinary floating point operations.
X86 (modern CPUs) and X86_64 (all CPUs) have two entirely separate floating point instruction sets, a legacy floating point instruction set and an SSE floating point instruction set.
GCC in X86 defaults to using Legacy. GCC in X86_64 defaults to using SSE. SSE is usually better. That is often the reason a 64 bit application runs faster than a 32 bit application.
I believe an asm programmer can use either or both floating point instruction sets (but I switched to SSE long ago and haven't used Legacy floating point in asm since).
Also, compilers are still either terrible or don't even try to use SSE. Even though there's a huge win *just by treating the SSE or MMX registers like really fast memory*.
They are not that terrible; there are vendor supplied performance libraries using SIMD; I am using certain SIM-based routines coded in pure "C", and they do perform better than equivalent generic ones.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.