4 ms·
Having taken up x86 assembly coding again after many, many years (last time was on a 486, really), I find 64-bit assembly much easier to get started with compar
by csl 10y ago
Having taken up x86 assembly coding again after many, many years (last time was on a 486, really), I find 64-bit assembly much easier to get started with compared to 32-bit: Simpler calling convention (on UNIX, at least), no segments, more registers, etc. If anyone is starting out, this is a pretty good time to do so.
- sdegutis 10y agoLearning x86 (Intel) assembly is definitely something I've been interested in, as someone who inexplicably enjoys writing C code. But PDFs like this one are all I can really find, which are a bit daunting and intimidating.
- csl 10y agoThat's rather surpising, coming from someone proficient in C. Perhaps you only need to discover the close connection between C and assembly. The layer between them is really razor thin — by learning a few C idioms (function prologue/epilogue and the stack frames, argument passing, etc.) you'd be well on your way. You also need to start writing simple asm code as soon possible; only reading about it won't make it stick.
- kabdib 10y agoIt's not that bad. I usually start small: - Write a program that just returns, or halts; - Write a program that prints something or blinks an LED; - Print numbers 1-10; - Handle some input, using function calls. - Write some data structure (binary tree or hash table). Or maybe get an MMU working, and handle a system trap. ... working your way up to writing a context switch handler, for a coroutine or threading system, of course :-) ... at that point, you're off to the races. Mostly I try to get the toolchain a debugger working reliably in the first step, and everything just builds on that.
- lsr32 10y agoFor learning purposes I would recommend against using any kind of macro assembler. As tempting as macros are for making subroutines, calling conventions easier it starts to look a lot like verbose pseudo-C and you're better off just writing C at that point.
- justin66 10y agoKip Irvine's assembly language textbook is pretty good, as I recall: http://kipirvine.com/asm/ http://kipirvine.com/asm/ At least one guy in our class used Linux tools to work through the chapters we studied, although the instructions are focused on VS.
- e12e 10y agohttps://github.com/0xAX/asm https://github.com/0xAX/asm was posted a while back on hn - since then it's grown a bit - I've not kept up entirely, but it does start off pretty basic. It's a nice quick read/work-through before you get "serious". [ed: Initial hn discussion should be relevant to this thread: Say hello to x64 Assembly, part 1 (0xax.blogspot.com) https://news.ycombinator.com/item?id=8245581 https://news.ycombinator.com/item?id=8245581 (The posts are posted on the blogspot blog, but if I'm not mistaken they're all there in full, in the github repo) ]
- wolfgke 10y ago> I find 64-bit assembly much easier to get started with compared to 32-bit: Simpler calling convention (on UNIX, at least), no segments, more registers, etc. Segments are used in about the same amount on x86-64 vs. x86-32. Where they are used a lot is in 16 bit mode (real mode).
- csl 10y agoOh, well, then I stand corrected. I thought it was by and large dropped in 64-bit mode? (I remember a lot of segment usage in 32-bit, but I only ever coded in real mode back in the day...)
- wolfgke 10y ago> I thought it was by and large dropped in 64-bit mode? Indeed: cs, ds, ss and es cannot be used in 64 bit mode (source: https://en.wikipedia.org/w/index.php?title=X86_memory_segmentation&oldid=728102976#Later_developments https://en.wikipedia.org/w/index.php?title=X86_memory_segmen...), but fs and gs can still be used. On x86 in 32 bit they are never used at least in ring 3. So not much difference. fs and gs may still be used in both x86-32 and -64 and gs is for both: Under Windows for accessing the Thread Environment Block and under Linux for accessing per-CPU data.