semble un programme de Yescard
c'est du bon ou pas ?
; RS-232 Communication With PIC16C54
INCLUDE "PICREG.H"
IO equ 7
Raz equ 1
Indic equ 2
Temoin equ 3
fsr equ 4
indf equ 0
eeadr equ 9
eedata equ 8
eecon1 equ 8
eecon2 equ 9
wren equ 2
rp0 equ 5
wr equ 1
;
ORG 0ch
DelayL RES 1
DelayH RES 1
BitCnt RES 1 ;Compteur de bits envoi/reception
Parity RES 1 ;Utilise pour le calcul du bit de parite
XmtReg RES 1 ;Registre d'envoi
Offset RES 1
BytCnt RES 1
Cpteur RES 1
RcvReg RES 1
Addh RES 1
Addb RES 1
Value RES 1
Dur RES 1
;Test RES 1
org 0
main movlw 00H
tris Port_A
bcf Port_B,Raz
bsf Port_B,IO
bsf Port_B,Indic
bsf Port_B,Temoin
movlw 7fH
tris Port_B
; movlw 0ffh
; movwf Dur
bsf Dur,0
clrf eeadr
clrf 1ah
; movlw .0
; movwf Test
;init ecriture
; movlw 1ah
; movwf fsr
; movlw 00h
; movwf indf
;future lecture adresse pour eeprom
; clrf eeadr
; bsf status,rp0
; bsf eecon1,rd
; bcf status,rp0
; movf eedata,0
; movwf eeadd
;tempo de boot
movlw .255
movwf DelayL
call Tempo
movlw .4
movwf DelayL
call Tempo
;Init
clrf Offset
movlw 3
call Env
movlw .3
movwf DelayH
movlw .220
call LgTpo
movlw .3
movwf Offset
movlw 1
call Env
movlw .5
movwf DelayH
movlw .128
call LgTpo
movlw .4
movwf Offset
movlw 5
call Env
;Arrivee commande
Anal movlw 0ffh ;Term -> Puce
tris Port_B
movlw 2
call RecTerm
;octet commande en eeprom : 12 cycles
movf RcvReg,0
movwf eedata
incf eeadr,1
bsf STATUS,rp0
bsf eecon1,wren
movlw 55h
movwf eecon2
movlw 0aah
movwf eecon2
bsf eecon1,wr
bcf eecon1,wren
bcf STATUS,rp0
; b0 gestion lecture
movlw 0b0h
subwf RcvReg,0
btfss STATUS,Z_bit
goto FinB0
;debug Test
; btfsc Test,0
; bcf Port_B,Temoin
;gestion b0 parametree
movlw 1
call RecTerm
movf RcvReg,0
movwf Addh
movlw 1
call RecTerm
movf RcvReg,0
movwf Addb
movlw 1
call RecTerm
movf RcvReg,0
movwf Value
movlw 7fh ;sortie
tris Port_B
bcf STATUS,CARRY
rrf Addh,1
rrf Addb,1
;octet reponse
movlw .9
movwf Offset
movlw .1
call Env
;bloc donnees
movlw .0
movwf Dur
movlw .0 ;??
movwf Offset
movf Value,0
call Env
;90 00
movlw 0ffh
movwf Dur
movlw .7 ;octets de fin sequence
movwf Offset
movlw .2
call Env
; movlw 0ffh
; movwf Test ;pour pouvoir detecter 2eme passage
goto Anal
FinB0
; 20 presentation de la clef
movlw 020h
subwf RcvReg,0
btfss STATUS,Z_bit
goto Fin20
;Fin commande
movlw 3
call RecTerm
;octet reponse
movlw .6
movwf DelayH
movlw .241
call LgTpo
movlw 07fh ;sortie
tris Port_B
movlw .11
movwf Offset
movlw 1
call Env
;lecture de la clef
movlw 0ffh ;Term -> Puce
tris Port_B
movlw 4
call RecTerm
;90 00
movlw .180
call Tempo
movlw 7fh ;sortie
tris Port_B
movlw .7 ;octets de fin sequence
movwf Offset
movlw .2
call Env
goto Anal
Fin20
;Validation de la clef 2A
movlw 040h
subwf RcvReg,0
btfss STATUS,Z_bit
goto Fin40
movlw 3 ;Fin commande
call RecTerm
;octet reponse
movlw 07fh ;sortie
tris Port_B
movlw .12
movwf Offset
movlw 1
call Env
;90 00
movlw .7 ;octets de fin sequence
movwf Offset
movlw .2
call Env
goto Anal
Fin40
;Lecture resultat telepass
movlw 0c0h
subwf RcvReg,0
btfss STATUS,Z_bit
goto Finc0
movlw 3 ;Fin commande
call RecTerm
movlw 07fh ;sortie
tris Port_B
;octet reponse
movlw .13
movwf Offset
movlw .1
call Env
movlw 22h
movwf fsr
movlw 08h
movwf Cpteur
Bclc0
movlw .88 ;Tempo inter-bit
call Tempo
incf BytCnt,1
; movlw .1
; movwf BytCnt
movf indf,0
call EnvDirect
incf fsr,1
decfsz Cpteur,1
goto Bclc0
;90 00
movlw .7 ;octets de fin sequence
movwf Offset
movlw .2 ;2
call Env
goto Anal
Finc0
;Activation fonction telepass
movlw 080h
subwf RcvReg,0
btfss STATUS,Z_bit
goto Fin80
movlw 20h
movwf fsr
movlw 1
call RecTerm
movf RcvReg,0 ;addh
movwf indf
incf fsr,1
movlw 1
call RecTerm
movf RcvReg,0 ;addb
movwf indf
movlw 1
call RecTerm ;nb
movlw 20h
movwf fsr
bcf STATUS,CARRY
rrf indf,1
incf fsr,1
rrf indf,1
movlw .3
movwf DelayH
movlw .140
call LgTpo
movlw 08h
movwf Cpteur
Bcl80
;octet reponse
movlw .34
call Tempo
movlw 07fh ;sortie
tris Port_B
movlw .14
movwf Offset
movlw .1
movwf BytCnt
call EnvRapid
;donnee
movlw 0ffh ;Term -> Puce
tris Port_B
movlw 1
call RecTerm
movf RcvReg,0
incf fsr,1
movwf indf
decfsz Cpteur,1
goto Bcl80
;90 00
movlw 07fh ;sortie
tris Port_B
movlw .7 ;octets de fin sequence
movwf Offset
movlw .2
call Env
goto Anal
Fin80
;Demande de grillage
movlw 0d0h
subwf RcvReg,0
btfss STATUS,Z_bit
goto Find0
movlw 1ah
movwf fsr
movlw 1
call RecTerm
movf RcvReg,0 ;addh
movwf indf
incf fsr,1
movlw 1
call RecTerm
movf RcvReg,0 ;addb
movwf indf
movlw 1
call RecTerm ;nb
movlw 1ah
movwf fsr
bcf STATUS,CARRY
rrf indf,1
incf fsr,1
rrf indf,1
movlw .3
movwf DelayH
movlw .140
call LgTpo
movlw 04h
movwf Cpteur
Bcld0
;octet reponse
movlw .34
call Tempo
movlw 07fh ;sortie
tris Port_B
movlw .16
movwf Offset
movlw .1
movwf BytCnt
call EnvRapid
;donnee
movlw 0ffh ;Term -> Puce
tris Port_B
movlw 1
call RecTerm
movf RcvReg,0
incf fsr,1
movwf indf
decfsz Cpteur,1
goto Bcld0
;90 00
movlw 07fh ;sortie
tris Port_B
movlw .7 ;octets de fin sequence
movwf Offset
movlw .2
call Env
goto Anal
Find0
;Validation ecriture
movlw 070h
subwf RcvReg,0
btfss STATUS,Z_bit
goto Fin70
movlw 3 ;Fin commande
call RecTerm
;action interne
bcf 1ch,7
movlw 7fh ;sortie
tris Port_B
;octet reponse
movlw .15
movwf Offset
movlw .1
call Env
;90 00
movlw .7 ;octets de fin sequence
movwf Offset
movlw .2
call Env
goto Anal
Fin70
goto Anal
Env movwf BytCnt
PaLoop movlw .107 ;Tempo inter-bit
call Tempo
EnvRapid
movf Offset,0
call Table
EnvDirect
movwf XmtReg
movlw 8
movwf BitCnt
bcf Port_B,IO ;start bit
bsf Parity,0
; nop
nop
movlw .26
call Tempo
Suiv rlf XmtReg,1
btfss STATUS,CARRY ;On ajoute 2 cycles bidons si 1
goto Bid1
Bid1 btfss STATUS,CARRY
goto Bid2
Bid2 btfss STATUS,CARRY
bsf Port_B,IO ;On met 1
btfsc STATUS,CARRY
bcf Port_B,IO ;On met 0
btfsc STATUS,CARRY ;On ajoute 2 cycles bidons si 0
goto Bid3
Bid3 btfsc STATUS,CARRY
goto Bid4
Bid4 btfss STATUS,CARRY
comf Parity,1 ;Inversion bit de parite
movlw .23 ;tempo bit
; nop
call Tempo
decfsz BitCnt,1
goto Suiv
;Traitement bit de parite
nop
nop
btfsc Parity,0 ;2 cycles bidon si 1
goto Bid5
Bid5 btfsc Parity,0
goto Bid6
Bid6 btfsc Parity,0
bsf Port_B,IO ;On met 1
btfss Parity,0
bcf Port_B,IO ;On met 0
btfsc Parity,0 ;2 cycles bidon si 0
goto Bid7
Bid7 btfsc Parity,0
goto Bid8
Bid8 movlw .27
nop
nop
call Tempo
;Traitement bit de stop
bsf Port_B,IO
movlw .31
call Tempo
incf Offset,1
decfsz BytCnt,1
goto PaLoop
retlw 0
; Recoit octets du terminal
RecTerm movwf BytCnt
BytNex2 movlw 8
movwf BitCnt
clrf RcvReg
bcf Port_B,Indic
ostr2 btfsc Port_B,IO ;attend start
goto ostr2
; bcf Port_B,Puce
bsf Port_B,Indic
;attend un demi caractere
movlw .15
call Tempo
;attend un entier avec modif du signal
BitNex2 movlw .12
movwf DelayL
Entie2 btfsc Port_B,IO
nop
; bsf Port_B,Puce
btfss Port_B,IO
nop
; bcf Port_B,Puce
decfsz DelayL,1
goto Entie2
;ajout du bit arrive
bcf STATUS,CARRY
rlf RcvReg,1
btfss Port_B,IO
bsf RcvReg,LSB
;traite retour boucle
;debug
btfss Port_B,Indic
goto Met1
bcf Port_B,Indic
goto Mis0
Met1
bsf Port_B,Indic
Mis0
decfsz BitCnt,1
goto BitNex2
movlw .33 ;parite et bit de stop (26)
movwf DelayL
; bcf Port_B,Indic
nop
BFi2 btfsc Port_B,IO
nop
; bsf Port_B,Puce
btfss Port_B,IO
nop
; bcf Port_B,Puce
decfsz DelayL,1
goto BFi2
; bsf Port_B,Indic
nop
decfsz BytCnt,1
goto BytNex2
bsf Port_B,IO
retlw 0
;Traitement temporisation
Tempo movwf DelayL
Tpo decfsz DelayL,1
goto Tpo
retlw 0
TpoL2 movlw .255
LgTpo movwf DelayL
TpoL decfsz DelayL,1
goto TpoL
decfsz DelayH,1
goto TpoL2
retlw 0
ORG 0200h
Table
movwf DelayL
movlw .02
movwf 0ah
movf DelayL,0
btfss Dur,0
goto TableDyn
TableDur
addwf PC
retlw 03fh
retlw 065h
retlw 025h
retlw 008h
retlw 033h
retlw 004h
retlw 06ch
retlw 090h
retlw 000h
retlw 0b0h
retlw 0ffh
retlw 020h
retlw 040h
retlw 0c0h
retlw 07fh
retlw 070h
retlw 02fh
TableDyn
movlw 44h
subwf Addb,0
movwf Offset
movlw 4
btfss STATUS,CARRY ;negatif si carry=0
movlw 5
subwf Addh,0
btfss STATUS,CARRY ;negatif si carry=0
goto TableADT
incf Addb,1
btfsc STATUS,Z_bit
incf Addh,1
movf Offset,0
addwf PC
;66 04 10 e3 73 3d bb a0 75 74 93 e0 ADT 444
retlw 066h
retlw 004h
retlw 010h
retlw 0e3h
retlw 073h
retlw 03dh
retlw 0bbh
retlw 0a0h
retlw 075h
retlw 074h
retlw 093h
retlw 0e0h
;77 74 93 e0 79 74 93 e0 6e 11 04 e3 71 83 01 10 ADT 450
retlw 077h
retlw 074h
retlw 093h
retlw 0e0h
retlw 079h
retlw 074h
retlw 093h
retlw 0e0h
retlw 06eh
retlw 011h
retlw 004h
retlw 0e3h
retlw 071h
retlw 083h
retlw 001h
retlw 010h
;6e 00 08 e2 ff ff ff ff 70 ff 8f ff ff ff ff ff ADT 460
retlw 06eh
retlw 000h
retlw 008h
retlw 0e2h
retlw 0ffh
retlw 0ffh
retlw 0ffh
retlw 0ffh
retlw 070h ;8d0
retlw 0ffh
retlw 08fh
retlw 0ffh
retlw 0ffh
retlw 0ffh
retlw 0ffh
retlw 0ffh
;no : 4976 8100 0258 4609 09/01
;redondance 38000004976810002584609fff50199072500109
;public=10000000000000000000090B8AAA8DE358E7782E81C7723653BE644F7DCC6F816DAF46E532B91E84F
;no=38000004976810002584609fff50199072500109
;prive = 1423991357280606721596681803333085864700730227882257313609900555054188454201824800920161049221243
;no2=no+(2^160)*no
;VA=no2 ^ prive [public]
;VA=8142675F01D382A2AB45FDC4D2C3EF8144058B27EFB4C3B830067956E31476C12EF136A92E6B8C32
;30 00 08 14 32 67 5F 01 3D 38 2A 2A 3B 45 FD C4 3D 2C 3E F8 31 44 05 8B
32 7E FB 4C 33 B8 30 06 37 95 6E 31 34 76 C1 2E 3F 13 6A 92 3E 6B 8C 32
;2e 03 30 33 30 00 08 14 32 67 5F 01 3D 38 2A 2A ADL ligne 1
retlw 02eh
retlw 003h
retlw 030h
retlw 033h
retlw 030h
retlw 000h
retlw 008h
retlw 014h
retlw 032h
retlw 067h
retlw 05fh
retlw 001h
retlw 03dh
retlw 038h
retlw 02ah
retlw 02ah
;3B 45 FD C4 3D 2C 3E F8 31 44 05 8B 32 7E FB 4C ADL ligne 2
retlw 03bh
retlw 045h
retlw 0fdh
retlw 0c4h
retlw 03dh
retlw 02ch
retlw 03eh
retlw 0f8h
retlw 031h
retlw 044h
retlw 005h
retlw 08bh
retlw 032h
retlw 07eh
retlw 0fbh
retlw 04ch
;33 B8 30 06 37 95 6E 31 34 76 C1 2E 3F 13 6A 92 ADL ligne 3
retlw 033h
retlw 0b8h
retlw 030h
retlw 006h
retlw 037h
retlw 095h
retlw 06eh
retlw 031h
retlw 034h
retlw 076h
retlw 0c1h
retlw 02eh
retlw 03fh
retlw 013h
retlw 06ah
retlw 092h
;3E 6B 8C 32 2e 02 38 f1 30 04 97 68 31 00 02 58 ADL ligne 4
;4976 8100 0258 4609 09/01
retlw 03eh
retlw 06bh
retlw 08ch
retlw 032h
retlw 02eh
retlw 002h
retlw 038h
retlw 0f1h
retlw 030h
retlw 004h
retlw 097h
retlw 068h
retlw 031h
retlw 000h
retlw 002h
retlw 058h
;34 60 9f ff 35 01 99 07 32 50 01 09 32 50 34 97 ADL ligne 5
;4976 8100 0258 4609 suite emis 07/99 fin 09/01
;004976810002584609fff50199072500109
retlw 034h
retlw 060h
retlw 09fh
retlw 0ffh
retlw 035h
retlw 001h
retlw 099h
retlw 007h
retlw 032h
retlw 050h
retlw 001h
retlw 009h
retlw 032h
retlw 050h
retlw 034h
retlw 097h
;34 d4 c4 52 30 4d 41 4a 34 f4 94 52 30 49 53 41 MLE MAJOIE ISA
;3M L E SP3 M A J 3O I E SP3 I S A
;4976 8100 0258 4609
retlw 034h
retlw 0d4h
retlw 0c4h
retlw 052h
retlw 030h
retlw 04dh
retlw 041h
retlw 04ah
retlw 034h
retlw 0f4h
retlw 094h
retlw 052h
retlw 030h
retlw 049h
retlw 053h
retlw 041h
;32 02 02 02 30 20 20 20 32 02 02 02 30 20 f2 83 espaces
retlw 032h
retlw 002h
retlw 002h
retlw 002h
retlw 030h
retlw 020h
retlw 020h
retlw 020h
retlw 032h
retlw 002h
retlw 002h
retlw 002h
retlw 030h
retlw 020h
retlw 0f2h
retlw 083h
;11 1f f5 05 23 9f 0a c3 0a c3 0a 57 09 f1 08 d9 ;zone pointeurs
retlw 011h
retlw 01fh
retlw 0f5h
retlw 005h
retlw 023h
retlw 09fh
retlw 00ah
retlw 0c3h
retlw 00ah
retlw 0c3h
retlw 00ah
retlw 057h
retlw 009h
retlw 0f1h
retlw 008h
retlw 0d9h
;3f e5 20 02 08 4d 00 6f 05 a3 59 f4 02 e3 9f ff
retlw 03fh
retlw 0e5h
retlw 020h
retlw 002h
retlw 008h
retlw 04dh
retlw 000h
retlw 06fh
retlw 005h
retlw 0a3h
retlw 059h
retlw 0f4h
retlw 002h
retlw 0e3h
retlw 09fh
retlw 0ffh
org 300h
;etude zone ecrite
ADTwr
movlw 1ah
movwf fsr
movf indf,0
btfsc STATUS,Z_bit
goto ADTff
subwf Addh,0 ; w = f - w
btfss STATUS,Z_bit
goto ADTff
incf fsr,1
movf indf,0
subwf Addb,0 ; w = f - w = Addb - Stockee
movwf Offset
;calcul longueur
movlw 04h
subwf Offset,0
btfsc STATUS,CARRY ;negatif si carry=0
goto ADTff ;dans ADT
movlw 1ch
addwf Offset,0
movwf fsr
movf indf,0
incf Addb,1
btfsc STATUS,Z_bit
incf Addh,1
return
ADTff
incf Addb,1
btfsc STATUS,Z_bit
incf Addh,1
retlw 0ffh
TableADT
movlw .03
movwf 0ah
movlw 58h
subwf Addb,0
movwf Offset
movlw 1
subwf Addh,0
btfss STATUS,Z_bit ;negatif si carry=0
goto ADTwr ;si avant ADT
;calcul longueur
movlw 30h
subwf Offset,0
btfsc STATUS,CARRY ;negatif si carry=0
goto ADTwr ;dans ADT
incf Addb,1
btfsc STATUS,Z_bit
incf Addh,1
movf Offset,0
addwf PC
;30 00 97 11 32 d8 d4 80 33 e0 d8 68 33 e0 af c8 ADT 158
retlw 030h
retlw 000h
retlw 097h
retlw 011h
retlw 032h
retlw 0d8h
retlw 0d4h
retlw 080h
retlw 033h
retlw 0e0h
retlw 0d8h
retlw 068h
retlw 033h
retlw 0e0h
retlw 0afh
retlw 0c8h
;33 e8 cc 46 33 e8 ae 74 30 00 97 12 33 18 32 c8 ADT 168
retlw 033h
retlw 0e8h
retlw 0cch
retlw 046h
retlw 033h
retlw 0e8h
retlw 0aeh
retlw 074h
retlw 030h
retlw 000h
retlw 097h
retlw 012h
retlw 033h
retlw 018h
retlw 032h
retlw 0c8h
;33 20 bf 68 33 d8 9f 42 30 00 98 01 33 50 27 10 ADT 178
retlw 033h
retlw 020h
retlw 0bfh
retlw 068h
retlw 033h
retlw 0d8h
retlw 09fh
retlw 042h
retlw 030h
retlw 000h
retlw 098h
retlw 001h
retlw 033h
retlw 050h
retlw 027h
retlw 010h
END
Free, encrypted, secure Web-based email at www.hushmail.com