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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Code generating a WebAssembly 6502 emulator from specifications

71 点作者 ColinEberhardt超过 4 年前

5 条评论

masswerk超过 4 年前
Regarding the 6502 instruction set linked in the article, please mind that this list doesn't cover any of the "illegal opcodes", which matters for the VCS, AKA Atari 2600, as these were/are often used to optimize the instruction count of game kernels. (Author of that page here.)
djhworld超过 4 年前
Cool!<p>Not sure if this approach would work for CPUs with bigger instruction sets&#x2F;more complex instructions, e.g. the Gameboy CPU &quot;DAA&quot; instruction [1] is notorious for being tricky to implement when writing a GB emulator<p>I guess tackling the tedious&#x2F;easy to implement ones with this code generation method would be helpful, leaving the more complicated ones to be tackled manually though!<p>[1] <a href="https:&#x2F;&#x2F;ehaskins.com&#x2F;2018-01-30%20Z80%20DAA&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ehaskins.com&#x2F;2018-01-30%20Z80%20DAA&#x2F;</a>
评论 #25111848 未加载
sm_ts超过 4 年前
I personally consider the approach very solid from an engineering perspective, however, it&#x27;s definitely a hell of a work to implement: with more complex ISAs, e.g. Sharp LR25902 (the Gameboy Classic&#x27;s), it becomes a very demanding work of balancing right level of abstraction; lowering the level too much will cause the generator to be intricate, raising it too much will make the generator too difficult to recycle for other architectures.<p>I did something very similar, going as far as automatically generating the test suites (note that this is a WIP):<p>- generator: <a href="https:&#x2F;&#x2F;github.com&#x2F;saveriomiroddi&#x2F;libemuls&#x2F;tree&#x2F;master&#x2F;component_sharp_lr35902&#x2F;extra" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;saveriomiroddi&#x2F;libemuls&#x2F;tree&#x2F;master&#x2F;compo...</a><p>- example cpu: <a href="https:&#x2F;&#x2F;github.com&#x2F;saveriomiroddi&#x2F;libemuls&#x2F;blob&#x2F;example_code_generation&#x2F;component_sharp_lr35902&#x2F;src&#x2F;cpu.rs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;saveriomiroddi&#x2F;libemuls&#x2F;blob&#x2F;example_code...</a><p>- example test suite: <a href="https:&#x2F;&#x2F;github.com&#x2F;saveriomiroddi&#x2F;libemuls&#x2F;blob&#x2F;example_code_generation&#x2F;component_sharp_lr35902&#x2F;src&#x2F;cpu_test.rs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;saveriomiroddi&#x2F;libemuls&#x2F;blob&#x2F;example_code...</a><p>The metadata itself is generated from another generator (!), then the required code is manually added, along with the autogenerated one.<p>I think the 6502 is a very good target for this type of work, as (AFAIK) it&#x27;s very common in commercial contexts, so that the documentation is more rigorous. Since the GBC CPU was used just for a now obsolete console, the information sources are more or less hacked together.
评论 #25118389 未加载
评论 #25114968 未加载
junon超过 4 年前
Curious, for NES emulation, the most accurate emulators also simulate minor timing inaccuracies to allow for certain hacks to take place (if memory serves).<p>How is this handled in such code-generation projects?
ngcc_hk超过 4 年前
Amazing. But to be consistent should have an example using this approach, not said he did it with rust.