Advertisement
kernel_memory_dump

Untitled

Apr 27th, 2014
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. void stringcmp(char* s1, char* s2, int *rez);
  4.  
  5. int main()
  6. {
  7.     int rez;
  8.     char str1[100];
  9.     char str2[100];
  10.     gets(str1);
  11.     gets(str2);
  12.     stringcmp(str1,str2,&rez);
  13.     if(rez==-1)
  14.         printf("prvi string je manji od drugog");
  15.     else if(rez==0)
  16.         printf("prvi string je veci od drugog");
  17.     else
  18.         printf("stringovi su jednaki");
  19. }
  20.  
  21.  
  22. .section .text
  23. .globl stringcmp
  24. stringcmp:
  25.     pushl %ebp
  26.     movl %esp, %ebp
  27.     movl 8(%ebp), %eax
  28.     movl 12(%ebp), %ebx
  29.     movl 16(%ebp), %edx
  30. petlja:
  31.     movb (%eax), %cl
  32.     cmpb (%ebx), %cl
  33.     ja veci
  34.     jb manji
  35.     cmpb $0, %cl
  36.     je jednaki
  37.     incl %eax
  38.     incl %ebx
  39.     jmp petlja
  40. jednaki:
  41.     movl $0, (%edx)
  42.     jmp kraj
  43. veci:
  44.     movl $1, (%edx)
  45.     jmp kraj
  46. manji:
  47.     movl $-1, (%edx)
  48. kraj:
  49.     movl %ebp, %esp
  50.     popl %ebp
  51.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement