Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 21
- 22 .text
- 23 main:
- 24
- 25 # Read in the integer
- 26 li $v0 5 # service 5 is read integer
- 27 syscall # make call
- 28
- 29 # Prepare registers for loop
- 30 move $t3 $v0 # move inputed integer into $t3
- 31 li $t0 0 # set counter for loop
- 32 li $t1 4 # set condition for loop
- 33
- 34 loop:
- 35 beq $t0 $t1 done # if $t0 == $t1, goto done
- 36 addi $t0 1 # add 1 to counter
- 37 add $t4 $t3 0x00FF # mask last byte of $t3 into $t4
- 38 or $t5 $t5 $t4 # or $t4 and $t5 into $t5
- 39 sll $t5 $t5 8 # shift left $t5 by 8 bits
- 40 srl $t0 $t0 8 # shift right $t3 by 8 bits
- 41 j loop # jump to loop
- 42
- 43 done:
- 44 li $v0 1 # service 1 is print integer
- 45 move $a0 $t5 # move $t5 into $a0
- 46 syscall # make call
- 47 jr $ra # exit program
- 48
- 49
- 50
- 51
- ~
- 51,0-1 Bot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement