TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: what happens between assembly and c?

2 pointsby ktran03almost 12 years ago
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 comments

syberslidderalmost 12 years ago
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.
ktran03almost 12 years ago
&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
deanfranksalmost 12 years ago
Are you asking what languages fill that gap, or how C programs interface with assembler libraries and OS interfaces?
checker659almost 12 years ago
EE Major?