assembly - Bootloader - Doesn't jmp or load second sector correctly -
i've been desperatly trying create bootloader. @ point got working doesn't work anymore. when run it, prints , b. means actualy read, reason when jumps doesn't execute code set @ sec sector of usb drive.
i wonder if there's wrong adressing or jumps?
i included image of usb memory
[bits 16] [org 0x7c00] jmp start ;%include "bios_parameter_block.inc" ;%include "extensions.inc" ;%include "print.inc" ; prepare stack segment ;----------------------------------------------------------------- start: xor ax, ax mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax mov sp, 0x7c00 ; move stack sp mov bp, sp ; store current stack base of operations ; print character create sure bootloader has reached point ;----------------------------------------------------------------- mov ah, 0x0e ; print character screen mov bh, 0x00 ; no page numbering mov bl, 0x07 ; white text, black background mov al, 65 ; print letter int 0x10 ; check if int0x13 extentions supported ;----------------------------------------------------------------- mov ah, 0x41 ; set function 0x41 mov word bx, 0x55aa force dx ; save old drive identifier mov dl, 0x80 ; load 'active' id dl int 0x13 ; phone call interupt jc short unsupported ; if extentions aren't supported, jump clc ; clear carry bit ; read device. ;----------------------------------------------------------------- mov si, daps ; load daps struct ds:si mov ah, 0x42 ; read functions (al ignored) mov dl, 0x80 ; load 'active' id dl int 0x13 jc short unsupported ; if goes wrong... mov ah, 0x0e ; print character screen mov bh, 0x00 ; no page numbering mov bl, 0x07 ; white text, black background mov al, 66 ; print letter b int 0x10 ; print above jmp 0x0:0x7e00 ; jump main ; errors ;----------------------------------------------------------------- unsupported: mov ah, 0x0e ; print letter f, gives indication of failure mov bh, 0x00 mov bl, 0x07 mov al, 70 int 0x10 clc hlt ; memory info structures , other variables ;----------------------------------------------------------------- ; disk address packet construction (used loading rest of os) daps: db 0x10 ; size of construction (16 bytes) db 0 ; 0 dw 1 ; number of sectors read (1x512) dw 0x7e00 ; offset load to. dw 0x0000 ; segment load to. dq 1 ; read sec block ; fill out rest of bootloader ;----------------------------------------------------------------- times 510-($-$$) db 0 db 0x55, 0xaa ; add together boot record signature
stage2 placed @ sec sector
[org 0x7e00] [bits 16] mov ah, 0x0e ; print character screen mov bh, 0x00 ; no page numbering mov bl, 0x07 ; white text, black background mov al, 67 ; print letter c int 0x10 cli hlt
hope guys help me!
int 0x13 bios calls utilize drive id in dl register - 0x80 id of first hdd. may need alter in order load additional sector usb drive (which presumably not first hdd).
assembly x86 bootloader
No comments:
Post a Comment