From 41b0b0f809b1187c62f6ef4c59497bcf18205c6a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 26 Jun 2017 14:15:15 +0200 Subject: [PATCH] Fixlets to palindrome example MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- TD4/mips3.asm | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/TD4/mips3.asm b/TD4/mips3.asm index 889258c..2d22a85 100644 --- a/TD4/mips3.asm +++ b/TD4/mips3.asm @@ -1,10 +1,10 @@ .data -input: .space 20 +input: .space 50 input_string: .asciiz "Saisir un mot ? " msg_palindrome_part_1: .asciiz "Le mot " msg_palindrome_part_2: .asciiz " un palindrome" -msg_is_palindrome: .asciiz "est" -msg_is_not_palindrome: .asciiz "n'est pas" +msg_is: .asciiz " est" +msg_is_not: .asciiz " n'est pas" newline: .asciiz "\n" .text @@ -21,12 +21,12 @@ input_word: syscall li $v0, 8 la $a0, input - li $a1, 20 + li $a1, 50 syscall jr $ra clean_and_length_word: - la $s4, ($zero) + la $s4, ($zero) # word length la $s0, input # $s0 contains base address of the string buffer addi $s3, $0, '\n' # $s3 = '\n' loop1: @@ -36,6 +36,7 @@ loop1: addi $s4, $s4, 1 j loop1 end1: + sb $0, 0($s0) # replace newline with 0 la $a2, ($s4) jr $ra @@ -81,7 +82,7 @@ display_palindrome: la $a0, input li $v0, 4 syscall - la $a0, msg_is_palindrome + la $a0, msg_is li $v0, 4 syscall la $a0, msg_palindrome_part_2 @@ -99,7 +100,7 @@ display_not_palindrome: la $a0, input li $v0, 4 syscall - la $a0, msg_is_not_palindrome + la $a0, msg_is_not li $v0, 4 syscall la $a0, msg_palindrome_part_2 @@ -108,4 +109,4 @@ display_not_palindrome: la $a0, newline li $v0, 4 syscall - jr $ra \ No newline at end of file + jr $ra -- 2.34.1