Printing memory in c

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
letrstotheprez
Posts: 9
Joined: Tue Jul 17, 2012 11:09 am

Re: Printing memory in c

Post by letrstotheprez »

Or I'm doing os development because it's fun and I want a challenge to help me learn even faster.
Tosi
Member
Member
Posts: 255
Joined: Tue Jun 15, 2010 9:27 am
Location: Flyover State, United States
Contact:

Re: Printing memory in c

Post by Tosi »

letrstotheprez wrote:Or I'm doing os development because it's fun and I want a challenge to help me learn even faster.
If OS dev. is one of your first projects then you are going to run into some big trouble sooner or later as I did when I first started.

If you just want to know how to write formatted output, then there is no reason to go through all the pain of writing even a basic kernel to do it, just write a function that uses putchar or puts to write the information once you've formatted. Then it can run in user-mode where it is much easier to debug.
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

Re: Printing memory in c

Post by Antti »

letrstotheprez wrote:I've been reading through the babysteps tutorials; does anyone have an example c function that works similarly to the example in babystep 8?
This post is not an actual answer to you question but I would like to introduce an approach that might help you with this. This also applies to the low-level programming in general.

Try to learn to visualize how basic C code snippets usually get translated to the assembly (for example, gcc with -S switch is quite handy). After doing that for a while, you will have a good understanding what is the relation between C and the assembly. That helps really much.
letrstotheprez wrote:I know both but assembly is still new enough to me that it's hard to translate it to c because they're so vastly different.
They are different language, of course, but I think that they are not vastly different. They are both rather low-level.
Dennis Ritchie wrote:[C has] the power of assembly language and the convenience of ... assembly language.
letrstotheprez
Posts: 9
Joined: Tue Jul 17, 2012 11:09 am

Re: Printing memory in c

Post by letrstotheprez »

I'm looking much farther into printf() now and deciding how I plan to implement it.

I know I'm going to run into challenges with this project but I'm hoping that I will because I enjoy them. This is the reason why I like programming; it gives me an opportunity to work through problems and forces me to learn a lot as I go.
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Printing memory in c

Post by iansjack »

Here you go: http://www.sparetimelabs.com/tinyprintf/index.html. It took about 30 seconds on Google to find that.

Google is a great resource; learn to use it wisely and you will have all the answers. And if it takes a little longer than 30 seconds you'll probably learn a great deal more than you intended. If you want to be at all successful in OS development you are going to learn how to do simple research - else, how are you going to do the hard stuff?
Post Reply