feat: passage a la convention d'appel stdcall

BREAKING CHANGE: attention modification majeure du code
This commit is contained in:
Nicolas Hordé 2005-12-05 08:16:09 +00:00
parent 8c1701b5af
commit 8db2a163d4
1 changed files with 139 additions and 135 deletions

View File

@ -1,55 +1,39 @@
.model tiny .model tiny,StdCall
.486 .486
smart
.code .code
Locals
jumps
org 0h org 0h
include ..\include\mem.h
include ..\include\bmp.h
start: start:
jmp tsr header exe <,1,0,,,,offset exports,>
db 'PIC8259A'
Tsr: exports:
cli db "enableirq",0
cmp ax,1234h dw enableirq
jne nomore db "disableirq",0
mov ax,4321h dw enableirq
jmp itsok db "readmaskirq",0
nomore: dw readmaskirq
push bx db "readirr",0
mov bl,ah dw readirr
xor bh,bh db "readisr",0
shl bx,1 dw readisr
mov bx,cs:[bx].tables db "installhandler",0
mov cs:current,bx dw installhandler
pop bx db "replacehandler",0
call cs:current dw replacehandler
itsok: db "getint",0
jnc noerror dw getint
push bp db "setint",0
mov bp,sp dw setint
or byte ptr [bp+6],1b db "seteoi",0
pop bp dw seteoi
mov ax,cs dw 0
shl eax,16
mov ax,cs:current
jmp endofint
noerror:
push bp
mov bp,sp
and byte ptr [bp+6],0FEh
pop bp
endofint:
sti
iret
current dw 0
tables dw enableirq
dw disableirq
dw readmaskirq
dw readirr
dw readisr
dw installhandler
dw replacehandler
dw getint
dw setint
dw seteoi
;Adresses de port du contr“leur IRQ ;Adresses de port du contr“leur IRQ
MASTERPIC = 020h ;Adresse de base du PIC maŒtre MASTERPIC = 020h ;Adresse de base du PIC maŒtre
@ -82,98 +66,118 @@ IRR = 0Ah ; Pas d'op
;Autorise une interruption lectronique ;Autorise une interruption lectronique
;Entre : AL - Numro de l'interruption (0-15) … autoriser 0-7 = MASTERPIC , 8-15 = SLAVEPIC ;Entre : %1 - Numro de l'interruption (0-15) … autoriser 0-7 = MASTERPIC , 8-15 = SLAVEPIC
EnableIRQ: EnableIRQ PROC FAR
push ax cx dx ARG @irq:word
mov dx,MASTERPIC+IRQMASK USES ax,cx,dx
cmp al,7 mov ax,[@irq]
jbe master mov dx,MASTERPIC+IRQMASK
mov dx,SLAVEPIC+IRQMASK cmp al,7
master: jbe @@master
mov cl,al mov dx,SLAVEPIC+IRQMASK
and cl,7 @@master:
mov al,1 mov cl,al
shl al,cl and cl,7
not al mov al,1
mov ah,al shl al,cl
in al,dx not al
and al,ah mov ah,al
out dx,al in al,dx
pop dx cx ax and al,ah
ret out dx,al
ret
EnableIRQ endp
;Desactive une interruption lectronique ;Desactive une interruption lectronique
;Entre : AL - Numro de l'interruption (0-15) … desactiver 0-7 = MASTERPIC , 8-15 = SLAVEPIC ;Entre : %0 - Numro de l'interruption (0-15) … desactiver 0-7 = MASTERPIC , 8-15 = SLAVEPIC
DisableIRQ: DisableIRQ PROC FAR
push ax cx dx ARG @irq:word
mov dx,MASTERPIC+IRQMASK USES ax,cx,dx
cmp al,7 mov ax,[@irq]
jbe master2 mov dx,MASTERPIC+IRQMASK
mov dx,SLAVEPIC+IRQMASK cmp al,7
master2: jbe @@master
mov cl,al mov dx,SLAVEPIC+IRQMASK
and cl,7 @@master:
mov al,1 mov cl,al
shl al,cl and cl,7
mov ah,al mov al,1
in al,dx shl al,cl
or al,ah not al
out dx,al mov ah,al
pop dx cx ax in al,dx
ret or al,ah
out dx,al
ret
DisableIRQ endp
;Signale "End Of Interrupt" de l'interruption %0
SetEOI PROC FAR
ARG @irq:word
USES ax,dx
mov ax,[@irq]
cmp al,7
jbe @@master
mov al,EOI
out SLAVEPIC,al
@@master:
mov al,EOI
out MASTERPIC,al
ret
DisableIRQ endp
;Lit les masques d'un contr“leur IRQ dans ax, 0 master ou slave 1 ds %1
ReadmaskIrq PROC FAR
ARG @controleur:word
USES bx,dx
mov bx,[@controleur]
mov dx,MASTERPIC+ IRQMASK
cmp bl,0
jne @@master
mov dx,SLAVEPIC+ IRQMASK
@@master:
xor ah,ah
in al,dx
pop dx
ret
ReadmaskIrq endp
;Lit le registre d'tat d'un contr“leur IRQ dans ax, 0 master ou slave 1 ds %1
ReadISR PROC FAR
ARG @controleur:word
USES bx,dx
mov bx,[@controleur]
mov dx,MASTERPIC
cmp bh,0
jne @@master
mov dx,SLAVEPIC
@@master:
mov al,isr
out dx,al
xor ah,ah
in al,dx
ret
ReadISR endp
;Signale "End Of Interrupt" de l'interruption al
SetEOI:
push ax dx
cmp al,7
jbe master3
mov al,EOI
out SLAVEPIC,al
master3:
mov al,EOI
out MASTERPIC,al
pop dx ax
ret
;Lit les masques d'un contr“leur IRQ dans al, 0 master ou slave 1 ds bh
ReadmaskIrq:
push dx
mov dx,MASTERPIC+ IRQMASK
cmp bh,0
jne Master5
mov dx,SLAVEPIC+ IRQMASK
master5:
in al,dx
pop dx
ret
;Lit le registre d'tat d'un contr“leur IRQ dans al, 0 master ou slave 1 ds bh ;Lit le registre d'tat d'un contr“leur IRQ dans al, 0 master ou slave 1 ds bh
ReadISR: ReadIRR PROC FAR
push dx ARG @controleur:word
mov dx,MASTERPIC USES bx,dx
cmp bh,0 mov bx,[@controleur]
jne Master6 mov dx,MASTERPIC
mov dx,SLAVEPIC cmp bh,0
master6: jne @@master
mov al,isr mov dx,SLAVEPIC
out dx,al @@master:
in al,dx mov al,irr
pop dx out dx,al
ret xor ah,ah
in al,dx
;Lit le registre d'tat d'un contr“leur IRQ dans al, 0 master ou slave 1 ds bh ret
ReadIRR: ReadIRR endp
push dx
mov dx,MASTERPIC
cmp bh,0
jne Master7
mov dx,SLAVEPIC
master7:
mov al,irr
out dx,al
in al,dx
pop dx
ret
;remplace le handler pointer par ds:si en bx:100h interruption ax ;remplace le handler pointer par ds:si en bx:100h interruption ax
replacehandler: replacehandler: