0

How can I execute my compiled C program (with VGA codes for example) by USB at computer power up?

I'm utilizing GCC compiler and no libraries, by example:

int main()
{
    int a = 0;
    int b = 2;
    int c = a + b;

    // bitmap codes to output image
    // vga registers input bitmap
}

... compiled file generated >> transfer do USB ... insert USB on PC, set BIOS to USB boot, and no O.S detected

how to?

jwpfox
  • 5,124
  • 11
  • 45
  • 42
Juba F.
  • 23
  • 5
  • 2
    Programs in C aren't bootable, for more details: [http://stackoverflow.com/questions/9983353/how-to-make-a-bootable-program][1] – Rasty Oct 29 '16 at 17:42
  • You should make a bootable USB drive first, then configure its OS to run your program on startup. – Weather Vane Oct 29 '16 at 17:48
  • You, personally know do this, in which step I'm missing? This is a community and I believe help is welcome, without taking the value of the sent link... – Juba F. Oct 29 '16 at 17:51
  • I have to download the GRUB, I have to set it up? I need to download any interpreter? Must allocate the first 512 bytes that are required at startup ... Any solid thing? It is very content and there is no step-by-step? The C programming language is compilable but not interpretable? – Juba F. Oct 29 '16 at 17:54
  • Booting a PC is a bit complicated but not that much, vid. e.g.: http://stackoverflow.com/questions/22054578/how-to-run-a-program-without-an-operating-system and here is a step-by-step one http://wiki.osdev.org/Bare_Bones – deamentiaemundi Oct 29 '16 at 18:07
  • @JubaF. - Regarding your question: _The C programming language is compilable but not interpretable?_ That is a correct statement, in general, but there are caveats. _[Look Here](http://stackoverflow.com/questions/584714/is-there-an-interpreter-for-c)_. – ryyker Oct 29 '16 at 21:23
  • real mode or protected mode code? – Michael Petch Oct 31 '16 at 00:58

1 Answers1

0

...set BIOS to USB boot, and no O.S detected

The USB has to be prepared as bootable before the PC can boot to it. See link containing details on how to do that below.

How can I execute my compiled C program (with VGA codes for example) by USB at computer power up?

Your post leaves out which OS you are running, and the approach will depend on that. See comments below.

(If more information is needed, you must provide more details in your post, or ask questions in comments under this answer, and I, or others will respond...)

Windows (two separate ideas)
For any recent Windows OS, you can simply place the exe you want to start upon boot up into the startup directory. For example in Windows 7, read this

Also for Windows, there is a discussion here on how to automatically launch an application in USB via autorun.

Linux
First step: Create a bootable USB drive... Or different instructions here

Second step: Modify the autofs file on your PC so that it will use the external drive. automatically mount USB external drive with autofs

Third step: This link explains in detail how to run your file upon boot up. Basically a script is added to the /etc/init.d/ directory to run an executable upon boot. (Note that this change needs to be in the OS contained on the USB bootable drive.)

Community
  • 1
  • 1
ryyker
  • 22,849
  • 3
  • 43
  • 87