home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / screen / stest / 386.mac next >
Encoding:
Text File  |  1992-12-21  |  1.2 KB  |  58 lines

  1. ;; Special 386 macro file.
  2. P386
  3.  
  4. ;; This macro is designed to replace a normal REP STOSB instruction
  5. ;; with a 386 version that will store as many long words as possible.
  6. ;; However, the entire EAX register will get trashed in this process.
  7. Macro    RepStosb
  8.        mov     ah,al           ; AH=AL
  9.        push    ax        ; push word size of move
  10.        push    ax        ; and again
  11.        pop     eax        ; pop long word value of move
  12.        push    cx        ; Save the total number of bytes to store
  13.        shr     cx,2        ; how many double words to move?
  14.        rep     stosd        ; store this many long words.
  15.        pop     cx        ; restore CX register.
  16.        and     cx,3        ; remaining number of bytes to move.
  17.        rep     stosb        ; move the final bytes.
  18.        endm
  19.  
  20.  
  21. Macro    RepMovsb
  22.     push    cx
  23.     shr    cx,2        ; words.
  24.     rep    movsd
  25.     pop    cx
  26.     and    cx,3
  27.     rep    movsb
  28.     endm
  29.  
  30. ;; This macro replaces the LOOP instruction, because the loop instruction
  31. ;; is too damned slow on a 386/486
  32. macro    CLOOP LABEL
  33.     dec    cx
  34.     jnz    LABEL
  35.     endm
  36.  
  37. macro    CLODSB
  38.     mov    al,[ds:si]
  39.     inc    si
  40.     endm
  41.  
  42. macro    CSTOSB
  43.     mov    [es:di],al
  44.     inc    di
  45.     endm
  46.  
  47. macro    CLODSW
  48.     mov    ax,[ds:si]
  49.     add    si,2
  50.     endm
  51.  
  52. macro    CSTOSW
  53.     mov    [es:di],ax
  54.     add    di,2
  55.     endm
  56.  
  57.  
  58.