Hacker News new | ask | show | jobs
by majika 4478 days ago
This seems like a great start, but it's lacking something that every assembly programming resource that I've ever come across lacks too:

How can I experiment?

How do I go from instructions in a text file, to compiling, to getting input in some form? What programs do I use (on Linux)? What commands do I run? What are fun projects that are worthwhile doing with assembly?

Beyond that, what are good applications of assembly in general? Where should I use it in my day-to-day development projects? Where can I read about best practices? Where can I find good examples of x86_64 assembly programming?

It's really easy to merely describe the instructions, the registers, the mapping from compiled procedural languages - but I feel like that information is superficial so long as you don't tell us how to apply it.

2 comments

You might like the assembly tutorial I am writing: https://plus.google.com/111794994501300143213/posts/9gxSUZMJ...

It's focused on actually doing rather than how stuff works. In order to succinctly be able to present this, I had to choose a target platform, which unfortunately seems not to be the one that you prefer.

My tutorial targets OS X, and there is great similarity between coding assembly on OS X and Linux. The tutorial does not spend much time pointing out these similarities, and you unfortunately don't get sensible error messages if you make mistakes. Never the less, you might want to try :)

It would be cool if someone made a VM for development only, on which you could run x86_64 assembly, and get sensible error messages.
Qemu comes pretty close. You can dump register and memory values, crashes outputs useful dumps, etc.
"the overly abstract world of C" I chuckled at that. Looks like you have a fun tutorial though; I'd like to go through it more.
On Linux, you can use 'as', the gnu assembler, or you can also use nasm, which most people prefer over 'as'. I've used both, and I got used to 'as' syntax after a while.

I long time ago I wrote a threaded/fiber system for DOS. It was mostly C, but the task switching and interrupt stuff was all assembly. It's basically an implementation of setjmp/longjmp hooked up with timer interrupts.

You might use it in your day to day if you were a driver developer for something like PCI chipset drivers, network drivers, things like that. Even then, C is usually preferred. I worked for a company that wrote drivers for scsi jukebox systems and they had a compete software suite written in 100% assembly. It was very clean, modular, well commented, and even object oriented. Yes, you can have objects in assembly, you just have to make your own this pointers. Since the language itself is so limited, most good assembly programs have a lot of macro wizardry involved.

you can use the intel syntax with gas too (see -masm=intel or .intel_syntax noprefix).