diff options
author | biouman <> | 2001-04-16 01:14:59 +0000 |
---|---|---|
committer | biouman <> | 2001-04-16 01:14:59 +0000 |
commit | 9a50f1e65b9489a1421d9c169fa9b1f9168e41bd (patch) | |
tree | b43907f99074634eeaeca5a0838bdcfcb1b78a60 /samples/sommeentiers.asm | |
parent | c9ad75bd7d192a3c21402de7d0de3bfb907ed842 (diff) |
*** empty log message ***
Diffstat (limited to 'samples/sommeentiers.asm')
-rw-r--r-- | samples/sommeentiers.asm | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/samples/sommeentiers.asm b/samples/sommeentiers.asm new file mode 100644 index 0000000..2e533a7 --- /dev/null +++ b/samples/sommeentiers.asm @@ -0,0 +1,28 @@ +;Ce programme va calculer la somme des 97 premiers entiers +.DATA +MSG DS "La somme des " +MSG2 DS " premiers entiers est égale à" +N DB 97 +ZERO DB 0 +SOMME DB 4 + +.TEXT + +.START + MOV R5,[N] ;init du compteur + MOV R1,0 ;init de R1 + MOV R2,0 ;init de R2 + +BOUCLE: ADD R1,R1,R5 ; R1=R1+R5 + AND R3,Fl,0x00000001 ; + ADD R2,R2,R3 ; R2=R2+CF + SUB R5,R5,1 ; DEC R5 + MOV R6,ZERO ; + JNE R5,R6,BOUCLE ; si R5!=0 on refait la boucle + MOV, [SOMME], R1 ; ; + MOV, [SOMME+2], R2 ;on place la valeur de la somme + MOV, [0xffffff04], MSG ;on affiche le msg et la somme + MOV, [0xffffff06], SOMME ; + MOV, [0xffffff06], SOMME+2 ; + MOV, [0xffffff04], MSG2 ; + HALT
\ No newline at end of file |