OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Nov 22, 2019 9:59 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: boot2c - a simple way to write standalone programs for i386
PostPosted: Mon Sep 30, 2019 7:00 am 
Offline

Joined: Wed Jun 17, 2015 4:05 pm
Posts: 3
Hi there,

I was recently wondering how hard would it be to run C programs on i386 without an OS, and created a GitHub repo to share my approach. I traded portability for simplicity, so it's not the most correct way, but maybe someone will find it useful:

https://github.com/luke8086/boot2c

Any feedback will be appreciated!


Top
 Profile  
 
 Post subject: Re: boot2c - a simple way to write standalone programs for i
PostPosted: Mon Sep 30, 2019 8:38 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 3567
Location: Chichester, UK
You ask in your readme.md
Quote:
So why bother doing such a thing in 2019?
I've got to agree - why, when it is so simple to produce bootable DOS media which would allow you access to more facilities?


Top
 Profile  
 
 Post subject: Re: boot2c - a simple way to write standalone programs for i
PostPosted: Mon Sep 30, 2019 9:41 am 
Offline

Joined: Wed Jun 17, 2015 4:05 pm
Posts: 3
Quote:
I've got to agree - why, when it is so simple to produce bootable DOS media which would allow you access to more facilities?

Well, the whole premise was not to use any operating system.


Top
 Profile  
 
 Post subject: Re: boot2c - a simple way to write standalone programs for i
PostPosted: Fri Oct 04, 2019 5:19 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 409
Hi,

luke64 wrote:
I was recently wondering how hard would it be to run C programs on i386 without an OS
Are you familiar with Bellard's Tiny C compiler? It is capable of compiling and running C programs in memory (no disks involved). It is perfectly valid to do some script like this under Linux:
Code:
#!/usr/local/bin/tcc -run
#include <stdio.h>

int main()
{
    printf("Hello World\n");
    return 0;
}
Using this feature you can truly boot a C program directly, compiled at boot time. However you'll need to integrate a minimal libc at least.

Cheers,
bzt


Top
 Profile  
 
 Post subject: Re: boot2c - a simple way to write standalone programs for i
PostPosted: Fri Oct 04, 2019 10:48 am 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 985
Or Smaller C + e.g. BootProg (or FreeDOS).
Unreal mode is supported by the compiler.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: pharos and 5 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