Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. ;*****************************************************************************
  2. ;*
  3. ;*                            Open Watcom Project
  4. ;*
  5. ;*    Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
  6. ;*
  7. ;*  ========================================================================
  8. ;*
  9. ;*    This file contains Original Code and/or Modifications of Original
  10. ;*    Code as defined in and that are subject to the Sybase Open Watcom
  11. ;*    Public License version 1.0 (the 'License'). You may not use this file
  12. ;*    except in compliance with the License. BY USING THIS FILE YOU AGREE TO
  13. ;*    ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
  14. ;*    provided with the Original Code and Modifications, and is also
  15. ;*    available at www.sybase.com/developer/opensource.
  16. ;*
  17. ;*    The Original Code and all software distributed under the License are
  18. ;*    distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  19. ;*    EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
  20. ;*    ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
  21. ;*    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
  22. ;*    NON-INFRINGEMENT. Please see the License for the specific language
  23. ;*    governing rights and limitations under the License.
  24. ;*
  25. ;*  ========================================================================
  26. ;*
  27. ;* Description:  WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
  28. ;*               DESCRIBE IT HERE!
  29. ;*
  30. ;*****************************************************************************
  31.  
  32.  
  33. ;
  34. ;  __STOSB( char *EAX, int EDX, unsigned ECX );
  35. ;  __STOSD( char *EAX, int EDX, unsigned ECX );
  36. ;
  37. include mdef.inc
  38. include struct.inc
  39.  
  40.         modstart __stos,para
  41.  
  42.         xdefp   __STOSB
  43.         xdefp   __STOSD
  44.  
  45.  
  46.         defpe   __STOSB
  47.         or      ECX,ECX                 ; if length not zero
  48.         _if     ne                      ; then
  49.           cmp   [EAX],DL                ; - access cache line
  50.           _loop                         ; - loop (get onto 4-byte boundary)
  51.             test  AL,3                  ; - - quit if on 4-byte boundary
  52.             _quif e                     ; - - ...
  53.             mov   [EAX],DL              ; - - store byte
  54.             inc   EAX                   ; - - increment address
  55.             ror   EDX,8                 ; - - (DH can be different from DL)
  56.             dec   ECX                   ; - - decrement length
  57.           _until e                      ; - until done
  58.           push  ECX                     ; - save length
  59.           shr   ECX,2                   ; - calculate number of dwords
  60.           call  __STOSD                 ; - store dwords
  61.           pop   ECX                     ; - restore length
  62.           _guess                        ; - guess: some bytes left to do
  63.             and   ECX,3                 ; - - calculate number of bytes left
  64.             _quif e                     ; - - quit if done
  65.             mov   [EAX],DL              ; - - store a byte
  66.             dec   ECX                   ; - - decrement length
  67.             _quif e                     ; - - quit if done
  68.             mov   1[EAX],DH             ; - - store a byte
  69.             dec   ECX                   ; - - decrement length
  70.             _quif e                     ; - - quit if done
  71.             mov   2[EAX],DL             ; - - store a byte
  72.           _endguess                     ; - endguess
  73.         _endif                          ; endif
  74.         ret                             ; return
  75.         endproc __STOSB
  76.  
  77.         nop
  78.         nop
  79.         nop
  80.         nop
  81.         nop
  82.         nop
  83.  
  84.         defpe   __STOSD
  85.         or      ECX,ECX                 ; if length not zero
  86.         _if     ne                      ; then
  87.           _loop                         ; - loop (get onto 32-byte boundary)
  88.             test  AL,1Fh                ; - - quit if on 32-byte boundary
  89.             _quif e                     ; - - ...
  90.             mov   [EAX],EDX             ; - - store dword
  91.             lea   EAX,4[EAX]            ; - - increment address
  92.             dec   ECX                   ; - - decrement length
  93.           _until e                      ; - until done
  94.           push  ECX                     ; - save length
  95.           shr   ECX,2                   ; - calculate number of paragraphs
  96.           _if   ne                      ; - if at least one paragraph
  97.            dec    ECX                   ; - - decrement # of paragraphs
  98.            _if    ne                    ; - - if still have paragraphs to do
  99.             _loop                       ; - - - loop
  100.              mov  [EAX],EDX             ; - - - - store dword
  101.              mov  4[EAX],EDX            ; - - - - ...
  102.              dec  ECX                   ; - - - - decrement count
  103.              mov  8[EAX],EDX            ; - - - - store dword
  104.              mov  12[EAX],EDX           ; - - - - ...
  105.              je   short add16           ; - - - - quit if done
  106.              cmp  32[EAX],DL            ; - - - - access next cache line
  107.              mov  16[EAX],EDX           ; - - - - store dword
  108.              mov  20[EAX],EDX           ; - - - - ...
  109.              dec  ECX                   ; - - - - decrement count
  110.              mov  24[EAX],EDX           ; - - - - store dword
  111.              mov  28[EAX],EDX           ; - - - - ...
  112.              lea  EAX,32[EAX]           ; - - - - advance to next 32-byte chunk
  113.             _until  e                   ; - - - until done
  114.             lea  EAX,-16[EAX]           ; - - - back up 16
  115. add16:      lea  EAX,16[EAX]            ; - - - advance 16
  116.            _endif                       ; - - endif
  117.            mov  [EAX],EDX               ; - - fill last full paragraph
  118.            mov  4[EAX],EDX              ; - - ...
  119.            mov  8[EAX],EDX              ; - - ...
  120.            mov  12[EAX],EDX             ; - - ...
  121.            lea  EAX,16[EAX]             ; - - advance pointer
  122.           _endif                        ; - endif
  123.           pop   ECX                     ; - restore length
  124.           _guess                        ; - guess: some dwords left to do
  125.            and  ECX,3                   ; - - calculate number of dwords left
  126.            _quif e                      ; - - quit if done
  127.            mov  [EAX],EDX               ; - - store dword
  128.            lea  EAX,4[EAX]              ; - - advance pointer
  129.            dec  ECX                     ; - - decrement length
  130.            _quif e                      ; - - quit if done
  131.            mov  [EAX],EDX               ; - - store dword
  132.            lea  EAX,4[EAX]              ; - - advance pointer
  133.            dec  ECX                     ; - - decrement length
  134.            _quif e                      ; - - quit if done
  135.            mov  [EAX],EDX               ; - - store dword
  136.            lea  EAX,4[EAX]              ; - - advance pointer
  137.           _endguess                     ; - endguess
  138.         _endif                          ; endif
  139.         ret                             ; return
  140.         endproc __STOSD
  141.  
  142.         endmod
  143.         end
  144.