Re: Problem on real hardware
Posted: Wed Dec 07, 2011 6:25 pm
We have version control for that. If something makes things worse, you undo it and you complain to whomever made that suggestion.romfox wrote:Using EXACTLY the code I posted on page 4, it doesn't spawn anything now, how can it do that ?? Gonna burn my computer x_x.
Sleeping a night has a tendency to work as well. Especially since I'm pretty sure what time it is right now at your place.
At least your bootloader + stub kernel works on real hardware for me with the modifications provided, which is something I would like to recommend others as well: if your suggestion does not work on your own hardware, don't post it. There is way too much nonsense in this thread as every noob that comes in here will end up with worse code rather than better code.
The more people that get it working, the bigger the chance it will work on your particular setup as well.
I'll post my entire version for reference to eliminate all copy errors (no I did not substitute the french yet):
romfox_bootfn.asm
Code: Select all
; -------------------------------------------------------------
; Fonction d'affichage qui utilise le BIOS
; -------------------------------------------------------------
print16:
push ax
push bx
.debut:
lodsb
or al, al ; zero=end of str
jz .end ; get out
mov ah, 0x0E
mov bl, 0xff
int 0x10
jmp .debut
.end:
pop bx
pop ax
ret
; -------------------------------------------------------------
; Fonction d'affichage qui utilise le BIOS
; -------------------------------------------------------------
print_reg16:
pusha
mov di, buff16
mov ax, [reg16]
mov si, hexch
mov cx, 4
.debut:
rol ax, 4
mov bx, ax
and bx, 0x0f
mov bl, [si+bx]
mov [di], bl
inc di
dec cx
jnz .debut
mov si, buff16
call print16
popa
ret
reg16: dw 0
buff16: db '0000', 0
hexch: db '0123456789abcdef'
Code: Select all
%define BASE 0x100 ; 0x0100:0x0 = 0x1000
%define KSIZE 17 ; nombre de secteurs a charger
[BITS 16]
[ORG 0x7c00]
jmp 0x0:start
%include "romfox_bootfn.asm"
start:
; initialisation des segments en 0x07c0
; >> actually, zeroed
xor ax, ax
mov ds, ax
mov es, ax
mov fs, ax
mov ss, ax
mov sp, 0xf000
; recuparation de l'unite de boot
mov [bootdrv], dl
; affiche un msg
mov si, msgDebut
call print16
push es
push ds
initialise_disque: ; Initialise le lecteur de disque
xor ax, ax
mov dl, [bootdrv]
int 0x13
jc initialise_disque ; En cas d'erreur on recommence (sinon, de toute façon, on ne peut rien faire)
mov si, msg2
call print16
pop ds
push ds
lire:
mov ax, BASE
mov es, ax
mov [reg16], es
call print_reg16
xor bx, bx
mov ah, 2 ; Fonction 0x02 : chargement mémoire
mov al, KSIZE ; On lit KSIZE secteurs
xor ch, ch ; Premier cylindre (n° 0)
mov cl, 2 ; Premier secteur (porte le n° 2, le n° 1, on est dedans, et le n° 0 n'existe pas)
xor dh, dh ; Tête de lecture n° 0
mov dl, 0 ;>>[bootdrv]
; bios might not clear it
CLC
int 0x13 ; Lit !
jc lire ; En cas d'erreur, on recommence
pop ds
pop es
mov si, msg3
call print16
; passage en modep
cli
mov ax, 0
mov ds, ax
lgdt [gdtptr] ; charge la gdt
mov eax, cr0
or ax, 1
mov cr0, eax ; PE mis a 1 (CR0)
jmp 0x8:next
[BITS 32]
next:
mov ax, 0x10 ; segment de donne
mov ds, ax
mov fs, ax
mov gs, ax
mov es, ax
mov ss, ax
; >>> don't touch bios
; mov esp, 0x9F000
mov esp, 0x1000
; Affichage d'un message par ecriture dans la RAM video
mov byte [0xB8140], 'H'
mov byte [0xB8141], 0x57
.wait:
in al, 0x64
and al, 1
jz .wait
jmp BASE << 4
;--------------------------------------------------------------------
bootdrv: db 0
msgDebut: db "Loading kernel...", 13, 10, 0
msg2: db "Step 2", 0
msg3: db "Step 3", 0
;--------------------------------------------------------------------
gdt:
db 0, 0, 0, 0, 0, 0, 0, 0
gdt_cs:
dd 0xffff, 0x00cf9a00
gdt_ds:
dd 0xffff, 0x00cf9200
gdtend:
;--------------------------------------------------------------------
gdtptr:
dw gdtend - gdt -1
dd gdt ; base
;--------------------------------------------------------------------
;; NOP jusqu'a 510
times 510-($-$$) db 144
dw 0xAA55
Code: Select all
[BITS 32]
[ORG 0x1000]
mov byte [0xB8040], 'K'
mov byte [0xB8041], 0x57
jmp $
--------------
I have yet to see one myself. My complaint about stupid suggestions applies in particular to people like you. It is a bug and it needs a fix, not ignoring because it just works for you.DavidCooper wrote:Many EBDAs start at 9F000