OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 23, 2024 3:57 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: va_list etc...
PostPosted: Thu Aug 30, 2001 12:32 am 
Hi,

I'm thinking about writing my own OS (to learn more about OS-architecture), and well... I'm stuck... and I'm not even started yet.

I wrote a simple "Hello World !" bootsector (I think everybody tries that sooner or later), and I was thinking : Now I need a printf()-like function so I can display more useful information. I know how to use va_list and va_start in normal C-apps, but in an OS, you have to define those macros yourself.... and that's my problem.

I looked at the stdarg.h file from other Operating Systems (linux 0.1 and Thix 0.3.x), but those macro definitions don't make sense to me... I don't want to "cut & paste" them, because I want to understand the code (instead of just using it).

Do you have any information about what those macros actually do ?? It looks like voodoo to me...

Thnx in advance,

Jeroen Jacobs


Top
  
 
 Post subject: Re: va_list etc...
PostPosted: Thu Aug 30, 2001 5:00 pm 
Here's my stdarg.h:
http://www.execpc.com/~geezer/osd/code/inc/stdarg.h

It's a lot of C voodoo using pointers and casts and sizeof and the comma operator, but it works. It might even work with a 16-bit compiler, but I haven't checked this.

va_start() points to the first variable argument.
va_arg() advances the pointer, then evaluates to the previous argument (comma operator).
va_end() doesn't do anything.

Here's my printf(), too;
http://www.execpc.com/~geezer/osd/code/inc/_printf.h
http://www.execpc.com/~geezer/osd/code/ ... doprintf.c


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Majestic-12 [Bot] and 104 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group