diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2025-10-10 23:15:18 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2025-10-10 23:15:18 +0200 |
| commit | 4ed8060318b1807638c12b8b43660bb98fc99fba (patch) | |
| tree | 976f9b6be6cfbb72c3c908e2e1e60069f5a4296a /semestre 3/architecture des ordinateurs/tme/tme4/exo4.asm | |
| parent | 85fbaa4d9381e435be129aa7bc4ea6a472acb2b2 (diff) | |
Cours du 6 au 10 octobre
Diffstat (limited to 'semestre 3/architecture des ordinateurs/tme/tme4/exo4.asm')
| -rw-r--r-- | semestre 3/architecture des ordinateurs/tme/tme4/exo4.asm | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/semestre 3/architecture des ordinateurs/tme/tme4/exo4.asm b/semestre 3/architecture des ordinateurs/tme/tme4/exo4.asm new file mode 100644 index 0000000..28a4c30 --- /dev/null +++ b/semestre 3/architecture des ordinateurs/tme/tme4/exo4.asm @@ -0,0 +1,31 @@ +# "123456" = 0x31 32 33 34 35 36 00 +.data +cod: .byte 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x00 +.text + lui $8, 0x1001 + ori $2, $0, 4 + or $4, $0, $8 + syscall + + lb $16, 2($8) + or $4, $0, $16 + ori $2, $0, 1 + syscall + + # "0" est représenté par 0x30 + # les autres chiffres sont à la suite de 0x30 jusqu'à 0x39 ("9") + # pour transformer le code ASCII d'un chiffre en chiffre, il suffit donc de lui soustraire 0x30 pour obtenir le chiffre + + # on a besoin de mettre 0x30 dans un registre car l'opcode subi n'existe pas + ori $9, $0, 0x30 + sub $17, $16, $9 + or $4, $0, $17 + syscall + + ori $18, $0, 0x34 # est l'ascii de "4" + sub $18, $18, $9 + or $4, $0, $18 + syscall + + ori $2, $0, 10 + syscall
\ No newline at end of file |
