Question

What should I write as a condition to compare what I wrote from my keyboard with K? I want my code to continue when I press the letter K. That's my code.

   K1:li $v0, 4          
   la $a0, gram  #message to get the letter     
   syscall  
   li $v0,5
   syscall
   move $t4,$v0   

   bne $t4,48h,K1   
Was it helpful?

Solution

You should load the letter k into a register for comparison.

MIPS assembly supports character literals so you could do:

li $t5 'k'
bne $t4 $t5 K1

OTHER TIPS

Ascii code for 'K' is 4B, so you should compare the register where input byte is stored with 4Bh and then proceed if it's equal.

So assuming register $t4 has the input code of the input byte your condition should be:

bne $t4,4Bh,K1

Also, you might consider providing additional information what some lines and functions mean when you post some architecture specific code/languague.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top