From 20fc727d4f954eb2109b71a7686c3107fdfa4bbf Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Fri, 21 Nov 2025 18:37:48 +0100 Subject: Cours du 3 au 21 novembre ce qui fait 3 semaines en philo et une semaine en info --- .../tme/tme7/exo1-q1-q2.asm | 65 ++++++++++++++++++ .../tme/tme7/exo1-q3.asm | 51 +++++++++++++++ .../tme/tme7/exo1-q4.asm | 51 +++++++++++++++ .../tme/tme7/exo2-q1.asm | 76 ++++++++++++++++++++++ .../tme/tme7/exo2-q2.asm | 59 +++++++++++++++++ .../tme/tme7/exo2-q3.asm | 57 ++++++++++++++++ 6 files changed, 359 insertions(+) create mode 100644 semestre 3/architecture des ordinateurs/tme/tme7/exo1-q1-q2.asm create mode 100644 semestre 3/architecture des ordinateurs/tme/tme7/exo1-q3.asm create mode 100644 semestre 3/architecture des ordinateurs/tme/tme7/exo1-q4.asm create mode 100644 semestre 3/architecture des ordinateurs/tme/tme7/exo2-q1.asm create mode 100644 semestre 3/architecture des ordinateurs/tme/tme7/exo2-q2.asm create mode 100644 semestre 3/architecture des ordinateurs/tme/tme7/exo2-q3.asm (limited to 'semestre 3/architecture des ordinateurs/tme/tme7') diff --git a/semestre 3/architecture des ordinateurs/tme/tme7/exo1-q1-q2.asm b/semestre 3/architecture des ordinateurs/tme/tme7/exo1-q1-q2.asm new file mode 100644 index 0000000..325e98a --- /dev/null +++ b/semestre 3/architecture des ordinateurs/tme/tme7/exo1-q1-q2.asm @@ -0,0 +1,65 @@ +.data +ch1: .asciiz "1 exemple d'exemple\n" # @ 0x1001 0000 +ch2: .asciiz "Hello world!\n" # @ 0x1001 0015 +.text +#main + addiu $29, $29, -4 + sw $0, 0($29) + + # printf("%s", ch1) + lui $4, 0x1001 + ori $2, $0, 4 + syscall + # min_to_maj_chaine(ch1) + addiu $29, $29, -4 + lui $4, 0x1001 + sw $4, 0($29) + jal min_to_maj_chaine + # printf("%s", ch1) + lui $4, 0x1001 + ori $2, $0, 4 + syscall + + # printf("%s", ch2) + lui $16, 0x1001 + addiu $16, $16, 0x15 + or $4, $0, $16 + ori $2, $0, 4 + syscall + # min_to_maj_chaine(ch2) + or $4, $0, $16 + sw $4, 0($29) + jal min_to_maj_chaine + # printf("%s", ch2) + or $4, $0, $16 + ori $2, $0, 4 + syscall + + addiu $29, $29, 8 + ori $2, $0, 10 + syscall + +min_to_maj_chaine: + addiu $29, $29, -8 + sw $31, 4($29) +while: + # while ch[i] != 0 + lb $9, 0($4) + beq $9, $0, end_while + # if ch[i] >= 'a' + sltiu $10, $9, 'a' + bne $10, $0, end_if + # if ch[i] <= 'z' + ori $10, $0, 'z' + sltu $10, $10, $9 + bne $10, $0, end_if + # ch[i] - 0x20 + addiu $9, $9, -0x20 + sb $9, 0($4) +end_if: + addiu $4, $4, 1 + j while +end_while: + lw $31, 4($29) + addiu $29, $29, 8 + jr $31 \ No newline at end of file diff --git a/semestre 3/architecture des ordinateurs/tme/tme7/exo1-q3.asm b/semestre 3/architecture des ordinateurs/tme/tme7/exo1-q3.asm new file mode 100644 index 0000000..01d085c --- /dev/null +++ b/semestre 3/architecture des ordinateurs/tme/tme7/exo1-q3.asm @@ -0,0 +1,51 @@ +.data +ch: .asciiz "1 exemple d'exemple\n" # @ 0x1001 0000 +.text +# main + addiu $29, $29, -8 + # int i = 0 + sw $0, 4($29) + # printf("%s", ch) + lui $16, 0x1001 + or $4, $0, $16 + ori $2, $0, 4 + syscall +while: + # while ch[i] != 0 + lb $9, 0($16) + beq $9, $0, end_while + # ch[i] = min_to_maj_char(ch[i]) + sw $9, 0($29) + or $4, $0, $9 + jal min_to_maj_char + sb $2, 0($16) + # i++ + addiu $16, $16, 1 + j while +end_while: + # printf("%s", ch) + lui $4, 0x1001 + ori $2, $0, 4 + syscall + + addiu $29, $29, 8 + ori $2, $0, 10 + syscall + +min_to_maj_char: + addiu $29, $29, -8 + sw $31, 4($29) + # if ch[i] >= 'a' + sltiu $10, $4, 'a' + bne $10, $0, end_if + # if ch[i] <= 'z' + ori $10, $0, 'z' + sltu $10, $10, $4 + bne $10, $0, end_if + # c - 0x20 + addiu $4, $4, -0x20 +end_if: + lw $31, 4($29) + or $2, $0, $4 + addiu $29, $29, 8 + jr $31 \ No newline at end of file diff --git a/semestre 3/architecture des ordinateurs/tme/tme7/exo1-q4.asm b/semestre 3/architecture des ordinateurs/tme/tme7/exo1-q4.asm new file mode 100644 index 0000000..1fdf443 --- /dev/null +++ b/semestre 3/architecture des ordinateurs/tme/tme7/exo1-q4.asm @@ -0,0 +1,51 @@ +.data +ch: .asciiz "1 exemple d'exemple\n" # @ 0x1001 0000 +.text +# main + addiu $29, $29, -8 + # int i = 0 + sw $0, 4($29) + # printf("%s", ch) + lui $16, 0x1001 + or $4, $0, $16 + ori $2, $0, 4 + syscall +while: + # while ch[i] != 0 + lb $9, 0($16) + beq $9, $0, end_while + # ch[i] = min_to_maj_char(&(ch[i])) + sw $9, 0($29) + or $4, $0, $16 + jal min_to_maj_ptr_char + # i++ + addiu $16, $16, 1 + j while +end_while: + # printf("%s", ch) + lui $4, 0x1001 + ori $2, $0, 4 + syscall + + addiu $29, $29, 8 + ori $2, $0, 10 + syscall + +min_to_maj_ptr_char: + addiu $29, $29, -8 + sw $31, 4($29) + # if ch[i] >= 'a' + lb $8, 0($4) + sltiu $10, $8, 'a' + bne $10, $0, end_if + # if ch[i] <= 'z' + ori $10, $0, 'z' + sltu $10, $10, $8 + bne $10, $0, end_if + # c - 0x20 + addiu $8, $8, -0x20 + sb $8, 0($4) +end_if: + lw $31, 4($29) + addiu $29, $29, 8 + jr $31 diff --git a/semestre 3/architecture des ordinateurs/tme/tme7/exo2-q1.asm b/semestre 3/architecture des ordinateurs/tme/tme7/exo2-q1.asm new file mode 100644 index 0000000..2f22fd8 --- /dev/null +++ b/semestre 3/architecture des ordinateurs/tme/tme7/exo2-q1.asm @@ -0,0 +1,76 @@ +.data +.text +# main + addiu $29, $29, -36 + sw $0, 32($29) # i = 0 + # ch1 = 0($29) + # ch2 = 16($29) + + or $16, $0, $29 + addiu $17, $29, 16 + + ori $2, $0, 8 + or $4, $0, $16 + ori $5, $0, 16 + syscall + + ori $2, $0, 8 + or $4, $0, $17 + ori $5, $0, 16 + syscall + + # printf("%s", ch1) + or $4, $0, $16 + ori $2, $0, 4 + syscall + # min_to_maj_chaine(ch1) + addiu $29, $29, -4 + or $4, $0, $16 + sw $4, 0($29) + jal min_to_maj_chaine + # printf("%s", ch1) + or $4, $0, $16 + ori $2, $0, 4 + syscall + + # printf("%s", ch2) + or $4, $0, $17 + ori $2, $0, 4 + syscall + # min_to_maj_chaine(ch2) + or $4, $0, $17 + sw $4, 0($29) + jal min_to_maj_chaine + # printf("%s", ch2) + or $4, $0, $17 + ori $2, $0, 4 + syscall + + addiu $29, $29, 8 + ori $2, $0, 10 + syscall + +min_to_maj_chaine: + addiu $29, $29, -8 + sw $31, 4($29) +while: + # while ch[i] != 0 + lb $9, 0($4) + beq $9, $0, end_while + # if ch[i] >= 'a' + sltiu $10, $9, 'a' + bne $10, $0, end_if + # if ch[i] <= 'z' + ori $10, $0, 'z' + sltu $10, $10, $9 + bne $10, $0, end_if + # ch[i] - 0x20 + addiu $9, $9, -0x20 + sb $9, 0($4) +end_if: + addiu $4, $4, 1 + j while +end_while: + lw $31, 4($29) + addiu $29, $29, 8 + jr $31 diff --git a/semestre 3/architecture des ordinateurs/tme/tme7/exo2-q2.asm b/semestre 3/architecture des ordinateurs/tme/tme7/exo2-q2.asm new file mode 100644 index 0000000..92a960e --- /dev/null +++ b/semestre 3/architecture des ordinateurs/tme/tme7/exo2-q2.asm @@ -0,0 +1,59 @@ +.data +# on n'utilise pas cette chaƮne, mais elle fait partie du code +ch: .asciiz "1 exemple d'exemple\n" # @ 0x1001 0000 +.text +# main + addiu $29, $29, -24 + # int i = 0 + sw $0, 20($29) + # ch = 4($29) + addiu $16, $29, 4 + ori $2, $0, 8 + or $4, $0, $16 + ori $5, $0, 16 + syscall + # printf("%s", ch) + or $4, $0, $16 + ori $2, $0, 4 + syscall + + or $17, $0, $16 +while: + # while ch[i] != 0 + lb $9, 0($17) + beq $9, $0, end_while + # ch[i] = min_to_maj_char(ch[i]) + sw $9, 0($29) + or $4, $0, $9 + jal min_to_maj_char + sb $2, 0($17) + # i++ + addiu $17, $17, 1 + j while +end_while: + # printf("%s", ch) + or $4, $0, $16 + ori $2, $0, 4 + syscall + + addiu $29, $29, 24 + ori $2, $0, 10 + syscall + +min_to_maj_char: + addiu $29, $29, -8 + sw $31, 4($29) + # if ch[i] >= 'a' + sltiu $10, $4, 'a' + bne $10, $0, end_if + # if ch[i] <= 'z' + ori $10, $0, 'z' + sltu $10, $10, $4 + bne $10, $0, end_if + # c - 0x20 + addiu $4, $4, -0x20 +end_if: + lw $31, 4($29) + or $2, $0, $4 + addiu $29, $29, 8 + jr $31 diff --git a/semestre 3/architecture des ordinateurs/tme/tme7/exo2-q3.asm b/semestre 3/architecture des ordinateurs/tme/tme7/exo2-q3.asm new file mode 100644 index 0000000..2b1d363 --- /dev/null +++ b/semestre 3/architecture des ordinateurs/tme/tme7/exo2-q3.asm @@ -0,0 +1,57 @@ +.data +.text +# main + addiu $29, $29, -24 + # int i = 0 + sw $0, 20($29) + # ch = 4($29) + addiu $16, $29, 4 + ori $2, $0, 8 + or $4, $0, $16 + ori $5, $0, 16 + syscall + # printf("%s", ch) + or $4, $0, $16 + ori $2, $0, 4 + syscall + + or $17, $0, $16 +while: + # while ch[i] != 0 + lb $9, 0($17) + beq $9, $0, end_while + # ch[i] = min_to_maj_char(&(ch[i])) + sw $9, 0($29) + or $4, $0, $17 + jal min_to_maj_ptr_char + # i++ + addiu $17, $17, 1 + j while +end_while: + # printf("%s", ch) + or $4, $0, $16 + ori $2, $0, 4 + syscall + + addiu $29, $29, 24 + ori $2, $0, 10 + syscall + +min_to_maj_ptr_char: + addiu $29, $29, -8 + sw $31, 4($29) + # if ch[i] >= 'a' + lb $8, 0($4) + sltiu $10, $8, 'a' + bne $10, $0, end_if + # if ch[i] <= 'z' + ori $10, $0, 'z' + sltu $10, $10, $8 + bne $10, $0, end_if + # c - 0x20 + addiu $8, $8, -0x20 + sb $8, 0($4) +end_if: + lw $31, 4($29) + addiu $29, $29, 8 + jr $31 -- cgit v1.2.3