0

Currently I get output as

dsajnd

is not a palindrome

And I want it to output such that the (e.g dsajnd) and " is not a palindrome" are on the same line.

dsajnd is not a palindrome

the code I have for printing this is

true:   
move $a3, $t0
la $v0, 4
syscall
        # printing the true_msg, and exit.
la $a0, true_msg
li $v0, 4
syscall
b exit


false:
move $a3, $t0
la $v0, 4
syscall

la $a0, false_msg # printing the false_msg, and exit.
li $v0, 4
syscall
b exit


exit: ## exit the program:
li $v0, 10 # loading "exit" into $v0.
syscall 

.globl Print_string
Print_string: # print the string whose starting address is in register a0
li $v0, 4
syscall
jr $ra

.data
buffer: .space 12
true_msg: .asciiz "is a palindrome"
false_msg: .asciiz "is not a palindrome"
1
  • 2
    Presumably the string entered contains a line feed at the end. Strip that. Commented Sep 27, 2014 at 1:56

1 Answer 1

1

Whatever string you have must have a newline or line feed at the end. You need to remove that. MIPS will not automatically add newlines unless you explicitly tell it to.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.