FASM - Boot sector on USB don't work -
in first, sorry bad english, i'm french. @ moment, learn asm fasm test boot sector programming.
i have make simple boot program, have compiled , write boot.bin in first sector of usb.
but when boot on pc or in virtualbox, drive isn't found....
boot sector code:
;======================================================================= ;   simpliest 1.44 bootable image shoorick ;) ;======================================================================= _bs equ 512 _st equ 18 _hd equ 2 _tr equ 80 ;=======================================================================     org 7c00h     jmp start     nop ;=====================================================     db  "he-he os";     ; 8     dw  _bs             ; b/s     db  1               ; s/c       dw  1               ; rs     db  2               ; fats     dw  224             ; rde     dw  2880            ;      db  0f0h            ; media     dw  9               ; s/fat     dw  _st             ; s/t     dw  _hd             ; h     dd  0               ; hs     dd  0               ; --     db  0               ; drv     db  0               ; --     db  29h             ; ebr     dd  0               ; sn     db  "no name    ";  ; 11     db  "fat12   ";     ; 8 ;===================================================== start:     mov   ax,cs     mov   ds,ax     mov   cx,count     mov   si,hello     mov   bx,7     mov   ah,0eh @@:     lodsb     int   10h     loop  @b     xor   ah,ah     int   16h     int   19h  hello   db "hi! disk-invalid!" count = $ - hello    ;=======================================================================     rb 7e00h-2-$     db 055h,0aah ;=======================================================================   this code provide examples of fasm's website.
there couple of reasons why bootloader wont work:
- the bootloader not in first sector of usb/floppy/etc.
 - the bootloader not exactly 512 bytes long
 - you missing 0xaa55 signature @ last 2 bytes of bootloader
 
in example assume have wrong bootloader size ( not 512 bytes )
try replacing
rb 7e00h-2-$ db 055h,0aah   with
times 510-($-$$) db 0 dw 0xaa55        this ensures file 512 bytes long , has required bootloader signature
Comments
Post a Comment