Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Convert Char to Int in MIPS, however do it using the $fp register and $sp regist

ID: 2268452 • Letter: C

Question

Convert Char to Int in MIPS, however do it using the $fp register and $sp register.

For example:

    li $t0, 97
   sb $t0, -1($fp)

   lb $t1, -1($fp)
   sb $t1, y

   lb $t3, -1($fp)
   la $sp, -4($sp)
   sw $t3, 0($sp)
   jal print_int

This will print 97.

However, I am having trouble converting the byte into an integer, what I tried:

    li $t0, 97
   sb $t0, -1($fp)

   lb $t1, -1($fp)
   sb $t1, y

   lb $t2, -1($fp)

   sw $t2, -5($fp)


   lb $t3, -5($fp)
   la $sp, -4($sp)
   sw $t3, 0($sp)
   jal print_int

This will print 0. Help please.

Explanation / Answer

So it is my suggestion to try this one using the ASCII code rather than converting the Char to Int, So that u can get the desired output

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote