Wang Shuang's learning process of the third edition of assembly language experiment 15

Install new int 9 interrupt routine

Install A new int 9 interrupt routine, function: under DOS, after pressing the "A" key, unless it is not released, if it is released, the screen will be full of "A", and other keys will be processed as usual.

Personal analysis:
I think this interrupt routine is essentially to judge whether the scanning code processed by the original int 9 is A interrupt code. If it is A full screen "A", if it is not processed as usual, there is only one thing I care about: when A is pressed, nothing is output or processed as usual. Due to the limitation of Chinese level, I'm not sure here. I deal with it as usual. If you find any wrong message, thank you.
Other attention details have been informed at the inspection point, which is not much nonsense.

Assembly code:

assume cs:code

code segment
        sli                         ;Prevent errors caused by keyboard input before setting interrupt vector table
        mov ax, cs
        mov ds, ax
        mov si, offset int9

        mov ax, 0
        mov es, ax
        mov di, 204h                ;[200]And[202]To store the original int 9 Of IP and CS

        mov cx, offset int9_end - offset int9
        cld                         ;Forward replication

        rep movsb

        mov ax, es:[9*4]
        mov es:[200h], ax
        mov ax, es:[9*4+2]
        mov es:[202h], ax           ;Preserve original int 9 Interrupt routine entry address

        mov word ptr es:[9*4], 204h
        mov word ptr es:[9*4+2], 0  ;Set interrupt vector table
        sti                         ;IF Set 1

        mov ax, 4c00h
        int 21h

        push ds
        push ax
        push cx
        push si 

        in al, 60h              ;Accept 60 h Scan code from
        call dword ptr cs:[200h]

        cmp al, 1eh+80h         ;A Is it released
        jne int9_ok             ;Not releasing normal handling

        mov ax, 0b800h
        mov ds, ax
        mov si, 0
        mov cx, 2000            ;It's 2000 characters on a screen

        mov byte ptr [si], 'A'
        add si, 2
        loop print_char

        pop si
        pop cx
        pop ax
        pop ds


code ends
end start

Operation result:
Other characters are processed as usual:

After releasing A, press A to take A screenshot:

Added by kmussel on Sun, 05 Jan 2020 09:19:31 +0200