Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
  2. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  3. /* Modified by SET to copy in reverse order */
  4. # This routine moves %ecx bytes from %ds:%esi to %es:%edi.  It clobbers
  5. # %eax, %ecx, %esi, %edi, and eflags.
  6. #include <libc/asmdefs.h>
  7. #include<libc/asm.h>
  8.  
  9.         .file "djmdr.s"
  10.         .text
  11.         .balign 16,,7
  12. MK_C_SYM(__dj_movedata_rev)
  13.         std
  14.         # Add the counter to the index
  15.         addl    %ecx,%edi
  16.         addl    %ecx,%esi
  17.         decl    %esi
  18.         decl    %edi
  19.  
  20.         cmpl    $15,%ecx
  21.         jle     small_move
  22.         jmp     mod_4_check
  23.        
  24.         # Transfer bytes until either %esi or %edi is aligned % 3
  25. align_mod_4:   
  26.         movsb
  27.         decl    %ecx
  28. mod_4_check:
  29.         movl    %esi,%eax
  30.         andl    $3,%eax
  31.         cmpl    $3,%eax
  32.         jz big_move
  33.         movl    %edi,%eax
  34.         andl    $3,%eax
  35.         cmpl    $3,%eax
  36.         jnz     align_mod_4
  37.  
  38. big_move:
  39.         movb    %cl,%al  # We will store leftover count in %al
  40.         shrl    $2,%ecx
  41.         andb    $3,%al
  42.         # Now retrocess the index 3 positions
  43.         subl    $3,%edi
  44.         subl    $3,%esi
  45.         rep
  46.         movsl
  47.  
  48.         # %ecx known to be zero here, so insert the leftover count in %al
  49.         movb    %al,%cl
  50.  
  51.         # advance the index by 3
  52.         addl    $3,%edi
  53.         addl    $3,%esi
  54.  
  55. small_move:
  56.         rep
  57.         movsb
  58.         ret
  59.