Fundamentals 68 min read

Mastering Computer Fundamentals: CPU Architecture, Memory, Binary, Assembly & OS Basics

A comprehensive guide that walks you through the inner workings of a computer—from the CPU’s fetch‑decode‑execute cycle and register set, through memory hierarchy and binary arithmetic, to function calls, assembly language, and essential operating‑system concepts like APIs, multitasking and virtual memory.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Mastering Computer Fundamentals: CPU Architecture, Memory, Binary, Assembly & OS Basics

CPU Overview

The Central Processing Unit (CPU) is the computer’s brain, executing instructions through the classic five‑stage pipeline: fetch, decode, execute, memory access, and write‑back. It contains a control unit, an Arithmetic Logic Unit (ALU), and a set of registers that hold temporary data and addresses.

Key Registers

Program Counter (PC)

: Holds the address of the next instruction to fetch. Control Unit: Decodes instructions and orchestrates execution. ALU: Performs arithmetic and logical operations. General‑purpose registers (e.g., EAX, EBX, ECX, EDX) store intermediate results. Flag register: Records condition codes such as zero, sign, and overflow.

CPU diagram
CPU diagram

Memory Basics

Memory stores program data and instructions. Primary types include RAM (volatile main memory), ROM (non‑volatile read‑only storage), and cache (fast, small‑capacity memory located between CPU and RAM). Memory is addressed in bytes, and larger units such as words (2 bytes) or double words (4 bytes) are built from them.

Memory hierarchy
Memory hierarchy

Binary Numbers and Two’s Complement

Computers represent data in base‑2. Converting a binary string like 00100111 yields the decimal 39. Negative numbers use two’s complement: invert all bits and add 1. Shift operations move bits left (logical shift) or right (arithmetic shift preserves the sign bit).

Instruction Execution Stages

Fetch

: Load the next instruction from memory into the CPU. Decode: Translate the binary opcode into control signals. Execute: Perform the operation (e.g., arithmetic). Memory Access: Read or write operands from/to memory. Write‑Back: Store the result into a register.

Function Calls and the Stack

When a C function is called, arguments are pushed onto the stack, the call instruction jumps to the callee, and ret returns to the caller. The stack pointer ( ESP) and base pointer ( EBP) manage local variables and saved registers.

push    ebp
mov     ebp, esp
push    456          ; argument 2
push    123          ; argument 1
call    _AddNum
add     esp, 8       ; clean arguments
pop     ebp
ret

Assembly Language Essentials

Assembly uses mnemonic opcodes ( mov, add, push, pop, call, ret) and pseudo‑ops ( segment, ends) to describe program structure. Registers are accessed directly, while memory operands are enclosed in brackets, e.g., mov eax, [ebp+8].

Operating‑System Fundamentals

An OS provides the API that applications use to interact with hardware, offers a graphical user interface (GUI), manages multitasking via time‑slicing, and implements virtual memory (paging) and disk caching to extend physical RAM.

Compiling C to Assembly

Using Borland C++ (or any modern compiler) the source file Sample4.c can be compiled with the -S flag to emit an .asm file. The compiler may optimise away unused variables, as shown by the warning about an unused local c variable.

_AddNum proc near
  push    ebp
  mov     ebp, esp
  mov     eax, dword ptr [ebp+8]
  add     eax, dword ptr [ebp+12]
  pop     ebp
  ret
_AddNum endp

Understanding this low‑level representation helps diagnose bugs, reason about performance, and appreciate higher‑level language features such as Java’s native methods.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CPUAssemblyMemoryRegisterscomputer architectureBinary
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.