That's where Assembly Language comes in, a low-level programming language, that allows to work with instructions specific to a processor's architecture 🤩.
For introduction, I take the legendary 8-bit MOS 6502 🎚 processor released in 1975, which powered computers like the Apple II and Commodore 64 while a modified version was used in the Nintendo Entertainment System 🎮 (aka Famicom for Japan🇯🇵 or Dendy for post-soviet countries including Ukraine🇺🇦).
⁉️ How does it work?
The 6502 has three main 8-bit registers that we'll be working with:
A - the accumulator, which used for arithmetic operations and data manipulation;
X and Y, which index registers, commonly used for counters and memory operations.
💃Let's write a tiny program that adds 5 and 3:
LDA #$05
CLC
ADC #$03
STA $0200
What's happening here?
LDA #$05 - loading the number 5 into accumulator.
CLC - clears the carry flag so it doesn't affect our addition.
ADC #$03 - adds 3 to the accumulator, including the carry flag.
STA $0200 - stores the result at memory address $0200.
And there we go! The result is 8
By the way, the $ symbol indicates hexadecimal notation,
while # means we're using an immediate value rather than reading from a memory address.
⁉️ But processors don't understand text!
The instruction: LDA #$05
Is translated by an assembler into machine code: A9 05
Here, A9 is the operation code (opcode), and 05 is the value we're loading.
These bytes are what the processor actually understands and executes!
⁉️ Where can you try it yourself?
You don't need to buy a vintage computer or a physical processor to start experimenting!
There's a wonderful online simulator called Easy 6502, where you can write Assembly code, execute it, and watch how registers and memory change. 😄
Learning Assembly helps you understand what's really happening under the hood of your favorite programming languages. Even if you never use it in a commercial project, it can fundamentally change how you understand computers.
Because every Hello World ⚠️ eventually becomes instructions executed by a processor 🥠
Discord | Boost | Commissions | #other