summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/FC/MOVE.ASM
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/CMD/FC/MOVE.ASM')
-rw-r--r--v4.0/src/CMD/FC/MOVE.ASM73
1 files changed, 73 insertions, 0 deletions
diff --git a/v4.0/src/CMD/FC/MOVE.ASM b/v4.0/src/CMD/FC/MOVE.ASM
new file mode 100644
index 0000000..d40e5d6
--- /dev/null
+++ b/v4.0/src/CMD/FC/MOVE.ASM
@@ -0,0 +1,73 @@
1;
2; memory routines
3;
4
5.xlist
6include version.inc
7include cmacros.inc
8.list
9
10sBegin code
11assumes cs,code
12
13cProc Move,<PUBLIC>,<DS,SI,DI>
14parmD src
15parmD dst
16parmW count
17cBegin
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
29SimpleMove:
30 shr cx,1
31 rep movsw
32 jnc NoByte
33 movsb
34 jmp short NoByte
35
36TestMove:
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
48NoByte:
49 cld
50cEnd
51
52cProc Fill,<PUBLIC>,<DI>
53parmD dst
54parmB value
55parmW count
56cBegin
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
65fill1:
66 jnc fill2
67 stosb
68fill2:
69cEnd
70
71sEnd
72
73end