Monday, April 6, 2026

Wait to be Wowed by nand2tetris Vol III

nand2tetris Part III — Coming Soon

November 10, 2026

You built a computer from a NAND gate. In Part I you wired up logic gates, an ALU, memory, and a CPU. In Part II you wrote an assembler, a virtual machine, a compiler for the Jack language, and a small operating system. At the end you had a working machine that runs programs you wrote yourself, top to bottom, with no magic left in the stack.

And then the course ends — right at the point where the questions get interesting.

How does a debugger actually stop your program on a line and let you poke at its memory? How does a buffer overflow turn a sloppy loop into an attacker's foothold — and how do the defenses that stop it really work? How can one computer pretend to be another, running a whole second machine inside itself? These aren't in the book. Part III is a new, independent sequel that answers them — built entirely on the Hack computer and Jack OS you already have.

No new platform to learn. You bring your Part I/II machine; we extend it, break it, and defend it.

One idea, at three altitudes

Part III isn't a grab-bag of topics. Everything in it is one pattern seen from different heights: a privileged layer that watches and controls a less-privileged one. We call it supervision, and once you see it, you see it everywhere.

  • A debugger supervises your program: it traps on a breakpoint, inspects memory and registers, then hands control back.
  • A kernel supervises user processes: it traps on a system call, does the privileged work, then returns to the caller.
  • A hypervisor supervises a whole guest machine: it traps on a privileged instruction, emulates it, then resumes the guest.

Same move — trap, inspect, resume — at three altitudes. A breakpoint and a system call and a virtual-machine exit are the same mechanism pointed at different things. By the end, you'll have built all three, and the payoff is seeing that a debugger, a kernel, and a hypervisor are the same idea wearing different clothes.

That's why the modules are ordered the way they are: each one hands the next its machinery.

What you'll build

Five modules, each a working tool, each building strictly on the one before.

III-A — Hardware for supervision

We add three small primitives to the Hack machine: a user/kernel mode bit, a timer interrupt, and base/bound memory protection. Each is tiny; together they're the toolbox everything else draws from. Dull on its own, decisive for everything after — so we get it out of the way first, and the later modules become applications of it rather than detours into hardware.

III-B — Debuggers

You build a real source-level debugger for Jack, with break, continue, step, print, backtrace, and watch. Breakpoints work the way gdb's do — by patching a trap instruction over the target and restoring the original. Backtrace walks the VM frame chain your Part II calling convention already lays down. And symbol/line tables mean extending your Jack compiler to emit debug info, so you feel firsthand that a debugger depends on the compiler's cooperation.

III-C — Memory safety and exploitation

The module people come for. You'll craft three escalating attacks and then defend against them:

  1. Heap overflow in pure Jack — overflow one object into the next and hijack a later method call.
  2. Return-address overwrite at the VM level — redirect control to existing code. This is the seed of ret2libc and ROP, not shellcode.
  3. The finale — flip the simulator into von Neumann mode so data becomes executable, and watch classic shellcode injection finally work. The contrast is the whole lesson in why NX/DEP exists.

Then you implement the defenses as real passes — stack canaries, bounds checking, a shadow stack, a poisoned-allocator (an ASan analog), and base randomization (an ASLR analog) — and re-run each exploit to watch it get caught.

III-D — Processes and the kernel

The bridge from tool to operating system. Context switching, a scheduler driven by III-A's timer, system calls via trap, and user-vs-kernel enforced by III-A's mode bit. Here "supervisor" grows up into "kernel."

III-E — Virtualization (capstone)

You write a Hack CPU that runs inside Hack — first as a plain interpreter, for the "a computer can simulate any computer" moment. Then you upgrade it to trap-and-emulate, reusing III-B's trap mechanism and III-D's context switching, so the guest runs on the real CPU and only privileged instructions trap to your hypervisor. You finish by meeting the real vocabulary — Popek–Goldberg, ring compression, why x86 needed VT-x — right after hitting the exact problems those names solve.

Why Hack, of all machines?

Here's the surprise: the Hack computer is a Harvard machine — instructions live in ROM, data in RAM, and no instruction can write to ROM. So the textbook "inject shellcode into a buffer and jump to it" attack is impossible by construction on stock Hack. You simply cannot execute data.

That's not a limitation we're apologizing for. It's the best teaching moment in the whole course. Real CPUs spent decades bolting on the NX/DEP/W^X protections that Hack has for free — and in III-C you get to discover that by hitting the wall yourself, then flipping a switch to tear the wall down and see exactly what you lose. A protection you had to remove to get hacked teaches more than one you were told to add.

One honest note: because Hack is a 16-bit Harvard machine with a VM calling convention, the fine mechanics won't transfer one-to-one to real-world x86-64 exploitation. The goal is conceptual — the shape of each vulnerability class, the attacker's mindset, the defender's tradeoffs. That's the right scope for learning, and it's exactly the foundation that makes a real target comprehensible later.

Who it's for, and what you'll need

Part III is for anyone who finished The Elements of Computing Systems (Parts I and II) and wants to keep going — self-learners, students, and working engineers who want systems and security concepts grounded in a machine they fully understand. If you can read and write Jack and you remember how the VM calling convention works, you're ready.

What you'll need: your own Part I/II project (or the book's supplied one), and a willingness to extend the tools rather than just run them. Each module ships with specs, starter code, and test scripts; the simulator extensions stay behind flags so your original machine keeps working untouched.

Honest scope note: this is a full semester's worth of material, not a weekend. III-A and III-D are real modules, not warmups, and the virtualization capstone is genuinely ambitious. We'd rather tell you that now than have you expect a quick add-on.

What you'll walk away with

A debugger, a kernel, and a hypervisor you built yourself — and the lasting realization that they were the same idea the whole time.

Modules will roll out one at a time, starting with III-A. Stay tuned — and if there's a direction you most want to see first, that feedback shapes the order.

Sunday, August 30, 2020

Wireless Hello World

That means - you press a (possibly virtual) button and an LED lights up someplace else.

https://www.youtube.com/watch?v=OhnxU8xALtg

 Arduino, HC-05 bluetooth module, breadboard, processing, sketch, blue control Android app

Google search that was useless : "what is the easiest way to get a notification on your phone from a device at home?"

Another one "do you need a subscription to get notifications from home kit devices?"

Wednesday, January 15, 2020

Set Up Raspberry Pi's WiFi Access Through Windows

Okay, had heard that, once you have the card ready for the Pi, it's also readable on the PC - in an intelligible way.

Tried the card from 5 years ago - and, when I plug it in (it's an SD, not microSD BTW - for the version 1 Pi)- I get two new USB drives showing - one readable, the other saying "Need to format." No thanks.

But, with the brand new one I just got, when I plug in, I get..

four new drives! And yes, there's a boot(G:) that does have the wpa_supplicant.conf

So, let's see :)

Yes, that gets the Pi showing up when you run nmap through the Zenmap GUI (for those of you who are wary of the Russian alternative - Advanced IP Scanner).

But, try getting in with ssh and... connection refused. *d Caleb Bergquist. Be thorough man!

Turns out, you need a file in your boot directory called ssh - just an empty file. And that will take care of it. My advice, go to Cygwin and then /cygdrive/g and touch it and you're done. Notepad++ manages to still give you grief, though I'm sure it's Windows to be blamed.

But, beware - what do you do if you've booted up your Pi and now can't turn it off for want of being able to connect? Caveman :( You have to connect a USB keyboard and then, very carefully,

CTRL-ALT-F1 and then very carefully, "sudo shutdown -h now" and see the LED blink 10 times and then you're good to pull the plug.

Friday, August 25, 2017

A More Efficient If (VM Code) Than Shimon's

Shimon (or one of his underlings - maybe Yaron)

expression
if-goto IF_TRUE0
goto IF_FALSE0
label IF_TRUE0
if-statements
goto IF_END0
label IF_FALSE0
else-statements
label IF_END0

when all you really need is :

expression
if-goto IF_TRUE0
else-statements
goto IF_END0
label IF_TRUE0
if-statements
label IF_END0

So, why would they choose to implement the less optimal thing?

Monday, August 21, 2017

VMEmulator Help - Can't Set Value of a RAM Word

If you have your Animation set to "No Animation", then you won't be able to. So, change that to "Program Flow", set your RAM, and then revert..

Sunday, August 13, 2017

Jack FAQ

Are fields private? Accessible only to methods? Or, if you have an object, can you do

obj.field from anywhere?

Can't find a good FAQ on their web :(