Page 1 of 1
BootLoader 3
Posted: Wed Mar 04, 2009 8:48 am
by Zig
hi guys,
It seems I'm making a habit of posting a topic for every tutorial I read

.
I have some questions for bootloader 3, could you guys help out?
1. I am trying out the demo for bootloader 3. I typed the code and try to compile to NASM,
but I got an error because there are 2 [ORG] directive in the same ASM file. How else I can specify the second sector to be loaded at 0x1000 without the org directive?
2.
Code: Select all
mov ah, 0x02 ; read floppy sector function
mov al, 1 ; read 1 sector
mov ch, 1 ; we are reading the second sector past us, so its still on track 1
mov cl, 2 ; sector to read (The second sector)
mov dh, 0 ; head number
mov dl, 0 ; drive number. Remember Drive 0 is floppy drive.
int 0x13 ; call BIOS - Read the sector
Are we trying to read the second sector of the floppy disc, which supposes to be the second stage boot loader right? The first sector is the first bootloader, and the second sector contains the second stage boot sector. Is it where the second stage boot loader usually stays?
Thanks
Posted: Wed Mar 04, 2009 6:10 pm
by Andyhhp
I have some answers about bootloader 3 - they might help
1) You can only have a singe org declaration per asm file.
Therefore, you need a seporate file for the 2nd stage loader, assemble them separatly and copy them separatly to the disk.
2)Yes and No. In this case, the 2nd stage is written to the 2nd sector of the disk. However, in general, Floppy disks should use the FAT12 filesystem and the 1st stage booloader should be able to use the filesystem to load the 2nd stage. The next tutorials explain how to do this.
~Andrew
Posted: Wed Mar 04, 2009 9:08 pm
by Zig
thanks again

Re: BootLoader 3
Posted: Thu May 28, 2009 1:18 am
by ggeorgak
Actually there is an error too on using int 0x13. Cylinders are numbered starting from 0 whereas sectors are numbered starting 1. This must be changed in the bootloaders tutorial too.
Re: BootLoader 3
Posted: Thu May 28, 2009 12:28 pm
by Andyhhp
What do you mean
Cylinders are numbered starting from 0 whereas sectors are numbered starting 1
.
The CHS address scheme is defined with Heads starting from 0 while Cylinders (Tracks) and Sectors start from 1.
Are you saying that the tutorial has a mistake?
~Andrew
Re: BootLoader 3
Posted: Thu May 28, 2009 11:33 pm
by ggeorgak
Actually in CHS addressing cylinders start from 0 (
http://en.wikipedia.org/wiki/Cylinder-head-sector), and Heads start from 0. Just tracks start from 1.
In tutorial BootLoader 3, the code to read sector 2 from floppy is:
Code: Select all
.Read:
mov ah, 0x02 ; function 2
mov al, 1 ; read 1 sector
mov ch, 1 ; we are reading the second sector past us, so its still on track 1
mov cl, 2 ; sector to read (The second sector)
mov dh, 0 ; head number
mov dl, 0 ; drive number. Remember Drive 0 is floppy drive.
int 0x13 ; call BIOS - Read the sector
jc .Read ; Error, so try again
The higher byte of CX, CH must be set to 0 (it is set
wrongfully to 1) in order to read the first cylinder (having track 1)
You can see that this is the case also at:
http://en.wikipedia.org/wiki/INT_13
Re: BootLoader 3
Posted: Fri May 29, 2009 12:22 pm
by Andyhhp
Hmm
I stand corrected - you make a very good point.
Furthermore, this is a bug that appears to exists in all of the bootloader tutorials, including the algorithms for reading clusters from FAT12 sources.
Mike: any comments?
~Andrew
Re: BootLoader 3
Posted: Sat May 30, 2009 1:28 am
by Mike
Hello,
It will exist in all later tutorials/demos do to the way the later tutorials build off the code from the previous demos. However this might be a bug in the initial code that has not been detected and thus still existent in the later tutorials. It will be looked at.