Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a method in basic MIPS assembly (no pseudo instructions) which determines whether or not an input string is a palindrome. .data String0: .asciiz

Write a method in basic MIPS assembly (no pseudo instructions) which determines whether or not an input string is a palindrome.

.data

String0:

.asciiz ""

String1:

.asciiz "a"

String2:

.asciiz "b"

String3:

.asciiz "aba"

String4:

.asciiz "abba"

String5:

.asciiz "baab"

String6:

.asciiz "ababa"

String7:

.asciiz "aabba"

String8:

.asciiz "abbab"

Is:

.asciiz" is a palindrome. "

IsNot:

.asciiz" is not a palindrome. "

.text

la $a0, String0

jalCheckPalindrome

addi $a1, $v0, 0

jalWriteResult

la $a0, String1

jalCheckPalindrome

addi $a1, $v0, 0

jalWriteResult

la $a0, String2

jalCheckPalindrome

addi $a1, $v0, 0

jalWriteResult

la $a0, String3

jalCheckPalindrome

addi $a1, $v0, 0

jalWriteResult

la $a0, String4

jalCheckPalindrome

addi $a1, $v0, 0

jalWriteResult

la $a0, String5

jalCheckPalindrome

addi $a1, $v0, 0

jalWriteResult

la $a0, String6

jalCheckPalindrome

addi $a1, $v0, 0

jalWriteResult

la $a0, String7

jalCheckPalindrome

addi $a1, $v0, 0

jalWriteResult

la $a0, String8

jalCheckPalindrome

addi $a1, $v0, 0

jalWriteResult

addi $v0, $0, 10

syscall

WriteResult:

addi $sp, $sp, -8

sw $a0, 0($sp)

sw $v0, 4($sp)

addi $v0, $0, 4

syscall

beq$a1, $0, PrintNot

la $a0, Is

syscall

j WriteDone

PrintNot:

la $a0, IsNot

syscall

WriteDone:

lw $v0, 4($sp)

lw $a0, 0($sp)

addi $sp, $sp, 8

jr $ra

CheckPalindrome:

# $a0 string address

# $v0 result (1 = is a palindrome, 0 is not)

# your code goes here

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions