Okay figured out the problem , silly mistake . The hex dump made things clear .
the correct chain of dd s should be
Code: Select all
dd bs=512 if=boot_stage1.bin of=floppy.img //no count here , 1st mistake
dd bs=512 seek=1 count=2779 if=/dev/zero of=floppy.omg // one more step ,second mistake :P
rest everything was the same , set up a loopback device , mount it . blah blah .
But now , I have a new problem . I copied the code , it works fine , but I do not understand these series of steps
Code: Select all
; compute size of root directory and store in "cx"
xor cx, cx
xor dx, dx
mov ax, 0x0020 ; 32 byte directory entry
mul WORD [bpbRootEntries] ; total size of directory
div WORD [bpbBytesPerSector] ; sectors used by directory
xchg ax, cx
This is fine , computes the size , stores it in cx , osum . But ,
Code: Select all
mov al, BYTE [bpbNumberOfFATs] ; number of FATs
mul WORD [bpbSectorsPerFAT] ; sectors used by FATs
add ax, WORD [bpbReservedSectors] ; adjust for bootsector(means the reserved sector , But why don't we add the bootsector as well , the fist 512 bytes :O)
mov WORD [datasector], ax ; base of root directory
add WORD [datasector], cx
We add the reserved sectors for FAT12 which come after the bootsector to calculate the offset for the root directory , but we don't add for the bootsector(or do we ?
) , e.g . let's say we have the bootsector , reserved sector , FAT table , and extended FAT .. all in their one sector , which makes the root partition to be located at 2056 offset , but this code will only calculate the offset as 2056-512 ("poor at maths don't know
) because it doesn't add the bootsector's size (I suppose )
So , what's the problem . Code is still working fine .