I've understood that, now I use another interrupt.Bender wrote:Why are you using int 0x21? It's a DOS interrupt, not a BIOS interrupt.
How can I push AL or AH to stack? Is there a way to do that?
I've understood that, now I use another interrupt.Bender wrote:Why are you using int 0x21? It's a DOS interrupt, not a BIOS interrupt.
Code: Select all
cli
lgdt [gdtr]
mov eax, cr0
or al, 1
mov cr0, eax
jmp 08h:main
Code: Select all
section .text
use16
org 0x1000 ; Load address.
What's wrong with that? (causes reboots, triple fault?)Bender wrote:You must define the "GDTR" yourself, You would need to refer to the manuals and some Google Fu will be required.
Also, you may triple fault since the "LGDT" instruction expects the linear address and you're only providing the offset.
Code: Select all
section .text
use16
org 0x1000 ; Load address.
start:
mov ax, cs
mov ds, ax ; Select data segment.
mov ah, 13h ; Tell user, that stage 2 has started.
mov al, 1
mov bh, 0
mov bl, 0_7h
mov cx, stage2_start_msg_len
inc dh
mov dl, 0
mov bp, stage2_start_msg
int 0x10
call check_a20
cmp ax, 1
jnz en_a20
call check_a20
cmp ax, 1
jnz error
mov ah, 42h ; Load kernel.
mov dl, 0x80
mov si, DAPACK
int 0x13
jc error
mov ah, 0
mov al, 0x13
int 0x10
cli
lgdt [gdtr]
mov eax, cr0
or al, 1
mov cr0, eax
mov edi,0x0A0000
mov al, 4 ; the color of the pixel
mov [edi],al
mov edi,0x0A0025
mov al, 7 ; the color of the pixel
mov [edi],al
jmp dword 0x2000:0000
hlt
error:
call cls
mov ah, 0bh
mov bh, 0
mov bl, 4_4h
int 0x10
mov ah, 13h
mov al, 1
mov bh, 0
mov bl, 8_Fh
mov cx, err_msg_len
mov dh, 0
mov dl, 0
mov bp, err_msg
int 0x10
cli
hlt
cls:
mov ah, 0
mov al, 2
int 0x10
ret
en_a20:
mov ax, 0x2401
int 0x15
jc error
ret
check_a20:
pushf
push ds
push es
push di
push si
cli
xor ax, ax ; ax = 0
mov es, ax
not ax ; ax = 0xFFFF
mov ds, ax
mov di, 0x0500
mov si, 0x0510
mov al, byte [es:di]
push ax
mov al, byte [ds:si]
push ax
mov byte [es:di], 0x00
mov byte [ds:si], 0xFF
cmp byte [es:di], 0xFF
pop ax
mov byte [ds:si], al
pop ax
mov byte [es:di], al
mov ax, 0
je check_a20__exit
mov ax, 1
check_a20__exit:
pop si
pop di
pop es
pop ds
popf
ret
DAPACK:
db 0x10
db 0
blkcnt: dw 1
db_add: dw 0x2000
dw 0
d_lba: dd 2
dd 0
stage2_start_msg db "Stage 2 has started."
stage2_start_msg_len equ $-stage2_start_msg
err_msg db "Critical boot error occured, cannot continue."
err_msg_len equ $-err_msg
gdtr DW 200 ; For limit storage
DD 0
Code: Select all
gdtr DW 200 ; For limit storage
DD 0