My first prog (find if a string is palindromic)

Hi this is my first post in this forum! I learned a bit of mips assembly and did my first exercise, I have some questions though. Where can I find the list of all the assembly commands? Some websites do not include bge (branch if greater or equal) in their list. I'm going to learn computer architecture from this book soon in my university:Computer Organization and Design: The Hardware/Software Interface (J.Hennessy), what kind of assembly I'm going to see there? Currently I'm studying from here:
and I have downloaded PcSpim 8.0 does anyone now how to run a programme on this thing?
Ok here's the programme (if you have any suggestions/corrections or a different approach please tell me):

li $v0
la $a0,usrstr
li $a1,1024
la $t1,usrstr #$t1 used to hold the left index
la $t2,usrstr #$t2 used to hold the right index

lb $t3,($st2)
beq $t3,10,sseek #go to the search of a char or an int which is starting from the left
addu $t2,$t2,1
b findend

lb $t3,($t1) #$t3 to hold the byte
addu $t1,$t1,1
bge $t1,$t2,ypal # the way out if the string is palindromic or null

li $t4,0 # $t4=0 to indicate integer
blt $t3,48,sseek
blt $t3,58,endsseek
li $t4,1 # $t4=1 to indicate char
blt $t3,65,sseek
blt $t3,91,endsseek
blt $t3,97,sseek
blt $t3,123,endsseek
b sseek

lb $t6,($t2) # $t6 to hold the byte
subu $t2,$t2,1

li $t5,0 #$t5=0 to indicate int
blt $t6,48,endsseek
blt $t6,58,checkeq #checkeq to check equality of ints or chars inside $t3,$t6
li $t5,1 #$t5=1 to indicate char
blt $t6,65,endsseek
blt $t6,91,checkeq
blt $t6,97,endsseek
blt $t6,123,checkeq
b endsseek

beq $t3,$t6,sseek
bne $t4,$t5,npal
beq $t4,0,npal #$t5 used as scratch place from now on
addu $t5,$t3,32
beq $t5,$t6,sseek
addu $t5,$t6,32
beq $t5,$t3,sseek

li $v0,4
la $a0,npalmsg
li $v0,10

li $v0,4
la $a0,ypalmsg
li $v0,10
usrstr: .space 1024
npalmsg: .asciiz "The input string is not a palindromic one."
ypalmsg: .asciiz "The input string is a palindromic one."


  • Something I didn't mention :P :
    The programme must ignore punctuation, white space and capitalization. It must recognize these as palindromic:
    1. "1 2 321"
    2. "Madam, I'm Adam."
    3. "Able was I, ere I saw Elba."
    4. "A man, a plan, a canal{ Panama!"
    5. "Go hang a salami; I'm a lasagna hog."
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion