tyler569 icon

How printf works

tyler569 | PRO | 04/03/18 02:49:49 AM UTC | 0 ⭐ | 723 👁️ | Never ⏰ | []
text |

700 B

|

None

|

0 👍

/

0 👎

printf("foo");
// calls
raw_print("foo", 3);
// calls
write(stdout, "foo", 3);
// calls
syscall3(SYS_WRITE, stdout, "foo", 3);
// runs                USER MODE
interrupt 0x80    //   ---------
// calls               KERNEL MODE
isr_syscall(...registers)
// calls
c_interrupt_shim(...registers)
// calls
syscall_handler(...registers)
// calls
do_syscall(SYS_WRITE, stdout, "foo", 3);
// calls
sys_write(stdout, "foo", 3);
// calls
stdout_write("foo", 3);
// calls
printf("%c", 'f'); // and then ... printf("%c", 'o'); printf("%c", 'o');
// calls
raw_print("f", 1);
// calls
vga_write("f", 1);
// calls
vga_pack_char('f', COLOR_LIGHT_GREY, COLOR_BLACK);
// and puts it at
vga_curser_offset();

Comments