Converting C to Assembly – A Programmer's Tale ??
Hello LinkedIn Community! ??
Let me take you on a delightful detour I recently embarked upon in the world of programming. It all started quite unexpectedly, inspired by a snippet from a vlogger's tech interview experience.
The Spark: From Vlog to Venture
Picture this: a regular day turned intriguing. I was watching Piyush Itankar's vlog, where he shared a brain-teaser from his ARM interview - converting C code into assembly
The Process: C to Assembly
To demystify this process, let's take a classic example - the 'printf' function in C. We all use it, but how does it work under the hood? When we compile a C program, each function, including 'printf', is translated into a series of assembly instructions. These instructions are what the CPU directly executes.
The C to Assembly Odyssey
Diving into this challenge, I realised it's more than just a technical exercise
?? Example Dissection:
C Code:
Assembly Code:
Assembly Breakdown:
2. The For Loop – A Closer Look
C Code:
领英推荐
Assembly Code:
Assembly Breakdown:
3. If-Else: The Decision-Making Drama
C Code:
Assembly Code:
Assembly Breakdown:
The How-To: Setting Up and Diving In
Eager to try it yourself? Here's how I approached it:
gcc -S -o output.s yourprogram.c
In Conclusion: A Journey of Insight and Intrigue
What started as a curious peek into Piyush Itankar's interview experience turned into a deep dive into the nuts and bolts of programming. It's fascinating how a simple interview anecdote can lead to such an enriching learning experience
#embeddedsystem #cprogramming #c2assembly #assemblylanguage #firmwareengineering
Graduate Research Assistant | Embedded Firmware Developer
1 年Can you share any link to the vlog you mentioned? Thanks
Embedded Software Engineer | MSc Embedded Systems
1 年Interesting read, I have done a similar thing a while back to dive into the assembly and explore how the code was converted: https://cthecosmos.com/2022/10/29/peeking-into-the-assembly/
Embedded Systems @Google | pyjamabrah.com
1 年Kiran Jojare ?? this is so much fun! I see you generated the assembly for x86. try it for ARM or RISC-V the assembly is more readable and relatable… ??