Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CompE 271 - x86 assm notes, Study notes of Computer Science

Machine-Level Programming I: Basics - Study Notes

Typology: Study notes

2024/2025

Uploaded on 05/01/2025

magda-baghdadze
magda-baghdadze 🇺🇸

2 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Machine-Level Programming I: Basics - Study Notes
Lecture Overview
- History of Intel processors and architectures
- C, assembly, and machine code
- Assembly basics (registers, operands, mov)
- Introduction to x86-64 architecture
Intel Processor Evolution
x86 Dominance:
- CISC architecture, backward compatible to 8086
- Intel succeeded in speed despite RISC competition
Milestones:
| Name | Year | Transistors | MHz | Notes |
|------------|------|-------------|------------|--------------------------------------|
| 8086 | 1978 | 29K | 5-10 | First 16-bit, IBM PC & DOS |
| 386 | 1985 | 275K | 16-33 | 32-bit IA32, Unix support |
| Pentium 4F | 2004 | 125M | 2800-3800 | First 64-bit x86-64 |
| Core i7 | 2008 | 731M | 2667-3333 | Used in CMU labs |
IA vs Microarchitecture:
- ISA: programmer-visible components
- Microarchitecture: implementation details like cache, frequency
CPU Programmer's View:
- PC: EIP (IA32) or RIP (x86-64)
- Registers for data, Condition codes for branching
- Memory: Byte-addressable, stack, user & OS data
From C to Machine Code:
- Compile -> .s (assembly) -> .o (object) -> executable
Example:
C: int sum(int x, int y) { return x + y; }
Assembly:
pushl %ebp
movl %esp, %ebp
movl 12(%ebp), %eax
addl 8(%ebp), %eax
popl %ebp
ret
Data Types:
- Integers: 1, 2, 4 bytes
- Floats: 4, 8, 10 bytes
- No arrays/structs: use contiguous memory
Operations:
- Arithmetic, data transfer (mov), jumps, branches
Registers:
pf2

Partial preview of the text

Download CompE 271 - x86 assm notes and more Study notes Computer Science in PDF only on Docsity!

Machine-Level Programming I: Basics - Study Notes

Lecture Overview

  • History of Intel processors and architectures
  • C, assembly, and machine code
  • Assembly basics (registers, operands, mov)
  • Introduction to x86-64 architecture

Intel Processor Evolution x86 Dominance:

  • CISC architecture, backward compatible to 8086
  • Intel succeeded in speed despite RISC competition

Milestones:

NameYearTransistorsMHzNotes
8086197829K5-10First 16-bit, IBM PC & DOS
3861985275K16-3332-bit IA32, Unix support
Pentium 4F2004125M2800-3800First 64-bit x86-64
Core i72008731M2667-3333Used in CMU labs

IA vs Microarchitecture:

  • ISA: programmer-visible components
  • Microarchitecture: implementation details like cache, frequency

CPU Programmer's View:

  • PC: EIP (IA32) or RIP (x86-64)
  • Registers for data, Condition codes for branching
  • Memory: Byte-addressable, stack, user & OS data

From C to Machine Code:

  • Compile -> .s (assembly) -> .o (object) -> executable Example: C: int sum(int x, int y) { return x + y; } Assembly: pushl %ebp movl %esp, %ebp movl 12(%ebp), %eax addl 8(%ebp), %eax popl %ebp ret

Data Types:

  • Integers: 1, 2, 4 bytes
  • Floats: 4, 8, 10 bytes
  • No arrays/structs: use contiguous memory

Operations:

  • Arithmetic, data transfer (mov), jumps, branches

Registers:

IA32: %eax, %ebx, %ecx, %edx, %esi, %edi, %esp, %ebp x86-64: adds %r8-%r15 and extends others

Memory Addressing:

  • Simple: (%eax), 8(%ebp)
  • Complex: D(Rb, Ri, S)

Example Swap Function (IA32): swap: pushl %ebp movl %esp, %ebp pushl %ebx movl 8(%ebp), %edx movl 12(%ebp), %ecx movl (%edx), %ebx movl (%ecx), %eax movl %eax, (%edx) movl %ebx, (%ecx) popl %ebx popl %ebp ret

x86-64 version: swap: movl (%rdi), %edx movl (%rsi), %eax movl %eax, (%rdi) movl %edx, (%rsi) ret

Disassembling:

  • Use objdump -d program
  • Use gdb to disassemble and inspect memory

Summary:

  • x86 architecture evolved over time
  • Assembly gives low-level access to machine
  • Key concepts: registers, mov, memory addressing, disassembly