Page 1 of 1

loading second stage bootloader

Posted: Wed Aug 11, 2010 11:08 pm
by ashken
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

Re: loading second stage bootloader

Posted: Wed Aug 11, 2010 11:27 pm
by halofreak1990
could you post the contents of the asm file, so we can see what's wrong?

Re: loading second stage bootloader

Posted: Wed Aug 11, 2010 11:46 pm
by ashken

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
								

Re: loading second stage bootloader

Posted: Thu Aug 12, 2010 12:28 am
by halofreak1990
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?

Re: loading second stage bootloader

Posted: Thu Aug 12, 2010 7:09 pm
by Andyhhp
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