11 ; Set up source and destination pointers for movmd.
15 ; See whether the copy is long enough to use the movmd.l code.
16 ; Although the code can handle anything longer than 6 bytes,
17 ; it can be more expensive than movmd.b for small moves.
18 ; It's better to use a higher threshold to account for this.
20 ; Note that the exact overhead of the movmd.l checks depends on
21 ; the alignments of the length and pointers. They are faster when
22 ; er0 & 3 == er1 & 3 == er2 & 3, faster still when these values
23 ; are 0. This threshold is a compromise between the various cases.
27 ; movmd.l only works for even addresses. If one of the addresses
28 ; is odd and the other is not, fall back on a simple move.
33 ; Make the addresses even.
40 ; See if copying one word would make the first operand longword
41 ; aligned. Although this is only really worthwhile if it aligns
42 ; the second operand as well, it's no worse if doesn't, so it
43 ; hardly seems worth the overhead of a "band" check.
50 ; Set (e)r4 to the number of longwords to copy.
54 #ifdef __NORMAL_MODE__
55 ; 16-bit pointers and size_ts: one movmd.l is enough. This code
56 ; is never reached with r4 == 0.
66 ; Skip the first iteration if the number of longwords is divisible
71 ; This loop copies r4 (!= 0) longwords the first time round and 65536
72 ; longwords on each iteration after that.
79 ; Mop up any left-over bytes. We could just fall through to the
80 ; simple code after the "and" but the version below is quicker
81 ; and only takes 10 more bytes.
90 ; Simple bytewise copy. We need to handle all lengths, including zero.
105 ; MOVP @(2/4,r7),A0P ; dst
106 ; MOVP @(4/8,r7),A1P ; src
107 ; MOVP @(6/12,r7),A2P ; len
109 MOVP A0P,A3P ; keep copy of final dst
110 ADDP A2P,A0P ; point to end of dst
111 CMPP A0P,A3P ; see if anything to do
114 ADDP A2P,A1P ; point to end of src
116 ; lets see if we can do this in words
117 or A0L,A2L ; or in the dst address
118 or A3L,A2L ; or the length
119 or A1L,A2L ; or the src address
120 btst #0,A2L ; see if the lsb is zero
124 #ifdef __NORMAL_MODE__
127 subs #2,A1P ; point to word
129 mov.w @A1P,A2 ; get word
130 mov.w A2,@-A0P ; save word
131 CMPP A0P,A3P ; at the front again ?
136 #ifdef __NORMAL_MODE__
139 subs #1,A1P ; point to byte
141 mov.b @A1P,A2L ; get byte
142 mov.b A2L,@-A0P ; save byte
143 CMPP A0P,A3P ; at the front again ?
146 ; return with A0 pointing to dst