Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. codgen: # your code here.
  2. addiu $t1, $zero, 32 #amount of loops
  3. addiu $t2, $zero, 0 #amount of zeroes
  4. lw $t0, 0($s1) #load seed into $t0
  5. codegen_loop:
  6. andi $t3, $t0, 1 #Get the first bit
  7. bne $t3, $zero, codegen_iterate #If not 0
  8. addiu $t2, $t2, 1 #Then add 1
  9. codegen_iterate:
  10. addiu $t1, $t1, -1 #loops--
  11. srl $t0, $t0, 1 #Put the next bit in position
  12. bgtz $t1, codegen_loop #If loops left to do reiterate
  13. lw $t0, 0($s1) #Get the seed
  14. codegen_while: #t0=seed, t1=x, t2=nZeroes, t3=y
  15. rol $t1, $t0, 2 #x := seed Rotate left to bits
  16. srl $t3, $t0, 5 #y := seed Right shift logical 5 bits
  17. subu $t0, $t1, $t3 #seed := x - y
  18. addiu $t2, $t2, -1 #n := n - 1
  19. bgez $t2, codegen_while #If loops left
  20. li $t4, 0x1c4f5bde
  21. xor $v0, $t0, $t4 #Return seed xor 0x1c4f5bde
  22. sw $t0, 0($s1) #Store new seed in memory
  23. jr $ra
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement