PMTheQuick
Grünschnabel
Hi,
ich hatte erst gerade kürzlich nen alten Schrotthaufen-PC gekriegt (ein zweiter, Test-PC)
Jetzt habe ich ein eigenes kleines Betriebssystem durchgearbeitet, und habe noch ein 386-CPU Check eingebunden... Hier mal mein aktueller Code:
boot.asm:
kernel.asm:
Das funktioniert alles bestens! Nur... wie gehts weiter? Wie macht man Punkte auf den Bildschirm? Wie leert man den Bildschirm? Sorry, aber ich weiss das nicht, das es für NASM so gut wie gar kein deutsches Tutorial gibt!
Ich verwende NASM... Bis jetzt alles prima! Und, hat jemand einen besseren Code, der das gleiche erreicht? Oder hat jemand ein NASM-Tut aus deutsch? Schon jetzt mal vielen, vielen Dank!
Seit aber bitte nicht zu streng, werde dieses Jahr erst 11, behersche aber MASM, C++, C, PureBasic, PHP und MySQL... Und nen bissel NASM... Allerdings! Ich will NASM für das BS verwenden!
Gruss
PMTheQuick ;-)
ich hatte erst gerade kürzlich nen alten Schrotthaufen-PC gekriegt (ein zweiter, Test-PC)

boot.asm:
Code:
org 0x7C00
; --------------------------------------------
; Unser Bootloader
; --------------------------------------------
start:
cli
mov ax, 0x9000
mov ss, ax
mov sp, 0
sti
; Bootlaufwerk aus DL speichern
mov [bootdrv], dl
; Lade unseren Kernel
call load
; Springe zu diesem Kernel
mov ax, 0x1000
mov es, ax
mov ds, ax
push ax
mov ax, 0
push ax
retf
; --------------------------------------------
; Funktionen und Variablen
; --------------------------------------------
bootdrv db 0
loadmsg db "Loading...", 13, 10, 0
; Einen String ausgeben
putstr:
lodsb
or al, al
jz short putstrd
mov ah, 0x0E
mov bx, 0x0007
int 0x10
putstrd:
retn
; Lade den Kernel vom Bootlaufwerk
load:
; Diskdrive reset
push ds
mov ax, 0
mov dl, [bootdrv]
int 13h
pop ds
jc load
load1:
mov ax, 0x1000
mov es, ax
mov bx, 0
; Sektoren lesen
mov ah, 2
mov al, 5
mov cx, 2
mov dx, 0
int 13h
jc load1
mov si, loadmsg
call putstr
retn
times 512-($-$$)-2 db 0
dw 0AA55h
kernel.asm:
Code:
; --------------------------------------------
; Unser Kernel
; --------------------------------------------
;- Interrupt vorbereiten
push dx
push es
xor ax, ax
mov es, ax
cli
mov word [es:0x21*4], _int0x21
mov [es:0x21*4+2], cs
sti
pop es
pop dx
mov ax, 1000h
mov ds, ax
mov es, ax
start:
; Willkommen
mov si, msg_welcome
mov al, 0x01
int 0x21
; CPU Check starten (Anfrage)
mov si, msg_cpu
mov al, 0x01
int 0x21
call getkey
; CPU Check Ausgabe
mov si, msg
mov al, 0x01
int 0x21
mov si, msg_cpu_check
mov al, 0x01
int 0x21
call cpu_check
; Rebootanforderung
mov si, msg
mov al, 0x01
int 0x21
mov si, msg_boot
mov al, 0x01
int 0x21
; Taste abwarten
call getkey
; Rebooten
jmp reboot
; --------------------------------------------
; Funktionen und Variablen
; --------------------------------------------
msg db "", 13, 10, 0
msg_welcome db "Willkommen bei Cats 1.0!", 13, 10, 0
msg_cpu db "Druecke eine beliebige Taste, um den CPU-Check durchzufuehren...", 13, 10, 0
msg_cpu_check db "CPU-Check:", 13, 10, 0
msg_is_386 db "Du hast eine 386-CPU!", 13, 10, 0
msg_not_386 db "Du hast keine 386 CPU!", 13, 10, 0
msg_boot db "Druecke eine beliebige Taste, um zu rebooten...", 13, 10, 0
msg_1 db "1", 13, 10, 0
msg_2 db "2", 13, 10, 0
msg_3 db "3", 13, 10, 0
; Warte auf einen Tastendruck
getkey:
mov ah, 0
int 016h
ret
; Rebooten
reboot:
db 0EAh
dw 0000h
dw 0FFFFh
; CPU Check
cpu_check:
cli
pushf
pushf
pop ax
mov bx, ax
and ax, 0x0FFF
or bx,0x7000
push ax
popf
pushf
pop ax
push bx
popf
pushf
pop bx
popf
and ax, 0xF000
cmp ax, 0xF000
je not_386
test bx, 0x7000
jne is_386
retn
not_386:
mov si, msg_not_386
mov al, 0x01
int 0x21
retn
is_386
mov si, msg_is_386
mov al, 0x01
int 0x21
retn
; --------------------------------------------
; Interrupts
; --------------------------------------------
; Text ausgeben
_int0x21:
_int0x21_ser0x01:
cmp al, 0x01
jne _int0x21_end
_int0x21_ser0x01_start:
lodsb
or al, al
jz _int0x21_ser0x01_end
mov ah, 0x0E
mov bh, 0x00
mov bl, 0x07
int 0x10
jmp _int0x21_ser0x01_start
_int0x21_ser0x01_end:
jmp _int0x21_end
_int0x21_end:
iret
Das funktioniert alles bestens! Nur... wie gehts weiter? Wie macht man Punkte auf den Bildschirm? Wie leert man den Bildschirm? Sorry, aber ich weiss das nicht, das es für NASM so gut wie gar kein deutsches Tutorial gibt!


Gruss
PMTheQuick ;-)