8086大会键盘执行ISR [英] 8086 Assembly keyboard ISR implementation

查看:189
本文介绍了8086大会键盘执行ISR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白为什么键盘中断服务程序,我写我的程序(应打印Hello World的每个I PSS的关键$ P $时间),当我执行上的DOSBox中的.exe只发生一次。
这里是code:

I can't understand why the keyboard interrupt service routine I wrote for my program (should print "hello world" each time I press a key) only occurs once when I execute the .exe on dosbox. Here is the code:

  NAME keyb

PILE    SEGMENT STACK
    db      20 dup ('LA PILE ')
PILE    ENDS


DONNEE SEGMENT
message db "Hello wolrd !$"
DONNEE ENDS

PROGRAMME SEGMENT
ASSUME CS:PROGRAMME , DS:DONNEE, ES:NOTHING, SS:PILE
debut:

    mov ax,DONNEE
    mov ds,ax

    cli

    xor ax,ax
    mov es, ax ; load ES with segment address of interrupt pointer table
    mov bx, 24h ; load BX with interrupt type
    mov word ptr es:[bx], OFFSET SUBR ; isr address
    mov word ptr es:[bx]+2, SEG SUBR ; isr segment
    mov ax, 01h
    sti

BOUCLE: jmp BOUCLE

SUBR PROC NEAR
    cli
    mov ah,9
    mov dx,OFFSET message
    int 21h
    sti

    IRET
SUBR ENDP

PROGRAMME ENDS

    END debut

我尝试了一些东西,比如推ING和弹出式ING寄存器,使用另一个中断(系统时钟08H),但他们没有工作。
我知道ISR至少执行一次,因为该消息的Hello World出现在屏幕上,但它应该打印每次我一次preSS的关键,我不知道为什么它没有。

I tried a few things, like push-ing and pop-ing registers, using another interrupt (system clock 08h), but none of them worked. I know that the ISR runs at least once because the message "hello world" appears on screen, but it should print every time I press a key and I have no idea why it doesn't.

我怎样才能解决这个问题?

How can I resolve this?

推荐答案

您必须做一些工作,以免费键盘和中断。看看这里。最简单的方法是在你自己的处理程序结束跳转到老IRQ处理程序:

You have to do some work to "free" keyboard and interrupt. Take a look here. The easiest way is to jump to the old IRQ-handler at the end of your own handler:

NAME keyb

PILE    SEGMENT STACK
    db      20 dup ('LA PILE ')
PILE    ENDS

DONNEE SEGMENT
message db "Hello wolrd !$"
oldvec dw 0, 0
DONNEE ENDS

PROGRAMME SEGMENT
ASSUME CS:PROGRAMME , DS:DONNEE, ES:NOTHING, SS:PILE
debut:

    mov ax,DONNEE
    mov ds,ax

    cli

    xor ax,ax
    mov es, ax ; load ES with segment address of interrupt pointer table
    mov bx, 24h ; load BX with interrupt type

    ; Store the old IRQ vector
    mov ax, es:[bx]
    mov oldvec, ax
    mov ax, es:[bx+2]
    mov oldvec + 2, ax

    mov word ptr es:[bx], OFFSET SUBR ; isr address
    mov word ptr es:[bx]+2, SEG SUBR ; isr segment
    mov ax, 01h
    sti

BOUCLE: jmp BOUCLE

SUBR PROC NEAR
    push ax
    push dx

    mov ah,9
    mov dx,OFFSET message
    int 21h

    pop dx
    pop ax    

    jmp dword ptr [oldvec]
SUBR ENDP

PROGRAMME ENDS

END debut

这篇关于8086大会键盘执行ISR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆