Boot From Flash Drive: Sector change.
-
- Posts: 3
- Joined: Sun Mar 13, 2011 1:16 am
Boot From Flash Drive: Sector change.
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)
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)
- Attachments
-
- STAGE2.asm
- It is compiled to be KERNEL.BIN to fit to the primary bootstrap.
- (389 Bytes) Downloaded 51 times
Re: Boot From Flash Drive: Sector change.
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.
You've attached the Stage2 file. You need to attach the Stage1 file as well, it's where we can possibly track the error.
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.DW 0xAA55
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
-
- Posts: 3
- Joined: Sun Mar 13, 2011 1:16 am
Re: Boot From Flash Drive: Sector change.
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
Matt C
- Attachments
-
- 2stageloader0.1.asm
- Primary Boot file.
- (9.05 KiB) Downloaded 57 times
Re: Boot From Flash Drive: Sector change.
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 "
...
http://msdn.microsoft.com/en-us/windows ... e/gg463080
If you have seen bad English in my words, tell me what's wrong, please.
-
- Posts: 3
- Joined: Sun Mar 13, 2011 1:16 am
Re: Boot From Flash Drive: Sector change.
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.Wow! Read the books guys.
http://msdn.microsoft.com/en-us/windows ... e/gg463080
-
- Member
- Posts: 255
- Joined: Tue Jun 15, 2010 9:27 am
- Location: Flyover State, United States
- Contact:
Re: Boot From Flash Drive: Sector change.
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.
If you are changing something you should understand what you doing.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 have seen bad English in my words, tell me what's wrong, please.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Boot From Flash Drive: Sector change.
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?Falconspire wrote:Ok first, I am asking a question, so obviously I am not getting help from available tutorials.
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.
Your Bios Parameter Block is wrong. Here's a quick update:
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.
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
Hope this helps...
Thank you.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !