.386p
fastmem_TEXT	segment byte public use16 'CODE'
		assume	cs:_TEXT

memset8_	proc    far
                jcxz thatsIt_8

                mov ah,al
                mov bx,ax
                shl eax,16
                mov ax,bx

                test di,1
                jnz aligned16_8
                stosb
                dec cx
                jz thatsIt_8
aligned16_8:    test di,2
                jz aligned32_8
                stosb
                dec cx
                jz thatsIt_8
                stosb
                dec cx

aligned32_8:    push cx
                shr cx,2
                rep stosd
                pop cx
                and cx,3
                rep stosb

thatsIt_8:      ret
memset8_  	endp


memset16_       proc far
                jcxz thatsIt_16
                mov bx,ax
                shl eax,16
                mov ax,bx

                cld
                test di,2
                jz aligned32_16
                stosw
                dec cx
aligned32_16:   shr cx,1
                rep stosd
                jnc thatsIt_16
                stosw

thatsIt_16:     ret
memset16_       endp
		public memset8_
                public memset16_

fastmem_TEXT	ends

		end
