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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

X86 Addressing Under the Hood

87 点作者 ScottWRobinson超过 6 年前

3 条评论

userbinator超过 6 年前
x86 instruction encoding is best viewed in octal --- not just the ModRM, but the primary opcode too:<p><a href="http:&#x2F;&#x2F;www.dabo.de&#x2F;ccc99&#x2F;www.camp.ccc.de&#x2F;radio&#x2F;help.txt" rel="nofollow">http:&#x2F;&#x2F;www.dabo.de&#x2F;ccc99&#x2F;www.camp.ccc.de&#x2F;radio&#x2F;help.txt</a><p>You can mentally assemble&#x2F;disassemble the bulk of the commonly encountered instructions by memorising a few tables (in octal), the addressing modes being one of them. In 16-bit the memory addressing modes can be described as &quot;one or more of {displacement}{BX,BP}{SI,DI}&quot; and 32-bit &quot;one or more of {displacement}{register}{scaled register}&quot; with (e)BP as a special case.
vardump超过 6 年前
Good homework is to implement an x86-64 mod&#x2F;rm encoder.<p>Quite a few corner cases. Sometimes you&#x27;ll need to up-convert input parameters, because some combinations can&#x27;t use 8-bit offset, for example, but require a 32-bit value. RSP can&#x27;t use scaling, etc.<p>There&#x27;s also plenty of redundancy: <a href="https:&#x2F;&#x2F;www.strchr.com&#x2F;machine_code_redundancy" rel="nofollow">https:&#x2F;&#x2F;www.strchr.com&#x2F;machine_code_redundancy</a>
dsamarin超过 6 年前
I once had to multiply the `rsi` register by 3 so you bet I used `imul rsi, 3`, right? Nope. This does the exact same thing with an unknown or small performance advantage:<p>lea rsi, [rsi + rsi*2]
评论 #18081915 未加载
评论 #18081864 未加载