如何将第二阶段Bootloader复制到软盘或Cd(Iso) [英] How Do I Copy Second Stage Bootloader To Floppy Or Cd (Iso)
问题描述
Hello Friends,
我开发了第二阶段bootloader,我正在尝试将其复制到软盘img但是每次我从这个图像第一阶段bootloader工作正常,但没有加载第二阶段bootloader。
谁能告诉我怎么做,
我通过CD和El-torito使用软盘模拟没有软盘模拟
我的操作系统:Linux
汇编程序:Nasm
用于测试:虚拟盒子
Thnx提前:)
这里是我的代码
第一阶段启动加载程序
位 16
org 7c00h
start:
mov [driveno],dl
jmp loader
TIMES 0Bh - $ + start DB 0
bpbBytesPerSector:DW 512
bpbSectorsPerCluster:DB 1
bpbReservedSectors:DW 1
bpbNumberOfFATs:DB 2
bpbRootEntries:DW 224
bpbTotalSectors:DW 2880
bpbMedia:DB 0xF0
bpbSectorsPerFAT:DW 9
bpbSectorsPerTrack:DW 18
bpbHeadsPerCylinder:DW 2
bpbHiddenSectors:DD 0
bpbTotalSectorsBig: DD 0
bsDriveNumber:DB 0
bsUnused:DB 0
bsExtBootSignature:DB 0x29
bsSerialNumber:DD 0xa0a1a2a3
bsVolumeLabel:DB MOS FLOPPY
bsFileSystem:DB < span class =code-string> FAT12
msg db 原始消息, 0
succmsg1:db 驱动器存在, 0
succmsg2:db Extensions Present, 0
succmsg3:db Dap Readed, 0
ackmsg1:db 错了!!!, 0
errmsg1 db 错误:驱动器缺失, 0
errmsg2 db Extension Absent, 0
errmsg3 db < span class =code-string> DAP读取错误, 0
driveno:db 0
result :times 30 db 0
;忽略此dap表
DAP:
DAP_Size db 10h; 1h
DAP_Res1 db 0 ; 2h
DAP_Bytes2Transfer db 1h; 3h
DAP_Res2 db 0 ; 4h
DAP_Buff_Addr1 dw 0000h; 6h
DAP_Buff_Addr2 dw 1000h; 8h
DAP_LBA dq 1h; 9h
打印:
lodsb
或al,al
jz pdone
mov ah,0eh
int 10h
jmp print
pdone:ret
nlin:
mov啊,0eh; 设置 BIOS子功能
mov al,0x0A;将换行符移至 al
int 10h; Interupt ...
ret;返回
loader:
xor ax,ax
mov es,ax
mov ds,ax
mov啊,0h
mov dl,[driveno]
int 13h
jnc succdd
mov si,errmsg1
call print
int 19h
succdd:
mov si,succmsg1
call print
call nlin
mov ax,1000h
mov es,ax
xor bx,bx
mov al, 1
mov ch, 0
mov cl, 2
mov dh, 0
mov dl,[driveno]
int 13h
jc hlt
mov ax, 00h
int 16h
jmp 1000h: 0000
hlt:
mov si,errmsg3
电话打印
cli
hlt
次 510 - ($ - $$)db 0
dw 0xaa55
2 nd Stage Bootloader
位 16
org 0
jmp loader
打印:
lodsb
或al,al
jz pdone
mov啊,0eh
int 10h
jmp print
pdone:ret
loader:
mov si,msg
调用print
cli
hlt
msg db 准备加载操作系统......, 13 , 10 , 0
+ start DB 0
bpbBytesPerSector:DW 512
bpbSectorsPerCluster:DB 1
bpbReservedSectors:DW 1
bpbNumberOfFATs:DB 2
bpbRootEntries:DW 224
bpbTotalSectors:DW 2880
bpbMedia:DB 0xF0
bpbSectorsPerFAT:DW 9
bpbSectorsPerTrack:DW 18
bpbHeadsPerCylinder:DW 2
bpbHiddenSectors:DD 0
bpbTotalSectorsBig:DD 0
bsDriveNumber:DB 0
bsUnused:DB 0
bsExtBootSignature:DB 0x29
bsSerialNumber:DD 0xa0a1a2a3
bsVolumeLabel:DB MOS FLOPPY
bsFileSystem:DB FAT12
msg db 原始消息, 0
succmsg1:d b 驱动器存在, 0
succmsg2:db Extensions Present, 0
succmsg3:db Dap Readed, 0
ackmsg1:db 错了!!!, 0
errmsg1 db 错误:Drive Absent, 0
errmsg2 db 扩展缺席, 0
errmsg3 db < span class =code-string> DAP读取错误, 0
driveno:db 0
result :times 30 db 0
;忽略此dap表
DAP:
DAP_Size db 10h; 1h
DAP_Res1 db 0 ; 2h
DAP_Bytes2Transfer db 1h; 3h
DAP_Res2 db 0 ; 4h
DAP_Buff_Addr1 dw 0000h; 6h
DAP_Buff_Addr2 dw 1000h; 8h
DAP_LBA dq 1h; 9h
打印:
lodsb
或al,al
jz pdone
mov ah,0eh
int 10h
jmp print
pdone:ret
nlin:
mov ah,0eh; 设置 BIOS子功能
mov al,0x0A;将换行符移至 al
int 10h; Interupt ...
ret;返回
loader:
xor ax,ax
mov es,ax
mov ds,ax
mov啊,0h
mov dl,[driveno]
int 13h
jnc succdd
mov si,errmsg1
call print
int 19h
succdd:
mov si,succmsg1
call print
call nlin
mov ax,1000h
mov es,ax
xor bx,bx
mov al, 1
mov ch, 0
mov cl, 2
mov dh, 0
mov dl,[driveno]
int 13h
jc hlt
mov ax, 00h
int 16h
jmp 1000h: 0000
hlt:
mov si,errmsg3
电话打印
cli
hlt
次 510 - (
-
)db 0
dw 0xaa 55
第二阶段Bootloader
位 16
org 0
jmp loader
打印:
lodsb
或al,al
jz pdone
mov ah,0eh
int 10h
jmp print
pdone:ret
loader:
mov si,msg
call print
cli
hlt
msg db 准备加载操作系统...... , 13 , 10 , 0
Hello Friends,
i've developed a second stage bootloader and i'm trying to copy it to floppy img but it wont works every time i boot from this image the 1st stage bootloader works fine but doesn't load the second stage bootloader.
can anyone tell me how to do it,
i'm using floppy emulation through CD and El-torito for no floppy emulation
My OS: Linux
assembler: Nasm
for testing: Virtual Box
Thnx in advance :)
here is my code
1st stage boot loader
bits 16
org 7c00h
start:
mov [driveno],dl
jmp loader
TIMES 0Bh-$+start DB 0
bpbBytesPerSector: DW 512
bpbSectorsPerCluster: DB 1
bpbReservedSectors: DW 1
bpbNumberOfFATs: DB 2
bpbRootEntries: DW 224
bpbTotalSectors: DW 2880
bpbMedia: DB 0xF0
bpbSectorsPerFAT: DW 9
bpbSectorsPerTrack: DW 18
bpbHeadsPerCylinder: DW 2
bpbHiddenSectors: DD 0
bpbTotalSectorsBig: DD 0
bsDriveNumber: DB 0
bsUnused: DB 0
bsExtBootSignature: DB 0x29
bsSerialNumber: DD 0xa0a1a2a3
bsVolumeLabel: DB "MOS FLOPPY "
bsFileSystem: DB "FAT12 "
msg db "Raw msg",0
succmsg1: db "Drive is Present",0
succmsg2: db "Extensions Present",0
succmsg3: db "Dap Readed",0
ackmsg1: db "Goes Wrong!!!",0
errmsg1 db "Error:Drive Absent",0
errmsg2 db "Extension Absent",0
errmsg3 db "Error in DAP read",0
driveno: db 0
result: times 30 db 0
;Ignore this dap table
DAP:
DAP_Size db 10h ;1h
DAP_Res1 db 0 ;2h
DAP_Bytes2Transfer db 1h ;3h
DAP_Res2 db 0 ;4h
DAP_Buff_Addr1 dw 0000h ;6h
DAP_Buff_Addr2 dw 1000h ;8h
DAP_LBA dq 1h ;9h
print:
lodsb
or al,al
jz pdone
mov ah,0eh
int 10h
jmp print
pdone: ret
nlin:
mov ah, 0eh ; Set BIOS subfunction
mov al, 0x0A ; Move newline to al
int 10h ; Interupt...
ret ; Return
loader:
xor ax,ax
mov es,ax
mov ds,ax
mov ah,0h
mov dl,[driveno]
int 13h
jnc succdd
mov si,errmsg1
call print
int 19h
succdd:
mov si,succmsg1
call print
call nlin
mov ax,1000h
mov es,ax
xor bx,bx
mov al,1
mov ch,0
mov cl,2
mov dh,0
mov dl,[driveno]
int 13h
jc hlt
mov ax,00h
int 16h
jmp 1000h:0000
hlt:
mov si,errmsg3
call print
cli
hlt
times 510-($-$$) db 0
dw 0xaa55
2nd Stage Bootloader
bits 16
org 0
jmp loader
print:
lodsb
or al,al
jz pdone
mov ah,0eh
int 10h
jmp print
pdone: ret
loader:
mov si,msg
call print
cli
hlt
msg db "Preparing to load operating system...",13,10,0
+start DB 0 bpbBytesPerSector: DW 512 bpbSectorsPerCluster: DB 1 bpbReservedSectors: DW 1 bpbNumberOfFATs: DB 2 bpbRootEntries: DW 224 bpbTotalSectors: DW 2880 bpbMedia: DB 0xF0 bpbSectorsPerFAT: DW 9 bpbSectorsPerTrack: DW 18 bpbHeadsPerCylinder: DW 2 bpbHiddenSectors: DD 0 bpbTotalSectorsBig: DD 0 bsDriveNumber: DB 0 bsUnused: DB 0 bsExtBootSignature: DB 0x29 bsSerialNumber: DD 0xa0a1a2a3 bsVolumeLabel: DB "MOS FLOPPY " bsFileSystem: DB "FAT12 " msg db "Raw msg",0 succmsg1: db "Drive is Present",0 succmsg2: db "Extensions Present",0 succmsg3: db "Dap Readed",0 ackmsg1: db "Goes Wrong!!!",0 errmsg1 db "Error:Drive Absent",0 errmsg2 db "Extension Absent",0 errmsg3 db "Error in DAP read",0 driveno: db 0 result: times 30 db 0 ;Ignore this dap table DAP: DAP_Size db 10h ;1h DAP_Res1 db 0 ;2h DAP_Bytes2Transfer db 1h ;3h DAP_Res2 db 0 ;4h DAP_Buff_Addr1 dw 0000h ;6h DAP_Buff_Addr2 dw 1000h ;8h DAP_LBA dq 1h ;9h print: lodsb or al,al jz pdone mov ah,0eh int 10h jmp print pdone: ret nlin: mov ah, 0eh ; Set BIOS subfunction mov al, 0x0A ; Move newline to al int 10h ; Interupt... ret ; Return loader: xor ax,ax mov es,ax mov ds,ax mov ah,0h mov dl,[driveno] int 13h jnc succdd mov si,errmsg1 call print int 19h succdd: mov si,succmsg1 call print call nlin mov ax,1000h mov es,ax xor bx,bx mov al,1 mov ch,0 mov cl,2 mov dh,0 mov dl,[driveno] int 13h jc hlt mov ax,00h int 16h jmp 1000h:0000 hlt: mov si,errmsg3 call print cli hlt times 510-(
-
) db 0 dw 0xaa55
2nd Stage Bootloader
bits 16 org 0 jmp loader print: lodsb or al,al jz pdone mov ah,0eh int 10h jmp print pdone: ret loader: mov si,msg call print cli hlt msg db "Preparing to load operating system...",13,10,0
这篇关于如何将第二阶段Bootloader复制到软盘或Cd(Iso)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!