微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 8位单片机随机数

8位单片机随机数

时间:12-03 来源:互联网 点击:

列表1024个字节

; 速度: 调用F_RandomSeed需要94个周期

;==============================================================================

F_RandomSeed:

CLC ; 计算低32位:

LDX R_Seed0 ; 1664525*($100* R_Seed1+ R_Seed0)+1

LDY R_Seed1

LDA T0,X

ADC #1

STA R_Seed0

LDA T1,X

ADC T0,Y

STA R_Seed1

LDA T2,X

ADC T1,Y

STA R_Temp

LDA T3,X

ADC T2,Y

TAY ; 把字节3留在Y中

CLC ; 加低32位:

LDX R_Seed2 ; 1664525*($10000* R_Seed2)

LDA R_Temp

ADC T0,X

STA R_Seed2

TYA

ADC T1,X

CLC

LDX R_Seed3 ; 加低32位:

ADC T0,X ; 1664525*($1000000* R_Seed3)

STA R_Seed3

rts

;==============================================================================

; 产生T0,T1,T2和T3列表,使用F_GeneratTables,列表在ram中

;==============================================================================

F_GeneratTables:

LDX #0 ;1664525*0=0

STX T0

STX T1

STX T2

STX T3

INX

CLC

L_GT1:

LDA T0-1,X ;把1664525加入

ADC #$0D ;字节0

STA T0,X

LDA T1-1,X

ADC #$66 ;字节1

STA T1,X

LDA T2-1,X

ADC #$19 ;字节2

STA T2,X

LDA T3-1,X

ADC #$00 ;字节3

STA T3,X

INX ;进位C=0退出

BNE L_GT1

RTS

;------------------------------------------------------------------------------

; 生成的列表,如果不要F_GeneratTables,可以直接将此表放在Rom中

;------------------------------------------------------------------------------

;1664525 * X的第31~24位(X = 0 to 255)

T3:

.DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$01,$01

.DB $01,$01,$01,$01,$01,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$03

.DB $03,$03,$03,$03,$03,$03,$03,$03,$03,$04,$04,$04,$04,$04,$04,$04

.DB $04,$04,$04,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$06,$06,$06

.DB $06,$06,$06,$06,$06,$06,$06,$07,$07,$07,$07,$07,$07,$07,$07,$07

.DB $07,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$09,$09,$09,$09,$09

.DB $09,$09,$09,$09,$09,$0A,$0A,$0A,$0A,$0A,$0A,$0A,$0A,$0A,$0A,$0B

.DB $0B,$0B,$0B,$0B,$0B,$0B,$0B,$0B,$0B,$0C,$0C,$0C,$0C,$0C,$0C,$0C

.DB $0C,$0C,$0C,$0C,$0D,$0D,$0D,$0D,$0D,$0D,$0D,$0D,$0D,$0D,$0E,$0E

.DB $0E,$0E,$0E,$0E,$0E,$0E,$0E,$0E,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F

.DB $0F,$0F,$10,$10,$10,$10,$10,$10,$10,$10,$10,$10,$11,$11,$11,$11

.DB $11,$11,$11,$11,$11,$11,$12,$12,$12,$12,$12,$12,$12,$12,$12,$12

.DB $13,$13,$13,$13,$13,$13,$13,$13,$13,$13,$14,$14,$14,$14,$14,$14

.DB $14,$14,$14,$14,$15,$15,$15,$15,$15,$15,$15,$15,$15,$15,$16,$16

.DB $16,$16,$16,$16,$16,$16,$16,$16,$17,$17,$17,$17,$17,$17,$17,$17

.DB $17,$17,$18,$18,$18,$18,$18,$18,$18,$18,$18,$18,$19,$19,$19,$19

;1664525 * X的第23~16位(X = 0 to 255)

T2:

.DB $00,$19,$32,$4C,$65,$7E,$98,$B1,$CB,$E4,$FD,$17,$30,$4A,$63,$7C

.DB $96,$AF,$C9,$E2,$FB,$15,$2E,$48,$61,$7A,$94,$AD,$C7,$E0,$F9,$13

.DB $2C,$46,$5F,$78,$92,$AB,$C5,$DE,$F7,$11,$2A,$44,$5D,$76,$90,$A9

.DB $C3,$DC,$F5,$0F,$28,$42,$5B,$74,$8E,$A7,$C1,$DA,$F3,$0D,$26,$40

.DB $59,$72,$8C,$A5,$BF,$D8,$F1,$0B,$24,$3E,$57,$70,$8A,$A3,$BD,$D6

.DB $EF,$09,$22,$3C,$55,$6E,$88,$A1,$BB,$D4,$ED,$07,$20,$3A,$53,$6C

.DB $86,$9F,$B9,$D2,$EB,$05,$1E,$38,$51,$6A,$84,$9D,$B7,$D0,$E9,$03

.DB $1C,$36,$4F,$68,$82,$9B,$B5,$CE,$E7,$01,$1A,$34,$4D,$66,$80,$99

.DB $B3,$CC,$E5,$FF,$18,$32,$4B,$64,$7E,$97,$B1,$CA,$E3,$FD,$16,$30

.DB $49,$62,$7C,$95,$AE,$C8,$E1,$FB,$14,$2D,$47,$60,$7A,$93,$AC,$C6

.DB $DF,$F9,$12,$2B,$45,$5E,$78,$91,$AA,$C4,$DD,$F7,$10,$29,$43,$5C

.DB $76,$8F,$A8,$C2,$DB,$F5,$0E,$27,$41,$5A,$74,$8D,$A6,$C0,$D9,$F3

.DB $0C,$25,$3F,$58,$72,$8B,$A4,$BE,$D7,$F1,$0A,$23,$3D,$56,$70,$89

.DB $A2,$BC,$D5,$EF,$08,$21,$3B,$54,$6E,$87,$A0,$BA,$D3,$ED,$06,$1F

.DB $39,$52,$6C,$85,$9E,$B8,$D1,$EB,$04,$1D,$37,$50,$6A,$83,$9C,$B6

.DB $CF,$E9,$02,$1B,$35,$4E,$68,$81,$9A,$B4,$CD,$E7,$00,$19,$33,$4C

;1664525 * X的第15~ 8位(X = 0 to 255)

T1:

.DB $00,$66,$CC,$32,$98,$FE,$64,$CA,$30,$96,$FC,$62,$C8,$2E,$94,$FA

.DB $60,$C6,$2C,$92,$F9,$5F,$C5,$2B,$91,$F7,$5D,$C3,$29,$8F,$F5,$5B

.DB $C1,$27,$8D

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top