This is not the current version of the class.

Assembly 1: Data movement and arithmetic

Overview

We introduce data movement and arithmetic instructions on x86-64.

Full lecture notes on assemblyTextbook readings

Machine code and assembly

How machine code is executed: simple model

How machine code is generated: simple model

Simple model of compilation

How machine code is generated: assembler model

Compilation with assembler

How machine code is generated: linking

Compilation with linking

Assembly example

0000000000401210 <add>:
  401210: 8d 04 3e                      leal    (%rsi,%rdi), %eax
  401213: c3                            retq
  401214: 66 2e 0f 1f 84 00 00 00 00 00 nopw    %cs:(%rax,%rax)
  40121e: 66 90                         nop

Assembly flavors

Extracting assembly from different points

Reading assembly

Simple functions

    .file   "f00.cc"
    .text
    .globl  _Z1fv
    .type   _Z1fv, @function
_Z1fv:
    ret
    .size   _Z1fv, .-_Z1fv
    .ident  "GCC: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0"
    .section    .note.GNU-stack,"",@progbits

Directives, labels, instructions

f00.s, f01.s

ret

f02.s, f03.s

mov

Registers

Register slices

f04.s, f05.s, f06.s, f07.s