Tampilkan postingan dengan label NASM bootstraps tutorial. Tampilkan semua postingan
Tampilkan postingan dengan label NASM bootstraps tutorial. Tampilkan semua postingan

Jumat, 21 Februari 2014

NASM bootstraps tutorial

The basics
----------
These are the rules that you must follow:
  - The BIOS will load your bootstrap to address 07C00h. Sadly, the segment and     offset varies.
  - Bootstraps must be compiled as plain binary files.
  - The filesize for the plain binary file must be 512 bytes.
  - The file must end with AA55h.

A minimal bootstrap
-------------------
This bootstrap just hangs:

    ; HANG.ASM
    ; A minimal bootstrap
    hang:                   ; Hang!
            jmp hang

    times 510-($-$$) db 0   ; Fill the file with 0's
    dw 0AA55h               ; End the file with AA55

The line starting with "times" is a command that only NASM understands. The line will insert 0's until the filesize is 510 bytes. The whole file will therefore be 512 bytes. The last instruction puts AA55 at the end of the file.