OK. Here is a code:
boot.asm - MBR Bootloader
Code: Select all
[BITS 16]
[ORG 0x00007C00]
BOOT_MAIN:
cli
xor bx,bx ;BX = 0
mov ss,bx ;Stack Segment = 0
mov sp,0x7C00 ;Stack Pointer = 0x7C00
sti ;Enable Interrupts
call fClrScr
mov si, [ DB_MSG_BOOTSTART ]
call fPrint
call fReadFloppy
call fExecExtendBoot
jmp $
fPrint:
mov ah,0x0E
mov bh,0x00
mov bl,0x07 ; Normal text attribute
.fPrintChar:
lodsb
or al,al
jz .fPrintReturn
int 0x10
jmp .fPrintChar
.fPrintReturn:
ret
fClrScr:
mov ax, 3
int 10h
ret
fReadFloppy:
mov ah,0x02 ;Read disk sectors
mov al,0x01 ;Read ONE sector
mov ch,0x00 ;Track 0
mov cl,0x02 ;Sector 2
mov dh,0x00 ;Head 0
mov dl,0x00 ;Drive 0
mov bx,0x7E00 ;Set BX offset to our desired load location
mov es,bx ;Set Head Offset to 0, Set Drive Number to 0 (First Floppy Disk)
mov bx, 0x0000;
int 0x13 ;Execute BIOS Interrupt:
ret
fReadFloppy2:
mov ah,0x02 ;BIOS Interrupt Function 0x02 (Read Sectors int Memory)
mov al,0x02 ;Load 1 sector from floppy
mov es,bx ;Zeroed-out above, sets the ES Segment Register
mov bx,0x7E00 ;Set BX offset to our desired load location
mov cx,0x0002 ;Set Cylinder Offset to 0, Set Sector offset to 2
xor dx,dx ;Set Head Offset to 0, Set Drive Number to 0 (First Floppy Disk)
int 0x13 ;Execute BIOS Interrupt:
ret
fExecExtendBoot:
jmp 0x7E00:0x0000
ret
DB_MSG_BOOTSTART db 13, 10, ' Booting MBR... ', 0
DB_MSG_OK db '[OK]', 13, 10, 0
DB_MSG_FAILURE db '[FAILURE]', 13, 10, 0
DB_MSG_ERROR db 13, 10, ' **** [ERROR]: ', 0
times 510-($-$$) db 0 ; Fill the rest with zeros
dw 0xAA55 ; Boot loader signature
fReadFloppy and fReadFloppy2 dosn't works.
Extended Bootloader
Code: Select all
[BITS 16]
[ORG 0x00007E00]
EBOOT_MAIN:
cli
xor bx,bx ;BX = 0
mov ss,bx ;Stack Segment = 0
mov sp,0x7E00 ;Stack Pointer = 0x7C00
sti ;Enable Interrupts
mov si, [ DB_Message_Starting ]
call fPrint
jmp $
fPrint:
mov ah,0x0E ; The function to display a chacter (teletype)
mov bh,0x00 ; Page number
mov bl,0x07 ; Normal text attribute
.fPrintNextChar
lodsb
or al,al
jz .fPrintReturn
int 0x10
jmp .fPrintNextChar
.fPrintReturn:
ret
fClrScr:
mov ax, 3
int 10h
ret
DB_Message_Starting db 'OK',13,10,0
I can't understand how to read floppy, 'cose It is not works anyway
Thanks