PIC单片机产生伪随机数程序
扫描二维码
随时随地手机看文章
PSWEQU03
R0EQU08
R1EQU09
R2EQU0AH
R3EQU0BH
R4EQU0CH
R5EQU0DH
R6EQU0EH
R7EQU0FH
TEMPEQU13H
CNT1EQU11H
CNTHEQU12H
BUF0EQU17H
BUF1EQU18H
ESUM1EQU13H
ESUM2EQU14H
ESUM3EQU15H
ESUM4EQU16H
DSUM1EQU19H
DSUM2EQU1AH
DSUM3EQU1BH
DSUM4EQU1CH
DSUM5EQU1DH
DSUM6EQU1EH
ORG1FFH
GOTORADM
ORG000
D_ADD MOV FR0,0
ADDWFR6,1
BTFSCPSW,0
INCFR7
MOV FR1,0
ADDWFR7,1
RETLW0
DMU1 MOV LW16
MOV WFTEMP
CLRFR7
CLRFR6
DMUL_1RRFR3
RRFR2
BTFSCPSW,0
CALLD_ADD
RRFR7
RRFR6
RRFR5
RRFR4
DECFSZTEMP
GOTODMUL_1
RETLW0
RADMCLRFESUM1
CLRFESUM2
CLRFESUM3
CLRFESUM4
CLRFDSUM1
CLRFDSUM2
CLRFDSUM3
CLRFDSUM4
CLRFDSUM5
CLRFDSUM6
MOV LW20H
MOV WFCNTH
RADM_1 MOV LW00
MOV WFCNTL
RADM_2 MOV LW64H
MOV WFR3
MOV LW85H
MOV WFR2
MOV FBUF1,0
MOV WFR1
MOV FBUF0,0
MOV WFR0
CALLDMUL
MOV LW19H
ADDWFR4,0
MOV WFR0
MOV WFBUF0
BTFSCPSW,0
INCFR5
MOV LW36H
ADDWFR5,0
MOV WFR1
MOV WFBUF1
MOV FR0,0
ADDWFESUM1,1
BUFSSPSW,0
GOTOEADD_1
INCFESUM2
BTFSSPSW,2
GOTOEADD_1
INCFESUM3
BTFSSPSW,2
GOTOEADD_1
INCFESUM4
EADD_1 MOV FR1,0
ADDWFESUM2,1
BTFSSPSW,0
GOTOEADD_2
BTFSSPSW,2
GOTOEADD_2
INCFESUM4
EADD_2BTFSCR1,7
GOTORADM_3
COMFR0,1
COMFR1,1
MO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