Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- codgen: # your code here.
- addiu $t1, $zero, 32 #amount of loops
- addiu $t2, $zero, 0 #amount of zeroes
- lw $t0, 0($s1) #load seed into $t0
- codegen_loop:
- andi $t3, $t0, 1 #Get the first bit
- bne $t3, $zero, codegen_iterate #If not 0
- addiu $t2, $t2, 1 #Then add 1
- codegen_iterate:
- addiu $t1, $t1, -1 #loops--
- srl $t0, $t0, 1 #Put the next bit in position
- bgtz $t1, codegen_loop #If loops left to do reiterate
- lw $t0, 0($s1) #Get the seed
- codegen_while: #t0=seed, t1=x, t2=nZeroes, t3=y
- rol $t1, $t0, 2 #x := seed Rotate left to bits
- srl $t3, $t0, 5 #y := seed Right shift logical 5 bits
- subu $t0, $t1, $t3 #seed := x - y
- addiu $t2, $t2, -1 #n := n - 1
- bgez $t2, codegen_while #If loops left
- li $t4, 0x1c4f5bde
- xor $v0, $t0, $t4 #Return seed xor 0x1c4f5bde
- sw $t0, 0($s1) #Store new seed in memory
- jr $ra
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement