.model small .stack 100h .data commande db 10,13,"saisir une phrase$" msg1 db 10,13,"la chaine set vide$" msg2 db 10,13,"la taille de la chaine saisie est$" msg5 db 10,13, "le nombre de separateur est:$" msg4 db 10,13, "la longueur du mot le plus long est:$" msg6 db 10,13, "le mot le plus long dans votre chaine est$" taille dw 0 chaine dw ? .code saisir_chaine_et_taille macro chaine,taille,msg2,msg1 local repeter,vide mov si,0 repeter: inc si inc taille mov ah,1 int 21h mov chaine[si],al cmp chaine[si],"#" je vide jne repeter mov ah,9 mov dx,offset msg 2 int 21h mov dx,taille mov ah,2 int 21h mov ah,4ch mov al,0 int 21h vide: mov ah,9 mov dx,offset msg1 int 21h endm nombre_mot macro chaine,nbm local boucle_pour_chaque_caractere,mot_trouve mov nbm,0 mov bx, OFFSET chaine boucle_pour_chaque_caractere: mov al, BYTE PTR [bx] cmp al,20h je mot_trouve inc bx cmp al, '$' jnz boucle_pour_chaque_caractere mov ax,nbm mov ah,9 int21h mot_trouve: inc nbm endm longueur macro chaine,msg6,t_max local calcul_longueur_mot,oui_separateur,re_initialisation,incrementation, stockage mov ah,9 mov dx,offset msg4 int 21h mov t_max,0 mov cx,n mov si,0 mov p,0 calcul_longueur_mot: test_si_separateur: cmp chaine[si],' ' je oui_separateur cmp chaine[si],';' je oui_separateur cmp chaine[si],',' je oui_separateur cmp chaine[si],'.' je oui_separateur cmp chiane[si],':' je oui_separateur cmp chaine[si],'-' je oui_separateur jne non_separateur oui_separateur: mov bx,p cmp bx,t_max ja stockage jbe re_initialisation stockage: mov bx,p mov t_max,ax mov indice_mot,si mov p,0 mov ah,9 mov dx,offset msg6 int 21h sub indice_mot,t_max mov cx,t_max mov ah,2 mov si,indice_mot le_mot_plus_long: mov dl,chaine[si] int 21h inc si loop le_mot_plus_long jmp incrementation re_initialisation: mov p,0 incrementation: inc si loop calcul_longueur_mot nombre_separateur macro chaine,taille,sep,msg5, local repete13,condition13,incrementation mov si,offset chaine mov sep,0 mov cx,taille repete13: mov al,byte ptr[si] cmp al,';' je separateur cmp al,' ' je separateur cmp al,',' je separateur cmp al,'.' je separateur jmp incrementation separateur: inc sep incrementation: inc si loop repete13 mov dx,offset msg5 affiche_msg mov ax,sep affiche_entier mov dx,offset entre affiche_msg endm main proc mov ax,@data mov ds, ax saisir_chaine_et_taille chaine,taille,msg2,msg1 nombre_mot chaine,nbm longueur chaine,msg6,t_max nombre_separateur chaine,sep,msg5,taille main endp end main
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
main proc
mov ax,@data
mov ds, ax
saisir_chaine_et_taille chaine,taille,msg2,msg1
nombre_mot chaine,nbm
longueur chaine,msg6,t_max
nombre_separateur chaine,sep,msg5,taille
RET ;<<<<<<<<<
main endp
mov indice_mot,0 \\indice du mot le plus long mov bx,chaine[si] \\l'indice du mot courant mov t_max,0 \\ longueur du mot le plus long mov cx,0 \\ la longueur du mot courant mov si,offset chaine scrute: cmp byte ptr[ds:si],35 \\comparaison avec # qui marque la fin de la chaine jz findescrutation cmp byte ptr[ds:si],20h \\comp avec les espaces je separateur inc si inc cx separateur: cmp t_max,cx jge stockage stockage: mov t_max,cx \\ stckage de la nouvelle longueur mov indice_mot,bx \\stockage du nouveau indice mov bx,chaine[si+2] mov cx,0 jmp scrute findescrutation: \\traitement du dernier mot et affichage mov bx,chaine[si+2] cmp t_max,cx jge stock mov ah,9 mov dx,offset msg3 int 21h mov cx,t_max mov ah,2 int 21h mov ah,9 mov dx,offset msg6 int 21h mov dx,bx mov ah,2 int 21h