loading second stage bootloader

If you are new to OS Development, plan on spending some time here first before going into the other forums.

Moderator:Moderators

Post Reply
ashken
Posts:2
Joined:Wed Aug 11, 2010 11:00 pm
loading second stage bootloader

Post by ashken » Wed Aug 11, 2010 11:08 pm

am following the tutorial which suggests i should put

Code: Select all

0x1000
after the boot signature in the first bootloader but nasm gives an error

Code: Select all

error: program origin redefined

halofreak1990
Posts:92
Joined:Thu May 27, 2010 8:54 pm
Location:Netherlands

Re: loading second stage bootloader

Post by halofreak1990 » Wed Aug 11, 2010 11:27 pm

could you post the contents of the asm file, so we can see what's wrong?

ashken
Posts:2
Joined:Wed Aug 11, 2010 11:00 pm

Re: loading second stage bootloader

Post by ashken » Wed Aug 11, 2010 11:46 pm

Code: Select all

[ bits	16 ]							
 
[ org	0x7c00	]					
 
start:          jmp loader					
 
;*************************************************;
;	OEM Parameter block / BIOS Parameter Block
;*************************************************;
 
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   "
 
;***************************************
;	Prints a string
;	DS=>SI: 0 terminated string
;***************************************
 
Print:
			lodsb					
			or			al, al		
			jz			PrintDone	
			mov			ah,	0eh	
			int			10h
			jmp			Print		
PrintDone:
			ret					
 
;*************************************************
;	Bootloader Entry Point
;*************************************************
 
loader:
 
.Reset:
	mov		ah, 0					

	mov		dl, 0					
	int		0x13					
	jc		.Reset					
	mov		ax, 0x1000				
	mov		es, ax
	xor		bx, bx
 
	mov		ah, 0x02				
	mov		al, 1					
	mov		ch, 1					
	mov		cl, 2					
	mov		dh, 0					
	mov		dl, 0					
	int		0x13					
	
 
	jmp		0x1000:0x0				
 
 
times 510 - ($-$$) db 0						
 
dw 0xAA55							
 
; End of sector 1, beginning of sector 2 ---------------------------------
 
 
org 0x1000							
 
cli
hlt
								

halofreak1990
Posts:92
Joined:Thu May 27, 2010 8:54 pm
Location:Netherlands

Re: loading second stage bootloader

Post by halofreak1990 » Thu Aug 12, 2010 12:28 am

this is your problem:

Code: Select all

; End of sector 1, beginning of sector 2 ---------------------------------

org 0x1000                     

cli
hlt
You can only have one 'org' statement in any asm file.

And, may I ask why you want the second stage to start at 0x1000, and not where the 1st stage bootloader ended?

Andyhhp
Moderator
Posts:387
Joined:Tue Oct 23, 2007 10:05 am
Location:127.0.0.1
Contact:

Re: loading second stage bootloader

Post by Andyhhp » Thu Aug 12, 2010 7:09 pm

More importently, if you are wanting to support FAT12 then stage2 will almost certainly not be on the second sector of the disk, unless you mess around with the number of reserved sectors

~Andrew
Image

Post Reply