Creating a pure binary image using binutils ?

Sep 11, 2008 3 Replies

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?



Kaustubh


Yes, you use objcopy:

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

Jim

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

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?

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required