CPU Architecture

Von Neumann
CPU
System Bus
I/O & Interrupts
Internal Memory
Bit Length & Word Size
Registers
Architecture
Fetch-Execute
  1. Copy IP -> MAR
    Issue read request to MMU
    (CPU can do something else in time waiting)
  2. Increment IP
  3. Instruction arrives from memory to MBR
    Copy MBR -> IR
  4. Decode IR
  5. Fetch operands
  6. Execute instruction
  7. Repeat
Instruction Sets

Six broad categories of instructions:

Instruction Format

Each instruction has an opcode

A single instruction can be 1 to 15 bytes long
It's assumed here that every instruction takes up 4 bytes of memory

Addressing Modes

The mode tells CPU where operands are located

Assembly
Intel x86 Registers
Status Flags
Instructions
Arrays
Program Stack
Parameter Handling

Pass by Value - Values copied into registers

The stack can be used for parameters

Calling Conventions

Four calling conventions in Intel x86 architecture:

I/O in Assembly

Use printf and scanf
printf:

Push important register values onto stack before calling a subroutine, and pop them back off after to avoid them being corrupted during the subroutine's execution

Format Specifiers
Stack Frames

When a subroutine is called, a new stack frame is created on the stack, holding:

When a subroutine is called:

Nested Calls and Stack Frames
Recursion

A recursive subroutine calls itself
Mutual recursion is where two or more subroutines call each other
Two parts to recursive subroutines

Accessing single char in memory

movzx edx, byte ptr [eax] gets the single character at location in eax, just gets a single byte and zero fills it

Operating Systems

Main purposes:

Four essential parts of every OS

Each manager must perform certain tasks:

Program vs Process

Program:

OS Structure

System Boot