Back to Browse

Calling assembly functions from C code

1.1K views
Jan 11, 2026
37:26

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...

Download

1 formats

Video Formats

360pmp457.6 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Calling assembly functions from C code | NatokHD