Probl avec un code (rectification)

marooh Messages postés 130 Statut Membre -  
marooh Messages postés 130 Statut Membre -
Bonjour,
j'ai ecrit un code assembleur qui permet de trouver le mmot le plus long dans une chaine de caractere mais ça ne fonctionne pas.si vous pouvez bien m'aider
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 chaine[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


1 réponse

  1. marooh Messages postés 130 Statut Membre
     
    En tout cas j'ai ecrit un nouveau code pour la fonction qui cherche le mot le plus long et je demande des rectifications:
    je n'ai pas su comment faire pour afficher le mot le plus long
    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
    0