diff lib/alib/memmove.a @ 2474:7d70b7e1cb21

Moved net and alib files into here
author boisy
date Tue, 30 Mar 2010 02:44:42 +0000
parents
children aaba193af04f
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/alib/memmove.a	Tue Mar 30 02:44:42 2010 +0000
@@ -0,0 +1,66 @@
+**************************************
+
+* Memory move
+
+* NOTE: This routine properly moves overlapping areas of memory.
+*       Uses fast move algorithm
+
+* ENTRY: X=source data
+*        Y=destination
+*        D=count
+
+* EXIT: all registers (except CC) preserved
+
+ nam Move Memory
+ ttl Assembler Library Module
+
+
+
+ psect MEMMOVE,0,0,0,0,0
+
+MEMMOVE:
+ pshs d,x,y,u
+ std -2,s test u
+ beq exit zero count, exit
+ tfr y,u use u for dest
+ tfr d,y count in y
+ cmpu 2,s compare dest. to source (x)
+ beq exit same, no need to move
+ bhi down u>x
+
+up
+ bitb #1 see if odd number to move
+ beq up1
+ lda ,x+ move odd byte
+ sta ,u+
+ leay -1,y could be only one
+ beq exit
+
+up1
+ ldd ,x++ move 2 bytes 
+ std ,u++
+ leay -2,y count down
+ bne up1
+ bra exit
+
+down
+ leau d,u u=dest end (count in D)
+ leax d,x x=source end
+
+ bitb #1
+ beq down2
+ lda ,-x move odd byte
+ sta ,-u
+ leay -1,y could be only one to do
+ beq exit
+
+down2
+ ldd ,--x get 2 bytes
+ std ,--u move them
+ leay -2,y count down
+ bne down2
+
+exit
+ puls d,x,y,u,pc
+
+ endsect