teru

rng for 6502

Sep 18th, 2020 (edited)
819
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. random:
  2.     ;note: all arithmetic should be unsigned
  3.     ;a, b, c, and d are the input variables
  4.     ;a', b', c', d' are the outputs
  5.    
  6.     ;e = a - 8bit_rotate_left(b)
  7.     lda RndB
  8.     asl a
  9.     adc #$80
  10.     eor #$FF
  11.     sec
  12.     adc RndA
  13.     tay
  14.     ;a' = b eor nibble_swap(c)
  15.     lda RndC
  16.     asl a
  17.     adc #$80
  18.     rol a
  19.     asl a
  20.     adc #$80
  21.     rol a
  22.     eor RndB
  23.     sta RndA
  24.     ;b' = c + d
  25.     lda RndC
  26.     clc
  27.     adc RndD
  28.     sta RndB
  29.     ;c' = d + e
  30.     tya
  31.     clc
  32.     adc RndD
  33.     sta RndC
  34.     ;d' = a' + e
  35.     ;(also this is the result)
  36.     tya
  37.     clc
  38.     adc RndA
  39.     sta RndD
  40.     rts
RAW Paste Data