-1

I believe I can read string using

li $v0, 8
syscall

how can I take what was read and check if it was a specific value.

e.g.
if input was Y then jump to loop label. if it was N then jump to exit label.

thanks

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by wildgoose
0

Of course you need $a0 to be the address of the buffer
An $a1 to be the maximum number of characters to read (buffer size - 1) as a terminator is written!

Since the data is in $a0 you will need to do a load byte (LB) with 0 offset for each byte until you encounter the terminator.

mov $t1,$t0  
          
Scan:
 lb $t2,0($t1)            #  c = ary[ 0 ]
 beq $zero,$t2, Done    # Terminator?

 addi $t1,$t1,1         # inc ary base     ary += 1

# do your compares here
# Value has to be in a register for a register to register compare

 j Scan


Done:
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.