home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 48
/
Amiga_Dream_48.iso
/
Atari
/
c
/
libs
/
dlibs.memcpy
< prev
next >
Wrap
Text File
|
1998-01-19
|
3KB
|
95 lines
Article 9733 of comp.sys.atari.st:
Path: corona!pbinfo!unido!mcvax!uunet!seismo!sundc!pitstop!sun!decwrl!ucbvax!tut.cis.ohio-state.edu!unmvax!ncar!tank!shamash!com50!pwcs!stag!daemon
From: to_stdnet@stag.UUCP
Newsgroups: comp.sys.atari.st
Subject: Replacement memcpy() for dLibs
Message-ID: <736@stag.UUCP>
Date: 10 Mar 89 03:03:17 GMT
Sender: daemon@stag.UUCP
Lines: 81
Posted: Fri Mar 10 04:03:17 1989
From: thelake!steve@stag.UUCP (Steve Yelvington)
I'm posting the following on the behalf of David Brooks, who is having
some trouble with the postnews mechanism at his site.
-- Steve Yelvington
David Brooks Internet: BROOKS@CSSS-A.PRIME.COM
uucp: {mit-eddie,uunet}!csss-a.prime.com!brooks
-----8<-----------------------------------------------------------
The broken memcpy() in the version of Dlibs distributed with Sozobon C
will hurt xargs processing (and a few other routines). Replace it with
the following, which fixes several bugs...
* memcpy by David Brooks 1/23/89
*
* char *memcpy(dest, source, len)
* char *dest at 4(sp)
* char *source at 8(sp)
* unsigned int len at 12(sp)
*
* This is generally optimized around the commonest case (even alignment,
* more than 4 bytes) but the time savings and space cost are minimal.
* Also, we avoid using "btst #n,dn" because of a bug in the Sozobon
* assembler.
.text
.globl _memcpy
_memcpy:
lea 12(a7),a2 ; Point to argument list
move.w (a2),d2 ; d2 = len
move.l -(a2),a0 ; a0 = source
move.l -(a2),a1 ; a1 = dest
move.l a1,d0 ; d0 = dest, ready to return
move.l a0,d1 ; Check for odd/even alignment
add.w a1,d1 ; This is really eor.w on the lsb. Really.
asr.w #1,d1 ; Get lsb into C. If it's 1, alignment is off.
bcs memcpy8 ; Go do it slowly
move.l a0,d1 ; Check for initial odd byte
asr.w #1,d1 ; Get lsb
bcc memcpy1
subq.w #1,d2 ; Move initial byte
bcs memcpy6 ; (unless d2 was 0). We could use dbra here,
move.b (a0)+,(a1)+ ; but that would have been bigger.
memcpy1:
moveq.l #3,d1 ; Split into a longword count and remainder
and.w d2,d1
lsr.w #2,d2
bra memcpy3 ; Enter loop. Note d2 could equal 0.
memcpy2:
move.l (a0)+,(a1)+
memcpy3:
dbra d2,memcpy2
bra memcpy5 ; Enter final loop. Again d1 could equal 0.
memcpy4:
move.b (a0)+,(a1)+ ; Up to 3 trailing bytes
memcpy5:
dbra d1,memcpy4
memcpy6:
rts ; All done.
memcpy7:
move.b (a0)+,(a1)+ ; Handle the odd/even aligned case
memcpy8:
dbra d2,memcpy7
rts ; and exit normally
-----8<-----------------------------------------------------------
forwarded by:
/*
* UUCP: {uunet!rosevax,amdahl!bungia,chinet,killer}!orbit!thelake!steve
* ARPA: crash!orbit!thelake!steve@nosc.mil
* #member <STdNET> The ST Developers Network
*/