Zhu Hengzhi + "Linux kernel analysis" MOOC course http://mooc.study.163.com/course/USTC-1000029000 "
Use the same system call using the Library function API and the embed assembly code in C code two ways
List of system calls see HTTP://CODELAB.SHIYANLOU.COM/XREF/LINUX-3.18.6/ARCH/X86/SYSCALLS/SYSCALL_32.TBL
I have chosen number 20th:
Use the Library function API to display the ID of the process on the screen:
Use the C language to embed the assembly code:
Code:
#include <unistd.h>
#include <stdio.h>
int main ()
{
pid_t pid; PID = Getpid ();
ASM volatile (
"Mov $0x14,%%eax\n\t"
"Int $0x80\n\t"
"Mov%%eax,%0\n\t"
< Span class= "Hljs-keyword" >&NBSP;: "=m" (PID));
< Span class= "Hljs-keyword" > printf ( "pid =%d \ n", pid);
< Span class= "Hljs-keyword" > return 0;
< Span class= "Hljs-keyword" > }
Use the same system call using the Library function API and the embed assembly code in C code two ways