3 input_string: .asciiz "Saisir un mot ? "
4 msg_palindrome_part_1: .asciiz "Le mot "
5 msg_palindrome_part_2: .asciiz " un palindrome"
6 msg_is_palindrome: .asciiz "est"
7 msg_is_not_palindrome: .asciiz "n'est pas"
13 jal clean_and_length_word
28 clean_and_length_word:
30 la $s0, input # $s0 contains base address of the string buffer
31 addi $s3, $0, '\n' # $s3 = '\n'
33 lb $s1, 0($s0) # load character into $s1
34 beq $s1, $s3, end1 # break if byte is newline
35 addi $s0, $s0, 1 # increment buffer address
45 bne $t0, $zero, returnTrue
47 # Make sure first and last are equal
52 bne $t0, $t1, returnFalse
54 # Shift pointer, length, recurse
63 jal display_not_palindrome
72 jal display_palindrome
78 la $a0, msg_palindrome_part_1
84 la $a0, msg_is_palindrome
87 la $a0, msg_palindrome_part_2
95 display_not_palindrome:
96 la $a0, msg_palindrome_part_1
102 la $a0, msg_is_not_palindrome
105 la $a0, msg_palindrome_part_2