search in a string

Reply

Join Date: Dec 2007
Posts: 10
Reputation: pdrino is an unknown quantity at this point 
Solved Threads: 0
pdrino pdrino is offline Offline
Newbie Poster

search in a string

 
0
  #1
Dec 24th, 2007
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:

  1. .text
  2. .globl main
  3. main:
  4. subu $sp, $sp,4
  5. sw $ra,0($sp)
  6.  
  7. li $v0, 8 # Read string.
  8. la $a0, buf # Buffer
  9. li $a1, 256 # Length of buffer
  10. syscall
  11.  
  12.  
  13. # Space for the input string.
  14. buf: .space 256

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

Thanks in advance...
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 10
Reputation: pdrino is an unknown quantity at this point 
Solved Threads: 0
pdrino pdrino is offline Offline
Newbie Poster

Re: search in a string

 
0
  #2
Dec 24th, 2007
...deleted...
Last edited by pdrino; Dec 24th, 2007 at 8:48 pm. Reason: repeated post
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 10
Reputation: pdrino is an unknown quantity at this point 
Solved Threads: 0
pdrino pdrino is offline Offline
Newbie Poster

Re: search in a string

 
0
  #3
Dec 24th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,951
Reputation: Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of 
Solved Threads: 214
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: search in a string

 
0
  #4
Dec 27th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 10
Reputation: pdrino is an unknown quantity at this point 
Solved Threads: 0
pdrino pdrino is offline Offline
Newbie Poster

Re: search in a string

 
0
  #5
Jan 5th, 2008
thanks duoas for reply, i did it char by char as you said.
my work is done
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC