From 5ec876912a20b3315809da78ae8cdd6d8f99e4d6 Mon Sep 17 00:00:00 2001 From: deraadt Date: Fri, 15 Dec 1995 01:53:03 +0000 Subject: [PATCH] common bcopy used by all the m68k ports --- sys/arch/m68k/m68k/copy.s | 77 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/sys/arch/m68k/m68k/copy.s b/sys/arch/m68k/m68k/copy.s index 1f2bdc4f978..263bbfbe3cb 100644 --- a/sys/arch/m68k/m68k/copy.s +++ b/sys/arch/m68k/m68k/copy.s @@ -1,4 +1,4 @@ -/* $NetBSD: copy.s,v 1.21 1995/02/11 21:59:29 mycroft Exp $ */ +/* $NetBSD: copy.s,v 1.22 1995/12/11 02:37:55 thorpej Exp $ */ /*- * Copyright (c) 1994, 1995 Charles Hannum. @@ -455,3 +455,78 @@ Lsdone: clrl a1@(PCB_ONFAULT) | clear fault handler rts +/* + * {ov}bcopy(from, to, len) + * memcpy(to, from, len) + * + * Works for counts up to 128K. + */ +ENTRY(memcpy) + movl sp@(12),d0 | get count + jeq Lbccpyexit | if zero, return + movl sp@(8), a0 | src address + movl sp@(4), a1 | dest address + jra Lbcdocopy | jump into bcopy +ALTENTRY(ovbcopy, _bcopy) +ENTRY(bcopy) + movl sp@(12),d0 | get count + jeq Lbccpyexit | if zero, return + movl sp@(4),a0 | src address + movl sp@(8),a1 | dest address +Lbcdocopy: + cmpl a1,a0 | src before dest? + jlt Lbccpyback | yes, copy backwards (avoids overlap) + movl a0,d1 + btst #0,d1 | src address odd? + jeq Lbccfeven | no, go check dest + movb a0@+,a1@+ | yes, copy a byte + subql #1,d0 | update count + jeq Lbccpyexit | exit if done +Lbccfeven: + movl a1,d1 + btst #0,d1 | dest address odd? + jne Lbccfbyte | yes, must copy by bytes + movl d0,d1 | no, get count + lsrl #2,d1 | convert to longwords + jeq Lbccfbyte | no longwords, copy bytes + subql #1,d1 | set up for dbf +Lbccflloop: + movl a0@+,a1@+ | copy longwords + dbf d1,Lbccflloop | til done + andl #3,d0 | get remaining count + jeq Lbccpyexit | done if none +Lbccfbyte: + subql #1,d0 | set up for dbf +Lbccfbloop: + movb a0@+,a1@+ | copy bytes + dbf d0,Lbccfbloop | til done +Lbccpyexit: + rts +Lbccpyback: + addl d0,a0 | add count to src + addl d0,a1 | add count to dest + movl a0,d1 + btst #0,d1 | src address odd? + jeq Lbccbeven | no, go check dest + movb a0@-,a1@- | yes, copy a byte + subql #1,d0 | update count + jeq Lbccpyexit | exit if done +Lbccbeven: + movl a1,d1 + btst #0,d1 | dest address odd? + jne Lbccbbyte | yes, must copy by bytes + movl d0,d1 | no, get count + lsrl #2,d1 | convert to longwords + jeq Lbccbbyte | no longwords, copy bytes + subql #1,d1 | set up for dbf +Lbccblloop: + movl a0@-,a1@- | copy longwords + dbf d1,Lbccblloop | til done + andl #3,d0 | get remaining count + jeq Lbccpyexit | done if none +Lbccbbyte: + subql #1,d0 | set up for dbf +Lbccbbloop: + movb a0@-,a1@- | copy bytes + dbf d0,Lbccbbloop | til done + rts -- 2.20.1