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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: what happens between assembly and c?

2 点作者 ktran03将近 12 年前
Hi,<p>so in my undergrad, I&#x27;ve done some low level assembly programming I&#x27;ve also done quite a bit of c, and all the higher languages above that.<p>so my question is, what goes on between assembly and c?<p>HN please help me fill this gap, as it currently stands to be a mystery to me.<p>Thanks

4 条评论

syberslidder将近 12 年前
Are you asking how C gets turned into Assembly or how does C interact with the machine? A compiler will compile your C code into assembly and an assembler will produce machine code from your assembly. Everything, no matter how high level it is, eventually is a series of instructions on some physical processor. C is basically just a higher level of representation of the assembly code the machine runs. Since you have experience in both, I&#x27;m sure you can see how C constructs translate into assembly code. Example how a while or for loop uses conditional branching or how local variables are allocated on the stack. Operating systems are written in a mix of C and assembly, as some things are specific to the machine you are running on. For instance, switching between Protected mode and 32e mode on an x86-64 processor. If you&#x27;re also wondering how your code calls into operating system calls, it depends on both the processor and the operating system. For example on x86&#x2F;linux, some arguments are passed via registers and on the stack and a software interrupt is called to transfer control to the OS and have the OS service the request on your behalf, such as file I&#x2F;O or memory allocation. The more you study both of them, the more apparent it becomes how easily linked they are. I think what most people like about C is that its higher level than assembly but still gives you enough constructs that are close to the machine.
ktran03将近 12 年前
&quot;A compiler will compile your C code into assembly&quot;<p>basically what I was looking for. I have to look more into gnu gcc etc.<p>Thanks<p>checker659, actually mechatronics&#x2F;software engineering
deanfranks将近 12 年前
Are you asking what languages fill that gap, or how C programs interface with assembler libraries and OS interfaces?
checker659将近 12 年前
EE Major?