.model medium, basic
.stack 20h
.386
.code

;Declare Sub GStpCopy(byval sourceseg%,byval sourceoffset%,byval aryseg%, byval aryofs%, byval col%)

public GStpCopy
GStpCopy proc
;stack layout:
;bp+14  sseg
;bp+12  sofs
;bp+10  aseg
;bp+8   aofs
;bp+6   col
;bp+4   retseg
;bp+2   retofs
;bp     bp
;bp-2   ds
;ds:si = source
;es:di = destination

push bp
mov bp, sp
push es
push ds
mov ds, [bp+14]
mov si, [bp+12]
mov es, [bp+10]
mov di, [bp+8]
mov dx, [bp+6]
mov dh,dl
mov ax,[si]
cmp al,dl
je try1
mov es:[di],al
try1:
cmp ah,dh
je try2
mov es:[di+1],ah
try2:
add si,2
add di,2
mov cx,15999
narf:       
mov ax,[si]
mov bx,[si+2]
cmp ax,dx
jnz narfax
endofnarfax:
cmp bx,dx
jnz narfbx
endofnarfbx:
add si,4
add di,4
dec cx
jnz narf
mov ax,[si]
cmp al,dl
je try3
mov es:[di],al
try3:
cmp ah,dh
je try4
mov es:[di+1],ah
try4:
pop ds
pop es
pop bp
ret 10
narfax:
cmp ah,dh
jz narfal
mov es:[di+1],ah
cmp al,dl
jz endofnarfax
nop
narfal:
mov es:[di],al
jmp endofnarfax
narfbx:
cmp bh,dh
jz narfbl
mov es:[di+3],bh
cmp bl,dl
jz endofnarfbx
nop
narfbl:
mov es:[di+2],bl
jmp endofnarfbx
GStpCopy endp
end
