Stuck on a program I am working on, converting a ASCII charchter to 7 Bit

Reply

Join Date: Mar 2005
Posts: 1
Reputation: wernerradio is an unknown quantity at this point 
Solved Threads: 0
wernerradio wernerradio is offline Offline
Newbie Poster

Stuck on a program I am working on, converting a ASCII charchter to 7 Bit (MIPS)

 
0
  #1
Mar 24th, 2005
I am working on a program where I need to convert a ASCII charchter to a 7-bit code, eg. 'A' is 65 (decimal) and it would be 1000001

I am not sure how to attack this...
Below is the code I have started with so far, I guess my main question is how do I get the ASCII code entered to a decimal number?


  1. .text
  2. .globl __start
  3. __start:
  4.  
  5. # code asking for the input
  6. li $v0, 4
  7. la $a0, ch
  8. syscall
  9.  
  10. # read string syscall to read in a single charchter and newline charchter
  11. la $a0, L
  12. li $a1, 3
  13. li $v0, 8
  14. syscall
  15.  
  16. # store the charchter into a register, t1
  17. li $t0, 0
  18. lw $t1, L($t0)
  19. sw $tl, L
  20.  
  21.  
  22. # at this point I am stuck, how do I convert the ASCII charchter to a decimal number? I have no idea where to even start, the book I have has no examples of this...
  23.  
  24. ...program continues
  25. The next step I need to do is to take the decimal number and use shifting and msaking to get the value of each bit to convert it to a 7 bit binary code.
  26.  
  27. .text
  28. ch: .asciiz "ch? "
  29. L: .space 12

thanks for any help, if there are more details I need to provide just let me know!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC