TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Statically Recompiling NES Games into Native Executables with LLVM and Go (2013)

265 pointsby woobyover 7 years ago

10 comments

Animatsover 7 years ago
All that work, and then he hits the expected killer problem - self modifying code. Getting past that without an interpreter is going to be tough. Not impossible, because the self modifying code isn&#x27;t that dynamic in the places he found it. It&#x27;s not like it&#x27;s reading external input and compiling it. There are a limited number of cases to be handled.<p>It&#x27;s amusing seeing this in a machine which gets its code from a ROM.
评论 #15255624 未加载
评论 #15256317 未加载
评论 #15255508 未加载
dogprezover 7 years ago
NES cartridges also could have their own hardware too. Don’t like the NES sound card? You could ship your own inside of the cartridge. I think notoriously castlevania 3 shipped some custom hardware in their cartridge. Some of the cartridges for the famicom came with an fm synth chip.
评论 #15260062 未加载
convivialdingoover 7 years ago
Wonderful, detailed deep-dive into static compilation and emulation with an approachable start. Good job.
nickcwover 7 years ago
Interesting read, shame about the dynamic code problems.<p>I wonder whether something like this might be better attempted in rpython which will build a JIT compiler for you.<p><a href="http:&#x2F;&#x2F;rpython.readthedocs.io&#x2F;en&#x2F;latest&#x2F;" rel="nofollow">http:&#x2F;&#x2F;rpython.readthedocs.io&#x2F;en&#x2F;latest&#x2F;</a>
ericfrederichover 7 years ago
<i>This means that they test some condition, and then either transfer control flow to the next instruction, or to a different label. This means that we can mark the possible branch address and the next address as instructions.</i><p>I hope all of these NES ROMs were coded well. Seems like you could do something like...<p><pre><code> if False: jump_to_data_address </code></pre> ... then he&#x27;d be interpreting data as code.
评论 #15258907 未加载
haydover 7 years ago
Aside, it&#x27;s surprising to me that there isn&#x27;t a (maintained) Java&#x2F;JVM implementation on top of LLVM...
评论 #15255432 未加载
评论 #15256428 未加载
评论 #15256234 未加载
emergedover 7 years ago
I had a similar project idea for ages. Instead of LLVM it would static recompile into C macros or C++ inline function calls for each opcode. Then it would compile the output and run the game.<p>Emulation is just plain fun.
评论 #15256858 未加载
k__over 7 years ago
lol, it just came to me that clang is an abbreviation for C language. I always imagined it to be the sound metal makes when you slam it together, because bare metal programming etc.
评论 #15256106 未加载
评论 #15256103 未加载
评论 #15259595 未加载
评论 #15256104 未加载
评论 #15256356 未加载
zsmizzleover 7 years ago
Dupe: submitted 1560 days ago - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=5838326" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=5838326</a>
评论 #15254936 未加载
评论 #15254927 未加载
评论 #15254959 未加载
mohaineover 7 years ago
This should have a 2013 added to the tittle.