aboutsummaryrefslogtreecommitdiff
path: root/semestre 3/architecture des ordinateurs/tme/tme5
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2025-11-01 13:27:41 +0100
committerAnhgelus Morhtuuzh <william@herges.fr>2025-11-01 13:27:41 +0100
commit341fc63ff791e08c7d0a00346080067c9bd1d5dd (patch)
tree817638957893aa4899da4386483a29baa6e99151 /semestre 3/architecture des ordinateurs/tme/tme5
parentb47e5b1518d7089a2f6fdba439cf35dcf29e6089 (diff)
Cours du 17 au 21 octobre
Diffstat (limited to 'semestre 3/architecture des ordinateurs/tme/tme5')
-rw-r--r--semestre 3/architecture des ordinateurs/tme/tme5/exo1.asm33
-rw-r--r--semestre 3/architecture des ordinateurs/tme/tme5/exo2.asm33
-rw-r--r--semestre 3/architecture des ordinateurs/tme/tme5/exo3.asm17
-rw-r--r--semestre 3/architecture des ordinateurs/tme/tme5/exo4.asm29
-rw-r--r--semestre 3/architecture des ordinateurs/tme/tme5/exo5.asm24
5 files changed, 136 insertions, 0 deletions
diff --git a/semestre 3/architecture des ordinateurs/tme/tme5/exo1.asm b/semestre 3/architecture des ordinateurs/tme/tme5/exo1.asm
new file mode 100644
index 0000000..4337468
--- /dev/null
+++ b/semestre 3/architecture des ordinateurs/tme/tme5/exo1.asm
@@ -0,0 +1,33 @@
+.data
+p: .word 0 # 0x1001 0000
+q: .word 0 # 0x1001 0004
+.text
+ lui $8, 0x1001 # $8 <- 0x1001 0000
+ ori $2, $0, 5
+ syscall
+ lui $8, 0x1001 # $8 <- 0x1001 0000
+ sw $2, 0($8)
+ ori $2, $0, 5
+ syscall
+ lui $8, 0x1001 # $8 <- 0x1001 0000
+ sw $2, 4($8)
+
+ lw $12, 0($8) # p
+ lw $13, 4($8) # q
+ or $10, $0, $12 # i
+ ori $11, $0, 0 # somme
+for:
+ # i+1 > q
+ addiu $14, $10, 1
+ slt $15, $13, $14
+ bne $15, $0, end_for
+ addu $11, $11, $10 # somme += i
+ addiu $10, $10, 1
+ j for
+end_for:
+ ori $2, $0, 1
+ or $4, $0, $11
+ syscall
+
+ ori $2, $0, 10
+ syscall \ No newline at end of file
diff --git a/semestre 3/architecture des ordinateurs/tme/tme5/exo2.asm b/semestre 3/architecture des ordinateurs/tme/tme5/exo2.asm
new file mode 100644
index 0000000..00354a7
--- /dev/null
+++ b/semestre 3/architecture des ordinateurs/tme/tme5/exo2.asm
@@ -0,0 +1,33 @@
+.data
+a: .word 0 # 0x1001 0000
+b: .word 0 # 0x1001 0004
+.text
+ lui $8, 0x1001 # $8 <- 0x1001 0000
+ ori $2, $0, 5
+ syscall
+ lui $8, 0x1001 # $8 <- 0x1001 0000
+ sw $2, 0($8)
+ ori $2, $0, 5
+ syscall
+ lui $8, 0x1001 # $8 <- 0x1001 0000
+ sw $2, 4($8)
+
+ lw $9, 0($8) # tmpa
+ lw $10, 4($8) # tmpb
+while:
+ beq $9, $10, end_while
+ # tmpb < tmpa -> else
+ slt $11, $10, $9
+ beq $11, $0, else
+ subu $9, $9, $10
+ j end_if
+else:
+ subu $10, $10, $9
+end_if:
+ j while
+end_while:
+ ori $2, $0, 1
+ or $4, $0, $9
+ syscall
+ ori $2, $0, 10
+ syscall \ No newline at end of file
diff --git a/semestre 3/architecture des ordinateurs/tme/tme5/exo3.asm b/semestre 3/architecture des ordinateurs/tme/tme5/exo3.asm
new file mode 100644
index 0000000..715303b
--- /dev/null
+++ b/semestre 3/architecture des ordinateurs/tme/tme5/exo3.asm
@@ -0,0 +1,17 @@
+.data
+ch: .asciiz "Bonjour, je suis une licorne avec des pouvoirs magiques :D" # len(ch) 58
+.text
+ lui $8, 0x1001
+ ori $9, $0, 0 # n
+while:
+ lb $10, 0($8)
+ beq $10, $0, end_while
+ addiu $9, $9, 1
+ addiu $8, $8, 1
+ j while
+end_while:
+ ori $2, $0, 1
+ or $4, $0, $9
+ syscall
+ ori $2, $0, 10
+ syscall \ No newline at end of file
diff --git a/semestre 3/architecture des ordinateurs/tme/tme5/exo4.asm b/semestre 3/architecture des ordinateurs/tme/tme5/exo4.asm
new file mode 100644
index 0000000..bac6a30
--- /dev/null
+++ b/semestre 3/architecture des ordinateurs/tme/tme5/exo4.asm
@@ -0,0 +1,29 @@
+.data
+val: .word 70
+tab: .word 42, 69, 420, 666, 1, 2, 0, -1
+.text
+ lui $8, 0x1001
+ ori $9, $0, 0 # n
+ lw $12, 0($8)
+ addiu $8, $8, 4
+ # cond d'arrĂȘt
+ or $13, $0, $0
+ ori $14, $0, 1
+ subu $13, $13, $14
+while:
+ # while tab[i] != '\0'
+ lw $10, 0($8)
+ beq $10, $13, end_while
+ slt $11, $10, $12
+ # if tab[i] < val
+ beq $11, $0, end_if
+ addiu $9, $9, 1
+end_if:
+ addiu $8, $8, 4
+ j while
+end_while:
+ ori $2, $0, 1
+ or $4, $0, $9
+ syscall
+ ori $2, $0, 10
+ syscall \ No newline at end of file
diff --git a/semestre 3/architecture des ordinateurs/tme/tme5/exo5.asm b/semestre 3/architecture des ordinateurs/tme/tme5/exo5.asm
new file mode 100644
index 0000000..1ca188b
--- /dev/null
+++ b/semestre 3/architecture des ordinateurs/tme/tme5/exo5.asm
@@ -0,0 +1,24 @@
+.data
+n: .word 123
+.text
+ lui $8, 0x1001
+ lw $9, 0($8)
+
+ ori $11, $0, 1
+ ori $10, $0, 31
+ ori $13, $0, 0
+while:
+ bltz $10, end_while
+ srlv $12, $9, $10
+ andi $12, $12, 1
+ beq $12, $0, end_if
+ addiu $13, $13, 1
+end_if:
+ subu $10, $10, $11
+ j while
+end_while:
+ ori $2, $0, 1
+ or $4, $0, $13
+ syscall
+ ori $2, $0, 10
+ syscall \ No newline at end of file