;--------------------------------------------------- ;programmed by Billal BEGUERADJ ;www.begueradj.50megs.com ;beg.bill@yahoo.com ;--------------------------------------------------- .model small .stack .data .code ;--------------------------------------------------- ;calculate GCD ;input : bx=ax=1 ;output : ax =gcd ;--------------------------------------------------- pgcd PROC push bx push dx or ax,ax etiq1: mov dx,0 div bx cmp dx,0 je etiq2 mov ax,bx mov bx,dx jmp etiq1 etiq2: mov ax,bx pop dx pop bx ret pGCD ENDP ;-------------------------------------------------- ;end of pgcd ;-------------------------------------------------- ;-------------------------------------------------- ;display a messgae that is stored in AX ;input: ax ;output : nothing ;-------------------------------------------------- afficher_chiffre PROC push ax push dx add al,48 mov dl,al mov ah,2 int 21h pop dx pop ax ret afficher_chiffre ENDP ;-------------------------------------------------- ;end of afficher_chiffre ;-------------------------------------------------- ;-------------------------------------------------- ;display a number that is sored in AX ;input : ax ;output: nothing ;-------------------------------------------------- afficher_nombre PROC NEAR push ax push dx push bx push cx mov cx,0 mov bx,10 separation: mov dx,0 div bx ;reste dans dx, quotient dans ax push dx ;on sauvegarde ce reste inc cx ;compter le nombre de chiffres que continent notre nombre cmp ax,0 ;est-ce que le quotient est nul jnz separation ;sinon, continuer à diviser afficher: pop ax ;récupérer un chiffre depuis la pile call afficher_chiffre ;on l'affiche loop afficher ;continuer l'affichage de tous les chiffre (jusqu'à ax=0) pop ax pop dx pop bx pop cx ret afficher_nombre ENDP ;-------------------------------------------------- ;end of afficher_nombre ;-------------------------------------------------- ;-------------------------------------------------- ;main program starts here ;-------------------------------------------------- main PROC mov ax,@data mov ds,ax mov ax,100 mov bx,200 call pgcd call afficher_nombre mov ax,04c00h int 21h main ENDP END main