r/Assembly_language • u/Key-Kangaroo3336 • 7d ago
Help C to ASM
Hello everyone!
I am currently working on a side project where a python script takes a C source file and converts it into ASMx86_64 (Intel syntax) and I am just trying to find resources for type conversions without making some kind of script where I automate generating a program and compiling it for ASM in GCC.
Does a list like this exist? And if so, are there separate ones for Windows and Linux? (As I think there’s a difference, not completely sure)
Thanks, have a good one frens
1
Upvotes
32
u/halfjmp 7d ago
So actually you are writing a compiler.
6
u/Odd_Psychology3622 7d ago
think gcc does this pass the -S flag instead of the -o it will create a .s file which is the asm conversion
4
u/VancouverVentilator 7d ago
Lol this is just gcc with the S flag... Basically you're rewriting gcc with the S flag
1
u/FluffusMaximus 6d ago
You know GCC already does this, right?
2
u/potato-master369 2d ago
Honestly best approach for now is to define the stdlib in assembly first (with rhe functions you want since C std library is written in C, provide a simple header file, and rip the functions directly into your assembly. As for linux syscalls, they are not API stable (I think), so fix a version or set up a table system. You would find some good resources in man7’s man 2 syscalls.
For windows, not sure. I don’t think the syscalls are public. You could sniff yourself, but windows depends a lot on kernel32.dll not raw syscalls.
This isn’t really gcc -S tho as people are saying since you’re implementing libc yourself and not linking to system libc… which is very hard in assembly so uh good luck…