could you use normal functions like "printf"

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.
Locked
truenoteno

could you use normal functions like "printf"

Post by truenoteno »

When you compile apps in C, without dos could you use "printf" still ?
Or do you have to integrate assembly into C.
Chris Giese

RE:could you use normal functions like "printf"

Post by Chris Giese »

>On 2001-09-24 20:04:12, truenoteno wrote:
>When you compile apps in C, without dos could you use "printf" still ?

printf() will eventually call a function to send
text to stdout. No DOS, no stdout.

If you have cprintf(), it might work without changes. If not, you might be able to use sprintf():

char buf[64];
sprintf(buf, "%u score and 7 years ago", 4);
cputs(buf);

(write your own cputs() function)

The printf() functions call a lot of other
code, for different character sets, floating
point math, etc, so it might be difficult to
use them without an OS. If all else fails,
you can write your own printf() or use mine:
http://www.execpc.com/~geezer/osd/code/ ... doprintf.c
http://www.execpc.com/~geezer/osd/code/inc/_printf.h
http://www.execpc.com/~geezer/osd/code/inc/stdarg.h

>Or do you have to integrate assembly into C.

You can write printf() in C.
jbarrow
Posts: 1
Joined: Sat Nov 07, 2009 4:59 pm

Re: could you use normal functions like

Post by jbarrow »

I am under the assumption that you can't use printf when you call it without DOS, unfortunately. Same with inputting data from what the user typed, or even letting the user see what they typed. This all has to be done by implementing C with ASM. I understand that normally you use 'extern void' to call an ASM function in C.
User avatar
-m32
Member
Member
Posts: 120
Joined: Thu Feb 21, 2008 5:59 am
Location: Ottawa, Canada

Re: could you use normal functions like

Post by -m32 »

Seriously?? This thread is 8 years old!
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: could you use normal functions like

Post by Combuster »

I'd say Necro and sheer stupidity. Please learn to read first.
you wrote:you can't use printf
Chris Giese wrote:you can write your own printf()
You wrote:This all has to be done by implementing C with ASM
Chris Giese wrote:You can write printf() in C.
"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 ]
Locked