c - Assembly , no such instruction popl? -
i have code in c main tak written in assembly. idea of programm example when x = abc def ,and y = deletes word @ least 1 letter same , writes words without same letters write def. have wrotten code, gives error :
- prog.c:10: error: no such instruction: `addl $112,%esp'
- prog.c:12: error: no such instruction: `xorl %eax,%eax'
- prog.c:13: error: no such instruction: `popl %ebx'
- prog.c:16: error: no such instruction: `popl %esi'
here code :
#include <stdio.h> #include <string.h> int main(){ char *x = "asbc4a2bab "; char *y = "ab"; char bufor[100]; asm volatile ( ".intel_syntax noprefix;" "mov ecx,%0;" "push ecx;" //wrzuca na stos "mov ecx,%1;" "mov eax,%2;" "call zadanie1;" "jmp wyjscie;" "zadanie1:" "push ebp;" //wrzucamy ebp na stos "push eax;" "push ecx;" //ecx zliczanie "push edi;" //edi destination "mov ebp,esp;" //do ebp adres stosu "mov esi,[ebp+20];" //esi bezposrednio x "mov edi,[ebp+4];" //edi adres y "mov ebx,[ebp+8];"//ebx bufor "mov eax,0;"//eax false "push eax;" "push esi;" "push eax;" "etykieta_x:" "mov eax,[esp+8];" "cmp eax,0;" "je etykieta_y;" "mov [esp+4],esi;" "mov eax,0;" "mov [esp+8],eax;" //"mov [esp+4],esi;" "etykieta_y:" "mov eax,[edi];" "cmp eax,'\0';" //porownoje eax z koncem "je koniec_etykiety_x;" "add edi,1;"//zwiekszamy petle "cmp eax,[esi];"//porownoje y x "jne etykieta_y;"//wrocimy etykiety y jesli nie sa rowne "ustaw_flage:" "pop eax;" "mov eax,1;" //ustawia flage "push eax;" "koniec_etykiety_x:" "pop eax;" "cmp eax,1;" "jne iteruj_dalej;" "mov eax,0;" "push eax;" "iteruj_po_znakach:" "add esi,1;" "mov eax,[esi];" "cmp eax,'\0';" "je koniec;" "cmp eax,' ';" "je spacja_wykryta;" "jmp etykieta_x;" "spacja_wykryta:" "mov eax,1;" "mov [esp+8],eax;" "jmp iteruj_po_znakach;" "iteruj_dalej:" "mov eax,0;" "push eax;" "add esi,1;"//zwiekszamy adres "mov eax,[esi];"//pobieramhy nast zznak "cmp eax,'\0';" "je zapisz_do_bufora;" "cmp eax,' ';" "je spacja_wykryta_2;" "mov eax,[esp+8];" "cmp eax,0;" "je etykieta_x;" "jmp zapisz_do_bufora;" "spacja_wykryta_2:" "mov eax,1;" "mov [esp+8],eax;" "jmp iteruj_dalej;" "zapisz_do_bufora:" "mov eax,[esp+4];" "interuj_po_slowie:" "mov edx,[eax];" "cmp edx,' ';" "je etykieta_x;" "cmp edx, '\0';" "je etykieta_x;" "mov [ebx],edx;" "add eax,1;" "add ebx,1;" "jmp iteruj_po_slowie;" "koniec:" "pop edi;" //zdejmuje ze stosu "pop ecx;" "pop eax;" "pop ebp;" "ret;" //wyjdzie z funkcji "wyjscie:" ".att_syntax_prefix;" : :"r"(x), "r"(y), "r"(bufor) :"eax", "ecx" ); return 0; }
and here ideone link : http://ideone.com/whfedk know may wrong ? help.
it's horrible hack manually switch syntax mode in inline asm , might not work if have argument substitutions. correct way use -masm=intel
if want intel syntax.
that said, problem have typo in directive wanted restore mode: have .att_syntax_prefix
instead of .att_syntax prefix
(notice don't need underscore before prefix
).
also, '\0'
won't work, should use 0
.
and, have typo: interuj_po_slowie
vs iteruj_po_slowie
.
ps: stackoverflow english language forum, please post code in english, , comment properly.
Comments
Post a Comment