home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 January / Chip_2001-01_cd1.bin / tema / mysql / mysql-3.23.28g-win-source.exe / strings / strxmov.asm < prev    next >
Assembly Source File  |  2000-08-31  |  2KB  |  104 lines

  1. ; Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  2. ; This library is free software; you can redistribute it and/or
  3. ; modify it under the terms of the GNU Library General Public
  4. ; License as published by the Free Software Foundation; either
  5. ; version 2 of the License, or (at your option) any later version.
  6. ; This library is distributed in the hope that it will be useful,
  7. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  9. ; Library General Public License for more details.
  10. ; You should have received a copy of the GNU Library General Public
  11. ; License along with this library; if not, write to the Free
  12. ; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  13. ; MA 02111-1307, USA
  14.  
  15.     TITLE   Optimized strxmov for MSDOS / Intel 8086
  16.  
  17. ifndef M_I386
  18.     .8087
  19.     DOSSEG
  20.     .MODEL LARGE
  21.     .CODE
  22.  
  23.     PUBLIC    _strxmov
  24. _strxmov    PROC
  25.     mov    bx,sp
  26.     add    bx,4
  27.     push    si
  28.     push    di
  29.     mov    cx,ds            ; Save ds
  30. ASSUME    DS:    NOTHING
  31. ASSUME    ES:    NOTHING
  32.     les    di,DWORD PTR ss:[bx]    ; dst
  33.     jmp    next_str
  34.  
  35. start_str:
  36.     mov    al,ds:[si]
  37.     movsb                ; move arg
  38.     and    al,al
  39.     jnz    start_str        ; Not last
  40.     dec    di
  41.  
  42. next_str:
  43.     add    bx,4
  44.     lds    si,DWORD PTR ss:[bx]
  45.     mov    ax,ds
  46.     or    ax,si
  47.     jnz    start_str
  48.  
  49.     mov    byte ptr es:[di],0    ; Force end null (if no source)
  50.     mov    ds,cx
  51.     mov    ax,di            ; Return ptr to last 0
  52.     mov    dx,es
  53.     pop    di
  54.     pop    si
  55.     ret
  56. _strxmov    ENDP
  57.  
  58. else
  59.  
  60. include macros.asm
  61.  
  62.     begcode strxmov
  63.     public    _strxmov
  64.  
  65. _strxmov    PROC near
  66. ASSUME    DS:    NOTHING
  67. ASSUME    ES:    NOTHING
  68.         push    EBP
  69.         mov    EBP,ESP
  70.         mov    EDX,EBX        ; Save EBX
  71.         mov    ECX,ESI        ; Save ESI
  72.         push    EDI
  73.         mov    EDI,8[EBP]    ; Get destination
  74.         lea    EBX,8[EBP]    ; Get adress to first source - 4
  75.         xor    al,al
  76.         jmp    next_str
  77.  
  78. start_str:    movsb
  79.         cmp    AL,[EDI-1]
  80.         jne    start_str
  81.         dec    EDI        ; Don't copy last null
  82.  
  83. next_str:    add    EBX,4
  84.         mov    ESI,[EBX]
  85.         or    ESI,ESI
  86.         jne    start_str
  87.         mov    byte ptr [EDI],0    ; Force last null
  88.  
  89.         mov    EAX,EDI        ; Return ptr to null
  90.         pop    EDI
  91.         mov    ESI,ECX
  92.         mov    EBX,EDX
  93.         pop    EBP
  94.         ret
  95. _strxmov endp
  96.     endcode strxmov
  97.  
  98. endif
  99.  
  100.     END
  101.