But the problem is that when processor reaches on line numbered 6 it resets,instead of returning to calling point.
please tell what's causing the problem.
actually i'm doing all that to call bios interrupts while my kernel is in protedted mode.
in future i'll call fuction "realmode" from C code to carry out some I/O stuff unless i write my own drivers.
Code: Select all
????????????????????????
[SECTION .text]
[ORG 0x7c00]
[BITS 16]
??? cli
xor ax,ax
mov ds,ax
lgdt [gdtr]
1: mov dx,cs
??? mov eax,cr0
??? or al,1
??? mov cr0,eax
jmp SYS_CODE_SEL:do_pm
[BITS 32]
do_pm:???
mov ax,SYS_DATA_SEL
??? mov ds,ax??????
??? mov ss,ax
??? mov es,ax
??? mov fs,ax
??? mov ax,LINEAR_SEL
mov gs,ax
mov byte [gs:0xB80A0],'r'
2: call realmode
mov ax,0x0000
mov gs,ax
mov byte [gs:0xB80A0],'Z'
hang1:
jmp hang1
realmode:
jmp REAL_CODE_SEL:do_16
[BITS 16]
do_16:
mov ax,REAL_DATA_SEL
???mov ds,ax
???mov ss,ax
lea bx,[do_rm]
3: push dx
push bx
???mov eax,cr0
???and al,0xFE
???mov cr0,eax
retf
do_rm:
mov ax,cs
???mov ds,ax
???mov ss,ax
???mov es,ax
???mov fs,ax
???mov gs,ax
???sti
mov al,'S'
mov ah,0eh
int 10h
mov ah,0x00
5: int 16h
cli
xor ax,ax
mov ds,ax
lgdt [gdtr]
???
mov eax,cr0
??? or al,1
??? mov cr0,eax
jmp SYS_CODE_SEL:do_pm1
[BITS 32]
do_pm1:
mov ax,SYS_DATA_SEL
??? mov ds,ax??????
??? mov ss,ax
??? mov es,ax
??? mov fs,ax
??? mov ax,LINEAR_SEL
??? mov gs,ax
mov byte [gs:0xB80A0],'O'
6: ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
gdtr:???
dw gdt_end - gdt - 1???
???dd gdt?????????
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;global descriptor table (GDT)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; null descriptor
gdt:???dw 0?????????
???dw 0?????????
???db 0?????????
???db 0?????????
???db 0?????????
???db 0?????????
; linear data segment descriptor
LINEAR_SEL???equ???$-gdt
???dw 0xFFFF??????
???dw 0?????????
???db 0
???db 0x92?????????
???db 0xCF?????????
???db 0
; code segment descriptor
SYS_CODE_SEL???equ???$-gdt
gdt1:???dw 0xFFFF
???dw 0?????????
???db 0
???db 0x9A?????????
???db 0xCF
???db 0
; data segment descriptor
SYS_DATA_SEL???equ???$-gdt
gdt2:???dw 0xFFFF
???dw 0?????????
???db 0
???db 0x92?????????
???db 0xCF
???db 0
REAL_CODE_SEL???equ???$-gdt
gdt3:???dw 0xFFFF
???dw 0?????????
???db 0
???db 0x9A?????????
???db 0?????????
???db 0
REAL_DATA_SEL???equ???$-gdt
gdt4:???dw 0xFFFF
???dw 0?????????
???db 0
???db 0x92?????????
???db 0?????????
???db 0
gdt_end: