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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

An 8086 PC emulator in 4043 bytes

196 点作者 epsylon超过 11 年前

15 条评论

mmastrac超过 11 年前
This is interesting, though it might be a bit of a cheat. He&#x27;s put some data in the BIOS image to assist in decoding instructions (not to take away from how amazing this is!):<p>&quot;CPU supports the full 8086&#x2F;186 instruction set. Due to the complexities of the 8086’s arbitrary-length instruction decoding and flags, 8086 instructions are first converted to a simpler intermediate format before being executed. This conversion, along with instruction lengths and how each instruction modifies the flags, is assisted by some lookup tables which form part of the BIOS binary.&quot;<p>With that in mind, the BIOS is _hand-written_ and about 12kB (gzips to &lt;4kB), so that&#x27;s also a fantastic achievement. All-in-all, this is a wonderful entry.
评论 #7012802 未加载
ori_b超过 11 年前
I went through and reformatted the code, after expanding all of the macros that contained unbalanced parens: <a href="http://eigenstate.org/cable3-formatted.c" rel="nofollow">http:&#x2F;&#x2F;eigenstate.org&#x2F;cable3-formatted.c</a><p>I still haven&#x27;t puzzled out exactly what all the variables are, but I think that this makes the structure much clearer.
petercooper超过 11 年前
The source itself: <a href="http://ioccc.org/2013/cable3/cable3.c" rel="nofollow">http:&#x2F;&#x2F;ioccc.org&#x2F;2013&#x2F;cable3&#x2F;cable3.c</a><p>Or after running through preprocessing (not a huge help I found, sadly): <a href="https://gist.github.com/peterc/8259713" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;peterc&#x2F;8259713</a>
评论 #7012949 未加载
评论 #7012558 未加载
userbinator超过 11 年前
&gt; Instruction codings are complex and irregular in size and structure, with multiple addressing modes and no consistent memory placement for operands, very often multiple possible encodings for the same instruction<p>It&#x27;s only complex and irregular if you look at it wrong. ;)<p>The x86 (like the 808{5,6} and the Z80) instructions look organised in an octal format: ftp:&#x2F;&#x2F;mipt.cc&#x2F;Opcode.txt<p>I haven&#x27;t inspected the code in any detail to see if it takes advantage of this.
bitwize超过 11 年前
I thought &quot;Wow, that&#x27;s a neat trick.&quot;<p>Then I saw AutoCAD, Flight Simulator, and Windows.<p>Mind = blown.
kyberias超过 11 年前
Here&#x27;s a link to a fully functional Windows binary (built with Visual Studio 2013):<p><a href="http://sdrv.ms/1hodqjP" rel="nofollow">http:&#x2F;&#x2F;sdrv.ms&#x2F;1hodqjP</a><p>Just add the bios and image files elsewhere.
评论 #7013048 未加载
lifeisstillgood超过 11 年前
&#x2F;snip This entry weighs in at a magical 4043 bytes (8086 nibbles, 28,301 bits). It manages to implement most of the hardware in a 1980’s era IBM-PC using a few hundred fewer bits than the total number of transistors used to implement the original 8086 CPU. &#x2F;snip<p>Just a small reminder how far we have come - and what Moore&#x27;s law (RIP) has done for us. Yes the original PC had few enough transistors one could actually count them. NowadAys ...<p>An awesome piece of work
joebo超过 11 年前
Neat, the linked hd.img file contains windows, Simcity, AutoCAD, etc. Has anyone compiled this for Windows? If so, would you kindly post the binary? It&#x27;d be fun to play with this old software again.
coin超过 11 年前
The BIOS is part of the PC, yet it&#x27;s not included in the 4043 bytes.
评论 #7013172 未加载
TazeTSchnitzel超过 11 年前
If you&#x27;re on Linux and don&#x27;t want to bother installing a VGA font, there&#x27;s no need. Do Ctrl+Alt+F6 (or lower) to switch to a terminal and run it there, then do Ctrl+Alt+F7 to switch back later.<p>Also, if someone can tell me how to make Windows not make the emulator segfault on my machine, that&#x27;d be great.<p>EDIT: Oh, it works fine in a graphical terminal. I&#x27;m guessing SDL failing to init on a text terminal broke everything.<p>EDIT 2: ALL THIS, PLUS REVERSI! You can even play Reversi!
kyberias超过 11 年前
MS Visual C++ 2013 chokes on this with &quot;&#x27;KB&#x27; undeclared identifier&quot; error.
评论 #7012940 未加载
mschuster91超过 11 年前
Has someone already unobfuscated the source code?
评论 #7035588 未加载
lelf超过 11 年前
All IOCCC winners — <a href="http://ioccc.org/years.html#2013" rel="nofollow">http:&#x2F;&#x2F;ioccc.org&#x2F;years.html#2013</a>
faragon超过 11 年前
Is licensed&#x2F;copyrighted? Do the IOCCC have any implicit license?
kriro超过 11 年前
Fantastic. Finally some &quot;hacker news&quot; on Hacker News ;P