Advertisement
kreteda

Asembler zliczanie a

Oct 31st, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 0.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. void main()
  4. {
  5.     char s[] = "Abaaaaaddaaafg";   //char *s = "Abcdefg";
  6.     short int y;
  7.     asm volatile(
  8.     ".intel_syntax noprefix;"
  9.     "mov ebx,%1;"
  10.     "mov cx, 0;"
  11.     "petla:"
  12.     "mov al, [ebx];"
  13.     "sub al, 0;"
  14.     "jz koniec;"
  15.     "cmp al,97;"
  16.     "jnz skocz;"
  17.     "inc cx;"
  18.     "skocz: "
  19.    
  20.     "inc ebx;"
  21.     "jmp petla;"
  22.     "koniec:"
  23.    
  24.    
  25.     "mov %0, cx;"
  26.     ".att_syntax prefix;"
  27.     : "=r" (y)
  28.     : "r" (s)
  29.     : "ebx", "cx", "al"  
  30.    
  31.     );
  32.    
  33.     printf("s=%s, y=%hd", s, y);
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement