Page 1 of 1

Boot From Flash Drive: Sector change.

Posted: Sun Mar 13, 2011 1:25 am
by Falconspire
Hello,
My friend and I are working together and are relatively new to ASM. We are planning on using a 2 part boot loader, but the problem is that we cannot successfully move to the second bin. We have read the tutorials on the FATs but, it never reaches the file. The tutorial we used is located at http://www.omninerd.com/articles/PC_Boo ... ial_in_ASM . Any help is appreciated, as we cannot seem to find the answer.
Thank you,
Matt C.

PS the file attached is the second file we are trying to load (for testing)

Re: Boot From Flash Drive: Sector change.

Posted: Sun Mar 13, 2011 1:58 am
by Chandra
Hi,

You've attached the Stage2 file. You need to attach the Stage1 file as well, it's where we can possibly track the error.
DW 0xAA55
It's the boot signature and is not required for the Stage2 file. Also a lot of code improvements (setup of segment registers, setup of stack segment etc.) is required. But before we continue on that, we need to see you Stage1 file. Thank you.

Re: Boot From Flash Drive: Sector change.

Posted: Sun Mar 13, 2011 9:27 am
by Falconspire
Thank you for replying. I did not realize the second stage did not require a signature. The beginning stage is attached. The beginning stage works correctly as far as I can tell, it will load and reaches "ERROR Press any key to reboot." But the beginning stage was not created by me (However I am not stupid, and I have gone over the source code many times.)
Matt C

Re: Boot From Flash Drive: Sector change.

Posted: Sun Mar 13, 2011 10:04 am
by egos

Code: Select all

[BITS 16]
ORG 0
jmp     START

OEM_ID                db "Flash"
BytesPerSector        dw 0x0200
SectorsPerCluster     db 0x01
ReservedSectors       dw 0x0001
TotalFATs             db 0x02
MaxRootEntries        dw 0x00E0
TotalSectorsSmall     dw 0x0B40
MediaDescriptor       db 0xF0
SectorsPerFAT         dw 0x0009
SectorsPerTrack       dw 0x0012
NumHeads              dw 0x0002
HiddenSectors         dd 0x00000000
TotalSectorsLarge     dd 0x00000000
DriveNumber           db 0x00
Flags                 db 0x00
Signature             db 0x29
VolumeID              dd 0xFFFFFFFF
VolumeLabel           db "Flash"
SystemID              db "W95 FAT32  "
...
Wow! Read the books guys.
http://msdn.microsoft.com/en-us/windows ... e/gg463080

Re: Boot From Flash Drive: Sector change.

Posted: Sun Mar 13, 2011 11:06 am
by Falconspire
Wow! Read the books guys.
http://msdn.microsoft.com/en-us/windows ... e/gg463080
Ok first, I am asking a question, so obviously I am not getting help from available tutorials. Secondly, thanks for a tutorial filled will C code, thats going to help me a lot when I'm coding with only ASM in the script.

Re: Boot From Flash Drive: Sector change.

Posted: Sun Mar 13, 2011 11:26 am
by Tosi
If you're writing systems-level code, you should have enough experience in both C and assembly that you can at least translate between the languages, especially C to assembler.

Re: Boot From Flash Drive: Sector change.

Posted: Sun Mar 13, 2011 12:32 pm
by egos
Falconspire wrote:Ok first, I am asking a question, so obviously I am not getting help from available tutorials. Secondly, thanks for a tutorial filled will C code, thats going to help me a lot when I'm coding with only ASM in the script.
If you are changing something you should understand what you doing.

Re: Boot From Flash Drive: Sector change.

Posted: Mon Mar 14, 2011 4:10 am
by Combuster
Falconspire wrote:Ok first, I am asking a question, so obviously I am not getting help from available tutorials.
Tip of the day: do not rely on tutorials alone. what will you do when you want to do something that's not part of a tutorial?

The point here is that you seem to either lacked to do some debugging of yourself, or lack the knowledge mentioned above. Download a hex editor, format a floppy with FAT and dump the bootsector so you have something that's known good for comparison, and then compare it byte-by-byte with your bootsector - You should spot the error soon enough. After that, you can use the hints mentioned above to fix the issue.

Re: Boot From Flash Drive: Sector change.

Posted: Mon Mar 14, 2011 9:31 pm
by Chandra
Your Bios Parameter Block is wrong. Here's a quick update:

Code: Select all

[BITS 16]
ORG 0
jmp     START

OEM_ID                db "Flash"  ; Must be 8 bytes
BytesPerSector        dw 0x0200
SectorsPerCluster     db 0x01
ReservedSectors       dw 0x0001
TotalFATs             db 0x02
MaxRootEntries        dw 0x00E0
TotalSectorsSmall     dw 0x0B40
MediaDescriptor       db 0xF0
SectorsPerFAT         dw 0x0009
SectorsPerTrack       dw 0x0012
NumHeads              dw 0x0002
HiddenSectors         dd 0x00000000
TotalSectorsLarge     dd 0x00000000
DriveNumber           db 0x00
Flags                 db 0x00
Signature             db 0x29
VolumeID              dd 0xFFFFFFFF
VolumeLabel           db "Flash"  ; Must be 12 bytes
SystemID              db "W95 FAT32  "  ; Must be 8 Bytes
This was just a quick review. I've not even looked at the other portions of code. I'd definately recommend reading FAT specification to start.
Hope this helps...

Thank you.