assemblyx86nasmbootsector

Test native x86 programs, building bootable images/drives


I have the next problem: I'm working with NASM and building some native and compiling it on this way:

nasm -f bin source -o out

I'm getting my native program for x86.

And now the most interesting, how can I make it bootable and then test it?

As I think there are 3 ways to make bootable ( but for me, all they has failed :( )

As for testing, all times rebooting PC is very bad, so it's better to use some Virtual OS soft like Vbox, VMWare etc..

So I used VBox for this. For building ISO - I used CDBurnerXP.

With cdburner I have optioned bootable sector for my native program, then choose new ISO in Vbox as disk from which will my program boot.

The result is always empty screen, no errors are showed, just nothing...

I think, that I have many errors...

Using mkbt, I can't write it to usb driver.... I don't have flooppy now, so I'm not able to write image to floppy, mkbt can't write to usb... :(

What do I wrong?

How can I solve my problem?


Solution

  • Just do this:
    nasm -f bin -o boot.bin boot.asm
    qemu -boot order=a -fda boot.bin

    And you should see the message. For other emulators you'll want to pad the image to 1474560 bytes.

    boot.asm:

            BITS 16
            ORG 0
            jmp 0x07c0:start
    
    start:
            mov ax, cs
            mov ds, ax
    
            mov si, msg
            call print_string
    
    hang:
            jmp hang
    
    print_string:
            cld
            lodsb
            or al, al
            jz .done
            mov ah, 0x0E
            int 0x10
            jmp print_string
    .done:
            ret
    
    msg:    db 'Hello World!', 13, 10, 0
    
            times 510-($-$$) db 0
            dw 0xAA55