Autor Thema: TeeJays Bootloader geht nicht.  (Gelesen 2373 mal)

bsunisol

  • Beiträge: 19
    • Profil anzeigen
Gespeichert
« am: 27. May 2006, 00:21 »
Hi Leute,
ich habe den Bootloader von TeeJays Tut abgetippt und direkt seine .asm Datei genommen, assembled und mit Rawwrite auf eine FDD gemacht.

egal ob ich eine Kernel-Datei auf die FDD kopiere oder nicht, es geht nicht.
Er macht auch keine Debug-Meldung, die ich eingefügt habe, nach dem ich den Stack auf gesetzt habe. Er bootet nur neu.

Kann mir da einer von euche helfen?
mfg
Uni_Sol


ps hier der code, aber den kenn ja sicher schon alle:

; ### MACRO SECTION ###############################################################################################

%define Param1 bp+4
%define Param2 bp+6
%define Param3 bp+8
%define Param4 bp+10
%define Param5 bp+12

%define Var1 bp-2
%define Var2 bp-4
%define Var3 bp-6
%define Var4 bp-8
%define Var5 bp-10


; ### MACRO SECTION END ###########################################################################################


; ### ORIGIN SECTION ##############################################################################################

ORG 0x7C00

; ### ORIGIN SECTION END ##########################################################################################


; ### FATINFOBLOCK JUMP SECTION ###################################################################################

JUMP:
jmp CODE_SECTION

; ### FATINFOBLOCK JUMP SECTION END ###############################################################################


; ### FATINFOBLOCK SECTION ########################################################################################

FAT_TABLE_0:
OSName db "MSDOS5.0"
         BytesPerSec dw 0x0200
         SecPerClus db 0x01
         ResvdSecCnt dw 0x0001
         NumFATs db 0x02
         RootEntCnt dw 0x00E0
         TotSec dw 0x0B40
         MediType db 0xF0
         FATSize dw 0x0009
         SecPerTrack dw 0x0012
         NumHeads dw 0x0002
         HiddenSec dd 0x00000000
         TotSec32 dd 0x00000000
         DrvNum db 0x00
         CurrentHead db 0x00
         BootSig db 0x29
         VolumeID dd 0xFFFFFFFF
         VolumeLabel db "           "
         FileSystype db "FAT12   "

; ### FATINFOBLOCK SECTION END ####################################################################################


; ### CODE SECTION ################################################################################################

CODE_SECTION:

; Stack setzen
         cli
         mov ax, 0x9000
         mov ss, ax
         xor sp, sp
         sti

; Anfang Zeigen
push WORD MsgStart
         call _PrintString
         inc sp
         inc sp

; Kernel suchen sonst medlung machen
         call _FindFileSector
         or ax, ax
         jz KernelNotFound

; FAT Tabelle in den Speicher laden
call _ReadFATTable

; Segmente festelegen in die der Kernel geladen werden soll und in Temp speichern
mov ax, 1000
         mov dx, [RootEntCnt]
         shl dx, 5
         dec dx
         shr dx, 9
         add [Temp], dx

LoadKernelFile:
          mov dx, [Temp]
                 add dx, ax
                 dec dx ; (?) sub dx, 2
                 dec dx
                 push bx
                 push dx
                 call _ReadSector
                 add sp, 4
; FATEintrag lesen
                 push ax
                 call _ReadFATEntry
                 add sp, 2

; Erfolgreich
                 cmp ax, 0xFFF
                 je ExecuteKernel
                 add bx, 0x20
                 jmp LoadKernelFile

ExecuteKernel:
          mov ax, 1000
                 push ax
                 mov ax, 0
                 push ax
          retf

         KernelNotFound:
          push WORD MsgFileNotFound
                 call _PrintString
                 add sp, 2

         WaitForKeyToReboot:
          mov ah, 0
                 int 0x16

         Reboot:
          db 0xEA
                 dw 0x0000
                 dw 0xFFFF

; ### CODE SECTION END ############################################################################################


; ### FUNCTIONS SECTION ###########################################################################################

FUNCTIONS_SECTION:
; --- _PutString -----------------------------------------------------------------------------------------
_PrintString:
          push bp
                 mov bp, sp

                 pusha

                 mov si, [Param1]
                 mov ah, 0x0E
                 mov bx, 0x0007
                 _PrintString_1:
                  lodsb
                         or al, al
                         jz _PrintString_2
                         int 10h
                         jmp _PrintString_1
                 _PrintString_2
                  popa

                         mov sp, bp
                         pop bp
          ret
; --- _PutString END -------------------------------------------------------------------------------------


         ; --- _FindFileSector ------------------------------------------------------------------------------------
         _FindFileSector:
          push bp
                 mov bp, sp
                 dec sp ; (?) sub sp, 2
                 dec sp

                 pusha

                 mov ax, 0x9200
                 mov es, ax

                 mov ax, [FATSize]
                 mov bl, [NumFATs]
                 mul bl
                 add ax, [ResvdSecCnt]
                 mov [Temp], ax

                 xor dx, dx

                 _FindFileSector_E:
                  cmp dx, [RootEntCnt]
                         je _FindFileSector_A

                         test dx, 15
                         jnz _FindFileSector_B

                         push es
                         push ax
                         call _ReadSector
                         add sp, 4
                         inc ax
                         xor bx, bx

                 _FindFileSector_B:
                  cmp BYTE [es:bx], 0x0E
                         je _FindFileSector_D
                         cmp BYTE [es:bx], 0
                         je _FindFileSector_A

                         mov si, FileName
                         mov di, bx
                         mov cx, 11
                         repe cmpsb
                         or cx, cx
                         jz _FindFileSector_C

                 _FindFileSector_D:
                  inc dx
                         add bx, 32
                         jmp _FindFileSector_E

                 _FindFileSector_A:
                  popa
                         xor ax, ax
                         jmp _FindFileSector_Ende

                 _FindFileSector_C:
                  push WORD [es:bx+26]
                         pop WORD [Var1]
                         popa
                         mov ax, [Var1]
                 _FindFileSector_Ende:
                  mov sp, bp
                         pop bp
                         ret
         ; --- _FindFileSector END --------------------------------------------------------------------------------


         ; --- _ReadSector ----------------------------------------------------------------------------------------
         _ReadSector:
          push bp
                 sub sp, 6

                 pusha

                 mov ax, [Param1]
                 mov bx, 36
                 xor dx, dx ; (?) mov dx, 0
                 div bx
                 mov [Var1], ax

                 mov ax, dx
                 push ax
                 mov bx, 18
                 xor dx, dx ; (?) mov dx, 0
                 div bx
                 mov ax, dx
                 inc ax
                 mov [Var3], ax

                 _ReadSector_1:
                  mov ax, [Param2]
                         mov es, ax
                         xor bx, bx ; (?) mov dx, 0
                         mov ah, 2
                         mov al, 1
                         mov ch, [Var1]
                         mov cl, [Var3]
                         mov dh, [Var2]
                         xor dl, dl ; (?) mov dl, 0
                         int 13h
                         jc _ReadSector_1

                 popa
                 mov sp, bp
                 pop bp
                 ret
         ; --- _ReadSector END ------------------------------------------------------------------------------------


         ; --- _ReadFATEntry --------------------------------------------------------------------------------------
         _ReadFATEntry:
          push bp
                 mov bp, sp
                 dec sp ; (?) sub sp, 2
                 dec sp

                 pusha

                 mov ax, [Param1]
                 mov bx, 3
                 mul bx
                 dec bx ; (?) mov bx, 3
                 xor dx, dx
                 div bx

                 mov bx, 0x9200
                 mov es, bx
                 mov bx, ax
                 mov ax, [es:bx]
                 mov [Var1], ax

                 mov cx, [Param1]
                 test cx, 1
                 jz _ReadFATEntry_Gerade

                 popa
                 mov ax, [Var1]
                 shr ax, 4
                 jmp _ReadFATEntry_Ende

                 _ReadFATEntry_Gerade:
                  popa
                         mov ax, [Var1]
                         and ax, 0xFFF

                 _ReadFATEntry_Ende:
                  mov sp, bp
                         pop bp
                         ret
         ; --- _ReadFATEntry END ----------------------------------------------------------------------------------


         ; --- _ReadFATTable --------------------------------------------------------------------------------------
         _ReadFATTable:
          pusha

                 mov bx, 0x9200
                 mov ax, [ResvdSecCnt]
                 mov cx, [FATSize]

                 _ReadFATTable_A:
                  push bx
                         push ax
                         call _ReadSector
                         add sp, 4
                         inc ax
                         add bx, 32
                         loop _ReadFATTable_A

                 popa

                 ret

         ; --- _ReadTATTable END ----------------------------------------------------------------------------------


; ### FUNCTIONS SECTION END #######################################################################################


; ### PLACEHOLDER SECTION #########################################################################################

PLACEHOLDER_SECTION:
times 465-($-$$) db 0

; ### PLACEHOLDER SECTION END #####################################################################################


; ### DATA SECTION ################################################################################################

DATA_SECTION:
MsgStart db "Loading kernel: ", 0
MsgFileNotFound db "File not found", 0
         FileName db "kernel16sys"
         Temp dw 0

; ### DATA SECTION END ############################################################################################


; ### BOOTSTRAP SECTION ###########################################################################################

BOOTSTRAP_SECTION:
dw 0AA55h

; ### BOOTSTRAP SECTION END #######################################################################################


und hier der kernel:
; ### MACRO SECTION ###############################################################################################

%define Param1 bp+4
%define Param2 bp+6
%define Param3 bp+8
%define Param4 bp+10
%define Param5 bp+12

%define Var1 bp-2
%define Var2 bp-4
%define Var3 bp-6
%define Var4 bp-8
%define Var5 bp-10


; ### MACRO SECTION END ###########################################################################################


; ### ORIGIN SECTION ##############################################################################################

ORG 0x1000

; ### ORIGIN SECTION END ##########################################################################################


; ### CODE SECTION ################################################################################################

START:
push WORD MsgStart
         call _PrintString
         inc sp
         inc sp

crash:
jmp crash

; ### CODE SECTION END ############################################################################################


; ### FUNCTIONS SECTION ###########################################################################################

FUNCTIONS:
; --- _PutString -----------------------------------------------------------------------------------------
_PrintString:
          push bp
                 mov bp, sp

                 pusha

                 mov si, [Param1]
                 mov ah, 0x0E
                 mov bx, 0x0007
                 _PrintString_1:
                  lodsb
                         or al, al
                         jz _PrintString_2
                         int 10h
                         jmp _PrintString_1
                 _PrintString_2
                  popa

                         mov sp, bp
                         pop bp
          ret
; --- _PutString END -------------------------------------------------------------------------------------


; ### FUNCTIONS SECTION END #######################################################################################


; ### DATA SECTION ################################################################################################

DATA:
MsgStart db "Done.", 13, 10, 0
         Temp dw 0

; ### DATA SECTION END ############################################################################################


Nicht erschrecken, die Comments mit # sind zu lang für eine Zeile, das sind nicht 2 in der richtigen asm-Datei ;P

 

Einloggen