]> wirehaze git hosting - MS-DOS.git/blob - v4.0/src/CMD/FC/MOVE.ASM

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / CMD / FC / MOVE.ASM
1 ;
2 ; memory routines
3 ;
4
5 .xlist
6 include version.inc
7 include cmacros.inc
8 .list
9
10 sBegin code
11 assumes cs,code
12
13 cProc Move,<PUBLIC>,<DS,SI,DI>
14 parmD src
15 parmD dst
16 parmW count
17 cBegin
18 mov cx,count
19 jcxz NoByte ; No characters to move
20 les di,dst ; grab pointers
21 lds si,src
22 cld
23 mov ax,ds
24 cmp ax,Seg_dst
25 jnz SimpleMove ; segments are NOT the same, no opt
26 cmp si,di ; is the start of source before dest
27 jb TestMove ; yes, try to optimize
28
29 SimpleMove:
30 shr cx,1
31 rep movsw
32 jnc NoByte
33 movsb
34 jmp short NoByte
35
36 TestMove:
37 mov ax,di
38 sub ax,si ; ax = difference between regions
39 cmp ax,cx ; is difference greater than region?
40 jae SimpleMove ; yes, no optimize
41 mov ax,cx ; optimize by copying down from top
42 dec ax
43 add di,ax
44 add si,ax
45 std
46 rep movsb ; no word optimization here
47
48 NoByte:
49 cld
50 cEnd
51
52 cProc Fill,<PUBLIC>,<DI>
53 parmD dst
54 parmB value
55 parmW count
56 cBegin
57 cld
58 les di,dst
59 mov al,value
60 mov ah,value
61 mov cx,count
62 shr cx,1
63 jcxz fill1
64 rep stosw
65 fill1:
66 jnc fill2
67 stosb
68 fill2:
69 cEnd
70
71 sEnd
72
73 end