From the course: Advanced C Programming: Integrating C and Assembly Language

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Passing arguments in assembly

Passing arguments in assembly

- [Tutor] To fully integrate C in assembly language functions, you must understand how to pass arguments to the functions in the other language. This process works both ways. You pass arguments from your C code to an assembly language function. And in assembly, you pass arguments to C functions including library functions in your source code. In the C code, the safe input function is prototyped at line three. It's an assembly language function which reads a specific number of characters from standard input, storing them in a buffer. The function is called at line 10. Here's the assembly language source code for the safe input function. The function is declared globally at line 16. The first argument pass the buffer or string address, is passed along in register rdi. The second argument is the length passed in register rsi. Because register rdi is used in the system call at line 25, it's value, the buffer's address,…

Contents