Introduction

What is a computer?

A bunch of rocks

History of Programming

  • 25th Century BC - Abacus (Babylon)
  • 5th Century BC - Pāṇinian grammar (India)
  • 1st Century BC - Antikythera mechanism (Greece)
  • 12th Century - Castle Clock (Arab World)
First computer program? (Ada Lovelace, 1840)

In Babbage’s world his engines were bound by number…what Ada Byron saw—was that number could represent entities other than quantity. So once you had a machine for manipulating numbers, if those numbers represented other things, letters, musical notes, then the machine could manipulate symbols of which number was one instance

A Bombe used for Enigma decryption

“Programming” scene from The Imitation Game

ENIAC - first general purpose computer
Punch card with Fortran statement

Why Languages?

“Hello World” binary

Editing Binaries Manually

objdump -d hello
hello:     file format elf64-x86-64

Disassembly of section .text:

00000000004000d4 <.text>:
  4000d4:   48 c7 c0 01 00 00 00    mov    $0x1,%rax
  4000db:   48 c7 c7 01 00 00 00    mov    $0x1,%rdi
  4000e2:   48 c7 c6 02 01 40 00    mov    $0x400102,%rsi
  4000e9:   48 c7 c2 0e 00 00 00    mov    $0xe,%rdx
  4000f0:   0f 05                   syscall
  4000f2:   48 c7 c0 3c 00 00 00    mov    $0x3c,%rax
  4000f9:   48 c7 c7 00 00 00 00    mov    $0x0,%rdi
  400100:   0f 05                   syscall

mov $0x1, %rax

48 c7 c0 01 00 00 00

Memory hierarchy

16 x64 Registers

  • RAX
  • RBX
  • RCX
  • RDX
  • RSI
  • RDI
  • RSP - Stack Pointer
  • RBP - Base Pointer
  • R8 - R15

System Calls

  • Provide a way to call a function in kernel space
  • Examples
    • read
    • write
    • exit

Example of syscall

# exit(0)
mov $60,%rax # exit
mov $0,%rdi # exit code 0
syscall