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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

From math to machine: translating a function to machine code

108 点作者 briansteffens超过 8 年前

6 条评论

conistonwater超过 8 年前
I wonder: since there are only thirteen factorials that fit into int32, and thus only 13 possible valid inputs, is it faster or slower to use a very small lookup table? <a href="https:&#x2F;&#x2F;godbolt.org&#x2F;g&#x2F;9ii0S0" rel="nofollow">https:&#x2F;&#x2F;godbolt.org&#x2F;g&#x2F;9ii0S0</a> It seems like this is the sort of thing a good compiler can figure out on its own, but I don&#x27;t fully understand what clang is doing with this loop: <a href="https:&#x2F;&#x2F;godbolt.org&#x2F;g&#x2F;ze5ycb" rel="nofollow">https:&#x2F;&#x2F;godbolt.org&#x2F;g&#x2F;ze5ycb</a>
nickpsecurity超过 8 年前
People wanting to go from math to machine might like a work that starts with formal specs.<p><a href="http:&#x2F;&#x2F;www.cl.cam.ac.uk&#x2F;~mom22&#x2F;miniml&#x2F;hol2miniml.pdf" rel="nofollow">http:&#x2F;&#x2F;www.cl.cam.ac.uk&#x2F;~mom22&#x2F;miniml&#x2F;hol2miniml.pdf</a><p>The resulting ML can be compiled to assembly by verified, CakeML compiler.<p><a href="https:&#x2F;&#x2F;cakeml.org" rel="nofollow">https:&#x2F;&#x2F;cakeml.org</a>
评论 #13692775 未加载
评论 #13694915 未加载
minimax超过 8 年前
What calling convention passes the first integer argument in rax and the return value in rdi? Thats exactly backwards from what I usually see.
bogomipz超过 8 年前
This was neat. I enjoyed reading it. It wouldn&#x27;t take much more to add the level below the machine code to this write up showing how the bits in the in the opcode generate control signals to carry out the micro-ops that make up the function.
评论 #13692806 未加载
chmaynard超过 8 年前
If the author is reading this thread, would you please comment on how math expressions are rendered in your blog? The factorial definition near the beginning looks absolutely perfect. I&#x27;d like to learn how to do this in Jekyll.
评论 #13694110 未加载
LeanderK超过 8 年前
out of interest, can somebody check how GHC compiles the factorial function as defined in the blogpost?
评论 #13694209 未加载
评论 #13691268 未加载