please tell me whats causing the problem and how to remove it.
actually i'm trying to switch to protected mode and then to real mode and then back to protected mode.
Code: Select all
1: [ORG 0x7c00]
2: [BITS 16]
3: start:
4: xor ebx,ebx
5: mov bx,ds
6: shl ebx,4
7: mov eax,ebx
8: lea eax,[gdt + ebx]
9: mov [gdtr + 2],eax
10: cli
11: mov ax,cs
12: mov [RealModeCS],ax
13: lea ax,[do_rm]
14: mov [RealModeIP],ax
15:
16: lgdt [gdtr]
17: mov eax,cr0
18: or al,1
19: mov cr0,eax
20: jmp SYS_CODE_SEL:do_pm
21: [BITS 32]
22: do_pm:
23: mov ax,SYS_DATA_SEL
24: mov ds,ax
25: mov ss,ax
26: mov ax,LINEAR_SEL
27: mov es,ax
28: mov byte [es:dword 0xB8000],'P'
29: [BITS 16]
30: do_16:
31: mov eax,cr0
32: and al,0xFE
33: mov cr0,eax
34: jmp far [RealModeIP]
35: [BITS 16]
36: do_rm: mov byte [es:dword 0xB8008],'4'
37: xor ax,ax
38: mov es,ax
39: mov byte [es:dword 0xB800A],'5'
40: sti
41: xor ebx,ebx
42: mov bx,ds
43: shl ebx,4
44: mov eax,ebx
45: lea eax,[gdt + ebx]
46: mov [gdtr + 2],eax
47: cli
48: lgdt [gdtr]
49: mov eax,cr0
50: or al,1
51: mov cr0,eax
52: jmp SYS_CODE_SEL:do_pm1
53: [BITS 32]
54: do_pm1:
mov ax,SYS_DATA_SEL
mov ds,ax
mov ss,ax
mov ax,LINEAR_SEL
mov es,ax
; questionable PM code here
mov byte [es:dword 0xB8002],'9'
hang:
jmp hang
RealModeIP:
dw 0
RealModeCS:
dw 0
gdtr: dw gdt_end - gdt - 1 ; GDT limit
dd gdt ; (GDT base gets set above)
gdt: dw 0
dw 0
db 0
db 0
db 0
db 0
LINEAR_SEL equ $-gdt
dw 0xFFFF
dw 0
db 0
db 0x92
db 0xCF
db 0
SYS_CODE_SEL equ $-gdt
gdt2: dw 0xFFFF
dw 0
db 0
db 0x9A
db 0xCF
db 0
SYS_DATA_SEL equ $-gdt
gdt3: dw 0xFFFF
dw 0
db 0
db 0x92
db 0xCF
db 0
REAL_CODE_SEL equ $-gdt
gdt4: dw 0xFFFF
dw 0
db 0
db 0x9A
db 0
db 0
REAL_DATA_SEL equ $-gdt
gdt5: dw 0xFFFF
dw 0
db 0
db 0x92
db 0
db 0
gdt_end: