Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

popcorn

printf

This topic is 5732 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey does anyone know how the printf function really works in c. I have some sort of idea about how it can accept a variable number of parameters(i.e using vastart and vaend i think) but how does it really output the string to the screen. I guess in a computer everything probably goes through the BIOS so does it use this to print out characters or does the operating system provide some kind of support for outputting text? How about them apples?

Share this post


Link to post
Share on other sites
Advertisement
See there for an example.

Notice their reliance on sys_write() which is probably provided by the OS kernel, which itself relies on the BIOS/graphics card driver to display them - depending on whether you''re in a VGA ASCII console or in some kind of graphics environment.

This shows that SYS_write is available in Linux as function 4 of interrupt 0x80 - a linux kernel call.


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | Free C++ IDE. ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Boost C++ Lib ]

Share this post


Link to post
Share on other sites
Ok so the answer is that the operating system provides some functions to handle printing out text through it''s kernal which is generally responsible for file input/output and memory management by providing a set of functions to use such as sys_write() etc. And then the printf function uses these to print out text to a screen rather than make calls to the bios.

Would i be right to assume that most of the functions that an operating system kernal provides eventually makes some kind of call to the bios to actually perform the task.

How about them apples?

Share this post


Link to post
Share on other sites
quote:
Original post by popcorn
Would i be right to assume that most of the functions that an operating system kernal provides eventually makes some kind of call to the bios to actually perform the task.



The VGA BIOS provides functions to draw ASCII characters, with
characters 0x80-0xFF varying from codepage to codepage. This is
what real (DOS-era) consoles use.

Operating systems running a GUI have their own character-drawing
routines that may or may not access the BIOS to draw individual
pixels on the screen : graphic card drivers provide the OS with
an alternative and usually richer interface to the hardware.

The same is true of other devices. For the most part, the BIOS
has been relegated to the task of booting up the OS, which then
use specific hardware drivers, with access to the exact
hardware interface - the BIOS is/was an abstraction layer.


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | Free C++ IDE. ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Boost C++ Lib ]


[edited by - Fruny on December 7, 2002 10:11:17 PM]

Share this post


Link to post
Share on other sites
printf formats the given arguments according to the format string, and writes them to the standard output, that is the stdout (of type FILE*). What exaclty is done with stdout and where it is pointing should not be the consern of the C programmer. The low-level stuff should be seemlessly handled by the implementation of the C compiler and its libraries at hand. Howerever, if you are interest in how exactly different types computers handle spewing text on the screen, you should look at the specific tehcnical documents of those systems, not C.

Share this post


Link to post
Share on other sites
What kind of apples are you talking about ? The really old ones, or the newer macs running OSX which has unix as its core ?

As far as I know, macs really do not have support for any purely text based video modes in their BIOS, since they had GUI's for user interfaces from the getgo, not like PCs. But I guess they could be emulated. So - I think that it is a safe bet to say that when you open up the unix shell(console) on a mac, everything is done via a terminal emulator running on the GUI of the mac OS, which in turn is making calls to the video system via some API, just like other applications do when rendering their content in a window owned by them. This is just educated speculation on my part, and I really do not know from where to find apple tech-specs, you can always try your luck on google though

[edited by - EvilTachikoma on December 8, 2002 12:18:22 PM]

[edited by - EvilTachikoma on December 8, 2002 12:19:17 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!