5 ms·
X86-64 machine level programming [pdf] (2005)
- Artlav 10y agoThat started out fairly nice, but then they used AT&T assembly syntax, which made it worthless. But opinions aside, it does look like a nice reference and exercise piece.
- adamnemecek 10y agoYeah, I don't understand why some people cling to it so much.
- chrisseaton 10y ago> they used AT&T assembly syntax, which made it worthless This is so silly. The two assembly syntaxes are equivalent and include just as much information. It doesn't make much to mentally flick between the two.
- adamnemecek 10y agoWhile they are the same, Intel is much easier to read.
- aerioux 10y agothis is an older version -- the actual book this is excerpted from uses Intel mostly now (the canonical CSPP book) and also has many revisions to 'modernize' it, such as reducing the x86 sections in favor of x64
- SilasX 10y agoOy. With respect, you're both wrong. AT&T's is uglier, regardless of the equivalence, and this matters for the cognitive load. But it's not so bad that anyone who uses it should be dismissed.
- kabdib 10y agoHaving multiple syntaxes and having to switch between them is error-prone and leads to bugs. Except in cases where manufacturers are totally clueless about syntax, I have far preferred using the "official" assembly, rather than the Unix version. (In some happy cases these are the same). Thank God I don't write assembly language much any more; maybe a few hundred to a thousand lines on a modern embedded product. At that level, it's still fun. [I've been using assembly since the late 1970s. Z-80 and 6502 FTW! :-)]
- harry8 10y agogdb: set disassembly-flavor intel gcc inline: asm(".intel_syntax noprefix"); objdump: objdump -M intel -d program_name All the fun of arguments over goddamn bracing conventions in C or C++. ATT is src,dest intel is dest,src Commit that to memory, the rest follows, get on with life which is much too short...
- csl 10y agoHaving 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.
- josteink 10y agoMan. First with x64 assembly did Intel catch up with where Motorola was over 2 decades ago with their 68k series. Lack of registers (and a logical organisation of those) and the boilerplate load/unload pain that caused when trying to write any non-trivial code was why I just stopped doing assembly when I moved to the Intel platform. Such a shame they didn't address this earlier.
- groovy2shoes 10y agoThe "x64" instruction set was produced by AMD, not Intel. This is why you frequently see the architecture referred to as "amd64".
- server_bot 10y agoThis 2005 PDF is supplemental material for an old edition of "Computer Systems: A Programmer's Perspective” by Randal E. Bryant and David R. O'Hallaron. The 2015 edition of the book includes an updated version of this x86-64 content in Chapter 3, replacing the IA32 content and no longer a just a supplement. I strongly recommend owning a copy of this book if you have any interest in systems programming or just want to be exploit hardware characteristics for better performance in your userspace applications. I took the class this book is written for, taught by the authors. They don’t place emphasis on being able to write assembly, since this is not a useful skill for the majority of programmers. Instead, the goal of this material is to get you to understand assembly and compilation well enough to 1) reverse engineer it if you need to for debugging or security reasons, and 2) be able to write compiler-friendly code, meaning code that can be safely translated into efficient assembly instructions (compilers are conservative, they only optimize when it's certain there's no repercussions).