Basics of Computer Programming: From Machine Code to Abstraction

Computer programming is the art of instructing machines to perform tasks through code. At its core, computers understand only binary—1's and 0's—but layers of abstraction make programming human-friendly. This overview explores machine code, assembly instructions, registers vs. memory, stack usage, and how early programmers worked by hand in the "old days."

Abstraction Layers: From Binary to Human-Readable Code

Computers execute instructions as binary patterns (machine code)—sequences of 1's and 0's representing operations and data. These are grouped into bytes (8 bits) or words (e.g., 16/32 bits). Abstraction layers build on this:

Example: Binary 1010 0110 (hex A6) might be LDA (load accumulator) in 6502 assembly—humans use "LDA $00" instead of bits.

Example Instruction Set: From a Simple Processor (MOS 6502)

The MOS 6502 (used in Apple II, Commodore 64) has a simple 8-bit instruction set. Here's a subset with opcodes, mnemonics, and descriptions:

Opcode (Hex)MnemonicDescriptionBytesCycles
A9LDA #Load accumulator with immediate value22
8DSTA absStore accumulator to absolute address34
18CLCClear carry flag12
69ADC #Add immediate to accumulator with carry22
4CJMP absJump to absolute address33
20JSR absJump to subroutine (push return address to stack)36
60RTSReturn from subroutine (pop return address from stack)16

This set allows basic operations: load/store data, arithmetic, jumps. Assemblers convert mnemonics to binary.

Registers vs. Instruction and Data Memory

Registers are fast, on-chip storage locations inside the CPU—small but accessible in 1-2 cycles. They differ from memory:

The Stack and Subroutine Calls

The stack is a LIFO (last-in, first-out) region in data memory for temporary storage, managed by the stack pointer (SP) register.

Programming in the "Old Days": By Hand

Early hobbyists (1970s) programmed without IDEs—often by hand-assembling code on paper.

This hands-on approach taught CPU internals but was tedious—modern tools abstract it away.

Back to Misc


Copyright 2026 - MicroBasement