.286 _TEXT segment byte public 'CODE' DGROUP group _DATA,_BSS assume cs:_TEXT,ds:DGROUP,ss:DGROUP _TEXT ends _DATA segment word public 'DATA' _DATA ends _BSS segment word public 'BSS' _irq_vector label word dw offset _DummyHandler dw offset _DummyHandler dw offset _DummyHandler dw offset _DummyHandler dw offset _DummyHandler dw offset _DummyHandler dw offset _DummyHandler dw offset _DummyHandler _BSS ends _TEXT segment byte public 'CODE' _DummyHandler proc near push ax in al, 0b6h nop nop out 0b6h, al pop ax iret _DummyHandler endp Interrupt0 proc near ; Divide by zero push ax pop ax iret Interrupt0 endp Interrupt1 proc near ; Single step iret Interrupt1 endp Interrupt2 proc near ; NMI iret Interrupt2 endp Interrupt3 proc near ; Breakpoint iret Interrupt3 endp Interrupt4 proc near ; Overflow iret Interrupt4 endp Interrupt5 proc near ; PrintScreen iret Interrupt5 endp IntrTransmit proc near cli push ax push si mov si, offset DGROUP:_irq_vector call word ptr [si] mov al, 1 out 0b6h, al pop si pop ax sti iret IntrTransmit endp IntrKeyPush proc near cli push ax push si mov si, offset DGROUP:_irq_vector + 2 call word ptr [si] mov al, 2 out 0b6h, al pop si pop ax sti iret IntrKeyPush endp IntrRTCAlarm proc near cli push ax push si mov si, offset DGROUP:_irq_vector + 4 call word ptr [si] mov al, 4 out 0b6h, al pop si pop ax sti iret IntrRTCAlarm endp IntrReceive proc near cli push ax push si mov si, offset DGROUP:_irq_vector + 6 call word ptr [si] mov al, 8 out 0b6h, al pop si pop ax sti iret IntrReceive endp IntrDrawLine proc near cli push ax push si mov si, offset DGROUP:_irq_vector + 8 call word ptr [si] mov al, 16 out 0b6h, al pop si pop ax sti iret IntrDrawLine endp IntrVblankCount proc near cli push ax push si mov si, offset DGROUP:_irq_vector + 10 call word ptr [si] mov al, 32 out 0b6h, al pop si pop ax sti iret IntrVblankCount endp IntrVblankBegin proc near cli push ax push di push si mov si, offset DGROUP:_irq_vector + 12 call word ptr [si] mov al, 64 out 0b6h, al pop si pop di pop ax sti iret IntrVblankBegin endp IntrHblankCount proc near cli push ax push di push si mov si, offset DGROUP:_irq_vector + 14 call word ptr [si] mov al, 128 out 0b6h, al pop si pop di pop ax sti iret IntrHblankCount endp _IRQ_Init proc near cli push ax push bx push dx push ds xor ax,ax mov ds,ax mov bx, 00000h ; Divide by zero mov ax, offset Interrupt0 mov dx, seg Interrupt0 mov ds:[bx], ax mov ds:[bx+2], dx mov bx, 00004h ; Single Step mov ax, offset Interrupt1 mov dx, seg Interrupt1 mov ds:[bx], ax mov ds:[bx+2], dx mov bx, 00008h ; NMI mov ax, offset Interrupt2 mov dx, seg Interrupt2 mov ds:[bx], ax mov ds:[bx+2], dx mov bx, 0000Ch ; Breakpoint mov ax, offset Interrupt3 mov dx, seg Interrupt3 mov ds:[bx], ax mov ds:[bx+2], dx mov bx, 00010h ; Overflow mov ax, offset Interrupt4 mov dx, seg Interrupt4 mov ds:[bx], ax mov ds:[bx+2], dx mov bx, 00014h ; PrintScreen mov ax, offset Interrupt5 mov dx, seg Interrupt5 mov ds:[bx], ax mov ds:[bx+2], dx mov al, 08h ; Interrupt base == 08h out 0b0h, al ; Hardware interruppt vector starts at 0x20 mov bx, 00020h mov ax, offset IntrTransmit mov dx, seg IntrTransmit mov ds:[bx], ax mov ds:[bx+2], dx mov bx, 00024h mov ax, offset IntrKeyPush mov dx, seg IntrKeyPush mov ds:[bx], ax mov ds:[bx+2], dx mov bx, 00028h mov ax, offset IntrRTCAlarm mov dx, seg IntrRTCAlarm mov ds:[bx], ax mov ds:[bx+2], dx mov bx, 0002Ch mov ax, offset IntrReceive mov dx, seg IntrReceive mov ds:[bx], ax mov ds:[bx+2], dx mov bx, 00030h mov ax, offset IntrDrawLine mov dx, seg IntrDrawLine mov ds:[bx], ax mov ds:[bx+2], dx mov bx, 00034h mov ax, offset IntrVblankCount mov dx, seg IntrVblankCount mov ds:[bx], ax mov ds:[bx+2], dx mov bx, 00038h mov ax, offset IntrVblankBegin mov dx, seg IntrVblankBegin mov ds:[bx], ax mov ds:[bx+2], dx mov bx, 0003Ch mov ax, offset IntrHblankCount mov dx, seg IntrHblankCount mov ds:[bx], ax mov ds:[bx+2], dx pop ds pop dx pop bx pop ax ret _IRQ_Init endp _TEXT ends public _IRQ_Init public _irq_vector public _DummyHandler end