Can't call BIOS Interrupts after switch to real mode
Posted: Tue Apr 08, 2014 7:36 pm
In my kernel, I am testing a 16 bit 'payload' to run after exit from 32-bit mode. (What I do is compile file w/ nasm, encode with base64, copy paste to C file and decode in kernel) After the jump to 16-bit mode, my code is something like this (Most of the switch to real mode is ripped off from the wiki):
This code successfully puts "HAI!" on the screen, but doesnt seem to clear the screen. As a result Im very confused . Could someone pls help?
Code: Select all
[ORG 0x7E00]
[bits 16]
Entry16:
; We are already in 16-bit mode here!
cli ; Disable interrupts.
; Need 16-bit Protected Mode GDT entries!
mov eax, 0x30 ; 16-bit Protected Mode data selector.
mov ds, eax
mov es, eax
mov fs, eax
mov gs, eax
; Disable paging (we need everything to be 1:1 mapped).
mov eax, cr0
mov [savcr0], eax ; save pmode CR0
and eax, 0x7FFFFFFe ; Disable paging bit & enable 16-bit pmode.
mov cr0, eax
lidt [idt_real]
mov sp, 0x8000
jmp 0:GoRMode
GoRMode:
mov ax, 0
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
sti
printHAI:
mov ax,0xB800
mov es,ax
xor ax,ax
mov al,'H'
mov ah,'!'
mov word [es:0],ax
mov al,'A'
mov ah,'!'
mov word [es:2],ax
mov al,'I'
mov ah,'!'
mov word [es:4],ax
mov al,'!'
mov ah,'!'
mov word [es:6],ax
clrScreen:
xor ax,ax
int 0x10
idt_real:
dw 0x3FF ; 256 entries, 4b each = 1K
dd 0 ; Real Mode IVT @ 0x0000
savcr0:
dd 0