How do I use DOS interrupt 21h/AH=25h (set interrupt vector)?

回眸只為那壹抹淺笑 提交于 2019-12-24 14:43:18

问题


I prompt the user for input:

mov ah, 0Ah
mov dx, OFFSET buffer
int 21h

My assignment tells me that ctrl-c should "abort the program with an appropriate error message".

I was told that int 23h is called whenever ctrl-c is called or detected. Apparently I can register my own interrupt handler via int 21h / ah=25h.

But I don't know how to make an interrupt handler, nor do I know where this is supposed to go in my code. Assistance would be appreciated, thank you in advance.


回答1:


As far as I know function ah=25h does nothing but writing the interrupt vector to the interrupt vector table.

This table is located at address 0000:0000 and contains segment:offset pointers to the interrupts.

This means: Function 25h would simply write the segment (value of CS) to address 0000:008E and the offset (address of your interrupt handler) to 0000:008C.




回答2:


do followings to write your custom interrupt handler

SettingIntVector:
     mov ah,25h      ;Here set your ah register for calling Interrupt vector
     mov al,22h      ;Your Interrupt Address
     mov dx,IntHandlerCode   ;Interrupt Handler
     int 21h                 ;Dos Interrupt 



 IntHandlerCode:
    mov ah,9
    mov dx, offset our_text
     mov ah,9
    int 21h   
    iret

our_text db "new Interrupt Handler... $"

I hope this helped to figure out how stuff works. This Interrupt Just write "new Interrupt Handler " to screen



来源:https://stackoverflow.com/questions/19398704/how-do-i-use-dos-interrupt-21h-ah-25h-set-interrupt-vector

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!