x86 IA-32 and x86-64 userland minimal examples tutorial. Hundreds of runnable asserts. Nice GDB setup. IO done with libc, so OS portable in theory. NASM and GAS covered. Tested in Ubuntu 18.04. Containers (ELF), linking, calling conventions. System land cheat at: https://github.com/cirosantilli/x86-bare-metal-examples, ARM cheat at: https://gith…
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
compiler-generated link to arm cheat Jul 16, 2018
gas gas: document comments properly Aug 23, 2018
interactive rename asm_io* headers to common.* headers Aug 4, 2018
lib nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
linker-scripts enable source code debug with nasm -gdwarf Jul 12, 2018
linux make test passes Jul 28, 2018
nasm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
x86-64 Remove a bunch of useless lib/common.asm functions Aug 4, 2018
.gitignore Multiboot hello world failed attempt Sep 3, 2015
.travis.yml travis: remove -no-pie since gcc too old there Jul 28, 2018
8086-pinout.gif Reduce depth of cheat, rdrand, popcnt Mar 23, 2015
Makefile examples of full cwde family Aug 4, 2018
README.md gas: document comments properly Aug 23, 2018
Vagrantfile Move ia-32 to top-level, rebrand as x86 assembly cheat Dec 3, 2015
adc.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
add.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
addressing.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
and.asm rename asm_io* headers to common.* headers Aug 4, 2018
ar.md Split large files, add index to README Apr 17, 2015
assemblers.md Split some large files, remove trash Dec 4, 2015
bibliography.md bibliography: 0xAX/asm Aug 12, 2018
binutils.md Minimal linker script examples, more GAS Oct 16, 2015
branch-prediction.md More CPU arch Nov 27, 2016
bswap.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
bt.asm rename asm_io* headers to common.* headers Aug 4, 2018
btc.asm rename asm_io* headers to common.* headers Aug 4, 2018
btr.asm rename asm_io* headers to common.* headers Aug 4, 2018
bts.asm rename asm_io* headers to common.* headers Aug 4, 2018
cache.md bak Mar 21, 2017
calling-conventions.md Split more ia-32/main Aug 24, 2015
cdecl.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
cdecl.md Move ia-32 to top-level, rebrand as x86 assembly cheat Dec 3, 2015
cdq.asm rename asm_io* headers to common.* headers Aug 4, 2018
cmovcc.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
cmp.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
cmps.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
cmpxchg.asm rename asm_io* headers to common.* headers Aug 4, 2018
containers.md ia32 works from x86-64 Apr 24, 2015
cpu-benchmarks.md lmbench Aug 1, 2018
cpu-bugs.md Comment on other architectures and implementations May 9, 2016
cpu-hardware-design.md bak Mar 21, 2017
cpu-optimizations.md More CPU arch Nov 27, 2016
cpu-pins.md Improve simd Apr 28, 2015
cpuid.asm rename asm_io* headers to common.* headers Aug 4, 2018
cwde.asm rename asm_io* headers to common.* headers Aug 4, 2018
debug-registers.md Move ia-32 to top-level, rebrand as x86 assembly cheat Dec 3, 2015
dec.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
div.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
dwarf.md gas works, add rip, start moving instruction encoding into test direc… May 11, 2015
elf.md movsb Oct 25, 2015
elfedit.md Split large files, add index to README Apr 17, 2015
endianess.asm rename asm_io* headers to common.* headers Aug 4, 2018
enter.asm rename asm_io* headers to common.* headers Aug 4, 2018
extensions.md Comment on other architectures and implementations May 9, 2016
floating-point.md Move ia-32 to top-level, rebrand as x86 assembly cheat Dec 3, 2015
flynns-taxonomy.md Split some large files, remove trash Dec 4, 2015
fma.md bak Mar 21, 2017
fpu.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
getting-started.md getting started: explain all asserts passed in subdirectories Aug 10, 2018
hello_world.asm rename asm_io* headers to common.* headers Aug 4, 2018
how-to-learn.md Split some large files, remove trash Dec 4, 2015
ia-32.md Comment on other architectures and implementations May 9, 2016
idiv.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
implementations.md improve description Sep 4, 2016
imul.asm rename asm_io* headers to common.* headers Aug 4, 2018
inc.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
instruction-level-parallelism.md More CPU arch Nov 27, 2016
instruction-sets.md Split some large files, remove trash Dec 4, 2015
intel-processor-history.md Split some large files, remove trash Dec 4, 2015
intel-vs-atet.md Split some large files, remove trash Dec 4, 2015
intel2gas.md Add usage to readme Sep 9, 2015
jcc.asm rename asm_io* headers to common.* headers Aug 4, 2018
jmp.asm rename asm_io* headers to common.* headers Aug 4, 2018
jmp_indirect.asm rename asm_io* headers to common.* headers Aug 4, 2018
ld-linux-so.md More CPU arch Nov 27, 2016
ld.md Split up GAS main.S Sep 21, 2015
ldd.md More CPU arch Nov 27, 2016
lea.asm rename asm_io* headers to common.* headers Aug 4, 2018
leave.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
lib_test.asm Remove a bunch of useless lib/common.asm functions Aug 4, 2018
lods.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
loopcc.asm rename asm_io* headers to common.* headers Aug 4, 2018
main.asm rename asm_io* headers to common.* headers Aug 4, 2018
microcode.md Split some large files, remove trash Dec 4, 2015
microcontrollers.md improve description Sep 4, 2016
misc.md Split some large files, remove trash Dec 4, 2015
mov.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
movs.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
movsx.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
movzx.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
mul.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
neg.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
nm.md elf relocation May 28, 2015
nop.asm rename asm_io* headers to common.* headers Aug 4, 2018
not.asm rename asm_io* headers to common.* headers Aug 4, 2018
objcopy.md Setup instruction encoding tests Sep 4, 2015
objdump.md Comment on other architectures and implementations May 9, 2016
or.asm rename asm_io* headers to common.* headers Aug 4, 2018
other-architectures.md move open ISAs to rtl cheat May 11, 2018
params.makefile enable source code debug with nasm -gdwarf Jul 12, 2018
pipeline.md More CPU arch Nov 27, 2016
popcnt.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
pros-and-cons-of-assembly.md Split some large files, remove trash Dec 4, 2015
provision Move ia-32 to top-level, rebrand as x86 assembly cheat Dec 3, 2015
push.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
pusha.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
pushf.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
rdrand.asm rename asm_io* headers to common.* headers Aug 4, 2018
rdtsc.asm rename asm_io* headers to common.* headers Aug 4, 2018
readelf.md Comment on other architectures and implementations May 9, 2016
registers.asm rename asm_io* headers to common.* headers Aug 4, 2018
rep.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
rings.md Split some large files, remove trash Dec 4, 2015
risc-vs-cisc.md Split some large files, remove trash Dec 4, 2015
rol.asm rename asm_io* headers to common.* headers Aug 4, 2018
sal.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
sbb.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
scas.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
segment Move ia-32 to top-level, rebrand as x86 assembly cheat Dec 3, 2015
segment_registers.asm rename asm_io* headers to common.* headers Aug 4, 2018
setcc.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
shl.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
simd.asm rename asm_io* headers to common.* headers Aug 4, 2018
size.md Split large files, add index to README Apr 17, 2015
stack-instructions.md Move ia-32 to top-level, rebrand as x86 assembly cheat Dec 3, 2015
stdcall.md Move ia-32 to top-level, rebrand as x86 assembly cheat Dec 3, 2015
stos.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
string-instructions.md Move ia-32 to top-level, rebrand as x86 assembly cheat Dec 3, 2015
strip.md Split more ia-32/main Aug 24, 2015
sub.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
superscalar.md More CPU arch Nov 27, 2016
symbol-versioning.md movabs May 25, 2015
synchronization.md Move ia-32 to top-level, rebrand as x86 assembly cheat Dec 3, 2015
system-vs-application-programming.md Split some large files, remove trash Dec 4, 2015
template.asm rename asm_io* headers to common.* headers Aug 4, 2018
test_instruction.asm rename asm_io* headers to common.* headers Aug 4, 2018
vliw.md More CPU arch Nov 27, 2016
xadd.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
xchg.asm nasm: remove ASSERT_EQ 0 and 1, use explicit ASSERT_EQ eax since saner Aug 4, 2018
xor.asm rename asm_io* headers to common.* headers Aug 4, 2018

README.md

x86 Assembly Cheat

Build Status

x86 IA-32 and x86-64 userland minimal examples tutorial. Hundreds of runnable asserts. Nice GDB setup. IO done with libc, so OS portable in theory. NASM and GAS covered. Tested in Ubuntu 18.04. Containers (ELF), linking, calling conventions. System land cheat at: https://github.com/cirosantilli/x86-bare-metal-examples, ARM cheat at: https://github.com/cirosantilli/arm-assembly-cheat

  1. Getting started
  2. IA-32
    1. main.asm
    2. hello_world.asm
    3. Base concepts
      1. Registers
        1. Segment registers
      2. Addressing
      3. Endianess
    4. Instructions
      1. mov family
        1. mov
        2. movzx
        3. movsx
        4. cmovcc
        5. xchg
        6. lea
      2. Flags
        1. setcc
      3. Arithmetic
        1. Addition
          1. add
          2. adc
          3. inc
        2. Subtraction
          1. sub
          2. sbb
          3. dec
        3. Multiplication
          1. mul
          2. imul
          3. neg
        4. Division
          1. div
          2. idiv
        5. Comparison
          1. cmp
        6. cdq
        7. cwde
      4. Bit-wise
        1. Boolean
          1. not
          2. and
          3. or
          4. xor
          5. test
        2. Shifts
          1. shl, shr
          2. sal, sar
          3. rol, ror
        3. Test
          1. bt
          2. btr
          3. btc
      5. Branching
        1. jcc
        2. jmp
          1. jmp indirect
        3. loopcc
      6. Stack instructions
        1. enter
        2. leave
        3. pusha
        4. pushf
      7. String instructions
        1. rep
        2. cmps
        3. lods
        4. movs
        5. scas
        6. stos
      8. Floating point
        1. FPU
        2. SIMD
          1. FMA
      9. Synchronization
        1. xadd
        2. cmpxchg
        3. bts
      10. Misc
        1. rdrand
        2. popcnt
        3. rdtsc
        4. nop
        5. cpuid
    5. Calling conventions
      1. cdecl
      2. cdecl examples
      3. stdcall
    6. Linux
    7. Infrastructure
      1. lib_test
  3. x86-64
    1. x86_64 general principles
      1. cmp sign extend
      2. mov zero extend
    2. x86_64 instructions
      1. cdqe
      2. movabs
    3. main
    4. x86_64 Linux system calls
    5. x86_64 calling convention
      1. x86_64 GAS
    6. Infrastructure
      1. min
      2. lib_test
  4. Assemblers
    1. GAS
      1. Hello world
      2. Immediate
      3. Addressing
      4. Char literal
      5. x86_64 GAS
        1. min
        2. lib_test
        3. cltq
      6. Symbol scope
        1. Local symbol
        2. Local label
      7. Current address
      8. instructions
        1. cmp
        2. jmp indirect
        3. ljmp
        4. cbtw
        5. movz
        6. push
      9. Directives
        1. .ascii
        2. .asciz
        3. .byte
        4. .equ
        5. .extern
        6. .gasversion.
        7. .global
        8. .print
        9. .type
      10. Preprocessor
        1. .macro
          1. .altmacro
        2. .irp
        3. Comments
      11. Infrastructure
        1. lib_test
      12. Bibliography
    2. NASM
      1. RAM
        1. Symbol colon
      2. local labels
      3. equ
      4. ptr
      5. current address
      6. Preprocessor
        1. %define
        2. %if
        3. %include
        4. comments
  5. Introduction
    1. How to learn
    2. Instruction sets
      1. Other architectures
        1. ARM
        2. Microcontrollers
      2. RISC vs CISC
        1. Microcode
      3. System vs application programming
      4. Flynn's Taxonomy
    3. Pros and cons of assembly
    4. Intel processor history
    5. Intel vs AT&T syntax
      1. intel2gas
    6. Implementations
    7. Extensions
    8. CPU architecture
      1. CPU Optimizations
      2. CPU bugs
      3. Cache
      4. Instruction level parallelism
        1. Pipeline
        2. Branch prediction
        3. Superscalar
        4. VLIW
        5. SIMT
      5. CPU benchmarks
  6. Containers
    1. ELF
      1. ELF Hello World Tutorial
  7. Dynamic libraries
    1. ld-linux.so
      1. ldd
  8. Compiler generated
  9. Binutils
    1. ld
      1. Linker scripts
    2. readelf
    3. objcopy
    4. objdump
    5. size
  10. misc
  11. Bibliography
  12. Related tutorials
    1. x86 Instruction Encoding Tutorial
    2. C++ Cheat
    3. Linux Cheat

WIP

  1. Binutils
    1. ar
    2. elfedit
    3. nm
    4. strip
  2. DWARF
  3. Symbol Versioning
  4. Debug registers