Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding the hardware of printf

Tags:

c

hardware

I was wondering if there was any resources available online that explains what happens with something, like printf of C, that explains what's going on in the very low level (BIOS/kernel calls)

like image 325
tipu Avatar asked Mar 16 '10 19:03

tipu


People also ask

How does printf function work?

The printf function (the name comes from “print formatted”) prints a string on the screen using a “format string” that includes the instructions to mix several strings and produce the final string to be printed on the screen.

What is the use printf?

The printf() is a library function to send formatted output to the screen. The function prints the string inside quotations. To use printf() in our program, we need to include stdio.h header file using the #include <stdio.h> statement.

How does printf work in assembly?

Printf in Assembly To call printf from assembly language, you just pass the format string in rdi as usual for the first argument, pass any format specifier arguments in the next argument register rsi, then rdx, etc.

What is printf in programming?

"printf" is the name of one of the main C output functions, and stands for "print formatted". printf format strings are complementary to scanf format strings, which provide formatted input (lexing aka. parsing).


1 Answers

Linux:

printf() ---> printf() in the C library ---> write() in C library ---> write() system call in kernel.

To understand the interface between user space and kernel space, you will need to have some knowledge of how system calls work.

To understand what is going on at the lowest levels, you will need to analyze the source code in the kernel.

The Linux system call quick reference (pdf link) may be useful as it identifies where in the kernel source you might begin looking.

like image 77
jschmier Avatar answered Oct 11 '22 00:10

jschmier