how system call works

system call is a way for usermode program to call kernel functions,
this is needed because sometimes we need to talk to hardware or we need to execute some privilaged things, we should a way. that way is called system call instruction,
when this instructiojn is executed then cpu will switch its mode to kernal mode . then calls kernels function. the function is a group of code that exisit in kernel memmory , it willbe executed,
system calls arfgumnents are passed by adding values to some registers,so when kernels code excutes it will read registers and detemind values passed to it,
for example which system call is should be executed and what are its input arguemnts.
these registers and system call numbers are defined by kernal not instruction set,

below is the minimum instruction for a system call,

mov r8, #syscall_number
svc #0
Powered by Forestry.md