1
					Lowlevel-Coding / Re: Bootloader der C Kernel lädt
« am: 08. November 2006, 21:21 »
					FalShen hat mir via Messenger geholfen  
					
				
					04. November 2025, 12:18
Diese Sektion erlaubt es dir alle Beiträge dieses Mitglieds zu sehen. Beachte, dass du nur solche Beiträge sehen kannst, zu denen du auch Zugriffsrechte hast.
					
					
					
 
ORG 0x7C00 ; Unsere Startadresse
; ----------------------------------
; Unser Bootloader
; ----------------------------------
start:
; Stack erzeugen
cli ; Keine Interrupts!
mov ax, 0x9000 ; Stackadresse
mov ss, ax ; SS = 9000 (unser Stack)
mov sp, 0 ; SP = 0000 (der Stackpointer)
sti ; Interrupts zulassen
; Bootlaufwerk aus DL speichern
mov [bootdrv], dl
; Lade unseren kernel
call load
; Springe zu diesem Kernel
mov ax, 0x1000 ; Die Adresse des Programms
mov es, ax ; Segmentregister updaten
mov ds, ax
push ax
mov ax, 0
push ax
retf
; ---------------------------
; Funktionen und Variablen
; ---------------------------
bootdrv db 0 ; Das Bootlaufwerk
loading db "Loading...",13,10,0
; Einen String ausgeben:
putstr:
lodsb ; Byte laden
or al,al
jz short putstrd ; 0-Byte? -> Ende!
mov ah,0x0E ; Funktion 0x0E
mov bx,0x0007 ; Attribut-Byte (wird nicht bentigt)
int 0x10 ; schreiben
jmp putstr ; Nchstes Byte
putstrd:
retn
; Lade den Kernel vom Bootlaufwerk
load:
; Diskdrive reset (Interrupt 13h, 0)
push ds ; Sichere DS
mov ax, 0 ; Die gewnschte Funktion (reset)
mov dl, [bootdrv] ; Dieses Laufwerk ist gewnscht
int 13h ; den Interrupt ausfhren
pop ds ; DS wiederherstellen
jc load ; Geht nicht? -> Noch mal!
load1:
mov ax,0x1000 ; ES:BX = 10000
mov es,ax
mov bx, 0
; Sektoren lesen (Interrupt 13h, 2)
mov ah, 2 ; Funktion 2 (Lesen)
mov al, 5 ; Lese 5 Sektoren
mov cx, 2 ; Cylinder=0, Sector=2
mov dx, 0 ; Head=0, Laufwerk=0
int 13h ; ES:BX = Daten vom Laufwerk
jc load1 ; Fehler? Noch mal!
mov si,loadmsg
call putstr ; Meldung ausgeben
retn
times 512-($-$$)-2 db 0 ; Datenlnge = 512 Bytes
dw 0AA55h
					
AVRASM ver. 1.30  BOOT.ASM Tue Aug 22 23:15:32 2006
error : Unknown instruction opcode
error : Unknown instruction opcode
error : Unknown instruction opcode
error : Unknown instruction opcode
error : Unknown instruction opcode
error : Unknown instruction opcode
error : Unknown instruction opcode
error : Unknown instruction opcode
error : Unknown instruction opcode
error : Unknown instruction opcode
error : Unknown instruction opcode
error : Unknown instruction opcode
error : Unknown instruction opcode
error : Unknown instruction opcode
error : Unknown instruction opcode
error : Unknown instruction opcode
000000       org 0x7C00 ; Unsere Startadresse
         
         ; ----------------------------------
         ; Unser Bootloader
         ; ----------------------------------
         
          start:
         
         ; Stack erzeugen
000001 94f8      cli ; Keine Interrupts!
000002       mov ax, 0x90000 ; Stackadresse
error : Illegal argument type or count
000003       mov ss, ax ; SS = 9000 (unser Stack)
error : Illegal argument type or count
000004       mov sp, 0 ; SP = 0000 (der Stackpointer)
error : Illegal argument type or count
000005       sti ; Interrupts zulassen
         
         ; Bootlaufwerk aus DL speichern
000006       mov [bootdrv], dl
error : Illegal argument type or count
         
         ; Lade unseren kernel
000007 940e 0012 call load
         
         ; Springe zu diesem Kernel
000009       mov ax, 0x1000 ; Die Adresse des Programms
error : Illegal argument type or count
00000a       mov es, ax ; Segmentregister updaten
error : Illegal argument type or count
00000b       mov ds, ax
error : Illegal argument type or count
00000c       push ax
error : Illegal argument type or count
00000d       mov ax, 0
error : Illegal argument type or count
00000e       push ax
error : Illegal argument type or count
00000f       retf
         
         ; ---------------------------
         ; Funktionen und Variablen
         ; ---------------------------
         
000010       bootdrv db 0 ; Das Bootlaufwerk
000011       loading db "Loading...",13,10,0
         
         ; Einen String ausgeben:
          putstr:
000012       lodsb ; Byte laden
000013       or al,al
error : Illegal argument type or count
000014       jz short putstrd ; 0-Byte? -> Ende!
         
000015       mov ah,0x0E ; Funktion 0x0E
error : Illegal argument type or count
000016       mov bx,0x0007 ; Attribut-Byte (wird nicht bentigt)
error : Illegal argument type or count
000017       int 0x10 ; schreiben
000018 940c 000d jmp putstr ; Nchstes Byte
          putstrd:
00001a       retn
         
         ; Lade den Kernel vom Bootlaufwerk
          load:
         
         ; Diskdrive reset (Interrupt 13h, 0)
00001c       push ds ; Sichere DS
error : Illegal argument type or count
00001d       mov ax, 0 ; Die gewnschte Funktion (reset)
error : Illegal argument type or count
00001e       mov dl, [bootdrv] ; Dieses Laufwerk ist gewnscht
error : Illegal argument type or count
00001f       int 13h ; den Interrupt ausfhren
000020       pop ds ; DS wiederherstellen
error : Illegal argument type or count
000021       jc load ; Geht nicht? -> Noch mal!
         
          load:
000022       mov ax,0x1000 ; ES:BX = 10000
error : Illegal argument type or count
000023       mov es,ax
error : Illegal argument type or count
000024       mov bx, 0
error : Illegal argument type or count
         
         ; Sektoren lesen (Interrupt 13h, 2)
000025       mov ah, 2 ; Funktion 2 (Lesen)
error : Illegal argument type or count
000026       mov al, 5 ; Lese 5 Sektoren
error : Illegal argument type or count
000027       mov cx, 2 ; Cylinder=0, Sector=2
error : Illegal argument type or count
000028       mov dx, 0 ; Head=0, Laufwerk=0
error : Illegal argument type or count
000029       int 13h ; ES:BX = Daten vom Laufwerk
00002a       jc load1 ; Fehler? Noch mal!
00002b       mov si,loadmsg
error : Illegal argument type or count
00002c 940e 000d call putstr ; Meldung ausgeben
00002e       retn
         
000030       times 512-($-$$)-2 db 0 ; Datenlnge = 512 Bytes
000032       dw 0AA55h
Assembly complete with 42 errors