Advertisement
aaaaaa123456789

MIPS I reimplementation of StableRandom

Jun 17th, 2019
98
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Purely for shits and giggles.
  2.  
  3. glabel StableRandom
  4. lw $t0, ($a0)
  5. bne $t0, $zero, .leftloaded
  6. lw $t1, 4($a0)
  7. srl $t2, $t1, 24
  8. addiu $t3, $zero, 4
  9. .leftloop:
  10. sll $t4, $t2, 3
  11. addiu $t5, $t2, 29
  12. sll $t2, $t4, 3
  13. addu $t5, $t4, $t5
  14. addu $t4, $t2, $t5
  15. addiu $t3, $t3, -1
  16. andi $t2, $t4, 255
  17. sll $t4, $t0, 8
  18. bne $t3, $zero, .leftloop
  19. or $t0, $t2, $t4
  20. lui $t3, 256
  21. addiu $t3, $t3, -1
  22. sll $t2, $t2, 24
  23. and $t3, $t1, $t3
  24. or $t1, $t3, $t2
  25. .leftloaded:
  26. srl $t2, $t0, 8
  27. xor $t3, $t0, $t2
  28. sll $t0, $t3, 9
  29. xor $t2, $t3, $t0
  30. srl $t3, $t2, 23
  31. xor $t0, $t2, $t3
  32. andi $t4, $t1, 255
  33. addiu $t2, $t4, -210
  34. bltz $t2, .noreduction
  35. srl $t3, $t1, 8
  36. addu $t4, $zero, $t2
  37. .noreduction:
  38. srl $t2, $t1, 16
  39. andi $t3, $t3, 255
  40. andi $t2, $t2, 255
  41. addu $t5, $t4, $t3
  42. addu $t5, $t5, $t2
  43. srl $t1, $t1, 24
  44. beq $t5, $zero, .reloadright
  45. addiu $at, $zero, 719
  46. bne $t5, $at, .rightloaded
  47. nop
  48. .reloadright:
  49. sll $t4, $t1, 3
  50. addiu $t3, $t1, 29
  51. sll $t2, $t4, 3
  52. addu $t4, $t4, $t3
  53. addu $t1, $t2, $t4
  54. sll $t5, $t1, 3
  55. addiu $t3, $t1, 29
  56. sll $t4, $t5, 3
  57. addu $t6, $t5, $t3
  58. andi $t2, $t1, 255
  59. addu $t1, $t4, $t6
  60. sll $t5, $t1, 3
  61. andi $t4, $t1, 255
  62. addiu $t3, $t1, 29
  63. sltiu $at, $t4, 210
  64. addu $t5, $t5, $t3
  65. addiu $at, $at, -1
  66. sll $t6, $t1, 6
  67. andi $at, $at, 210
  68. addu $t1, $t5, $t6
  69. subu $t4, $t4, $at
  70. andi $t3, $t1, 255
  71. .rightloaded:
  72. addiu $at, $zero, 210
  73. multu $at, $t2
  74. sll $t2, $t3, 16
  75. mflo $t5
  76. addu $t4, $t5, $t4
  77. srl $t3, $t4, 8
  78. andi $t5, $t4, 255
  79. addu $t2, $t2, $t3
  80. sll $t4, $t5, 8
  81. addu $t2, $t2, $t4
  82. sll $t3, $t1, 3
  83. addiu $t4, $t1, 29
  84. sll $t1, $t1, 6
  85. addu $t3, $t3, $t4
  86. addu $t4, $t1, $t3
  87. sll $t1, $t4, 24
  88. addu $t1, $t1, $t2
  89. sw $t0, ($a0)
  90. sw $t1, 4($a0)
  91. srl $t2, $t1, 27
  92. andi $t3, $t2, 24
  93. srl $t4, $t1, 28
  94. srlv $t5, $t0, $t3
  95. srl $t2, $t1, 8
  96. andi $t3, $t4, 3
  97. andi $t1, $t2, 255
  98. andi $t0, $t5, 255
  99. addu $t2, $t0, $t1
  100. beq $t3, $zero, .done
  101. addiu $at, $zero, 1
  102. xor $t2, $t0, $t1
  103. beq $t3, $at, .done
  104. addiu $at, $zero, 2
  105. subu $t2, $t0, $t1
  106. beq $t3, $at, .done
  107. nop
  108. subu $t2, $t1, $t0
  109. .done:
  110. jr $ra
  111. andi $v0, $t2, 255
Advertisement
RAW Paste Data Copied
Advertisement