Commit | Line | Data |
---|---|---|
9cb0c823 | 1 | .data |
ca13ceb0 JB |
2 | buffer1: .space 20 |
3 | buffer2: .space 20 | |
4 | n: .asciiz "\n" | |
5558d026 JB |
5 | string_part_one: .asciiz "Le temps est " |
6 | string_part_two: .asciiz ", je devrais prendre " | |
7 | string_part_three: .asciiz " avant de sortir." | |
8 | string_hole: .asciiz "__________" | |
9 | input_string: .asciiz "Mot manquant ? " | |
9cb0c823 | 10 | .text |
5558d026 JB |
11 | la $a0, string_part_one |
12 | li $v0, 4 | |
13 | syscall | |
14 | la $a0, string_hole | |
15 | li $v0, 4 | |
16 | syscall | |
17 | la $a0, string_part_two | |
18 | li $v0, 4 | |
19 | syscall | |
20 | la $a0, string_hole | |
21 | li $v0, 4 | |
22 | syscall | |
23 | la $a0, string_part_three | |
24 | li $v0, 4 | |
25 | syscall | |
26 | la $a0, n | |
27 | li $v0, 4 | |
28 | syscall | |
29 | la $a0, input_string | |
30 | li $v0, 4 | |
31 | syscall | |
32 | li $v0, 8 | |
33 | la $a0, buffer1 | |
34 | li $a1, 20 | |
35 | syscall | |
ca13ceb0 | 36 | la $s0, buffer1 # $s0 contains base address of the string buffer |
5558d026 | 37 | addi $s3, $0, '\n' # $s3 = '\n' |
9cb0c823 | 38 | loop1: |
ca13ceb0 JB |
39 | lb $s1, 0($s0) # load character into $s0 |
40 | beq $s1, $s3, end1 # break if byte is newline | |
5558d026 | 41 | addi $s0, $s0, 1 # increment buffer address |
ca13ceb0 | 42 | j loop1 |
9cb0c823 | 43 | end1: |
ca13ceb0 | 44 | sb $0, 0($s0) # replace newline with 0 |
5558d026 JB |
45 | la $a0, input_string |
46 | li $v0, 4 | |
47 | syscall | |
48 | li $v0, 8 | |
49 | la $a0, buffer2 | |
50 | li $a1, 20 | |
51 | syscall | |
ca13ceb0 | 52 | la $s0, buffer2 # $s0 contains base address of the string buffer |
5558d026 | 53 | addi $s3, $0, '\n' # $s3 = '\n' |
9cb0c823 | 54 | loop2: |
ca13ceb0 JB |
55 | lb $s1, 0($s0) # load character into $s0 |
56 | beq $s1, $s3, end2 # break if byte is newline | |
5558d026 | 57 | addi $s0, $s0, 1 # increment buffer address |
ca13ceb0 | 58 | j loop2 |
9cb0c823 | 59 | end2: |
ca13ceb0 | 60 | sb $0, 0($s0) # replace newline with 0 |
5558d026 JB |
61 | la $a0, string_part_one |
62 | li $v0, 4 | |
63 | syscall | |
64 | la $a0, buffer1 | |
65 | li $v0, 4 | |
66 | syscall | |
67 | la $a0, string_part_two | |
68 | li $v0, 4 | |
69 | syscall | |
70 | la $a0, buffer2 | |
71 | li $v0, 4 | |
72 | syscall | |
73 | la $a0, string_part_three | |
74 | li $v0, 4 | |
75 | syscall | |
76 | li $v0, 10 | |
77 | syscall |