nand2tetris / web-ide

A web-based IDE for https://nand2tetris.org
https://nand2tetris.github.io/web-ide
Other
40 stars 11 forks source link

VM Simulator #18

Closed DavidSouther closed 3 months ago

DavidSouther commented 2 years ago

Implement the Stack Virtual Machine from chapters 7 and 8, and page like the VM emulator stand-alone app.

Basic:

Control:

Tests:

Goblinlordx commented 1 year ago

Hi~ I just wanted to put it out there that I have a VM implementation for this that I think could potentially be useful. It was pretty... minimal to say the least and it has been a few years since I did the implementation (prior to me using TS much).

Either way, you can find it here: https://github.com/Goblinlordx/hvm/blob/master/packages/vm/

Really, the core is here: https://github.com/Goblinlordx/hvm/blob/master/packages/vm/VM.js

DavidSouther commented 1 year ago

Nice, glad to see more of these!

The link you sent looks like an implementation of the nand2tetris CPU (chapter 4 and 5); this issue is meant to capture the VM described in chapters 7 and 8.

Goblinlordx commented 1 year ago

Hmmm~ I will need to check the book references. It was intended to simulate all the hardware and run actual code with video output and inputs. The "video" output just copies the framebuffer data and renders to a 2d canvas context. There is also functionality for dumping memory and registers for introspection and/or live view of those when running. Though I never did get around to implementing a "real" usable UI for it.

Goblinlordx commented 1 year ago

Ah~ I understand (looking back at the book). Sorry~ My misunderstanding.

DavidSouther commented 1 year ago

No worries, you at least poked me enough to add some details to the issue! :)