feat: fichier/répertoire effacé

This commit is contained in:
Nicolas Hordé 2007-03-31 20:07:58 +00:00
parent 465618e4d6
commit bd7b31f95f
6 changed files with 15 additions and 1339 deletions

15
SCREENSHOTS.md Normal file
View File

@ -0,0 +1,15 @@
![logo](https://github.com/dahut87/cos2000v1/raw/master/Graphisme/logo.png)
## Copies d'écran de COS2000
![screen](https://github.com/dahut87/cos2000v1/raw/develop/Graphisme/screenshots/bootnew.jpg)
![screen](https://github.com/dahut87/cos2000v1/raw/develop/Graphisme/screenshots/ceexplorer.jpg)
![screen](https://github.com/dahut87/cos2000v1/raw/develop/Graphisme/screenshots/chargement.jpg)
![screen](https://github.com/dahut87/cos2000v1/raw/develop/Graphisme/screenshots/dir.jpg)
![screen](https://github.com/dahut87/cos2000v1/raw/develop/Graphisme/screenshots/editeur.jpg)
![screen](https://github.com/dahut87/cos2000v1/raw/develop/Graphisme/screenshots/gestionnaire.jpg)
![screen](https://github.com/dahut87/cos2000v1/raw/develop/Graphisme/screenshots/installation.jpg)
![screen](https://github.com/dahut87/cos2000v1/raw/develop/Graphisme/screenshots/interpreteur.jpg)
![screen](https://github.com/dahut87/cos2000v1/raw/develop/Graphisme/screenshots/librairies.jpg)
![screen](https://github.com/dahut87/cos2000v1/raw/develop/Graphisme/screenshots/logo.jpg)
![screen](https://github.com/dahut87/cos2000v1/raw/develop/Graphisme/screenshots/pci.jpg)
![screen](https://github.com/dahut87/cos2000v1/raw/develop/Graphisme/screenshots/video.jpg)

View File

@ -1,266 +0,0 @@
;****************************************************************
; *
; Periphrique : DMA *
; Plages Entres-Sorties : 0000-000F *
; 00C0-00DF *
; 0080-0090 *
; (0094-009F) *
; Plages Mmoires : AUCUNES *
; *
DmaRead equ 044h ;I/O to memory, no autoinit, increment, single mode
DmaWrite equ 048h ;Memory to I/O, no autoinit, increment, single mode
;Lecture des bits du registre d'tat (08, D0 )
STATUS_REQ3 = 80h ;Bit actif: le canal DMA concern
STATUS_REQ2 = 40h ;re‡oit une requˆte DMA
STATUS_REQ1 = 20h ;Request
STATUS_REQ0 = 10h
STATUS_TC3 = 08h ;Bit actif: Un transfert DMA a t
STATUS_TC2 = 04h ;excut depuis la derniŠre lecture
STATUS_TC1 = 02h ;du registre d'tat.
STATUS_TC0 = 01h ;Terminal Count
;Ecriture des bits du registre de commande (08, D0)
COMMAND_DACKLEVEL = 80h ;Bit 7 actif: ligne DMA Acknowledge HIGH active
COMMAND_DREQLEVEL = 40h ;Bit 6 actif: ligne REQ Acknowledge LOW active
COMMAND_EXTWRITE = 20h ;Bit 5 actif: EXTENDED Write,sinon LATE Write
COMMAND_FIXEDPRI = 10h ;Bit 4 actif: priorit constante
COMMAND_COMPRESS = 08h ;Bit 3 actif: compression
COMMAND_INACTIVE = 04h ;Bit 2 actif: contr“leur dsactiv
COMMAND_ADH0 = 02h ;Bit 1 actif: Adress Hold pour canal 0/4 dsactiv
COMMAND_MEM2MEM = 01h ;Bit 0 actif: mmoire/mmoire, sinon mmoire/priphrie
;Ecriture des bits du registre de requˆte ( 09, D2 )
REQUEST_RESERVED = 0F8h ;Rglage des bits rservs =0
REQUEST_SET = 04h ;Dfinir requˆte DMA
REQUEST_CLR = 00h ;Supprimer requˆte DMA
REQUEST_MSK = 03h ;Indiquer le canal dans les deux bits du bas
;Ecriture des bits du registre de masquage de canal ( 0A, D4 )
CHANNEL_RESERVED = 0F8h ;Rglage des bits rservs =0
CHANNEL_SET = 04h ;Masquer/verrouiller canal DMA
CHANNEL_CLR = 00h ;Librer canal DMA
CHANNEL_MSK = 03h ;Indiquer le canal dans les deux bits du bas
;Ecriture des bits du registre de mode (0B,D6)
MODE_DEMAND = 00h ;Transfrer … la demande
MODE_SINGLE = 40h ;Transfrer valeurs uniques
MODE_BLOCK = 80h ;Transfrer en bloc
MODE_CASCADE = 0C0h ;Transfrer en cascade
MODE_DECREMENT = 20h ;Dcrmenter
MODE_AUTOINIT = 10h ;Autoinitialisation vers la fin
MODE_VERIFY = 00h ;Vrifier
MODE_WRITE = 04h ;Ecrire dans la mmoire
MODE_READ = 08h ;Lire depuis la mmoire
MODE_INVALID = 0Ch ;Incorrect
MODE_CHANNELMSK = 03h ;Indiquer le canal dans les deux bits du bas
;Ports du DMA esclave
DmaStatusS dw 08h ;R SLAVE Registre d'tat
DmaCommandS dw 08h ;W SLAVE Registre de commande
DmaRequestS dw 09h ;W SLAVE Excuter requˆte DMA
DmachMaskS dw 0ah ;W SLAVE Masquer canaux
DmaModeS dw 0bh ;W SLAVE Mode de transfert
DmaFlipFlopS dw 0ch ;W SLAVE Flipflop adr/compteur
DmaTempS dw 0dh ;R SLAVE Reset du contr“leur
DmaClearS dw 0dh ;R SLAVE Registre temporaire
DmaMaskClrS dw 0eh ;R SLAVE Librer canaux
DmaMaskS dw 0fh ;R SLAVE Masquer canaux
;Ports du DMA esclave
DmaStatusM dw 0D0h ;R MASTER Registre d'tat
DmaCommandM dw 0D0h ;W MASTER Registre de commande
DmaRequestM dw 0D2h ;W MASTER Excuter requˆte DMA
DmaMaskM dw 0D4h ;W MASTER Masquer canaux
DmaModeM dw 0D6h ;W MASTER Mode de transfert
DmaFlipFlopM dw 0D8h ;W MASTER Flipflop adr/compteur
DmaTempM dw 0DAh ;R MASTER Reset du contr“leur
DmaClearM dw 0DAh ;R MASTER Registre temporaire
DmaMaskClrM dw 0DCh ;R MASTER Librer canaux
DmaMaskM2 dw 0DEh ;R MASTER Masquer canaux
DmaAdress db 00h ;DMA address register 0
db 002h ;DMA address register 1
db 004h ;DMA address register 2
db 006h ;DMA address register 3
db 0c0h ;DMA address register 4
db 0c4h ;DMA address register 5
db 0c8h ;DMA address register 6
db 0cch ;DMA address register 7
DmaCount db 001h ;DMA count registers 0
db 003h ;DMA count registers 1
db 005h ;DMA count registers 2
db 007h ;DMA count registers 3
db 0c2h ;DMA count registers 4
db 0c6h ;DMA count registers 5
db 0cah ;DMA count registers 6
db 0ceh ;DMA count registers 7
DmaPage db 087h ;DMA page registers 0
db 083h ;DMA page registers 1
db 081h ;DMA page registers 2
db 082h ;DMA page registers 3
db 08fh ;DMA page registers 4
db 08bh ;DMA page registers 5
db 089h ;DMA page registers 6
db 08ah ;DMA page registers 7
;verouille le canal AL
DisableDma:
push ax dx
cmp al, 4
jae MasterDisableDma
mov dx, DmaMaskS
or al, 00000100b
out dx, al
jmp EndDisableDma
MasterDisableDma:
mov dx, DmaMaskS
and al, 00000011b
or al, 00000100b
out dx, al
EndDisableDma:
pop dx ax
ret
;déverouille le canal AL
EnableDma:
push ax dx
cmp al, 4
jae MasterDisableDma
mov dx, DmaMaskS
out dx, al
jmp EndEnableDma
MasterEnableDma:
mov dx, DmaMaskS
and al, 00000011b
out dx, al
EndEnableDma:
pop dx ax
ret
;Efface le FlipFlop canal AL
ClrDmaFlipFlop:
push ax dx
cmp al, 4
jae MasterClrFlipFlopDma
mov dx,DmaFlipFlopS
xor ax, ax
out dx, al
jmp EndClrFlipFlopDma
MasterClrFlipFlopDma:
mov dx,DmaFlipFlopM
xor ax, ax
out dx, al
EndClrFlipFlopDma:
pop dx ax
ret
;Met le mode du canal al à ah
SetDmaMode:
push ax dx
cmp al, 4
jae MasterSetDmaMode
mov dx,DmaModeS
or al, ah
out dx, al
jmp EndSetDmaMode
MasterSetDmaMode:
mov dx,DmaModeM
and al, 00000011b
or al, ah
out dx, al
EndSetDmaMode:
pop dx ax
ret
;Met le page du canal al a ah
SetDmaPage:
push ax bx dx si
cmp al, 4
jae MasterSetDmaPage
mov si, offset DmaPage
xor dh, dh
xor bh, bh
mov bl, al
mov dl, cs:[si+bx]
xchg al, ah
out dx, al
jmp EndSetDmaPage
MasterSetDmaPage:
EndSetDmaPage:
pop si dx bx ax
ret
;Met l'adresse du canal al a DS:BX
SetDmaAdress:
push ax bx cx dx si
push ax
mov ax, ds
and ax, 0000111111111111b
shl ax,4
add bx, ax
mov ax, ds
and ax, 1111000000000000b
shr ax, 4
mov cx,ax
pop ax
push ax
add ax,cx
call SetDmaPage
pop ax
call ClrDmaFlipFlop
mov si, offset DmaAdress
xor dh, dh
push bx
xor bh, bh
mov bl, al
mov dl, byte ptr cs:[si+bx]
pop bx
cmp al, 4
jae MasterSetDmaAddress
mov al, bh
out dx, al
mov al, bl
out dx, al
jmp EndSetDmaAddress
MasterSetDmaAddress:
mov al, bh
out dx, al
call ClrDmaFlipFlop
mov al, bl
out dx, al
EndSetDmaAddress:
pop si dx cx bx ax
ret
;Spécifie au controleur DMA le nombre d'octets à transférer dans CX
SetDmaCount:
push ax bx dx si
call ClrDmaFlipFlop
mov si, offset DmaCount
xor dh, dh
xor bh, bh
mov bl, al
mov dl, byte ptr cs:[si+bx]
cmp al, 4
jae MasterSetDmaCount
mov al, ch
out dx, al
mov al, cl
out dx, al
jmp EndSetDmaCount
MasterSetDmaCount:
mov al, ch
out dx, al
call ClrDmaFlipFlop
mov al, cl
out dx, al
EndSetDmaCount:
pop si dx bx ax
ret

View File

@ -1,261 +0,0 @@
.model tiny
.486
smart
.code
org 0h
include ..\include\mem.h
start:
jmp tsr
offsets dd 0
db 'KEYBOARD'
tsr:
pushf
db 2eh,0ffh,1eh
dw offsets
cli
cmp cs:isstate,1
je endofforce
mov cs:isstate,1
mov cs:eaxr,eax
in al,60h
cmp al,68
je F10
cmp al,87
je F11
cmp al,88
je F12
endof:
mov cs:isstate,0
mov eax,cs:eaxr
endofforce:
sti
iret
isstate db 0
infos db 40 dup (0)
feax dd 0
F10:
push cs
pop ds
mov si,offset com
mov ah,5
int 49h
pop ax
pop ax
pop ax
push gs
push gs
push gs
pop ds
pop es
pop fs
push gs
push size exe
sti
mov cs:[isstate],0
retf
com db 'COMMANDE.CE',0
F11:
push ax di es
push cs
pop es
mov di,offset infos
mov ah,34
int 47h
mov al,cs:[di+7]
inc al
cmp al,9
jbe notabove
mov al,0
notabove:
mov ah,0
int 47h
pop es di ax
jmp endof
f12:
pushad
pushf
push ds
mov cs:[eaxr],eax
mov cs:[ebxr],ebx
mov cs:[ecxr],ecx
mov cs:[edxr],edx
mov cs:[esir],esi
mov cs:[edir],edi
mov cs:[espr],esp
mov cs:[ebpr],ebp
mov cs:[csr],cs
mov cs:[dsr],ds
mov cs:[esr],es
mov cs:[fsr],fs
mov cs:[gsr],gs
mov cs:[ssr],ss
push cs
pop ds
mov si,offset sep
call Showstr
mov si,offset reg
mov di,offset regdata
mov bx,7
showregs:
cmp byte ptr cs:[si+6],":"
jne endshowregs
call Showstr
cmp byte ptr cs:[si+4]," "
je segsss
mov edx,cs:[di]
mov cx,32
call Showhex
add di,4
jmp showmax
segsss:
mov dx,cs:[di]
mov cx,16
call Showhex
add di,2
showmax:
add si,9
mov bp,dx
push si
mov si,offset beginds
call showstr
mov si,bp
mov cx,8
mov al,0
letshow:
mov dl,ds:[si]
inc si
call showhex
inc al
cmp al,10
jb letshow
mov si,offset ende
call showstr
mov si,offset begines
call showstr
mov si,bp
mov cx,8
mov al,0
letshow2:
mov dl,es:[si]
inc si
call showhex
inc al
cmp al,10
jb letshow2
mov si,offset ende
call showstr
pop si
jmp showregs
endshowregs:
mov si,offset sep
call Showstr
xor ax,ax
int 16h
pop ds
popf
popad
jmp endof
begines db ' es[',0
beginds db ' ds[',0
ende db '] ',0
;==============================Affiche le nombre nb hexa en EDX de taille CX et couleur BL==============
ShowHex:
push ax bx cx edx si di
mov di,cx
sub cx,32
neg cx
shl edx,cl
shr di,2
mov ah,09h
and bx,1111b
Hexaize:
rol edx,4
mov si,dx
and si,1111b
mov al,[si+offset tab]
push cx
mov cx,1
cmp al,32
jb control2
mov ah,09h
int 10h
control2:
mov ah,0Eh
int 10h
pop cx
dec di
jnz Hexaize
pop di si edx cx bx ax
ret
Tab db '0123456789ABCDEF'
;==============================Affiche une chaine DS:SI de couleur BL==============
showstr:
push ax bx cx si
mov cx,1
again:
lodsb
or al,al
jz fin
and bx,0111b
cmp al,32
jb control
mov ah,09h
int 10h
control:
mov ah,0Eh
int 10h
jmp again
fin:
pop si cx bx ax
ret
;================================================
;Routine de débogage
;================================================
regdata:
eaxr dd 0
ebxr dd 0
ecxr dd 0
edxr dd 0
esir dd 0
edir dd 0
espr dd 0
ebpr dd 0
csr dw 0
dsr dw 0
esr dw 0
fsr dw 0
gsr dw 0
ssr dw 0
reg db 0Dh,0Ah,"eax : ",0
db 0Dh,0Ah,"ebx : ",0
db 0Dh,0Ah,"ecx : ",0
db 0Dh,0Ah,"edx : ",0
db 0Dh,0Ah,"esi : ",0
db 0Dh,0Ah,"edi : ",0
db 0Dh,0Ah,"esp : ",0
db 0Dh,0Ah,"ebp : ",0
db 0Dh,0Ah,"cs : ",0
db 0Dh,0Ah,"ds : ",0
db 0Dh,0Ah,"es : ",0
db 0Dh,0Ah,"fs : ",0
db 0Dh,0Ah,"gs : ",0
db 0Dh,0Ah,"ss : ",0
sep db 0Ah,0Dh,'********************',0Ah,0Dh,0
end start

View File

@ -1,81 +0,0 @@
.model tiny
.486
smart
.code
org 0h
start:
jmp tsr
offsets dd 0
db 'HOURS'
tsr:
pushf
db 2eh,0ffh,1eh
dw offsets
cli
pusha
push ds es
push cs
push cs
pop ds
pop es
mov ah,22h
mov di,offset infos
int 47h
mov bl,[infos+1]
xor bh,bh
sub bl,8
mov di,bx
shl di,1
mov dx,71h
xor eax,eax
mov cx,0B800h
mov es,cx
mov cl,4
mov bp,8
show:
dec dx
mov al,cl
out dx,al
inc dx
in al,dx
call showbcd
cmp cl,0
je finic
mov byte ptr es:[di],':'
add di,2
sub cl,2
jmp show
finic:
pop es ds
popa
sti
iret
;==============================Affiche le nombre nb hexa en EDX==============
Showbcd:
push ax bx cx edx
mov edx,eax
mov cx,bp
sub cx,32
neg cx
shl edx,cl
mov ax,bp
shr ax,2
bcdaize:
rol edx,4
mov bx,dx
and bx,0fh
add bl,'0'
mov es:[di],bl
add di,2
dec al
jnz bcdaize
pop edx cx bx ax
ret
infos db 40 dup (0)
end start

View File

@ -1,32 +0,0 @@
.model tiny
.486
smart
.code
org 0h
start:
jmp tsr
offsets dd 0
db 'TIMER'
tsr:
pushf
db 2eh,0ffh,1eh
dw offsets
cli
push ax bx es
mov bx,cs:compteur
inc bx
and bx,11b
mov cs:compteur,bx
mov bx,cs:[offset fig+bx]
mov ax,0B800h
mov es,ax
mov es:[0],bl
pop es bx ax
sti
iret
compteur dw 0
fig db 'Ä\³/'
end start

View File

@ -1,699 +0,0 @@
.model tiny
.486
smart
.code
org 0h
start:
jmp tsr
drv db 'LPT ',0
Tsr:
cli
cmp ax,1234h
jne nomore
mov ax,4321h
jmp itsok
nomore:
push bx ax
mov ah,4
mov bh,1
int 50h
mov bl,al
pop ax
cmp byte ptr cs:isact,1
je nottest
mov cs:isact,1
cmp bl,80h
jae react
mov bl,ah
xor bh,bh
shl bx,1
mov bx,cs:[bx].tables
mov cs:current,bx
pop bx
call cs:current
itsok:
jnc noerror
push bp
mov bp,sp
or byte ptr [bp+6],1b
pop bp
mov ax,cs
shl eax,16
mov ax,cs:current
jmp endofint
noerror:
push bp
mov bp,sp
and byte ptr [bp+6],0FEh
pop bp
endofint:
mov cs:isact,0
sti
iret
nottest:
pop bx
jmp endofint
current dw 0
tables dw getlptin
dw getlptout
dw getlptinout
dw setlptin
dw setlptout
dw setlptinout
dw getlpt
dw getfirstlpt
dw setemettor
dw setreceptor
dw settimeout
dw gettimeout
dw receivelpt
dw sendlpt
dw receivelptblock
dw sendlptblock
dw receivecommand
dw sendcommand
react:
push ds es
mov cs:isact,1
pushad
push cs
pop ds
push cs
pop es
cmp byte ptr never,1
je oknever
mov bl,[drv+3]
sub bl,'0'
xor bh,bh
call getlpt
dec bl
shl bl,1
mov al,7
sub al,bl
mov ah,40
mov di,offset video
int 47h
push ax
mov ah,01h
int 50h
mov ah,21
mov cl,4
int 47h
sti
mov al,0111b
call setlptout
call setreceptor
call initlpt
jc errorie
mov cx,0
mov ah,20
mov bx,1012h
mov si,offset initok
int 47h
cmp byte ptr always,1
je yes
mov ah,20
mov bx,1010h
mov si,offset mdd
int 47h
mov ah,13
mov si,offset drv
int 47h
mov ah,6
int 47h
mov ah,20
mov bx,1011h
mov si,offset msg
int 47h
waitkey:
mov ax,0
int 16h
cmp al,'n'
je no
cmp al,'N'
je no
cmp al,'Y'
je yes
cmp al,'y'
je yes
cmp al,'e'
je nev
cmp al,'E'
je nev
cmp al,'a'
je alw
cmp al,'A'
je alw
jmp waitkey
yes:
call receivecommand
jc errortimeout
no:
mov al,0111b
call setlptout
cli
mov ah,41
mov si,offset video
int 47h
pop ax
mov ah,00h
int 50h
mov ah,09h
int 50h
oknever:
popad
pop es ds
mov cs:isact,0
pop bx
jmp endofint
errorie:
mov si,offset inits
jmp show
errortimeout:
mov si,offset timeouts
show:
mov ah,20
mov bx,1012h
int 47h
mov ax,0
int 16h
jmp no
nev:
mov byte ptr never,1
jmp no
alw:
mov byte ptr always,1
jmp yes
initok db 'Initialisation is realised !',0
inits db 'Error on initialisation',0
timeouts db 'Connection lost or timeout complete !!',0
mdd db 'Connection demand on ',0
msg db 'Accept connection ? (Y)es (N)o n(E)ver (A)lways',0
isact db 0
always db 0
never db 0
;envois une commande al
sendcommand:
push ax bx cx di
mov bl,al
xor bh,bh
shl bx,1
add bx,offset cmde
call cs:[bx]
pop di cx bx ax
ret
cmde dw nothing
dw getram
;recupŠre la ram en ds:si de cx distant caractŠres en es:di local
getram:
push ax bx cx ds
mov bx,offset command
mov cs:[bx+2],ds
mov cs:[bx],si
mov cs:[bx+4],cx
push cs
pop ds
mov si,bx
mov cx,6
call sendlptblock
jc endofget
call receivelptblock
endofget:
pop ds cx bx ax
ret
;Re‡ois une commande et l'execute
Receivecommand:
push ax bx cx di ds es
push cs
pop es
push cs
pop ds
mov di,offset command
call receivelptblock
jc endofno
mov bl,al
xor bh,bh
shl bx,1
add bx,offset cmd
call cs:[bx]
clc
endofno:
pop es ds di cx bx ax
ret
command db 25 dup (0)
cmd dw nothings
dw sendram
dw receiveram
dw sendreg
dw receivereg
dw sendport
dw receiveport
dw letexecute
nothings:
ret
letexecute:
push ds es fs gs
pushad
push cs
push offset suite
mov ax,es:[di+2]
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
push ax
mov ax,es:[di]
push ax
DB 0CBh
suite:
popad
pop gs fs es ds
ret
Sendram:
push ax cx si ds
mov si,es:[di]
mov ax,es:[di+2]
mov ds,ax
mov cx,es:[di+4]
call sendlptblock
pop ds si cx ax
ret
receiveram:
sendreg:
receivereg:
sendport:
push ax cx dx si
mov dx,es:[di]
in ax,dx
mov cx,2
mov si,offset tempblock
mov ds:[si],ax
call sendlptblock
pop si dx cx ax
ret
receiveport:
push ax dx
mov dx,es:[di]
mov ax,es:[di+2]
out dx,ax
pop dx ax
ret
tempblock db 25 dup (0)
;---------Segment Adress-----------
Bios equ 040h
;---------Offset Adress------------
Lptadr equ 008h
Timer equ 06Ch
;---------Constant-----------------
onesec equ 18
tensec equ 182
Ack equ 00
Nack equ 0FFh
maxtry equ 10
Initlpt:
push ax ecx
call StartTimer
cmp cs:emettor,0
je receptinit
mov al,10000b
call SetLptOut
waitinit1:
call EndTimer
cmp cx,cs:timeout
ja errorinit
call getlptIn
cmp al,00000b
jnz waitinit1
jmp endinit
receptinit:
call EndTimer
cmp cx,cs:timeout
ja errorinit
call getlptIn
cmp al,00000b
jnz receptinit
mov al,10000b
call SetLptOut
endinit:
clc
pop ecx ax
ret
errorinit:
stc
pop ecx ax
ret
;-Envoie DL (dh) JNE si problŠme JNC error timeout
Sendlpt:
push ax bx ecx
call StartTimer
mov dh,dl
mov al,dl
and al,0Fh
call SetLptOut
waitSend:
call EndTimer
cmp cx,cs:timeout
ja errorsend
call getlptIn
bt ax,4
jnc waitsend
and al,0Fh
mov bl,al
call StartTimer ;/////
mov al,dh
shr al,4
or al,10000b
call SetLptOut
waitSend2:
call EndTimer
cmp cx,cs:timeout
ja errorsend
call getlptIn
bt ax,4
jc waitsend2
and al,0Fh
shl al,4
add bl,al
cmp dl,bl
pop ecx bx ax
clc
ret
errorsend:
pop ecx bx ax
stc
ret
;-Re‡ois DL (dh)
Receivelpt:
push ax bx ecx
call StartTimer
waitreceive:
call EndTimer
cmp cx,cs:timeout
ja errorreceive
call getlptIn
bt ax,4
jnc waitreceive
and al,0Fh
mov dl,al
call SetLptOut
call StartTimer ;/////
waitreceive2:
call EndTimer
cmp cx,cs:timeout
ja errorreceive
call getlptIn
bt ax,4
jc waitreceive2
and al,0Fh
mov dh,al
shl dh,4
add dl,dh
or al,10000b
call SetlptOut
clc
pop ecx bx ax
ret
errorreceive:
stc
pop ecx bx ax
ret
;-AX
SetTimeout:
mov cs:Timeout,dx
ret
timeout dw tensec
getTimeout:
mov dx,cs:Timeout
ret
SetEmettor:
mov cs:Emettor,1
ret
Emettor db 0
SetReceptor:
mov cs:Emettor,0
ret
;->bx Nøport->Adresse dx
GetLpt:
push ax bx ds
mov ax,bios
mov ds,ax
dec bx
shl bx,1
mov dx,ds:[Lptadr+bx]
mov cs:lpt,dx
pop ds bx ax
ret
lpt dw 0
;->bx Nøport->Adresse dx
GetFirstLpt:
push ax ds
mov ax,bios
mov ds,ax
xor bx,bx
findlpt:
mov dx,ds:[Lptadr+bx]
cmp dx,0
jne oklpt
add bx,2
cmp bx,4
jbe findlpt
oklpt:
mov cs:lpt,dx
pop ds ax
ret
;->
StartTimer:
push ax ecx ds
mov ax,Bios
mov ds,ax
mov ecx,ds:[timer]
mov cs:times,ecx
pop ds ecx ax
ret
times dd 0
;->Ecx time elapsed
EndTimer:
push ax ds
mov ax,Bios
mov ds,ax
mov ecx,ds:[timer]
sub ecx,cs:times
pop ds ax
ret
;->
GetLptOut:
push dx
mov dx,cs:lpt
in al,dx
pop dx
ret
GetLptIn:
push dx
mov dx,cs:lpt
inc dx
in al,dx
shr al,3
pop dx
ret
GetLptInOut:
push dx
mov dx,cs:lpt
add dx,2
in al,dx
and al,11111b
pop dx
ret
SetLptOut:
push dx
mov dx,cs:lpt
out dx,al
pop dx
ret
SetLptIn:
push dx
mov dx,cs:lpt
inc dx
out dx,al
pop dx
ret
SetLptInOut:
push dx
mov dx,cs:lpt
add dx,2
out dx,al
pop dx
ret
;Ralise un checksum 8 bits sur donnes DS:SI, nb CX rsultat dans dl
Checksum8:
push cx si
check:
add dl,[si]
inc si
dec cx
jnz check
pop si cx
ret
;DS:SI pointeur sur donnes, CX nombres de donnes, AL token
SendLptBlock:
push ax bx cx edx si edi bp
mov dx,cx
shl edx,16
mov dh,al
call checksum8
mov edi,edx
xor dh,dh
mov bp,dx
mov ah,maxtry
retry:
mov bl,4
xor al,al
header:
mov dx,di
call sendlpt
setne al
jc outt
rol edi,8
dec bl
jnz header
cmp al,0
jne notgood
mov dl,ACK
jmp allsend
notgood:
mov dl,NACK
allsend:
call sendlpt
setne al
jc outt
cmp al,0
je okheader
dec ah
jnz retry
jmp outt
okheader:
cmp cx,0
je endoftrans
mov di,maxtry
retry2:
mov bx,cx
xor ax,ax
body:
mov dl,[si+bx-1]
add ah,dl
call sendlpt
setne al
jc outt
dec bx
jnz body
cmp al,0
jne notgood2
mov dl,ACK
jmp allisend
notgood2:
mov dl,NACK
allisend:
call sendlpt
setne al
jc outt
cmp al,0
je endoftrans
dec di
jnz retry2
outt:
stc
endoftrans:
mov al,ah
xor ah,ah
cmp bp,ax
pop bp edi si edx cx bx ax
ret
;Receptionne en es:di les donnes au nombres de CX token AL (AH) (ECX)
receiveLptBlock:
push bx dx si bp
mov ah,maxtry
retrye:
mov bl,4
headere:
call receivelpt
jc outte
mov cl,dl
rol ecx,8
dec bl
jnz headere
call receivelpt
jc outte
cmp dl,ACK
je okheadere
dec ah
jnz retrye
jmp outte
okheadere:
mov al,ch
xor ch,ch
mov bp,cx
rol ecx,16
cmp cx,0
je endoftranse
mov si,maxtry
retrye2:
mov bx,cx
xor ah,ah
bodye:
call receivelpt
jc outte
mov es:[di+bx-1],dl
add ah,dl
dec bx
jnz bodye
call receivelpt
jc outte
cmp dl,ACK
je endoftranse
dec si
jnz retrye2
outte:
stc
endoftranse:
mov bl,ah
xor bh,bh
cmp bp,bx
pop bp si dx bx
ret
video db 0
end start