Welcome to the Machine
You are about to learn PLP (Progressive Learning Platform). This isn't just coding; this is moving electrons. In high-level languages like Python, you ask the computer to do something. In Assembly, you tell the hardware exactly which wire to power.
The Mental Shift
Forget if statements and while loops for a moment. Think about:
- Registers: A handful of super-fast storage boxes inside the CPU.
- Memory: A giant wall of mailboxes far away from the CPU.
- The ALU: A calculator that can only add/subtract two numbers at a time.
Navigate through the sidebar to master the machine.
01. The Hardware Architecture
To write Assembly, you must understand the "Stage" where your code performs.
The CPU Core
The PLP processor is based on the MIPS architecture. It has three main parts:
- Control Unit (The Brain): Decodes your instructions. It sees
addiuand flips the switches to set the ALU to "add" mode. - ALU (The Muscle): The Arithmetic Logic Unit. It crunches the numbers. It takes two inputs, does math, and spits out one result.
- Registers (The Hands): Small, fast storage. The ALU can only work on data that is currently in a register.
The Cycle of Life (Fetch-Decode-Execute)
The CPU does this millions of times a second:
- FETCH: The
PC(Program Counter) points to a memory address. The CPU grabs the instruction code from there. - DECODE: The Control Unit figures out what the binary gobbledygook means (e.g., "Oh, this is a store word command").
- EXECUTE: The data moves. The math happens. The PC increments to the next line.
02. The Instruction Set
You only have a few commands. Master them, and you can build anything.
The "Project 1" Essentials
These are the specific tools you need for the LED Counter project.
-
li $dest, value
Load Immediate. Puts a raw number into a register.
Ex:li $t0, 0xf0200000(Put the LED address in $t0) -
sw $src, offset($addr)
Store Word. Copies data from a register TO memory.
Ex:sw $t1, 0($t0)(Take value in $t1, send it to the address held in $t0) -
addiu $dest, $src, value
Add Immediate Unsigned. Math time.
Ex:addiu $t1, $t1, 1(Take $t1, add 1, put it back in $t1) -
j label
Jump. Go to a specific bookmark (label) in the code.
Ex:j loop(Go back to the start)
Advanced Tools (Good to Know)
beq $t0, $t1, label: Branch if Equal. (If $t0 == $t1, go to label).bne $t0, $t1, label: Branch if Not Equal.jal label: Jump and Link. Used for functions (saves your spot in $ra).jr $ra: Jump Register. Used to return from a function.
03. Simulation Lab
This is your interactive "Hello World" for hardware. We are simulating the LED Counter Project.
CPU State
I/O Board (0xf0200000)
> READY FOR INSTRUCTIONS...
04. Data Representation
Computers don't know "15". They know 0000 1111.
Hexadecimal Crash Course
We use Hex (Base-16) because binary is too long to read. One Hex digit = 4 Binary bits.
2's Complement (Signed Numbers)
How do we store -5? We can't use a minus sign.
- Take the positive number in binary (5 =
0000 0101). - Flip all bits (
1111 1010). - Add 1 (
1111 1011).
Result: 0xFB is -5 in a byte.
05. Mac Users: The Automator Hack
.plp files directly with Java JARs.
Solution: We build a custom launcher app.
Step-by-Step Fix
- Open Automator on your Mac.
- Create a new document type: Application.
- Search for "Run Shell Script" and drag it to the workflow.
- Change "Pass input" to "as arguments".
- Paste this code into the script box:
for f in "$@" do java -jar /path/to/PLPToolStatic.jar "$1" done(Replace/path/to/...with the actual location of your jar file!) - Save the app as "PLPLauncher".
- Right-click any
.plpfile -> Get Info -> Open With -> Select your new PLPLauncher app -> Click Change All.
Now you can double-click your project files like a pro!