Hi everyone, i need to write a code with mips assembly that works on a string given by a user (command line input).

The code is supposed to search another given string in that string. There is a problem in my mind, in mips is there any instruction that search a string in another one, i mean without comparison byte by byte or chra by char. Also, i don't know how can i goto at a specific location on that string, for example to reach 12th character of the given string if i have the string like that:

	.globl main
	subu $sp, $sp,4
	sw $ra,0($sp)
	li      $v0, 8                    # Read string.
	la      $a0, buf                # Buffer
	li      $a1, 256                # Length of buffer
	# Space for the input string.
	buf:    .space  256

I gave "the string & the string" as input and how can i reach/get 12th character?

Thanks in advance...

10 Years
Discussion Span
Last Post by pdrino

Sorry for my carelessness, i learnt how to reach a specific location in a string but i still need some answer for searching in string.


MIPS is specifically designed to have as few instructions as possible/reasonable. Therefore, there aren't any string opcodes. You'll have to do it char by char. Sorry.


thanks duoas for reply, i did it char by char as you said.
my work is 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.