当按下键时,我试图覆盖默认中断。下面是我的代码:不要调用kbd_handler并更改“port60”,我如何解决这个问题?你觉得是什么引起的?
MAIN SEGMENT PUBLIC
ASSUME CS:MAIN, DS:DATA
MOV AX, MAIN ; Set up the Data Segment address
MOV DS, AX
mov bx, 9 * 4 ;find the int 9
mov dx, word ptr [bx]
push dx
mov dx, word ptr [bx] + 2
push dx
mov ax, DATA
mov DS, ax
mov es, ax
;mov bx, 09h * 04h
mov bx, 9 * 4 ;find the int 9
cli ; disable an interrupt
mov word ptr [bx], offset kbd_handler ; load your keyboard ISR
mov word ptr [bx] + 2, seg kbd_handler ;
sti ;enable interrupts
TEST_2 :
call printc
call delay_cx
jmp test_2
mov ax, MAIN
mov dx, ax
mov bx, 09h * 04h ;find the int 9
cli ; disable interrupt
pop dx
mov word ptr [bx], dx ;back to normal address
pop dx
mov word ptr [bx]+2, dx
sti ; enalbe interrupts
MOV AH, 4CH ;
INT 21H
PUBLIC kbd_handler
kbd_handler PROC NEAR
push ax
push bx
push cx
push dx
push sp
push bp
push si
push di
in al, 64h
test al, 01h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
in al, 60h
mov byte ptr ds:[port60], al
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov al, 20h
out 20h, al
pop di
pop si
pop bp
pop sp
pop dx
pop cx
pop bx
pop ax
IRET
kbd_handler ENDP
PRINT PROC NEAR
CLD ;
PRINT_1 :
MOVSB
MOV AL, DL
STOSB
LOOP PRINT_1
RET
PRINT ENDP
delay_cx proc near ;
delay_1:
push cx ;
mov cx, 50 ;
delay_2:
loop delay_2 ;
pop cx ;
loop delay_1 ;
ret ;
delay_cx endp
PRINTC PROC NEAR
MOV AL, port60
MOV DL, AL
MOV AH, 02H
INT 21H
RET
PRINTC ENDP
MAIN ENDS
DATA SEGMENT
msg1 db 'Press and hold ESC'
msg2 db 'ESC pressed, release ESC'
msg3 db 'ESC released'
kbdbuf db 128 dup (0)
port60 db '1'
DATA ENDS
END 发布于 2016-09-30 16:49:42
在代码中发现了几个错误:
ES段寄存器。
..。采购产品xor dx,dx mov es,dx mov dx,word ptr es:bx .CS段寄存器作为直接的覆盖。
在al中,60h移动字节ptr :port60 60,alpush sp和pop sp一直是红色的。call delay_cx时,仍然需要将CX寄存器设置为适当的值。我看到你的计划还在进行中。很多不再使用的临时代码。删除不需要的东西,以免在可读性上松懈。
看看您所写的消息,我敢建议您以某种方式对这些信息进行划界。
msg1 db 'Press and hold ESC',13,10,0
msg2 db 'ESC pressed, release ESC',13,10,0
msg3 db 'ESC released',13,10,0https://stackoverflow.com/questions/39782865
复制相似问题