Windows

         

MS-DOS


1 dostest.asm, MS-DOS, . 堠 ࠠ , .

_____________________________________________________________________

page ,132

; masm tisr ; >err

.286p

.xlist

include ..\..\include\bogus.inc

.list

Words struc

LoWord dw ?

HiWord dw ?

Words ends

EOI equ 020h ; EOI PIC

INTA00 equ 020h ; PIC

INTA01 equ 021h ; PIC

INT_MASTER_0 equ 08h ; INT . PIC



INTB00 equ 0A0h ; PIC

INTB01 equ 0A1h ; PIC

INT_SLAVE_0 EQU 70h ; INT PIC

;

;

;

ife (FAKE_IRQ GE 8)

INT_DEV equ (INT_MASTER_0+(FAKE_IRQ AND 7))

PIC00 equ INTA00

PIC01 equ INTA01

else

INT_DEV equ (INT_SLAVE_0+(FAKE_IRQ AND 7))

INT_MASK equ 1 SHL (FAKE_IRQ AND 7)

PIC00 equ INTB00

PIC01 equ INTB01

endif

CONST SEGMENT DWORD PUBLIC 'DATA'

sdNoBogus db 'I do not see the bogus device.',Odh,Oah,'$'

sdPrompt db Odh,Oah,'S)tart, or Q)uit: ','$'

sdCRLF db Odh,Oah,'$'

sdDot db '.','$'

CONST ENDS

DATA SEGMENT DWORD PUBLIC 'DATA'

dwCount1 dw 0

dwCount2 dw 0

lpPrevISR dd 0 ; ISR

fStopping db 0 ; TRUE

DATA ENDS

STACK SEGMENT DWORD STACK 'STACK'

db 512 dup (?)

STACK ENDS

DGroup GROUP CONST,DATA,STACK

;IP IntSvcRtn - The Interrupt Service Routine (

; )

; WARNINGS ()

;




; NOTES ()

; ISR (dwCount1)

; .

;

; "fStopping", .

;

FIXED_TEXT SEGMENT PARA PUBLIC 'CODE'

segData1 dw DGroup

assume CS:FIXED_TEXT,DS:NOTHING

IntSvcRtn proc far

push ax

push dx

push ds

mov ds,segDatal

assume ds:DGroup

inc dwCount1

mov al,NOT FAKE_CTL_EOI

mov dx,FAKE_PORT

out dx,al ; EOI

mov al,EOI

out PIC00,al ; EOI PIC

ife (PIC00 EQ INTA00)

out INTA00,al ; EOI . PIC

endif

cmp fStopping,0 ; ?

jnz isr9 ; ,

mov al,NOT FAKE_CTL_START

mov dx,FAKE_PORT

out dx,al ; -

isr9:

pop ds

assume ds:NOTHING

pop dx

pop ax

iret

IntSvcRtn endp

FIXED_TEXT ENDS

;IP_main -

; NOTES ()

; 𠠠 ࠠ :

;S)tart() Q)uit(). 蠠 S,

; ,

; , .

;

_TEXT SEGMENT PARA PUBLIC 'CODE'

segData2 dw DGroup

segfixed dw FIXED_TEXT

assume cs:_TEXT,ds:NOTHING

_main label far

mov ds,segData2 ;

assume ds:DGroup

mov dx,FAKE_PORT

in al,dx ; ?

or al,al

jns m10 ;,

mov dx,OFFSET DGroup:sdNoBogus

mov ah,9

int 21h ;

mov ax,4C01h

int 21h ;

m10:

mov ax,3500h+INT_DEV



cli

int 21h ; ISR

mov lpPrevISR.LoWord,bx

mov lpPrevISR.HiWord,es ;

mov dx,OFFSET FIXED_TEXT:IntSvcRtn

push ds

mov ds,segFixed

assume ds:NOTHING

mov ax,2500h+INT_DEV

int 21h ; ISR

pop ds

assume ds:DGroup

sti

mov dx,OFFSET DGroup:sdPrompt

mov ax,9

int 21h ; S)tart Q)uit

ml1:

mov dl,0PFh

mov ah,6

int 21h ; ,

jz ml3

or al,40h

cmp al,'q'

je ml8 ; , "Q"

cmp al,'s'

jne ml3 ; , "S"

cli

in al,PIC01 ;

and al,NOT INT_MASK

out PIC01,al

sti

mov al,NOT FAKE_CTL_START

mov dx,FAKE_PORT

out dx,al ; -

ml3:

mov ax,dwCount1

cmp ax,dwCount2

je ml4 ; ,

mov dwCount2,ax

mov dx,OFFSET DGroup:sdDot

mov ah,9

int 21,h ;

ml4:

jmp ml1 ;

ml8:

mov fStopping,1 ; ISR

mov dx,FAKE_PORT

ml9:

in al,dx

rcr al,1

jnc ml9 ; ,

cli

in al,PIC01

or al,INT_MASK

out PIC01,al ;

sti

push ds

lds dx,lpPrevISR

assume ds:NOTHING

mov ax,2500h+INT_DEV

int 21h ; ISR

pop ds

assume ds:DGroup

mov ax,4C00h

int 21h ;

_TEXT ENDS

end_main

_____________________________________________________________________

1. dostest.asm

, . MS-DOS 11.


, , , .

: Start() 蠠 Quit(). 蠠 򠠠 S, -. Q,  , 򠠠 .

-, MS-DOS 頠 頠 (programmable interrupt controller - PIC) ( 11). - 1 0 . , ࠠ 頠 (interrupt service routine - ISR).

, ISR , EOI (.. 1 1 ) PIC. , -, , ISR .   젠 堠 ࠠ ISR - , 1 0 . , ISR - , ,  -. - ISR (dwCount1) , .

- , (".") - , , .

, Q. , ISR , . , - , PIC .