2474
|
1 **************************************
|
|
2
|
|
3 * Memory move
|
|
4
|
|
5 * NOTE: This routine properly moves overlapping areas of memory.
|
|
6 * Uses fast move algorithm
|
|
7
|
|
8 * ENTRY: X=source data
|
|
9 * Y=destination
|
|
10 * D=count
|
|
11
|
|
12 * EXIT: all registers (except CC) preserved
|
|
13
|
|
14 nam Move Memory
|
|
15 ttl Assembler Library Module
|
|
16
|
|
17
|
|
18
|
|
19 psect MEMMOVE,0,0,0,0,0
|
|
20
|
|
21 MEMMOVE:
|
|
22 pshs d,x,y,u
|
|
23 std -2,s test u
|
|
24 beq exit zero count, exit
|
|
25 tfr y,u use u for dest
|
|
26 tfr d,y count in y
|
|
27 cmpu 2,s compare dest. to source (x)
|
|
28 beq exit same, no need to move
|
|
29 bhi down u>x
|
|
30
|
|
31 up
|
|
32 bitb #1 see if odd number to move
|
|
33 beq up1
|
|
34 lda ,x+ move odd byte
|
|
35 sta ,u+
|
|
36 leay -1,y could be only one
|
|
37 beq exit
|
|
38
|
|
39 up1
|
|
40 ldd ,x++ move 2 bytes
|
|
41 std ,u++
|
|
42 leay -2,y count down
|
|
43 bne up1
|
|
44 bra exit
|
|
45
|
|
46 down
|
|
47 leau d,u u=dest end (count in D)
|
|
48 leax d,x x=source end
|
|
49
|
|
50 bitb #1
|
|
51 beq down2
|
|
52 lda ,-x move odd byte
|
|
53 sta ,-u
|
|
54 leay -1,y could be only one to do
|
|
55 beq exit
|
|
56
|
|
57 down2
|
|
58 ldd ,--x get 2 bytes
|
|
59 std ,--u move them
|
|
60 leay -2,y count down
|
|
61 bne down2
|
|
62
|
|
63 exit
|
|
64 puls d,x,y,u,pc
|
|
65
|
|
66 endsect
|