annotate lib/alib/memmove.as @ 3003:68a167bc476d

level3 makefiles: Order BOOTERS list like in level2
author Tormod Volden <debian.tormod@gmail.com>
date Sun, 26 Oct 2014 13:02:12 +0100
parents 03f26e88b809
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2474
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
1 **************************************
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
2
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
3 * Memory move
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
4
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
5 * NOTE: This routine properly moves overlapping areas of memory.
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
6 * Uses fast move algorithm
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
7
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
8 * ENTRY: X=source data
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
9 * Y=destination
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
10 * D=count
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
11
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
12 * EXIT: all registers (except CC) preserved
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
13
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
14 nam Move Memory
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
15 ttl Assembler Library Module
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
16
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
17
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
18
2782
aaba193af04f Updated code to use lwasm/lwlink
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2474
diff changeset
19 section .text
2474
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
20
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
21 MEMMOVE:
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
22 pshs d,x,y,u
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
23 std -2,s test u
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
24 beq exit zero count, exit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
25 tfr y,u use u for dest
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
26 tfr d,y count in y
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
27 cmpu 2,s compare dest. to source (x)
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
28 beq exit same, no need to move
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
29 bhi down u>x
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
30
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
31 up
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
32 bitb #1 see if odd number to move
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
33 beq up1
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
34 lda ,x+ move odd byte
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
35 sta ,u+
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
36 leay -1,y could be only one
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
37 beq exit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
38
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
39 up1
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
40 ldd ,x++ move 2 bytes
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
41 std ,u++
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
42 leay -2,y count down
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
43 bne up1
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
44 bra exit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
45
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
46 down
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
47 leau d,u u=dest end (count in D)
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
48 leax d,x x=source end
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
49
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
50 bitb #1
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
51 beq down2
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
52 lda ,-x move odd byte
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
53 sta ,-u
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
54 leay -1,y could be only one to do
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
55 beq exit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
56
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
57 down2
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
58 ldd ,--x get 2 bytes
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
59 std ,--u move them
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
60 leay -2,y count down
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
61 bne down2
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
62
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
63 exit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
64 puls d,x,y,u,pc
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
65
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
66 endsect