r/cprogramming • • Jun 16 '26

Question about low level C integration

Hi, I have some experience in C but I still am fairly new, please correct me anytime.

I am coming from Python where everything is neatly organized, meaning the Python org is "controlling everything". As I understand this is not the case with C. Of course there is the ISO C standard, but there are many different compilers, implementations of the stdlib and different operating systems (in relevance to low level/embedded programming).

I really took liking in embedded programming. Experimenting with the Atmega328 (the standard Arduino MCU) is really fun. One thing I wanted to try is to combine C and Assembly, and it worked. I needed a function to slice one byte into each of its bits and put them into an array. I can call the assembly function from my C code. While researching how to do this I found the GCC ABI for AVR MCUs.

This brings me to my two questions:

1. How can one adapt a compiler to a specific target?

GCC was not developed for AVR MCUs. Is there just some file where the op-codes for AVR MCUs are written down? Something like a config file?

And the more important question:

2. Who makes/maintains ABIs?

They have to be different for every processor (architecture), OS and maybe even compilers? How can I find the relevant ABI if I want to make a function like above on a 64 bit, x86, AMD processor running Linux, using GCC?

Thanks in advance, please correct me if I am wrong. All this is a bit overwhelming.

15 Upvotes

13 comments sorted by

View all comments

Show parent comment

1

u/noob_main22 Jun 16 '26

So to find the ABI I need, I should look at the CPU manufacturer and OS?

2

u/edwbuck Jun 16 '26

You need to look for the conventions that surround your hardware. Standard is this case might be as loose as "what people tend to do"

1

u/WittyStick Jun 17 '26 edited Jun 17 '26

The CPU manual sometimes specifies a calling convention (eg, RISC-V), but it's a recommendation rather than a requirement. The OS defines the ABI.

Microsoft has its own ABI for Windows. Linux, OSX and others use the SYSV convention, which came from Unix. It is now maintained by The Open Group.