Ты бы хоть отладку какую подрубил... Попадаешь ли в use32 и т.п. Объяви дескриптор на video. Сто пудов у тебя сразу эксепшен какой-то возникает.
На всякий случай кидаю свой исходник - переделанный из книги Финогенова - работа с DRx:
| Цитата | .386p Port equ 170h ; Port to trap ; ; Common structures ; descr struc lim dw 0 base_l dw 0 base_m db 0 attr_1 db 0 attr_2 db 0 base_h db 0 descr ends trap struc offs1 dw 0 sel dw 16 rsrv db 0 attr_ db 8fh offs_h dw 0 trap ends intr struc ioffs_l dw 0 isel dw 16 irsrv db 0 iattr db 8eh ioffs_h dw 0 intr ends data segment use16 gdt_0 label word ; GDT table gdt_null descr <0,0,0,0,0,0> gdt_data descr <data_size-1,0,0,92h,0,0> gdt_code descr <code_size-1,0,0,98h,0,0> gdt_stack descr <255,0,0,92h,0,0> gdt_screen descr <4095,8000h,0bh,92h,0,0> gdt_himem descr <1023,0,10h,92h,80h> gdt_tss_0 descr <103,0,0,89h> gdt_tss_1 descr <103,0,0,89h> gdt_size= $-gdt_null idt label word trap <exc_0> trap <exc_1> trap <exc_2> trap <exc_3> trap <exc_4> trap <exc_5> trap <exc_6> trap <exc_7> trap <exc_8> trap <exc_9> trap <exc_10> trap <exc_11> trap <exc_12> trap <exc_13> trap <exc_14> trap <exc_15> trap 16 dup(<exc_test>) intr <new_08> intr <new_09> idt_size=$-idt pdescr dq 0 real_sp dw 0 real_ss dw 0 count db 0 sec dw 0 place dw 0 sym db 24 testt db 0 kode db ? attr db 1eh tabl db '0123456789' TabHex db '0123456789ABCDEF' n1 dw ? mes db 'We are in DOS',13,10 leng equ $-mes tss_0 db 104 dup(0) tss_1 db 104 dup(0) task1_offs dw 0 task1_sel dw 56 Trap1Msg db 'I/O trap raising ! DX= ?',0 DebugDX dw ? data_size equ $-gdt_null data ends text segment 'code' use16 assume cs:text,ds:data begin label word exc_0 proc mov bp,sp add dword ptr [bp],2 mov ax,666h mov es:[300],ax mov bx,1 db 66h iret exc_0 endp exc_1 proc pushad mov DebugDX,dx mov ax,DebugDX mov di,offset Trap1Msg+22 call HexWord_String push 10*160 push offset Trap1Msg call Out_String popad db 66h iret exc_1 endp exc_2 proc mov ax,2 mov gs:[0],ax mov place,800 call dword ptr task1_offs db 66h iret exc_2 endp exc_3 proc mov ax,3 mov gs:[0],ax mov place,800 call dword ptr task1_offs db 66h iret exc_3 endp exc_4 proc mov ax,4 mov gs:[0],ax mov place,800 call dword ptr task1_offs db 66h iret exc_4 endp exc_5 proc mov ax,5 mov gs:[0],ax mov place,800 call dword ptr task1_offs db 66h iret exc_5 endp exc_6 proc mov ax,6 mov gs:[0],ax mov place,800 call dword ptr task1_offs db 66h iret exc_6 endp exc_7 proc mov ax,7 mov gs:[0],ax mov place,800 call dword ptr task1_offs db 66h iret exc_7 endp exc_8 proc mov ax,8 mov gs:[0],ax mov place,800 call dword ptr task1_offs db 66h iret exc_8 endp exc_9 proc mov ax,9 mov gs:[0],ax mov place,800 call dword ptr task1_offs db 66h iret exc_9 endp exc_10 proc mov ax,10 mov gs:[0],ax mov place,800 call dword ptr task1_offs db 66h iret exc_10 endp exc_11 proc mov ax,11 mov gs:[0],ax mov place,800 call dword ptr task1_offs db 66h iret exc_11 endp exc_12 proc mov ax,12 mov gs:[0],ax mov place,800 call dword ptr task1_offs db 66h iret exc_12 endp exc_13 proc mov ax,13 mov gs:[0],ax mov place,800 call dword ptr task1_offs db 66h iret exc_13 endp exc_14 proc mov ax,14 mov gs:[0],ax mov place,800 call dword ptr task1_offs db 66h iret exc_14 endp exc_15 proc mov ax,15 mov gs:[0],ax mov place,800 call dword ptr task1_offs db 66h iret exc_15 endp exc_test proc mov ax,666 mov gs:[0],ax mov place,800 db 66h iret exc_test endp new_08 proc inc count cmp count,18 jbe NO_time cli mov count,0 inc sec mov ax,sec mov gs:[0],ax mov place,840 call dword ptr task1_offs sti NO_time: mov al,20h out 20h,al db 66h iret new_08 endp new_09 proc cli in al,60h mov kode,al xor ah,ah mov gs:[0],ax mov place,860 call dword ptr task1_offs sti in al,61h or al,80h out 61h,al and al,7fh out 61h,al mov al,20h out 20h,al db 66h iret new_09 endp main proc mov ax,0003h int 10h xor eax,eax mov ax,data mov ds,ax ; calculate liner address of data segment shl eax,4 mov ebp,eax mov bx,offset gdt_data mov [bx].base_l,ax rol eax,16 mov [bx].base_m,al ; and command segment xor eax,eax mov ax,cs shl eax,4 mov bx,offset gdt_code mov [bx].base_l,ax rol eax,16 mov [bx].base_m,al ; and stack segment xor eax,eax mov ax,ss mov real_ss,ax shl eax,4 mov bx,offset gdt_stack mov [bx].base_l,ax rol eax,16 mov [bx].base_m,al ; tss_0 mov eax,ebp add ax,offset tss_0 mov bx,offset gdt_tss_0 mov [bx].base_l,ax rol eax,16 mov [bx].base_m,al ; tss_1 mov eax,ebp add ax,offset tss_1 mov bx,offset gdt_tss_1 mov [bx].base_l,ax rol eax,16 mov [bx].base_m,al ; prepare psevdodescriptor mov dword ptr pdescr+2,ebp mov word ptr pdescr,gdt_size-1 lgdt pdescr push ebp ; cli mov word ptr tss_1+4ch,16 mov word ptr tss_1+20h,offset himem mov word ptr tss_1+50h,24 mov word ptr tss_1+38h,128 mov word ptr tss_1+54h,8 mov word ptr tss_1+48h,32 ;fuck off all interrupts ;cli mov al,8fh out 70h,al ;NMI off jmp $+2 ;stop little bit mov al,05h out 71h,al mov ax,40h mov es,ax mov word ptr es:[67h],offset return mov word ptr es:[69h],cs ;change controller regim mov dx,20h mov al,11h out dx,al jmp $+2 inc dx mov al,20h out dx,al jmp $+2 mov al,4 out dx,al jmp $+2 mov al,1 out dx,al mov al,0fch out dx,al mov dx,0a1h mov al,0ffh out dx,al ;load idtr table pop ebp mov word ptr pdescr,idt_size-1 xor eax,eax mov ax,offset idt add eax,ebp mov dword ptr pdescr+2,eax lidt pdescr mov al,0d1h out 64h,al mov al,0deh out 60h,al ; set the processor regim mov eax,cr0 ;get mashine word or eax,1 ;set PE bit mov cr0,eax ;load mashine word ; load cs:ip db 0eah ;jmp far dw offset continue dw 16 ;command selector continue: mov ax,8 mov ds,ax mov ax,24 mov ss,ax mov ax,32 mov es,ax mov ax,40 ;massive selector mov gs,ax ; Interrupts mov al,0dh out 70h,al sti ; Set trap to ports i/o mov eax,cr4 or eax,01000b mov cr4,eax ; FEDCBA9876543210 mov eax,(0110011001100110b shl 16)+(07FFh) ; 0010001000100010b shl 16 ; 020703h ; 010000001100000010b mov dr7,eax ; Ports set xor ebx,ebx mov bx,Port mov dr0,ebx
add ebx,2 mov dr1,ebx add ebx,2 mov dr2,ebx add ebx,2 mov dr3,ebx ; mov ax,48 ltr ax ; ; Waiting for filler ; @@MainLoop: cmp kode,130 jb @@NoNumKey cmp kode,139 ja @@NoNumKey ; Try to make exception mov dx,Port xor ax,ax mov al,kode sub al,130 add dx,ax in al,dx @@NoNumKey: cmp kode,57 jnz @@MainLoop ; mov al,0d1h out 64h,al mov al,0ddh out 60h,al ; mov al,0feh out 64h,al hlt ; turn back DOS media return: mov ax,data mov ds,ax mov ax,stk mov ss,ax mov sp,256 mov ss,real_ss ;interrupt on mov al,184 out 21h,al mov al,13 out 0a1h,al sti mov al,0 out 70h,al ;NMI on cmp n1,666 jne No mov cx,15 @2: push cx mov ah,40h mov bx,01 mov cx,leng mov dx,offset mes int 21h pop cx loop @2 NO: mov ax,4c00h int 21h main endp himem proc pusha mov ax,32 mov es,ax mov ax,40 mov gs,ax xor ebx,ebx mov cx,gs:[ebx] mov di,10000 mov bx,place mov testt,0 @1: mov ax,cx xor dx,dx div di mov si,ax mov dl,testt and dx,1 cmp dx,1 je Good cmp ax,0 je Ziro Good: mov testt,1 mov al,tabl[si] mov ah,13h mov es:[bx],ax Ziro: add bx,2 mov ax,di mul si sub cx,ax mov ax,di xor dx,dx mov si,10 div si mov di,ax cmp di,1 jae @1 popa iret jmp himem himem endp Out_String proc near push bp cli mov bp,sp pushad push es mov ax,32 mov es,ax mov si,[bp+4] mov di,[bp+6] mov ah,14 cld @@OutString: lodsb test al,al jz @@OutStringDone stosw jmp @@OutString @@OutStringDone: pop es popad pop bp sti retn 4 Out_String endp HexWord_String proc near pusha push es push ds pop es cld mov bx,offset TabHex mov cx,4 @@HexWordStr: rol ax,4 push ax and al,0Fh xlat stosb pop ax loop @@HexWordStr pop es popa retn HexWord_String endp Hex_String proc near pusha push es test cx,cx jz @@ExitHexStr cld mov bx,offset TabHex push ds pop es @@HexStr: lodsb mov ah,al shr al,4 xlat stosb mov al,ah and al,0Fh xlat stosb loop @@HexStr @@ExitHexStr: pop es popa retn Hex_String endp code_size= $-begin text ends stk segment stack 'stack' db 256 dup('~') stk ends end main
| |