PIC单片机产生伪随机数汇编语言程序
PSW EQU 03R0 EQU 08
R1 EQU 09
R2 EQU 0AH
R3 EQU 0BH
R4 EQU 0CH
R5 EQU 0DH
R6 EQU 0EH
R7 EQU 0FH
TEMP EQU 13H
CNT1 EQU 11H
CNTH EQU 12H
BUF0 EQU 17H
BUF1 EQU 18H
ESUM1EQU 13H
ESUM2EQU 14H
ESUM3EQU 15H
ESUM4EQU 16H
DSUM1EQU 19H
DSUM2EQU 1AH
DSUM3EQU 1BH
DSUM4EQU 1CH
DSUM5EQU 1DH
DSUM6EQU 1EH
ORG 1FFH
GOTORADM
ORG 000
D_ADDMOVFR0,0
ADDWF R6,1
BTFSC PSW,0
INCFR7
MOVFR1,0
ADDWF R7,1
RETLW 0
DMU1 MOVLW 16
MOVWF TEMP
CLRFR7
CLRFR6
DMUL_1 RRF R3
RRF R2
BTFSC PSW,0
CALLD_ADD
RRF R7
RRF R6
RRF R5
RRF R4
DECFSZ TEMP
GOTODMUL_1
RETLW 0
RADM CLRFESUM1
CLRFESUM2
CLRFESUM3
CLRFESUM4
CLRFDSUM1
CLRFDSUM2
CLRFDSUM3
CLRFDSUM4
CLRFDSUM5
CLRFDSUM6
MOVLW 20H
MOVWF CNTH
RADM_1 MOVLW 00
MOVWF CNTL
RADM_2 MOVLW 64H
MOVWF R3
MOVLW 85H
MOVWF R2
MOVFBUF1,0
MOVWF R1
MOVFBUF0,0
MOVWF R0
CALLDMUL
MOVLW 19H
ADDWF R4,0
MOVWF R0
MOVWF BUF0
BTFSC PSW,0
INCFR5
MOVLW 36H
ADDWF R5,0
MOVWF R1
MOVWF BUF1
MOVFR0,0
ADDWF ESUM1,1
BUFSS PSW,0
GOTOEADD_1
INCFESUM2
BTFSS PSW,2
GOTOEADD_1
INCFESUM3
BTFSS PSW,2
GOTOEADD_1
INCFESUM4
EADD_1 MOVFR1,0
ADDWF ESUM2,1
BTFSS PSW,0
GOTOEADD_2
BTFSS PSW,2
GOTOEADD_2
INCFESUM4
EADD_2 BTFSC R1,7
GOTORADM_3
COMFR0,1
COMFR1,1
MOVLW 1
ADDWF R0,1
BTFSC PSW,0
INCFR1
RADM_3 MOVLW 80H
ADDWF R1,1
MOVFR1,0
MOVWF R3
MOVFR0,0
MOVWF R2
CALLDMUL
MOVFR4,0
ADDWF DSUM1,1
BTFSS PSW,0
GOTODADD_1
INCFDSUM2
BTFSS PSW,2
GOTODADD_1
INCFDSUM3
BTFSS PSW,2
GOTODADD_1
INCFDSUM4
BTFSS PSW,2
GOTODADD_1
INCF DSUM6
DADD_1 MOVF R5,0
ADDWFDSUM2,1
BTFSSPSW,0
GOTO DADD_2
INCF DSUM3
BTFSSPSW,2
GOTO DADD_2
INCF DSUM4
BTFSSPSW,2
GOTO DADD_2
INCF DSUM5
BTFSSPSW,2
GOTO DADD_2
INCF DSSUM6
DADD_2 MOVF R6,0
ADDWFDSUM3,1
BTFSSPSW,0
GOTO DADD_3
INCF DSUM4
BTFSSPSW,2
GOTO DADD_3
INCF DSUM5
BTFSSPSW,2
GOTO DADD_3
INCF DSUM6
DADD_3 MOVF R7,0
ADDWFDSUM4,1
BTFSSPSW,0
GOTO DADD_4
INCF DSUM5
BTFSSPSW,2
GOTO DADD_4
INCF DSUM6
DADD_4 DECFSZ CNTL
GOTO RADM_2
DECFSZ CNTH
GOTO RADM_1
MOVLW5
MOVWFCNTL
RADM_4 BCF PSW,0
RRF ESUM4
RRF ESUM3
RRF ESUM2
RRF ESUM1
DECFSZ CNTL
GOTO RADM_4
MOVLW5
MOVWFCNTL
RADM_5 BCF PSW,0
RRF DSUM6
RRF DSUM5
RRF DSUM4
RRF DSUM3
RRF DSUM2
RRF DSUM1
DECFSZ CNTL
GOTO RADM_5
LOOP GOTO LOOP
END
页:
[1]