C Language Course: https://pyjamacafe.com/library/#c
In this video I show how to write a function in Assembler and then call it from C code. I demonstrate this by creating a bare-metal firmware for the risc-V CPU emulated using QEMU.
The RV32I instruction set doesn't include the multiplication instruction and so a multiply operation in C code requires a software implementation of the multiplication (__mulsi3)
I show how to implement the __mulsi3 function in assembly and how the parameter are passed to this function from the C code. Further, I demonstrate how the result is computed in the software sequence by monitoring the code using GDB.
Towards the end, I talk about scenarios in which one would consider writing functions in assembly and calling them from C code. Things like cache maintenance operations, mutexes, semaphore, spinlocks etc are written in Assembly...