use16 jmp short _start nop ; padding times 62-($-$$) db 0 _start: cli mov ax, 07c0h ; set data segment mov ds, ax mov ax, 09e0h mov ss, ax mov sp, 1000h sti mov [bootdrive], dl ; save boot drive information mov si, bootdrive call dump8hex ; get drive parameter mov dl, [bootdrive] mov ah, 0x08 int 13h mov si, buffer + 16 mov [si + 0], ch ; cylinder & 0xff mov [si + 4], dh ; head mov al, cl and al, 3fh mov [si + 8], al ; sector shr cl, 6 mov [si + 1], cl ; (cylinder & 0x300) >> 2 call dump8hex call dump8hex call dump8hex ; get drive parameter mov dl, [bootdrive] mov si, buffer mov ah, 0x48 int 13h jc die mov si, buffer + 4 call dump8hex call dump8hex call dump8hex die: hlt jmp die ; dump 32bit word dump8hex: ; SI: address mov di, hexchar mov bh, 0 mov ah, 0eh mov cx, 4 add si, 3 dump8hex_loop: mov dl, [si] mov dh, dl and dx, 0ff0h shr dl, 4 mov bl, dl mov al, byte [bx + di] int 10h mov bl, dh mov al, byte [bx + di] int 10h dec si loop dump8hex_loop mov al, 20h int 10h add si, 5 ret hexchar: db "0123456789ABCDEF" ; workarea bootdrive: dd 0 buffer: dw 32 times 30 db 0 ; padding, boot signature times 494-($-$$) db 0 BootFlag db 80h ; required StartHead db 01h StartSector db 01h StartCylinder db 00h SystemID db 0a6h EndHead db 07h EndSector db 48h EndCylinder db 00h StartLBA dd 00000008h TotalLBA dd 00004038h dw 0aa55h