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 456,573 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 3,607 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: 881 | Replies: 2
Reply
Join Date: Oct 2007
Posts: 3
Reputation: tommyny04 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tommyny04 tommyny04 is offline Offline
Newbie Poster

Load word

  #1  
Oct 26th, 2007
Pretty new to assembly language and I need help with this problem. I'm trying to traverse through a string and see if each character is either a number or a operand (+, -, *, /). Everytime I run the program, it doesn't work properly. I'm pretty sure the error is in the 'lb' line after my loop label but I can't figure out what is wrong. Any help would be greatly appreciated. Thank you.

	.data
string1: .asciiz "Please enter a string. Make sure the string only contains RPN characters: "
string2: .asciiz "Invalid input: "
string3: .asciiz "Input is valid.\n"
string4: .asciiz "The first operator is "
string5: .asciiz "No operator found.\n"
string6: .asciiz "Please enter a single interger: \n"
string7: .asciiz "Please enter a single operator (+,-,*,/): \n"
string8: .asciiz "The result is "
input: .space 50
output: .space 3

	.text
	.globl Olu
Olu:
	la	$a0, string1
	li	$v0, 4
	syscall
	
	la	$a0, input
	li	$v0, 8
	syscall

	move $s0, $a0			 #address of input

loop:
	lb $t0, ($s0) 			     # gets a character
	beq $t0, $zero, next		# runs loop till 0 is received
	blt $t0, 48, charCheck	       # checks if char is less than 0
	bgt	$t0, 57, notValid	# checks if char is greater than 9
	add $s0, $s0, 1			 # moves along string
	j loop

notValid:
	la $a0, string2
	li $v0, 4
	syscall

	move $a0, $t0
	li $v0, 11
	syscall
	j next

charCheck:
	bne $t0, 42, notValid		#checks if char is equal to op
	bne $t0, 43, notValid
	bne $t0, 45, notValid
	bne $t0, 47, notValid
	add $s0, $s0, 1	
	j loop

next:
	li $v0, 10
	syscall

Also, if anyone knows of a decent MIPS simulator/debugger, please let me know. Thanks again!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2007
Posts: 3
Reputation: tommyny04 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tommyny04 tommyny04 is offline Offline
Newbie Poster

Re: Load word

  #2  
Oct 27th, 2007
Figured out what was wrong, really stupid mistake. The move instruction before the loop label was supposed to be from $v0 to $s0, not $a0 to $v0. However, when I make the correction and run the program, I get an address out of range error at the 'lb' instruction which is definitely not supposed to happen. Any help would greatly be appreciated. Thanks again!
Reply With Quote  
Join Date: Oct 2007
Posts: 3
Reputation: tommyny04 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tommyny04 tommyny04 is offline Offline
Newbie Poster

Re: Load word

  #3  
Oct 27th, 2007
Never mind, figured it out. Made a stupid error, on the 'lb' instruction. Thanks for all the "help" everyone.
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 6:09 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC