Page 1 of 1

Can't enter protected mode

Posted: Wed Dec 12, 2007 8:16 pm
by matias_beretta
Hello, thanks for reading my topic.
This isn't working and can't find the error, can you help me?

Code: Select all

use16

mov ax, 7c0h
mov ds, ax

cli

lgdt [C]
mov ah, 0eh
mov al, 'A'
int 10h

mov eax, cr0
or al, 1
mov cr0, eax

jmp 8h:A

use32

A:
    mov ax, 10h
    mov es, ax
    mov byte [es:0], 'M'
    mov byte [es:1], 31
    jmp $
B:
    db 0h, 0h, 0h, 0h, 0h, 0h, 0h, 0h
    db 0FFh, 0FFh, 0h, 0h, 0h, 10011000b, 11001111b, 0h
    db 0FFh, 0FFh, 0h, 0h, 0h, 10010010b, 11001111b, 0h
C:
    dw C-B-1
    dd B

times 510-($-$$) db 0
db 55h, 0aah

Posted: Wed Dec 12, 2007 8:46 pm
by Dandee Yuyo
The '0x10' segment you are loading in ES is zero-based. Thus I'm afraid you are writting the character 'M' at memory location 0000000000 and the value 31 at 0000000001. That is the standard interrupt vector table.

Also I would LGDT right before switching to PM (or right after).

Reply

Posted: Thu Dec 13, 2007 4:11 am
by matias_beretta
thanks...