Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- char reference[]={"aeiou"};
- char chaine[]={'a','e','i','o','u','e','f','i'};
- unsigned char num_voyalles(0);
- asm(
- "xor %[num],%[num] \n\t"
- "lea %[chaine],%%rcx \n\t" /* cible une chaine de chars */
- "lea %[reference],%%rdx \n\t"
- "\n init :\n\t"
- "cmpb $0,(%%rcx) \n\t"/*il est arrive à la fin ?*/
- "jz fin \n\t"
- "movb (%%rdx) ,%%ah \n\t"/* charge voyal reference */
- "cmpb %%ah,(%%rcx) \n\t"/* exist dans l'index de la chaine ?*/
- "jz augmenter \n\t"/* oui ,augmente */
- "inc %%rdx \n\t"/* ++pointeur reference */
- "cmpb $0,(%%rdx) \n\t"/*reference est arrive à la fin ?*/
- "je normal \n\t"/* non donc continue normalement */
- "jmp init \n\t"
- "\n normal: \n\t"
- "lea %[reference],%%rdx \n\t"/* oui , reset index reference au debut*/
- "inc %%rcx \n\t"/* incremente l'index de la chaine */
- "jmp init \n\t"/* saute au debut */
- "\n augmenter: \n\t"/* aeiou trouve incremente num */
- "inc %[num] \n\t"
- "inc %%rcx \n\t"/* incremente l'index de la chaine */
- "lea %[reference],%%rdx \n\t"/* index reference au debut */
- "jmp init \n\t "/* saute au debut */
- "fin: \n\t"
- :[num] "=g"(num_voyalles) /* output */
- :[chaine]"m"(chaine),[reference]"m"(reference) /* input */
- :
- );
- cout <<"num de voyalles "<<(int) num_voyalles <<endl;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement