I'm trying to learn the assembly in more detail and I think that C code compilation and analysis of generated assemblies are a good way to start.
Compile a simple
printf ("% d n", 5 ") create the following:
.globl _main ## - Starts the main function _main: ## @main .cfi_startproc ##% bb.0: pushq% rbp .cfi_def_cfa_offset 16 .cfi_offset% rbp, -16 movq% rsp,% rbp .cfi_def_cfa_register% rbp under $ 16,% rsp leaq L_.str (% rip),% rdi movl $ 5,% esi movl $ 0, -4 (% rbp) movb $ 0,% al callq _printf xorl% esi,% esi movl% eax, -8 (% rbp) ## spill over 4 bytes movl% esi,% eax addq $ 16,% rsp popq% rbp retq .cfi_endproc ## - End function .section __TEXT, __ cstring, cstring_literals L_.str: ## @ .str .asciz "% d n"
Here are my questions:
1- What is the difference between using
callq _printf and make a system call with
int 0x80; or
system call? is
_printf to make the same system call behind the scenes? is
_printf defined in
2- Where can I see the documentation on the use of such calls i.e
_printf. The documentation indicating where to place specific values in which registry for this to work, is this called an ABI?
3- Same question as # 2 but on system calls such as
int 0x80;. Where can I see a list of these calls and how to use them in assembler?
I know the Linux manual pages but (correct me if I'm wrong), its documentation explains how to use them in C / C ++ code and not Assembly.