6 ms·
X86 Assembly Guide
- vortico 10y agoI've been meaning to solidify my memory of common x86 instructions for a while, but I never got around to it because I get distracted by the bazillion other more advanced instructions. This guide is nice because it covers a few common instructions in a complete-enough manner but not excruciating details like the Intel manual.
- userbinator 10y agoUnless you're looking at handwritten and/or deliberately obfuscated code, the "more advanced" instructions are unlikely to be encountered; the bulk of compiler-generated general-purpose code will be moves, ALU ops, pushes, and pops along with the usual control flow calls, returns, and jumps.
- vortico 10y agoI deal with a lot of manual SIMD code in C with <nmmintrin.h> etc, but being a C programmer, I've forgotten how some of the "normal" instructions work. Also the advanced instructions are useful to at least be familiar with when you're working with disassembly, or studying how compilers optimize code.
- tomsmeding 10y agoMost of the time you don't need all the special-purpose instructions. I mean, mov is Turing complete. runs away
- sigjuice 10y agoYou don't even need mov. X86 MMU fault handling mechanism is Turing complete. https://github.com/jbangert/trapcc https://github.com/jbangert/trapcc
- jaclaz 10y agoYep, just in case: https://news.ycombinator.com/item?id=9751312 https://news.ycombinator.com/item?id=9751312 https://github.com/xoreaxeaxeax/movfuscator https://github.com/xoreaxeaxeax/movfuscator And the XOR post-processor: https://github.com/xoreaxeaxeax/movfuscator/blob/master/post/xor.py https://github.com/xoreaxeaxeax/movfuscator/blob/master/post...
- kensai 10y agoExactly! This is a very nice and relatively brief guide. Bookmarked. :)
- deleted 10y ago[deleted]
- jaclaz 10y agoTo be fair, the document has been re-tagged July 2016, but it is there since 2006: http://web.archive.org/web/20060914031400/http://www.cs.virginia.edu/~evans/cs216/guides/x86.html http://web.archive.org/web/20060914031400/http://www.cs.virg... "Credits: This guide was originally created by Adam Ferrari many years ago, and since updated by Alan Batson, Mike Lack, and Anita Jones. It was revised for 216 Spring 2006 by David Evans."
- Const-me 10y agoAnd now x86 is deprecated: most new PCs ship with 4GB RAM or more, and even low-power CPUs are 64 bit.
- groovy2shoes 10y agoSure, but the principles are the same. The mnemonics are the same, the registers discussed are still around (there are more registers now, but the ones in TFA didn't go anywhere), addressing modes are the same, the stack still grows downward, the MASM syntax and directives are still the same, and the code still runs on modern hardware. Perhaps most importantly, the mindset you use while writing code in x86[_64] assembly language is still the same. Actually, my experience has been that once you learn the ropes of programming in one assembly language[1], picking up any other assembly language is just a matter of perusing the proper reference manual(s) to find an architecture overview, useful instructions, calling convention(s)/ABI, and the syntax accepted by your assembler. While a tutorial for some new-to-you assembly language may be convenient, it's typically not necessary so long as you've got the manuals (which you really should have if you plan on writing programs in or compilers to an assembly language, regardless of any tutorials or textbooks you might have). [1]: You can cut your teeth with any assembly language, really. However, I feel like it might be a little easier to start with a CISC instruction set architecture, because they tend to be designed with human programmers in mind, while other types of ISA (RISC, EPIC, etc.) are typically designed with "automatic programmers" (compilers) in mind.
- Const-me 10y agoI agree x86 and x64 assemblers are very close. That’s exactly why I think it’s better to learn x64. Besides generally useful concepts, mnemonics and addressing modes, you’ll at the same time learn something useful in practice, and should be able to start applying those concepts right away.
- vram22 10y agoIIRC the Randall Hyde assembly language book is also good. I've read some of it. https://en.wikipedia.org/wiki/Randall_Hyde https://en.wikipedia.org/wiki/Randall_Hyde Another is this one by Paul Carter, who taught Computer Science at the University of Central Oklahoma for 10 years, including PC assembly language programming. You can get both a free PDF and a physical copy of it from here: http://pacman128.github.io/pcasm/ http://pacman128.github.io/pcasm/ and it uses only free software such as NASM and GCC. The book covers 32-bit protected mode programming in assembly. It also covers interfacing assembly and C code.