Помогите, пожалуйста!
Есть код загрузчика:
Код:
format binary
org 600h
include "macros.inc"
jmp N
N: push cs
push cs
pop ds
pop fs
push 0b800h
pop es
xor si,si
xor di,di
mov [redx],dx
mov [rebx],ebx
mov [reax],eax
mov [recx],ecx
jmp gotoPM
redx dw ?
rebx dd ?
reax dd ?
recx dd ?
gotoPM:
in al,92h
or al,2
out 92h,al
cli
in al,70h
or al,80h
out 70h,al
lgdt fword [GDTR]
lidt fword [IDTR]
mov eax,cr0
or al,1
mov cr0,eax
push word 08h
push dword PM_entry
retfd
;============================================+
times 200h-($$-$) db 0 ;|
org 200h ;|
;============================================+
IDT: ;|
times 13 dq 0 ;|
dw EOI,10001110000000b,08h,0h ;|
dw GP_handler,10001110000000b,08h,0h ;|
times 18 dq 0 ;|
dw EOI,10001110000000b,08h,0h ;|
dw RIQ0_handler,10001110000000b,08h,0h ;|
dw RIQ1_handler,10001110000000b,08h,0h ;|
times 255 - 33 ;|
dw EOI,10001110000000b,08h,0h ;|
;============================================+
label IDT_SIZE at $-IDT ;|
;____________________________________________+
;--------------------------------------------+
org 1000h ;|
;============================================+
GDT: ;|
NULLS db 00h,00h,00h,00h,00h,00h,00h,00h ;|
CODES db 0ffh,0ffh,00h,00h,00h,9ah,0h,0h ;|
DATAS db 0ffh,0ffh,00h,00h,00h,92h,0h,0h ;|
;============================================+
label GDT_SIZE at $-GDT ;|
;____________________________________________+
;--------------------------------------------+
GDTR: ;|
dd GDT_SIZE - 1 ;|
dw GDT ;|
;____________________________________________+
;--------------------------------------------+
IDTR: ;|
dd IDT_SIZE - 1 ;|
dw IDT ;|
;============================================+
use32
PM_entry:
mov eax,10h
mov ds,ax
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov edi,0b8000h
xor esi,esi
mov ebx,ok
mov al,07h
call PM_printc
jmp $
ok db "ok",0
PM_printc:
mov ah,al
s: mov al,[bx]
cmp al,0h
je e
mov [es:di],ax
inc bx
inc di
inc di
jmp s
e:
ret
GP_handler:
pop [GP_code]
mov al,07h
call PM_printc
iretd
GP_msg db "GP exception:"
GP_code dd ?
db 0h
RIQ0_handler:
jmp EOI
RIQ1_handler:
jmp EOI
EOI:
push eax
mov al, 20h
out 020h, al
out 0a0h, al
pop eax
iretd
но на переходе в PM (команда retfd) возникает тройное исключение и bochs перезагружается!
Заранее спасибо!