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
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
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:
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.