flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Boot loader woes |
Author |
|
revolution 16 Feb 2008, 05:03
A problem looks to be here:
Code: mov ax,stage2 mov es,ax mov bx,0 Perhaps you mean this instead: Code: mov ax,0 mov es,ax mov bx,stage2 |
|||
16 Feb 2008, 05:03 |
|
fancy 16 Feb 2008, 05:07
Now it just hangs after "Loading stage 2..."
|
|||
16 Feb 2008, 05:07 |
|
sinsi 16 Feb 2008, 05:10
Always load your next stage at an absolute address (e.g. 0000:8000) and do a far jump to that explicit address.
|
|||
16 Feb 2008, 05:10 |
|
revolution 16 Feb 2008, 05:16
sinsi wrote: Always load your next stage at an absolute address (e.g. 0000:8000) and do a far jump to that explicit address. fnacy: Make sure you have written the second part of your assembled file to the disk at sector 2. Else you may be loading some random data. |
|||
16 Feb 2008, 05:16 |
|
fancy 16 Feb 2008, 05:20
revolution wrote:
I'm compiling it into one binary file. Stage 2 should start where the first sector ends. (it still hangs) As far as absolute addresses go, why do I need a far jump if I am working in pure real mode? |
|||
16 Feb 2008, 05:20 |
|
DJ Mauretto 16 Feb 2008, 11:47
Hello
I have correct your code,before to write some simply OS learn asm Code: ;----------------------------------------------------------------------------; ; Fancy Loader version 0.1 ; ; ; ; Coded by Fancy ; ; ; ; ``Do what thou wilt shall be the whole of the Law.'' ; ;----------------------------------------------------------------------------; ;----------------------------------------------------------------------------; ; Stage 1 ; ; ; ; Load the the stage 2 bootloader which loads the kernel. ; ;----------------------------------------------------------------------------; use16 org 0x7c00 jmp 0000h:start ;; FAT stuff goes here start: xor ax,ax mov ds,ax mov si,stage1_msg call PrintString xor ax,ax mov es,ax mov bx,7e00h mov dl,0 ; drive number = 0 mov dh,0 ; head number = 0 mov ch,0 ; track number = 0 mov cl,2 ; sector number = 2 mov al,1 ; number of sectors = 1 mov ah,2 ; BIOS 0x13 function 2 int 0x13 jc .read_error xor ax,ax mov ds,ax jmp 0000h:7e00h .read_error: mov si,stage_err_msg call PrintString jmp $ ;----------------------------------------------------------------------------; ; PrintString ; ; ; ; Prints the string in si. ; ;----------------------------------------------------------------------------; PrintString: mov ah,0x0e mov bh,0x00 mov bl,0x07 @@: lodsb or al,al je .done int 0x10 jmp @b .done: ret stage1_msg: db 'Loading stage 2...',13,10,0 stage_err_msg: db 'Failed to load stage 2.',13,10,0 ;; Make sure stage 1 uses 1 whole sector times 510-($-$$) db 0 dw 0xAA55 ;----------------------------------------------------------------------------; ; Stage 2 ; ; ; ; The stage 2 bootloader loads the kernel and such things. ; ;----------------------------------------------------------------------------; stage2: mov si,stage2_msg call PrintString jmp $ stage2_msg: db 'Loaded stage 2.',13,10,0 note: Remember to set up also the stack, it's better to have offset= 0 ,i have only correct your programs to run but this is not right way to boot |
|||
16 Feb 2008, 11:47 |
|
Alphonso 20 Feb 2008, 07:21
Fancy,
revolution has almost the right answer for you there but look at where your loading your sector, right on top of your stage2 routine, so this message 'Loaded stage 2.' will never be printed as it's overwritten. Either load further ahead after stage2_msg or move the stage2: routine to your boot sector. |
|||
20 Feb 2008, 07:21 |
|
revolution 20 Feb 2008, 07:46
Alphonso wrote: Fancy, |
|||
20 Feb 2008, 07:46 |
|
Alphonso 20 Feb 2008, 08:18
revolution wrote: The stage 2 code is what fancy wants to load, so loading it "right on top" is what needs to be done. The stage 2 code doesn't exist in memory until it is loaded from disc so there is really nothing to overwrite. Yep, your right. My apologies, sometimes I see what I want to see instead of what's actually there |
|||
20 Feb 2008, 08:18 |
|
edfed 20 Feb 2008, 12:57
Code: 00000000 IVT 00000400 BDA 00000600 BOOT COPY, for some coders 00001000 BOOT n°2 ,for me, GDT, IDT, lib n°1 00007c00 BOOT n°1 ,the address for all PC 00010000 BOOT n°3 00020000 00030000 00040000 00050000 Drive buffer .... 00090000 screen 13 double buffer 000A0000 screen 13 memory 000B8000 screen 3 memory .... BIOS CODE & DATAs .... 00100000 1 MB mark, where to reload the tables, IDT, GDT, etc... 00107c00 Where to reload the boot loader 00110000 1 MB + 64KB, where to reload the ORG 1000h code .... 01000000 16MB, the DMA limit, where to put the vesa buffer ... not really true, but can be a good start for your project! |
|||
20 Feb 2008, 12:57 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.