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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Porting Sweet 16 (2004)

40 点作者 potomak将近 7 年前

4 条评论

rwmj将近 7 年前
The Sinclair ZX81 (Z80-based) could do 16 bit arithmetic fine but it had a similar interpreted mechanism for floating point, called the Calculator Stack.<p>You used the single byte RST 28 Z80 instruction followed by opcodes in the special interpreted language, with opcode 34h meaning exit back to Z80 code.<p>The interpreter opcodes were quite powerful, including trigonometric, logarithms, string parsing and memory operations. As the name &quot;Calculator Stack&quot; implies the operands were stored on a stack in memory (persisting between invocations of the interpreter). However a downside was it was very slow - visible pauses when doing certain artithmetic operations.<p>(More here: <a href="http:&#x2F;&#x2F;www.users.waitrose.com&#x2F;~thunor&#x2F;mmcoyzx81&#x2F;chapter17.html" rel="nofollow">http:&#x2F;&#x2F;www.users.waitrose.com&#x2F;~thunor&#x2F;mmcoyzx81&#x2F;chapter17.ht...</a> )
tom_将近 7 年前
Regarding the opcode dispatch: setting up the RTS in this way is quite expensive, and (if you&#x27;ve got the room) you could be better off assembling a little thunk somewher in memory. 4C 00 &gt;SET (JMP &gt;SET*256). You&#x27;d do this on startup.<p>A JMP to this thunk costs 3 cycles, and the JMP in the thunk costs 3 cycles, so that buys you nothing compared to the RTS. And the STx to set up the low byte takes up 3 cycles (zero page) or 4 cycles (elsewhere), which is the same or worse than the PHA. But because the high byte is always set up, you save the 5 cycles spent setting that up.<p>(If you&#x27;re running from RAM, you don&#x27;t even need the thunk.)<p>(Also: the opcode dispatch&#x27;s EOR trick is space-efficient, but takes an extra cycle - and one fewer bytes, I won&#x27;t deny - compared to doing a TAY after fetching the byte, then a TYA:AND $F0 later. That sequence takes 6 cycles, whereas the LSR:EOR (R15L),Y sequence takes 7 or 8.)
评论 #17280353 未加载
kazinator将近 7 年前
&gt; FOLLOWING CODE MUST BE CONTAINED ON A SINGLE PAGE!<p>(Page == 256 byte block). Because the op dispatch table stores only the low-order byte of the opcode address; the high order byte is fixed in the interpreter. I think the last function could spill past the end of the page; its starting address just has to be in the page.
1over137将近 7 年前
From the title and URL, I mistakenly thought this was about the Sweet16 Apple IIgs emulator (for macOS) getting an update. That would have been nice, because it&#x27;s a 32 bit only app and so won&#x27;t work past macOS 10.14 Mojave. :(
评论 #17280742 未加载