.data
-buffer1: .space 20
-buffer2: .space 20
-n: .asciiz "\n"
-string_part_one: .asciiz "Le temps est "
-string_part_two: .asciiz ", je devrais prendre "
-string_part_three: .asciiz " avant de sortir."
-string_hole: .asciiz "__________"
-input_string: .asciiz "Mot manquant ? "
+ buffer1: .space 20
+ buffer2: .space 20
+ n: .asciiz "\n"
+ string_part_one: .asciiz "Le temps est "
+ string_part_two: .asciiz ", je devrais prendre "
+ string_part_three: .asciiz " avant de sortir."
+ string_hole: .asciiz "__________"
+ input_string: .asciiz "Mot manquant ? "
.text
-la $a0,string_part_one
-li $v0,4
-syscall
-la $a0,string_hole
-li $v0,4
-syscall
-la $a0,string_part_two
-li $v0,4
-syscall
-la $a0,string_hole
-li $v0,4
-syscall
-la $a0,string_part_three
-li $v0,4
-syscall
-la $a0,n
-li $v0,4
-syscall
-la $a0,input_string
-li $v0,4
-syscall
-li $v0,8
-la $a0,buffer1
-li $a1,20
-syscall
-
- la $s0, buffer1 # $s0 contains base address of the string buffer
- addi $s3, $0, '\n' # $s3 = '\n'
+ la $a0, string_part_one
+ li $v0, 4
+ syscall
+ la $a0, string_hole
+ li $v0, 4
+ syscall
+ la $a0, string_part_two
+ li $v0, 4
+ syscall
+ la $a0, string_hole
+ li $v0, 4
+ syscall
+ la $a0, string_part_three
+ li $v0, 4
+ syscall
+ la $a0, n
+ li $v0, 4
+ syscall
+ la $a0, input_string
+ li $v0, 4
+ syscall
+ li $v0, 8
+ la $a0, buffer1
+ li $a1, 20
+ syscall
+ la $s0, buffer1 # $s0 contains base address of the string buffer
+ addi $s3, $0, '\n' # $s3 = '\n'
loop1:
- lb $s1, 0($s0) # load character into $s0
- beq $s1, $s3, end1 # break if byte is newline
- addi $s0, $s0, 1 # increment buffer address
- j loop1
+ lb $s1, 0($s0) # load character into $s0
+ beq $s1, $s3, end1 # break if byte is newline
+ addi $s0, $s0, 1 # increment buffer address
+ j loop1
end1:
- sb $0, 0($s0) #replace newline with 0
-
-la $a0,input_string
-li $v0,4
-syscall
-li $v0,8
-la $a0,buffer2
-li $a1,20
-syscall
-
- la $s0, buffer2 # $s0 contains base address of the string buffer
- addi $s3, $0, '\n' # $s3 = '\n'
+ sb $0, 0($s0) #replace newline with 0
+ la $a0, input_string
+ li $v0, 4
+ syscall
+ li $v0, 8
+ la $a0, buffer2
+ li $a1, 20
+ syscall
+ la $s0, buffer2 # $s0 contains base address of the string buffer
+ addi $s3, $0, '\n' # $s3 = '\n'
loop2:
- lb $s1, 0($s0) # load character into $s0
- beq $s1, $s3, end2 # break if byte is newline
- addi $s0, $s0, 1 # increment buffer address
- j loop2
+ lb $s1, 0($s0) # load character into $s0
+ beq $s1, $s3, end2 # break if byte is newline
+ addi $s0, $s0, 1 # increment buffer address
+ j loop2
end2:
- sb $0, 0($s0) #replace newline with 0
-
-la $a0,string_part_one
-li $v0,4
-syscall
-la $a0,buffer1
-li $v0,4
-syscall
-la $a0,string_part_two
-li $v0,4
-syscall
-la $a0,buffer2
-li $v0,4
-syscall
-la $a0,string_part_three
-li $v0,4
-syscall
-
-li $v0,10
-syscall
+ sb $0, 0($s0) #replace newline with 0
+ la $a0, string_part_one
+ li $v0, 4
+ syscall
+ la $a0, buffer1
+ li $v0, 4
+ syscall
+ la $a0, string_part_two
+ li $v0, 4
+ syscall
+ la $a0, buffer2
+ li $v0, 4
+ syscall
+ la $a0, string_part_three
+ li $v0, 4
+ syscall
+ li $v0, 10
+ syscall