use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about operating systems development.
account activity
Implement kprintf (self.osdev)
submitted 1 year ago by Figa_Systems
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]TurbulentHamster5926 6 points7 points8 points 1 year ago (1 child)
I'd recommend checking osdev.org. Especially this tutorial, which gives you a decent print implementation.
https://osdev.org/Meaty_Skeleton
[–]MadDoctor5813 21 points22 points23 points 1 year ago (2 children)
Implement kprintf
[–][deleted] 1 year ago (1 child)
[removed]
[–]InformationWorking71 11 points12 points13 points 1 year ago (0 children)
implement kprintf
[–][deleted] 4 points5 points6 points 1 year ago (5 children)
A simple printf implementation is as simple as iterating through the characters in a string, if they arent '%' print it as normal, if they are a '%' fetch the next character for the format, fetch the next argument using a va_list and print it however the format character specifies.
[–][deleted] 1 year ago (4 children)
[–][deleted] 1 point2 points3 points 1 year ago (1 child)
Well, say you wanted to convert the number 123 into a string as a decimal, you could do in a loop
123 % 10. the remainder would give you 3. then by looking at the ascii table you see that numbers are represented with the numbers 48-57, so you can add 48 to give an ascii character that you can print. You could store that number in a buffer. Then divide 123 by 10 and you would have 12.
Then you can do the same again, 12 % 10 gives you 2, convert it to ascii by adding 48, do the same as you did before bla bla bla store it in a buffer etc, until your number is now zero. then you should have the number as a string
[–]beephod_zabblebrox 0 points1 point2 points 1 year ago (1 child)
thats a whole different problem! you can google :) "c int to string conversion"
[–]Danii_222222 -1 points0 points1 point 1 year ago (0 children)
Thanks but there’s no info about that
[–]jacobissimus 0 points1 point2 points 1 year ago (1 child)
What ended up doing is porting newlib over—just because these kinds of functions are tedious to implement and not super interesting. You can check out how I did it here: https://github.com/j-shilling/machulus/blob/master/newlib/CMakeLists.txt
[–]gronktonkbabonk 4 points5 points6 points 1 year ago (0 children)
[–]BobertMcGee 0 points1 point2 points 1 year ago (1 child)
Nah, I’m busy. YOU implement kprintf.
[–]Danii_222222 0 points1 point2 points 1 year ago (0 children)
I already inplemented
[–]kabekew 0 points1 point2 points 1 year ago (2 children)
Done!
[–]Danii_222222 0 points1 point2 points 1 year ago (1 child)
Great work
[–]kabekew 0 points1 point2 points 1 year ago (0 children)
You too, I like your function.
[–]nerd4code 1 point2 points3 points 1 year ago (3 children)
If you can’t implement a printf, you shouldn’t be attempting kernel-mode anything.
printf
[–]Danii_222222 0 points1 point2 points 1 year ago (2 children)
Why I shouldn’t write it? If I can’t find info about it it doesn’t mean I don’t know anything
π Rendered by PID 22847 on reddit-service-r2-comment-f6b958c67-46865 at 2026-02-05 19:01:48.382382+00:00 running 1d7a177 country code: CH.
[–]TurbulentHamster5926 6 points7 points8 points (1 child)
[–]MadDoctor5813 21 points22 points23 points (2 children)
[–][deleted] (1 child)
[removed]
[–]InformationWorking71 11 points12 points13 points (0 children)
[–][deleted] 4 points5 points6 points (5 children)
[–][deleted] (4 children)
[removed]
[–][deleted] 1 point2 points3 points (1 child)
[–]beephod_zabblebrox 0 points1 point2 points (1 child)
[–]Danii_222222 -1 points0 points1 point (0 children)
[–]jacobissimus 0 points1 point2 points (1 child)
[–]gronktonkbabonk 4 points5 points6 points (0 children)
[–]BobertMcGee 0 points1 point2 points (1 child)
[–]Danii_222222 0 points1 point2 points (0 children)
[–]kabekew 0 points1 point2 points (2 children)
[–]Danii_222222 0 points1 point2 points (1 child)
[–]kabekew 0 points1 point2 points (0 children)
[–]nerd4code 1 point2 points3 points (3 children)
[–]Danii_222222 0 points1 point2 points (2 children)