title: How can I convert hex string to binary?
body: <p>My problem is getting a 64-bit key from user. For this I need to get 16 characters as string which contains hexadecimal characters (123456789ABCDEF). I got the string from user and I reached characters with the code below. But I don't know how to convert character to 4-bit binary</p>
  
  <pre><code>.data 
  
  
  insert_into: 
      .word 8 
  
  Ask_Input:  
      .asciiz "Please Enter a Key which size is 16, and use hex characters : " 
  
  
  key_array: 
      .space 64
  
  .text
  .globl main
  
  
  main: 
  
      la $a0, Ask_Input 
  
      li $v0, 4 
      syscall 
  
      la $a0, insert_into 
      la $a1, 64 
      li $v0, 8
      syscall
  
      la $t0, insert_into
      li $t2, 0
      li $t3, 0
    loop_convert:
          lb $t1, ($t0)
          addi $t0, $t0, 1 
  
          beq $t1, 10, end_convert
  
  # Now charcter is in $t1 but 
    #I dont know how to convert it to 4 bit binary and storing it
  
  
          b loop_convert
  
      end_convert:        
  
      li $v0, 10  # exit
      syscall
  </code></pre>