Advertisement
dllbridge

Untitled

Mar 19th, 2024
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.57 KB | None | 0 0
  1.  
  2.  
  3.  
  4. #include    <stdio.h>
  5. //#include   <string.h>
  6.  
  7.  
  8.  
  9.  
  10. char* _strcpy(char* _s, const char* _d);
  11.  
  12. char sz1[99] = "SONY ",
  13.      sz2[99] = "Pictures 222";
  14.  
  15. ////////////////////////////////////////////////////
  16. int main()
  17. {
  18.  
  19.     printf("sz1 = %s \n", sz1);
  20.    
  21.     char *p =_strcpy(sz1, sz2);
  22.     printf("1address p = %d \n ", &p);         
  23.     printf("sz1 = %s \n ", p);  
  24.  
  25. return 0;
  26. }
  27.  
  28.  
  29. /////////////////////////////////////////////////////////
  30. char* _strcpy(char *s1, const char *s2)
  31. {
  32.     int i = 0;
  33.    
  34.     char *p = s1;
  35.     printf("2address p = %d \n ", &p);
  36.    
  37.     while(s2[i])
  38.     {
  39.        
  40.         s1[i] = s2[i];
  41.         i ++;  
  42.     }
  43.        
  44.      s1[i] = 0;  
  45.      
  46. return p;    
  47. }
  48.  
  49.  
  50.  
  51. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  52.  
  53.  
  54.  
  55. #include    <stdio.h>
  56. #include   <string.h>
  57.  
  58.  
  59. char* _strcpy(char* _s, const char* _d);
  60.  
  61. char sz1[99] = "SONY ",
  62.      sz2[99] = "Pictures_982143";
  63.  
  64. ////////////////////////////////////////////////////
  65. int main()
  66. {
  67.    
  68.     char *psz2 = _strcpy(sz1, sz2);
  69.                
  70.     printf("sz1 = %s \n ", psz2);  
  71.  
  72. return 0;
  73. }
  74.  
  75.  
  76. /////////////////////////////////////////////////////////
  77. char* _strcpy(char *_s1, const char *_s2)
  78. {
  79.        
  80.      __asm  // - - - - - - - - - - - - -
  81.        {                 mov  esi, _s2
  82.                          mov  edi, _s1
  83.                          mov  ebx, _s1
  84.             L_01:        mov   al, [esi]
  85.                          mov [edi], al
  86.                          or    al, 0
  87.                          jz    L_02
  88.                          inc   esi
  89.                          inc   edi
  90.                          jmp   L_01
  91.             L_02:        mov  eax, ebx
  92.        };   // - - - - - - - - - - - - -
  93.  
  94. }
  95.  
  96.  
  97.  
  98.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement