daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Mar 19th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .data
  2.      
  3. main:
  4.  
  5.  la $t2, Hex
  6.  
  7. la $a0, ans
  8. li $v0, 4
  9.  syscall
  10.  
  11.  
  12.  
  13.  li $t0, 8               # counter
  14.  la $t3, result      
  15.  Loop:
  16.  beqz $t0, Exit      # branch to exit if counter is equal to zero
  17.  rol $t2, $t2, 4     # rotate 4 bits to the left
  18.  
  19.  and $t4, $t2, 0xf           # mask with 1111
  20.  ble $t4, 9, Sum     # if less than or equal to nine, branch to sum
  21.  addi $t4, $t4, 0x37           # if greater than nine, add 55
  22.  b End
  23.  Sum:
  24.      addi $t4, $t4, 0x30   # add 48 to result
  25.  End:
  26.  sb $t4, 0($t3)          # store hex digit into result
  27.  addi $t3, $t3, 1        # increment address counter
  28.  sub $t0, $t0, 1       # decrement loop counter
  29.  j Loop
  30.   Exit:
  31.  
  32.  la $a0, result
  33.  
  34. li $v0, 4
  35.  syscall
  36.  
  37.  la $v0, 10
  38.  syscall
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top