Creating a pure binary image using binutils ?

Hello Friends,

I am trying to boot a floppy image on Bochs (x86 emulator). I have made a small program in assembly where i use the bios video services (0x10) to write a character to the screen. I compiled this program using gcc.

I am going to write it to the boot sector of the floppy image.

Can anybody tell me how to get a pure binary image from the elf file gcc has produced. I guess i have to use objcopy. But I am not sure. Can anybody help?


Reply to
Loading thread data ...

Yes, you use objcopy:

objcopy --output-target=3Dbinary ...


Reply to

It seems obvious that the file you produced with gcc is 32 bit code. A PC boots in 16 bit mode and it does not understand 32 bit code, when initially booted.

The code read from the boot diskette (image) has to transfer the computer into 32 bit mode before the binary produced by gcc is runnable.

On the other hand, the 32 bit code cannot use common BIOS routines which run in 16 bit mode.

Tauno Voipio
tauno voipio (at) iki fi
 Click to see the full signature
Reply to
Tauno Voipio

These are some very good points.

Maybe it's worth mentioning that MS-DOS "debug" gave you the capability to non-symbolically assemble 8086 mnemonics, write binary .com executables to disk, or even to disk sectors.

Does freedos have something comparable?

I think there were 16 bit dos ports of GCC at some point in the past that might be useful too?

Reply to

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.