;programmed by Billal BEGUERADJ ;beg.bill@yahoo.com ;www.begueradj.50megs.com ;affichage des mots palindromes saisis dans un text. .MODEL SMALL .STACK .DATA msssg DB 'La liste des mots palindromes saise est : $' mot Struc premier_car Dw ? dernier_car Dw ? mot EndS nb_max_car_a_saisir Db 255 nb_car_saisis Db 0 buffer_du_paragraphe Db 270 dup (0) bienvenue Db 'Veuillez saisir un paragraphe: $' tableau_qui_recoit_le_paragraphe_saisi mot 160 dup (<,>) nb_de_mots_total_saisis Dw 0 tab_de_mots_plein Dw 0 compteur Dw 0 fin_de_un_mot Db '$' deux_points Db ' ----> $' retour_chariot Db 0Dh,0Ah,'$' resultat Db 0Dh,0Ah,0Dh,0Ah,'Le nombre de palindromes saisis est: $' .CODE effacer_ecran PROC PUSH AX PUSH CX MOV AX,0003H INT 10H POP CX POP AX RET effacer_ecran ENDP affichage PROC PUSH BX PUSH DX MOV DX,OFFSET [retour_chariot] MOV AH, 9 INT 21H POP DX MOV AX,DX MOV DX,OFFSET [deux_points] MOV AH, 9 INT 21H POP BX MOV DI, [BX].dernier_car MOV AL, '$' MOV [DI],AL MOV DX,[BX].premier_car MOV AH, 9 INT 21H RET affichage ENDP traduire_heximal_en_decimal PROC MOV BX, OFFSET [fin_de_un_mot-1] MOV CX, 10 conversion: XOR DX, DX DIV CX ADD DL, '0' MOV [BX], DL DEC BX CMP AX,0 JNZ conversion MOV DX,BX INC DX RET traduire_heximal_en_decimal ENDP verifier_si_cest_un_palindrome PROC MOV SI, [BX].premier_car MOV DI, [BX].dernier_car DEC DI comparer_premier_et_dernier_car: MOV AL, [SI] CMP AL, [DI] JNE non_palindrome DEC DI INC SI CMP SI,DI JBE comparer_premier_et_dernier_car STC RET non_palindrome: CLC RET verifier_si_cest_un_palindrome ENDP distinguer_traiter_et_separer_les_mots PROC MOV SI,OFFSET [buffer_du_paragraphe] MOV DI,OFFSET [tableau_qui_recoit_le_paragraphe_saisi] XOR CX,CX XOR DX, DX lire_car_a_partir_du_buffer: MOV AL, [SI] CMP AL, 0Dh JE fin CMP AL,'/' JE non_alphabet CMP AL,'&' JE non_alphabet CMP AL,'~' JE non_alphabet CMP AL,'(' JE non_alphabet CMP AL,')' JE non_alphabet CMP AL,'{' JE non_alphabet CMP AL,'}' JE non_alphabet CMP AL,'[' JE non_alphabet CMP AL,']' JE non_alphabet CMP AL,';' JE non_alphabet CMP AL,',' JE non_alphabet CMP AL,':' JE non_alphabet CMP AL,'.' JE non_alphabet CMP AL,'+' JE non_alphabet CMP AL,'-' JE non_alphabet CMP AL,'*' CMP AL, 20h JE non_alphabet CMP AL,'0' JGE verifier_si_inf_a_neuf verifier_si_inf_a_neuf: CMP AL,'9' JBE non_alphabet TEST DX,DX JNZ le_car_suivant MOV [DI].premier_car,SI INC DX JMP le_car_suivant non_alphabet: TEST DX,DX JZ le_car_suivant CMP CX, 160 JE on_a_atteint_la_fin_du_tableau DEC DX MOV [DI].dernier_car, SI INC CX ADD DI, TYPE mot le_car_suivant: INC SI JMP lire_car_a_partir_du_buffer on_a_atteint_la_fin_du_tableau: INC tab_de_mots_plein fin: MOV nb_de_mots_total_saisis, CX RET distinguer_traiter_et_separer_les_mots ENDP compte_rendu PROC MOV CX, nb_de_mots_total_saisis MOV BX, OFFSET [tableau_qui_recoit_le_paragraphe_saisi] mot_suivant: PUSH CX CALL verifier_si_cest_un_palindrome JNC passer_au_mot_suivant INC compteur MOV DX, compteur PUSH BX CALL affichage POP BX passer_au_mot_suivant: ADD BX, TYPE mot POP CX LOOP mot_suivant MOV DX,OFFSET [resultat] MOV AH, 9 INT 21H MOV AX,compteur CALL traduire_heximal_en_decimal ;afficher le nombre de pal MOV AH, 9 INT 21H RET compte_rendu ENDP main PROC MOV AX, @DATA MOV DS,AX CALL effacer_ecran MOV DX, OFFSET [bienvenue] MOV AH, 9 INT 21h MOV DX, OFFSET [nb_max_car_a_saisir] MOV AH, 0AH INT 21H MOV SI, OFFSET [buffer_du_paragraphe] MOV BL, nb_car_saisis XOR BH,BH MOV AL, ' ' MOV [BX+SI], AL MOV AL, 0Dh INC SI MOV [BX+SI], AL CALL distinguer_traiter_et_separer_les_mots MOV DX,OFFSET[retour_chariot] MOV AH, 9 INT 21H MOV DX,OFFSET[retour_chariot] MOV AH, 9 INT 21H MOV DX,OFFSET[retour_chariot] MOV AH, 9 INT 21H MOV DX,OFFSET[msssg] MOV AH, 9 INT 21H MOV DX,OFFSET[retour_chariot] MOV AH, 9 INT 21H CALL compte_rendu MOV DX,OFFSET[retour_chariot] MOV AH, 9 INT 21H MOV DX,OFFSET[retour_chariot] MOV AH, 9 INT 21H MOV AX, 4C00H INT 21H main ENDP END main