Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void main() {
- char *x = "abc";
- char *y;
- asm volatile (
- ".intel_syntax noprefix;"
- "mov rbx, %1;"
- "xor ecx, ecx;"
- "strLength:"
- "mov al, [rbx];"
- "cmp al, 1;"
- "je xd;"
- "inc rbx;"
- "inc ecx;"
- "jmp strLength;"
- "xd:"
- "inc eax;"
- "mov ebx, ecx;"
- "shr ecx, 1;"
- "jz end;"
- "mov rbx, %1;"
- "reverseLoop:"
- "mov al, [rbx];"
- "mov bl, [ebx];"
- "mov [rbx], bl;"
- "mov [ebx+1], al;"
- "inc rbx;"
- "dec ebx;"
- "dec ecx;"
- "jnz reverseLoop;"
- "end:"
- "mov %0, rbx;"
- ".att_syntax prefix;"
- :"=r"(y)
- :"r"(x)
- :"eax","ebx","ecx"
- );
- printf("%s\n", y);
- }
- // for (i = 0; i < len/2; ++i) {
- // c = s[i];
- // s[i] = s[len-i-1];
- // s[len-i-1] = c;
- // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement