User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 426,439 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,290 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser: Programming Forums
Views: 3320 | Replies: 1
Reply
Join Date: Apr 2005
Posts: 2
Reputation: solaris is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
solaris solaris is offline Offline
Newbie Poster

Help MIPS - I'm Not getting the right answer :( Can anybody Review :)

  #1  
Apr 18th, 2005
Hi Guys,
So I started writing this program where i want the user to input a string
of numbers and letters and then i want to print out just the letters from
the sting ignoring all the letters and other characters such at , ; : * &...
I got it to take the string no problem and then i did the bgt and blt 's so
that it skips all the characters i don't want it to use but when it prints out
the resulting string I'm still getting the original string ;( I have no idea
where I made the mistake Please give me some ideas thx

.data 
ask:     .asciiz "Type a character string (<31 chars long): " 
count: 	.asciiz "number: "
maxlen:  .word 31 
buffer:  .space 31            # allocates 31 bytes of memory in the data segment 
str:     .space 31 
	

.text 
        .globl main

main: 	
	 li $v0, 4 
         la $a0, ask          	# Print "Type a character string: " 
         syscall 

         la $a0, buffer       	# $a0 holds the address of the read buffer 
         lw $a1, maxlen       	# Max number of chars (including the end of string char) 
         li $v0, 8            	# Load the service number 
         syscall              	# Call the operating system 

# Copy the buffer into str and replace lower case letters with upper case letters 

         li $t2, 58           	# the ASCII code of ":" 
	 li $t3, 47		# the ASCII code of "/" 
         li $t0, 0            	# $t0 is the index
	 li $t4, 0

	
loop:	 
	 lb $t1, buffer($t0)  	# fetch a char from the buffer 
	 blt $t1, $t2, skip   	# the char is before ":", skip it Branch on Less Than
         bgt $t1, $t3, skip   	# the char is after "/", skip it  Branch on Greater Than
	 

skip:    
	 addi $t4, $t4, 1           
	 sb $t1, str($t0)     	# and store it into str 
	 addi $t0, $t0, 1     	# increment index 
	 bne $t1, $0, loop    	# if $t1 <> "end of string" then goto loop 

	 

	 li $v0, 4 
         la $a0, str          	# Print str 
         syscall 

	 sub $t4, $t4, 2
	 li $v0, 4
	 la $a0, count
	 syscall
	 move $a0, $t4
	 li $v0, 1
	 syscall
      
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2005
Posts: 2
Reputation: solaris is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
solaris solaris is offline Offline
Newbie Poster

Re: MIPS - I'm Not getting the right answer :( Can anybody Review :)

  #2  
Apr 20th, 2005
AHHH i got it ;O) :p
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Assembly Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Assembly Forum

All times are GMT -4. The time now is 2:43 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC