Advertisement
Guest User

Untitled

a guest
Oct 29th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.     char s[] = "jebac tego asemblera";
  5.     char *y;
  6.  
  7.     asm volatile(
  8.         ".intel_syntax noprefix;"
  9.         "mov edx, %1;"
  10.         "mov ebx, %1;"
  11.         "xor ecx, ecx;"
  12.  
  13.         "loop:"
  14.             "mov al, [ebx];"
  15.             "cmp al, 0;"
  16.             "je xd;"
  17.             "inc ebx;"
  18.             "inc ecx;"
  19.             "jmp loop;"
  20.  
  21.         "xd:"
  22.             "dec ebx;"
  23.             "shr ecx, 1;"
  24.  
  25.         "reverseLoop:"
  26.             "mov al, [edx];"
  27.             "mov ah, [ebx];"
  28.             "mov [ebx], al;"
  29.             "mov [edx], ah;"
  30.             "inc edx;"
  31.             "dec ebx;"
  32.             "dec ecx;"
  33.             "jnz reverseLoop;"
  34.  
  35.         ".att_syntax prefix;"
  36.         :"=r"(y)
  37.         :"r"(s)
  38.         :"ebx", "ecx", "edx"
  39. );
  40.  
  41.     printf("%s\n", s);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement