Author Topic: BOOT bin files  (Read 3432 times)


  • Guest
BOOT bin files
« on: January 15, 2005, 01:39:27 AM »
I need to find a way to compile ASM files into boot records, i have the asm file i need (although im not 100% sure it will work ... can't test it!!!) but not the command.

NASM -fbin doesen't seem to be the one ... i can't use DOS com files for my boot sector!

and i can't figure out what option will compile plain binary assembler!

thanks for any help!

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2451
  • Country: us
Re: BOOT bin files
« Reply #1 on: January 15, 2005, 10:24:40 AM »
Hi jakykong,

"-f bin" is, in fact, the output format you want. Dos .com files are only one of it's uses. For a dos .com file, you'd want "org 100h" at the top of your source, and probably "-o" on the command line - the default output name in "-f bin" mode would be just "myfile"... which you'd have to rename to "" before it would work. "-f bin" is Nasm's default output mode, so you don't actually need it on the command line, but I recommend using it just for "clarity". (and it's possible to compile Nasm so that the default *isn't* "-f bin", though I've never heard of anybody doing so)

For a bootsector, you want either "org 0" (which would be the default) or "org 7C00h". Which you want depends on how the rest of the file is written. If you've got "org 0" (or don't say), you want to set ds (and perhaps es) to 7C0h. If you've got "org 7C00h", you need to set your segregs to 0. Failure to get this right is, by far, the most common reason bootsectors don't work, IME.

So a Nasm command line something like "nasm -fbin -o myboot.bin myboot.asm" is what you want. Then you need to get it written to floppy (I *hope* you're not doing this on a hard disk!). Not having the file written where you intend is another common reason why these thing don't work. Good ol' "debug"(ugh) will work fine... or rawrite. If Linux, "dd" will do it. I've also got a little "boot writer" that simplistically looks for "boot.bin" and writes it to sector 1 of drive a:. I can send you the source to that if you want, but if you can't do it yourself, you're not ready to mess with bootsectors, IMHO.

Happy Bootin',