Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- //string reverse
- int main(){
- char *x = "ala ma kota";
- char *y;
- // assembler
- asm volatile(
- ".intel_syntax noprefix;"
- "mov si,OFFSET *x;"
- "cld;"
- "repne scasb;"
- "dec di"
- "reverse:"
- "mov al, [si];"
- "mov bl, [di];"
- "mov [si], bl;"
- "mov [di], al;"
- "inc si;"
- "dec di;"
- "cmp di, si;"
- "jae reverse;"
- "mov %0, %1;"
- ".att_syntax prefix;"
- :"=r"(*y)
- :"r"(*x)
- :"eax","edx","ebx","ecx","di","si"
- );
- printf("y=%d\n",*y);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement