tyler569

How printf works

Apr 2nd, 2018
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. printf("foo");
  2. // calls
  3. raw_print("foo", 3);
  4. // calls
  5. write(stdout, "foo", 3);
  6. // calls
  7. syscall3(SYS_WRITE, stdout, "foo", 3);
  8. // runs USER MODE
  9. interrupt 0x80 // ---------
  10. // calls KERNEL MODE
  11. isr_syscall(...registers)
  12. // calls
  13. c_interrupt_shim(...registers)
  14. // calls
  15. syscall_handler(...registers)
  16. // calls
  17. do_syscall(SYS_WRITE, stdout, "foo", 3);
  18. // calls
  19. sys_write(stdout, "foo", 3);
  20. // calls
  21. stdout_write("foo", 3);
  22. // calls
  23. printf("%c", 'f'); // and then ... printf("%c", 'o'); printf("%c", 'o');
  24. // calls
  25. raw_print("f", 1);
  26. // calls
  27. vga_write("f", 1);
  28. // calls
  29. vga_pack_char('f', COLOR_LIGHT_GREY, COLOR_BLACK);
  30. // and puts it at
  31. vga_curser_offset();
Add Comment
Please, Sign In to add comment