-1

at the moment I try to write my own bootloader with nasm, but I'm not really successful.

The problem is, I want to convert my .bin file to .iso or annother image file, so that the VM recognizes it.

But my conversion programs say that the file is broken.

My .bin file was compiled with the NASM compiler under Linux and is exactly 512 bytes large.

nasm boot.asm -f bin -o boot.bin
[BITS 16]
[ORG 0x7C00]

start:
 mov    SI, msg

 call   eachstring
 jmp    $

eachstring:
 mov    AL, [SI]
 inc    SI

 OR     AL, AL
 je     end
 jne    printchar

printchar:
 mov    AL, [SI];Parameter festlegen

 mov    AH, 0x0E;Opcode ein Zeichen auszugeben
 mov    BH, 0x00;Keine Seite
 mov    BL, 0x07
 int    0x10
 ret

end:
 ret

msg     db 'Hallo Welt', 0
TIMES 510 - ($ - $$) db 0;Füllt den restlichen Speicher
dw 0xAA55;Magic key

I hope anybody can help me. =(

Thank you in advance

Best regards

Simon2215
  • 222
  • 1
  • 2
  • 12
  • You should show how you're converting it and what error message you got. – Ross Ridge May 15 '20 at 16:43
  • Thank you for answering. I tried two different tools, but both gave me an error. With the package "iat" under linux "Image is broken" and with ccd2iso "Error at sector 0. The sector does not contain complete data. Sector size must be 2352, while actual data read is 512" – Simon2215 May 15 '20 at 17:25

1 Answers1

1

An .iso for this is excessive, and the padding your bootloader has makes it so your .bin is the same size as a floppy disk sector, so use a floppy image instead:

#Prepare an empty image, this is the maximum size of a floppy disk
dd if=/dev/zero of=boot.img bs=1024 count=1440
#Insert your .bin to the first sector of the floppy disk
dd if=boot.bin of=boot.img conv=notrunc 

Running this will produce the bootable floppy disk image boot.img

See this answer for more information: https://stackoverflow.com/a/34108769/5269447

0x777C
  • 993
  • 7
  • 21