1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
| .MODEL small ;programme qui comporte maximum un segment de 64 bit
.STACK 512 ;zone de la pile, zone memoire 512 octets
;---------------DONNEES-------------------------------------------------------------------------;
.DATA
TITRE DB 10,13,"EXERCICE 2 :",10,"Multiplication de deux nombres",10,"de 0 ---> 99 et de 0 ---> 9",'$'
DEM1 DB 10,10,13,"Nombre 1 : ",'$'
DEM2 DB 10,"Nombre 2 : ",'$'
RESULTAT DB 10,10,"Resultat : ",'$'
NBRE1 db 3, 4 dup(?),'$'
NBRE2 db 4 dup(?),'$'
tmp db ?
tmp2 dw ?
RESULT db 4 dup(?),10,'$'
rest1 db 0,'$'
rest2 db 0,'$'
rest3 db 0,'$'
divi dw 10,'$'
multi db 10,'$'
;---------------CODE-----------------------------------------------------------------------------;
.CODE
mov ax,@data ;Contient l'adresse du debut du data segment
mov ds,ax ;set DS to point to the data segment
lea dx,TITRE ;Affichage du Titre
mov ah,09h
int 21h
lea dx,DEM1 ;Affichage de la demande pour le nombre 1
mov ah,09h
int 21h
mov dx, offset NBRE1 ;enregistre le premier chiffre
mov ah, 0Ah
int 21h
sub NBRE1+2,30h ;conversion -> ascii
sub NBRE1+3,30h
mov al, NBRE1+2 ;mise en forme du premier chiffre
mul multi
mov NBRE1+2, al
add al, NBRE1+3
mov tmp, al
mov dx,OFFSET DEM2 ;affichage de la demande du 2eme chiffre
mov ah,09h
int 21h
mov ah,1 ;Récupere le deuxieme nombre
int 21h
mov NBRE2,al
sub NBRE2,48d
mov ah, 0 ;attend qu'une touche soit pressée
int 16h
mov al, tmp ;multiplie les deux nombres
imul NBRE2
mov tmp2, ax
mov dx, 0
mov ax, tmp2
cmp ax, 0
je suite
div divi ;divise par 10
mov rest1, dl ;stock le reste
cmp ax, 0 ;si le nombre divisé par 10 est = a 0 alors on va faire la suite
je suite
div divi ;divise par 10
mov rest2, dl ;stock le reste
cmp ax, 0
je suite
div divi ;divise par 10
mov rest3, dl ;stock le reste
cmp ax, 0
je suite
suite:
add rest1, 30h
add rest2, 30h
add rest3, 30h
mov ah, rest3 ;stock les chiffres dans la chaine
mov RESULT, ah
mov ah, rest2
mov RESULT[1], ah
mov ah, rest1
mov RESULT[2], ah
mov RESULT[3],'$'
lea dx,RESULTAT ;affiche de RESULTAT
mov ah,09h
int 21h
;add RESULT,48d ;48d est egale a zero en ascii
mov ah,9 ;affichage du résultat
mov dx,OFFSET RESULT
int 21h
jmp fin
fin :
mov ah, 0 ;attend qu'une touche soi pressée
int 16h
mov ax,4c00h ;DOS terminate program function
int 21h ;terminate the program
END |
Partager