flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Help with FAT12 bootloader |
Author |
|
me239 14 Jan 2011, 09:45
Hello everyone, recently I've been building a new DOS project(Codename: DOS of Prey) and have run into a snag with the bootloader. The problem is nothing shows up. I've been trying to tweak it and read several articles and tutorials on it, but still don't know what I'm doing wrong. code attached.
|
|||||||||||
14 Jan 2011, 09:45 |
|
bitshifter 15 Jan 2011, 03:20
If the BPB is correct, you should be able to view the disk contents.
Can you view it, or is the file format unrecognized? Also FASM does a two byte jump if within range, so we must manually account for code requiring 3 byte jump... Code: jmp start nop Its very cold here so i cant spend much time looking at your code (sorry). Maybe my loader can help you? http://board.flatassembler.net/topic.php?t=11774 Not very robust, but it did what i needed it to |
|||
15 Jan 2011, 03:20 |
|
me239 15 Jan 2011, 04:07
bitshifter wrote: If the BPB is correct, you should be able to view the disk contents. I can read all the files, it just won't boot. |
|||
15 Jan 2011, 04:07 |
|
me239 15 Jan 2011, 05:50
bitshifter wrote: If the BPB is correct, you should be able to view the disk contents. I based my loader off yours and it still doesn't work. I know I'm doing something wrong that I keep overlooking. Code: org 7c00h jmp start nop db "DOSOPREY" dw 512 db 1 dw 1 db 2 dw 224 dw 2880 db 0f0h dw 9 sectpertrack dw 18 headpercylinder dw 2 dd 0 dd 0 drivenum db 0 db 0 db 29h dd 0 db "DOSOFPREY " db "FAT12 " filen db "KERNEL BIN" start: cld mov ax, cs mov ds, ax mov es, ax mov [ds:drivenum], dl cli mov ss, ax mov sp, sstack sti mov al, 14 mov bx, buffer mov cx, 2 mov dh, 1 call readsectors mov si, filen mov di, bx mov cx, 224 findfile: pusha mov cx, 11 rep cmpsb popa je load_fat add di, 20h loop findfile load_fat: mov si, [es:di+1ah] mov al, 9 mov cx, 2 xor dx, dx call readsectors mov ax, 0050h mov es, ax mov fs, ax mov gs, ax xor bx, bx load_file: mov ax, si add ax, 31d xor dx, dx div word[ds:sectpertrack] inc dx mov cl, dl xor dx, dx div word[ds:headpercylinder] mov ch, al mov dh, dl mov al, 1 call readsectors add bx, 200h mov ax, si mov cx, 3 mul cx dec cx div cx mov di, ax mov si, [ds:di+buffer] push es pop ds push es push 0 retf readsectors: pusha mov dl, [ds:drivenum] mov si, 5 .loop1: mov ah, 02h stc int 13h jnc .done dec si jnc .reset jmp error .reset: mov di, 5 .retry: xor ah, ah stc int 13h jnc .loop1 dec di jnc .retry jmp error .done: ret error: mov si, msg printf: lodsb cmp al, 0 je $ mov ah, 0eh int 10h jmp printf msg db "AN ERROR OCCURRED!", 0 times 512-($-$$) db 0 buffer: rb 8192 rb 8190 sstack: rb 2 |
|||
15 Jan 2011, 05:50 |
|
me239 15 Jan 2011, 06:24
neville wrote: AFAIK most BIOSs still insist on the historical 'Boot Signature' - the last two bytes in the bootsector must be 55H, 0AAH Nope, still not doing it. |
|||
15 Jan 2011, 06:24 |
|
bitshifter 15 Jan 2011, 10:09
I fixed my code, the stack that is.
I thought for some reason that push had placed the value before decrementing the stack pointer, but it gets decremented first. So instead of: Code: rb 8190 sstack: rb 2 It becomes corrected as: Code: rb 8192 sstack: Thanks for making me notice this As for fixing your code, it took me a long time to write my own. I have not the time to learn and fix yours also. You have choices, use other peoples code or write your own. In this situation i would use other peoples code for now. Then you will not burn yourself out trying to find rodents. Later, you will peek at your code and it will become apparent what is problem. |
|||
15 Jan 2011, 10:09 |
|
neville 15 Jan 2011, 10:35
me239:
Well I forgot the DB 0H at the end of my TIMES statement, but where did you put it? Is your bootsector exactly 512 bytes? _________________ FAMOS - the first memory operating system |
|||
15 Jan 2011, 10:35 |
|
me239 15 Jan 2011, 18:52
neville wrote: me239: Yes it's exactly 512 bytes ending with dw 0aa55h. |
|||
15 Jan 2011, 18:52 |
|
SeproMan 05 Feb 2011, 15:33
Why do you initialize your stackpointer at an odd address?
Better write : mov sp,0FFFEh |
|||
05 Feb 2011, 15:33 |
|
SeproMan 06 Feb 2011, 21:59
Errors in "boot.asm"
General observations
I'm sure you did not read the comments I made earlier on Bitshifter's version of a bootloader because you made the same mistakes! Perhaps you could take a look at http://board.flatassembler.net/topic.php?t=11748
_________________ Real Address Mode. |
|||||||||||
06 Feb 2011, 21:59 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.