Building an OS - 5 - How to implement printf

preview_player
Показать описание
How to implement printf without any standard libraries, from parsing the format string, passing variadic arguments to formatting numbers and implementing x86 division.

Links:

Tools:

Documentation:
- OpenWatcom manuals (in installation directory)

Chapters:
0:00 Introduction
0:38 The plan
1:44 Passing varargs
7:07 Parsing the format string
12:35 Implementation
20:36 Division issues
23:41 Long division
25:25 Implementation of long division
28:55 Conclusion
Рекомендации по теме
Комментарии
Автор

such high quality content (including the filming aspects) for such a small channel!

raxneff
Автор

Thank you for these videos, definitely the best resource I've found on these fun topics. Also, I am grateful for you describing the problems you run into and how you work around them!

ewhitest
Автор

For a bit there, i was a little confused, wasn't getting the proper output and I assumed for a while that it was from my C code, but after some trial and error I found that it was in the assembly! yippee for problem solving :)

Maid-Shaymim
Автор

holy shit i just discovered the holy grail of creating an os,
dude thank you so much for making such high quality videos, words can't express my appreciation you are awesome!!

perhaps
Автор

Programmers opposition to goto isn't primarily a safety concern. It's a readability, and maintainability concern.

It can become hard to reason about the flow of the program when goto is breaking normal flow control. This isn't really a concern for anyone intimately familiar with the code. Only for later maintainers.

As you are nesting switches and implementing the entire state machine within a single function it's pretty obvious that having maintainers other than yourself is not a concern of yours either. 😅

DevonBagley
Автор

Part 2 of documenting my errors: I was missing a break; instruction in the PRINTF_STATE_NORMAL case, completly jumbling my output

somethingwithtech
Автор

You use `bits 16` while using 32-bit eax and ecx registers! Why the heck it works?!

WareXProvider
Автор

Когда я вставляю реализацию printf в файл stdio.с и он становится больше, то при запуске кода в qemu я получаю сообщение "Read from disk failed" из загрузчика, в чем может быть проблема? Причем если я оставляю только puts, putc и удаляю реализацию printf, то все работает нормально

Ahuenen-tz
Автор

Why did you choose argp to be a pointer to an int?

arielfuxman
visit shbcf.ru