home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Phoenix Heaven Sunny 2
/
APPARE2.BIN
/
oh_towns
/
his
/
source
/
hisl1.asm
< prev
next >
Wrap
Assembly Source File
|
1995-06-20
|
6KB
|
310 lines
;*****************************************************************
;* *
;* 割り込み処理ライブラリ下請けプロシジャ *
;* *
;* ~ ハードウェア割り込みエントリ ~ *
;* *
;* 1995 / 6 / 12 ちょもらんま *
;* *
;*****************************************************************
.386
NULL equ 0
;************** 割り込みハードウェア関係の定数 *************
OCW1_M equ 0002h
OCW1_S equ 0012h
OCW2_M equ 0000h
OCW2_S equ 0010h
OCW3_M equ 0000h
OCW3_S equ 0010h
ISR_M equ 0000h
ISR_S equ 0010h
IRR_M equ 0000h
IRR_S equ 0010h
IMR_M equ 0002h
IMR_S equ 0012h
ReadIRR equ 00001010b
ReadISR equ 00001011b
EOIcommand equ 00100000b
WaitRegister equ 006ch
extrn topIntInfo:dword,userHandler:byte,stackAddress:dword
;----- ユーザー割り込みハンドラ記録用構造体 ----
userHandler_t struc
handlerAdr dp ?
dataSegment dw ?
userHandler_t ends
;------------ PICアクセス待ちウェイト -------------
PicWait macro
out WaitRegister,al ; 1μ秒ウェイト
cmc
cmc
endm
assume cs:code
code segment public use32 'CODE'
;*****************************************************************
;* 割り込みエントリ *
;*****************************************************************
HardIntEntry proc far
;--- 割り込みエントリ(割り込み番号0)---
public HardIntEntry0
HardIntEntry0:
pushad
mov ebx,0
jmp short #skipOthers
;--- 割り込みエントリ(割り込み番号1)---
public HardIntEntry1
HardIntEntry1:
pushad
mov ebx,1
jmp short #skipOthers
;--- 割り込みエントリ(割り込み番号2)---
public HardIntEntry2
HardIntEntry2:
pushad
mov ebx,2
jmp short #skipOthers
;--- 割り込みエントリ(割り込み番号3)---
public HardIntEntry3
HardIntEntry3:
pushad
mov ebx,3
jmp short #skipOthers
;--- 割り込みエントリ(割り込み番号4)---
public HardIntEntry4
HardIntEntry4:
pushad
mov ebx,4
jmp short #skipOthers
;--- 割り込みエントリ(割り込み番号5)---
public HardIntEntry5
HardIntEntry5:
pushad
mov ebx,5
jmp short #skipOthers
;--- 割り込みエントリ(割り込み番号6)---
public HardIntEntry6
HardIntEntry6:
pushad
mov ebx,6
jmp short #skipOthers
;--- 割り込みエントリ(割り込み番号7)---
public HardIntEntry7
HardIntEntry7:
pushad
mov ebx,7
jmp short #skipOthers
;--- 割り込みエントリ(割り込み番号8)---
public HardIntEntry8
HardIntEntry8:
pushad
mov ebx,8
jmp short #skipOthers
;--- 割り込みエントリ(割り込み番号9)---
public HardIntEntry9
HardIntEntry9:
pushad
mov ebx,9
jmp short #skipOthers
;--- 割り込みエントリ(割り込み番号10)---
public HardIntEntry10
HardIntEntry10:
pushad
mov ebx,10
jmp short #skipOthers
;--- 割り込みエントリ(割り込み番号11)---
public HardIntEntry11
HardIntEntry11:
pushad
mov ebx,11
jmp short #skipOthers
;--- 割り込みエントリ(割り込み番号12)---
public HardIntEntry12
HardIntEntry12:
pushad
mov ebx,12
jmp short #skipOthers
;--- 割り込みエントリ(割り込み番号13)---
public HardIntEntry13
HardIntEntry13:
pushad
mov ebx,13
jmp short #skipOthers
;--- 割り込みエントリ(割り込み番号14)---
public HardIntEntry14
HardIntEntry14:
pushad
mov ebx,14
jmp short #skipOthers
;--- 割り込みエントリ(割り込み番号15)---
public HardIntEntry15
HardIntEntry15:
pushad
mov ebx,15
; jmp short #skipOthers
;******************* 各割り込み共通の処理 ***********************
; レジスタ表
; EBX : 割り込みハンドラの情報
; ESI : 汎用レジスタの保存先
; EDI : セグメントレジスタの保存先
; AX : データセグメントセレクタ
; BP : 旧スタックセグメントセレクタ
; EDX : スタック切り換え元
; ECX : スタック切り換え先
#skipOthers:
cli
cld
; 割り込みハンドラが登録されているかチェック
cmp cs:topIntInfo[ ebx * 4 ],NULL
je #endInterrupt ; NULLポインタ
; 汎用レジスタのアドレス
mov esi,esp
; セグメントレジスタ書換え
push ds
push es
push fs
push gs
mov edi,esp
lea ebx,userHandler[ ebx * 8 ]
xor eax,eax
mov ax,cs:[ ebx ].dataSegment
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
; 旧スタック退避
mov edx,esp
xor ebp,ebp
mov bp,ss
; スタック切り換え
mov ecx,stackAddress
cmp ecx,NULL
jne short #UserStack
; DOS|Extenderのスタックを使う
mov ecx,esp
mov ax,ss
#UserStack:
mov ss,ax
mov esp,ecx
push edx ; 旧ESP
push ebp ; 旧SS
; ユーザーハンドラをコール
push edi ; セグメントレジスタ
push esi ; 汎用レジスタ
call dword ptr [ ebx ]
add esp,dword*2
; スタック復元
pop ebp
pop edx
mov ss,bp
mov esp,edx
; セグメントレジスタ復元
pop gs
pop fs
pop es
pop ds
#endInterrupt:
call sendEOI
; 割り込み処理終了
popad
iretd
HardIntEntry endp
;************************* EOI発行 **************************
sendEOI proc
push eax
; スレーブ側
; スレーブ側はアクティブか?
mov al,ReadISR
out OCW3_M,al
PicWait
in al,ISR_S
and al,7fh
jz short #MasterEOI
; スレーブ側EOI発行
mov al,EOIcommand
out OCW2_S,al
PicWait
; スレーブ側にまだ残っている割り込みがあるか?
mov al,ReadISR
out OCW3_S,al
PicWait
in al,ISR_S
cmp al,0
jnz short #skipMasterEOI
PicWait
; マスタ側EOI発行
#MasterEOI:
mov al,EOIcommand
out OCW2_M,al
#skipMasterEOI:
pop eax
ret
sendEOI endp
code ends
end