s-matyukevich / raspberry-pi-os

Learning operating system development using Linux kernel and Raspberry Pi
MIT License
12.98k stars 1.28k forks source link

why not used c in utils.S #252

Open merelyaspirant opened 2 years ago

merelyaspirant commented 2 years ago

In lesson 1, any specific reason of not using C to implement put32 and get32 in utils. Please clarify if its just a choice or any specific reason.

seusher commented 1 year ago

For anyone who is wondering the same: utils.S is an assembly source file, so you can't directly use C code in it. You can write the uart code all in C if you want to - see https://github.com/bztsrc/raspi3-tutorial/blob/master/03_uart1/uart.c

I'm not the author, but using assembly instead of C is a better educational experience and helps you understand ARM64 calling conventions rather than glossing over them and letting the compiler figure out the low-level details for you.