3 input_string: .asciiz "Saisir un mot ? "
4 msg_palindrome_part_1: .asciiz "Le mot "
5 msg_palindrome_part_2: .asciiz " un palindrome"
7 msg_is_not: .asciiz " n'est pas"
13 jal clean_and_length_word
28 clean_and_length_word:
29 la $s4, ($zero) # word length
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
39 sb $0, 0($s0) # replace newline with 0
46 bne $t0, $zero, returnTrue
48 # Make sure first and last are equal
53 bne $t0, $t1, returnFalse
55 # Shift pointer, length, recurse
64 jal display_not_palindrome
73 jal display_palindrome
79 la $a0, msg_palindrome_part_1
88 la $a0, msg_palindrome_part_2
96 display_not_palindrome:
97 la $a0, msg_palindrome_part_1
106 la $a0, msg_palindrome_part_2