* Copyright (c) 1991 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* %sccs.include.redist.c%
#if defined(LIBC_SCCS) && !defined(lint)
ASMSTR("@(#)bcopy.s 5.1 (Berkeley) %G%")
#endif /* LIBC_SCCS and not lint */
addu t0, a0, a2 # t0 = end of s1 region
and t1, t1, t2 # t1 = true if from < to < (from+len)
beq t1, zero, forward # non overlapping, do forward copy
slt t2, a2, 12 # check for small copy
addu t1, a1, a2 # t1 = end of to region
lb v0, -1(t0) # copy bytes backwards,
subu t0, t0, 1 # doesn't happen often so do slow way
bne t2, zero, smallcpy # do a small bcopy
xor v0, a0, a1 # compare low two bits of addresses
subu a3, zero, a1 # compute # bytes to word align address
beq v0, zero, aligned # addresses can be word aligned
subu a2, a2, a3 # subtract from remaining count
lwr v0, 0(a0) # get next 4 bytes (unaligned)
swr v0, 0(a1) # store 1, 2, or 3 bytes to align a1
and v0, a2, 3 # compute number of words left
addu a3, a3, a0 # compute ending address
lwr v0, 0(a0) # copy words a0 unaligned, a1 aligned
subu a2, a2, a3 # subtract from remaining count
lwr v0, 0(a0) # copy 1, 2, or 3 bytes to align
and v0, a2, 3 # compute number of whole words left
addu a3, a3, a0 # compute ending address
lw v0, 0(a0) # copy words
addu a3, a2, a0 # compute ending address
lbu v0, 0(a0) # copy bytes