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

Printing memory in c

Post by letrstotheprez »

I've been reading through the babysteps tutorials; does anyone have an example c function that works similarly to the example in babystep 8?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Printing memory in c

Post by Combuster »

Code: Select all

printf("%x", your_number_here);
no? :wink:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
letrstotheprez
Posts: 9
Joined: Tue Jul 17, 2012 11:09 am

Re: Printing memory in c

Post by letrstotheprez »

stdio.h isn't really available otherwise I would've thought of that.
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Printing memory in c

Post by Gigasoft »

There are numerous possible solutions to this problem, depending on your situation:

1. I know assembly, but not C
- Learn C
2. I don't know assembly, but know C
- Learn assembly
3. I don't know either assembly or C
- Learn C and assembly
4. I know both assembly and C
- Think about the problem some more
letrstotheprez
Posts: 9
Joined: Tue Jul 17, 2012 11:09 am

Re: Printing memory in c

Post by letrstotheprez »

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. If the example was written in any higher level language I wouldn't have a problem. Giving stupid answers like that helps no one and makes you sound like a douche.
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: Printing memory in c

Post by gravaera »

Yo:

Whom have you paid in here? Name one person on this forum you are paying, whether in cash or kind.

If you can't name anyone, then let it dawn on you that this is a special interest group kept together only by common interest, and it is highly vulnerable to decay due to proliferation of laziness. This special interest group has no funding or committee. If you don't like it, then don't use it. Don't call anyone here a douche. When you start paying me money, I'll give you detailed answers to supplement your lack of reading and preparedness.

You might have noticed by now that the key problem you have is that nobody is obliged to help you. Good job. Now work within the parameters given you, or seek some other source for help. Nobody here owes you anything...douche.

--Peace out
gravaera
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
letrstotheprez
Posts: 9
Joined: Tue Jul 17, 2012 11:09 am

Re: Printing memory in c

Post by letrstotheprez »

I didn't say he was a douche, I simply said that the rude way he replied made him sound like one and didn't help either of us. Obviously I'm not paying anyone in these forums and we all know that. But no one is. The point of forums such as these is to ask questions, to receive help, and to give help out of the goodness of your own heart, not for money. If this forum is full of people like you who think that they should only give helpful answers to people who pay them then maybe I'm wasting my time and the Internet is descending into anarchy (heh not like it hasn't already).
Darwin
Member
Member
Posts: 43
Joined: Sun Jan 16, 2011 6:58 pm
Location: United States

Re: Printing memory in c

Post by Darwin »

letrstotheprez wrote:The point of forums such as these is to ask questions, to receive help, and to give help out of the goodness of your own heart, not for money.
You're right. But if you want a question answered, you first need to put in some work of your own.
letrstotheprez
Posts: 9
Joined: Tue Jul 17, 2012 11:09 am

Re: Printing memory in c

Post by letrstotheprez »

Trust me, I spent time on it but apparently I need to include all of my failed attempts in my original question for people to not think I'm a useless idiot trying to copy other people's work.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Printing memory in c

Post by gerryg400 »

letrstotheprez, I think you dismissed combuster's answer too quickly. The answer, in c, is printf. If you don't have stdio.h available, you will need to port or write your own printf. It is the first step to success.
If a trainstation is where trains stop, what is a workstation ?
letrstotheprez
Posts: 9
Joined: Tue Jul 17, 2012 11:09 am

Re: Printing memory in c

Post by letrstotheprez »

Yes I know but doing that would still require being able to do this. I have a basic printing function but it currently doesn't do the format part of printf() which, to fully implement, I would need to know how to do what I'm asking. Obviously I want to learn something here or else I would just have copied down the asm exactly and complained when it wouldn't work perfectly with the functions I do have. (thanks for speaking reasonably)
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Printing memory in c

Post by Combuster »

There's two other things that aren't apparently obvious:
- C doesn't do registers, only variables. You can't print a register's value without resorting to at least some assembly.
- There is an entire page about Printing To Screen, including number conversions and varargs.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
letrstotheprez
Posts: 9
Joined: Tue Jul 17, 2012 11:09 am

Re: Printing memory in c

Post by letrstotheprez »

Thank you, that will definitely be helpful. I saw that page a while back but I guess I missed it in my search.
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Printing memory in c

Post by Gigasoft »

letrstotheprez wrote:The point of forums such as these is to ask questions, to receive help
No, it's not.

The purpose of this forum is to have a place where OS developers can talk about OS development. Nowhere is the word "help" mentioned on the front page. The use of the word "questions" in this section's description should not be taken as a statement of purpose for the site as a whole. Individual section descriptions are meant as a guide for separation of content into different sections. This question has nothing to do with OS development. It's like going to a Ferrari forum to get directions to the nearest Italian restaurant.
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:Yes I know but doing that would still require being able to do this. I have a basic printing function but it currently doesn't do the format part of printf() which, to fully implement, I would need to know how to do what I'm asking. Obviously I want to learn something here or else I would just have copied down the asm exactly and complained when it wouldn't work perfectly with the functions I do have. (thanks for speaking reasonably)
Frankly if you are doing OS development and C is your language of choice, you should know enough to be able to implement a user mode printf function.
Post Reply