TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

JSVM

69 点作者 jawb超过 11 年前
Javascript virtual machine is one instruction set machine to parse and execute an assembly like code.

6 条评论

chengsun超过 11 年前
Shameless plug: a while back I wrote an assembler-and-VM for a similarly hypothetical assembly language that I was studying in class. Just for kicks, I wondered if I could fit the entire thing into 1KB of JavaScript, whilst including features as step by step execution, a &quot;debugging GUI&quot; (as much as you could expect from 1KB!) featuring the stack, register contents and program counter, plus the assembler on top which performs full syntax&#x2F;opcode argument checking.<p>The result (which I&#x27;m pretty pleased with) is here: <a href="http://chengsun.github.io/ocremutiny.html" rel="nofollow">http:&#x2F;&#x2F;chengsun.github.io&#x2F;ocremutiny.html</a>
jared314超过 11 年前
I love low-level learning projects like this, but I wish more of them would centralize around something like Nand2Tetris[1] to create an expanded, and interconnected, learning ecosystem.<p>[1] <a href="http://www.nand2tetris.org/" rel="nofollow">http:&#x2F;&#x2F;www.nand2tetris.org&#x2F;</a>
knome超过 11 年前
Your VM will work much faster if you take the time to do a second pass over the generated &quot;code&quot; and resolve the jumps to LABELs all at once instead of linearly scanning the code for the appropriate target on each jump.
评论 #6975941 未加载
tylerkahn超过 11 年前
I had to write one of these (in C) for a class a couple years ago.<p><a href="https://github.com/tylerkahn/MIPS-Virtual-Machine" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tylerkahn&#x2F;MIPS-Virtual-Machine</a>
评论 #6965042 未加载
评论 #6964998 未加载
angersock超过 11 年前
If I make make a few suggestions (mostly from a desire to see a more familiar sort of spec):<p>&gt; Add arithmetic shift left&#x2F;right<p>&gt; Add logical shift left&#x2F;right<p>&gt; Add exclusive OR (XOR)<p>&gt; Pick a word size so your integer and bit ops have meaning<p>Questions:<p>&gt; How do I set the program counter from my assembly?<p>&gt; Do I have registers (seems like a stack-based VM, so no)? If not, can I have more stacks?<p>&gt; Can you setup a dedicated block of memory to use as a framebuffer and render it to a &lt;canvas&gt; tag?<p>~<p>Good work so far!
评论 #6976056 未加载
Xelom超过 11 年前
Better name it VM.js !!
评论 #6976101 未加载
评论 #6965629 未加载