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.
I've been toying with the idea of actually picking up assembly. I've been reading what I can find on the internet and playing with it a little, but I really haven't found anything beyond very basic training. Does anyone know a good free or non-free manual for Linux assembly using the nasm assembler.
There are several decent tutorials for 32 bit x86 assembler using NASM on Linux. Those can be found easily with Google.
I think you are better off learning the syntax of AS rather than the syntax of NASM.
If you have a 64 bit Linux, I think you are better off learning x86_64 assembler rather than 32 bit x86.
That info is quite a bit harder to find on the web than 32-bit, but it is enough more useful to learn that it is worth it.
In my opinion, the people who write asm tutorials waste so much time on obscurities needed for I/O and to be a stand alone program that most people never get to the more important parts of asm. Writing stand alone programs in asm is nearly worthless, even as a learning exercise. A much better learning exercise is writing functions in asm meant to be called via C interface from any language (such as C++) that can call C interface.
gcc is a great tool for learning how to write asm functions callable via C interface. Write a simple function in C and compile it to asm code rather than to a .o and look at the result. You can find a few threads at LQ where someone (sometimes me) has explained a gcc generated .s file, telling you which parts are extra decoration you don't really need in your own .s files and what the important parts mean.
You also need an instruction set reference manual for the architecture (x86 or x86_64). I downloaded that as a few pdf files from the AMD website long ago. I don't have a URL handy, but I expect AMD still gives away those pdf files.
For x86_64, the ABI (calling standard) is also important. Last time I looked, that pdf was free both from AMD and from some independent x86_64 standards group.
One of the benefits of learning asm can also be another training aid toward learning asm:
Some of the hardest bugs in programs in other languages are practical to debug only by using asm knowledge and using the debugger in asm mode.
I really hate direct use of gdb. I don't think it is practical for this purpose. But if you strongly prefer command line to GUI you might be OK with direct use of gdb.
I mainly do asm debugging of C++ programs on Windows. When I last did a lot of it on Linux, it was with Insight, which was a lot better than direct use of gdb but had quite a few problems. IIUC, Insight is barely supported at all. I think similar GUI asm debugging is available with CodeBlocks and other tools, but I'm not sure.
Anyway, if you have a usable asm mode debugger, step through some C code you understand, but in asm mode and learn some asm that way. Now try compiling optimized but with debug info and try to step through and understand. That might get a bit frustrating, but it is a powerful learning exercise.
Anyway, if you have a usable asm mode debugger, step through some C code you understand, but in asm mode and learn some asm that way. Now try compiling optimized but with debug info and try to step through and understand. That might get a bit frustrating, but it is a powerful learning exercise.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.