hello all,
i have declared a global descriptor as below:
gdt:
null_descriptor:
dw 0 ; seg_length1_15
dw 0 ; base_addr0_15
db 0 ; base_addr16_23
db 0 ; dflags
db 0 ; access
db 0 ; base_addr24_31
code_descriptor:
dw 0xFFFF ; seg_length1_15
dw 0 ; base_addr0_15
db 0 ; base_addr16_23
db 0x9A ; dflags
db 0xCF ; access
db 0 ; base_addr24_31
data_descriptor:
dw 0xFFFF
dw 0
db 0
db 0x92
db 0xCF
db 0
video_descriptor:
dw 0x00EF
dw 0xb800
db 0
db 0x92
db 0xCF
db 0
gdt_end:
gdt_descriptor:
dw gdt_end - gdt - 1
dd gdt
But, when i try to move the character 'a' into the video segment, it fails. The coding for moving is also given.
mov ax, 10h
mov ds, ax
mov byte [ds:0], 'A'
mov byte [ds:1], 1BH
Please, help me out of this problem.
Thanks in advance.
Newbie
RE:Newbie
You need properly switch to protected mode, I recommend you get some step-by-step tutorial. There are some well protected mode tutorials at:
http://osdev.neopages.net/tutorials.php?cat=4&sort=1
The author Chris Giese write the best protected mode examples I have found, but I don´t remeber where I get these examples. Ask him!
There is also an example at:
Intel Architecture Software Developer’s Manual Volume 3: System Programming
CHAPTER 8 PROCESSOR MANAGEMENT AND INITIALIZATION
8.9. INITIALIZATION AND MODE SWITCHING EXAMPLE
You can request a copy at the INTEL web site!
pepito
http://osdev.neopages.net/tutorials.php?cat=4&sort=1
The author Chris Giese write the best protected mode examples I have found, but I don´t remeber where I get these examples. Ask him!
There is also an example at:
Intel Architecture Software Developer’s Manual Volume 3: System Programming
CHAPTER 8 PROCESSOR MANAGEMENT AND INITIALIZATION
8.9. INITIALIZATION AND MODE SWITCHING EXAMPLE
You can request a copy at the INTEL web site!
pepito
RE:Newbie
OK, you need at least this steps to switch to protected mode:
1) Create a GDT (Your code have one!)
2) Load the GDTR with the base and limit of your GDT:
lgdt [gdt_descriptor]
(but be careful about what Adrian say!)
3) Set the PE bit at CR0 register:
mov eax, cr0
or al, 1
mov cr0, eax
4) Do a far jump to enable protected mode, you need a label before your PM code:
jmp 8:some_label ; Code descriptor
[BITS 32]
some_label:
; Update data segment registers
mov ax, 16 ; Data descriptor
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
; HERE YOU CAN TRY YOUR VIDEO CODE !!!
mov ax, 24 ; Video descriptor
mov ds, ax
mov byte [ds:0], 'A'
mov byte [ds:1], 1BH
pepito
1) Create a GDT (Your code have one!)
2) Load the GDTR with the base and limit of your GDT:
lgdt [gdt_descriptor]
(but be careful about what Adrian say!)
3) Set the PE bit at CR0 register:
mov eax, cr0
or al, 1
mov cr0, eax
4) Do a far jump to enable protected mode, you need a label before your PM code:
jmp 8:some_label ; Code descriptor
[BITS 32]
some_label:
; Update data segment registers
mov ax, 16 ; Data descriptor
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
; HERE YOU CAN TRY YOUR VIDEO CODE !!!
mov ax, 24 ; Video descriptor
mov ds, ax
mov byte [ds:0], 'A'
mov byte [ds:1], 1BH
pepito