Advertisement
Guest User

aaa

a guest
Oct 31st, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4. char *s = "Abcaabdsaa"; //char * s = "Abcdefg";
  5. char t[]={0};
  6. //short int y;
  7. short int a=0;
  8. //char t[]={0,0,0,0,0,0,0,0};
  9. asm volatile(
  10. ".intel_syntax noprefix;"
  11. "mov ecx,%0;"
  12. "mov edx,2;"
  13. "mov ebx,1;"
  14. "mov eax,4;"
  15.  
  16.  
  17. "mov al,[ecx];"
  18. "cmp al,'a';"
  19. "je dodaj;"
  20. "dodaj:"
  21. "inc cx;"
  22.  
  23. //"int 0x26;"
  24.  
  25. ".att_syntax prefix;"
  26. :
  27. :"r"(s)
  28. :"ebx","ecx","edx","eax"
  29.  
  30. );
  31.  
  32. printf("\n s= %s %i",s,a);
  33.  
  34. }
  35.  
  36.  
  37.  
  38. #include <stdio.h>
  39.  
  40. int main(){
  41. char s[] = "Abcdefg"; //char * s = "Abcdefg";
  42. //short int y;
  43. char t[]={0,0,0,0,0,0,0,0};
  44. asm volatile(
  45. ".intel_syntax noprefix;"
  46. /* "mov ebx,%1;"
  47. "xor cx,cx;" //"mov cx,0;"
  48.  
  49.  
  50. "petla:"
  51. "mov al,[ebx];"
  52. "cmp al,0;"//"sub al,0;"
  53. "jz koniec;"
  54.  
  55. "inc cx;"
  56. "inc ebx;"
  57. "jmp petla;"
  58.  
  59.  
  60. "koniec:"
  61.  
  62. "mov %0,cx;"
  63. "mov ebx,%1;"
  64. "call zliczznaki;"
  65. //"push ax;" //naprawienie ax
  66. "mov %0,cx;"
  67. "jmp wyjscie;"
  68. "zliczznaki:"
  69. "xor cx,cx;"
  70. "petla:"
  71. "mov al,[ebx];"
  72. "cmp al,0;"
  73. "jz koniec;"
  74. "inc cx;"
  75. "inc ebx;"
  76. "jmp petla;"
  77. "koniec:"
  78. // "pop ax;"
  79. "ret;"
  80. "wyjscie:"
  81.  
  82. skutki uboczne : zniszcznie al
  83.  
  84. */
  85. //nowy prog
  86. "mov ebx,%0;"
  87. "mov ecx,%1;"
  88. "call przepiszznak;"
  89. "inc ebx;"
  90. "inc ecx;"
  91. "call przepiszznak;"
  92. // do domu ma przepisac male na duze i duze na male
  93. "jmp wyjscie;"
  94. "przepiszznak:"
  95. "push ax;"
  96. "mov al,[ebx];"
  97. "mov [ecx],al;"
  98. "pop ax;"
  99. "ret;"
  100. "wyjscie:"
  101. ".att_syntax prefix;"
  102. :
  103. :"r"(s),"r"(t)
  104. :"ebx","ecx"
  105. //pierwszy program
  106. //:"=r" (y)
  107. //: "r" (s)
  108. //: "ebx","cx","al"
  109. );
  110.  
  111. printf("\n s= %s y= %s \n",s,t);
  112.  
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement