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:

.text
	.globl main
main:
	subu $sp, $sp,4
	sw $ra,0($sp)
	
	li      $v0, 8                    # Read string.
	la      $a0, buf                # Buffer
	li      $a1, 256                # Length of buffer
	syscall
	
	
	# 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...

Recommended Answers

All 4 Replies

...deleted...

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 ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.