Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

Delphi
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
Delphi
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
Posted

1 solution

 
Share this answer
 
Comments
vishal zende 25-Apr-15 14:26pm    
thnx.... but i've already read this.....it is good but not the solutions of may problem...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900