# 2.11BSD#431 - /usr/src/lib/libc/pdp/gen/bcopy.s

##### Functions

    _bcopy            X

##### Macros

    N                 X

       1: /*
       2:  * Copyright (c) 1987 Regents of the University of California.
       3:  * All rights reserved.  The Berkeley software License Agreement
       4:  * specifies the terms and conditions for redistribution.
       5:  */
       6:
       7: #ifdef LIBC_SCCS
       8:         <@(#)bcopy.s	1.2 (Berkeley) 8/21/87\0>
       9:         .even
      10: #endif LIBC_SCCS
      11:
      12: #include "DEFS.h"
      13:
      14: /*
      15:  * bcopy(src, dst, length)
      16:  *	caddr_t	src, dst;
      17:  *	u_int	length;
      18:  *
      19:  * Copy length bytes from src to dst - handles overlapping moves.  Bcopy uses
      20:  * a cost analysis heuristic to determine if it's worth while to see if a word
      21:  * copy should be tried.  The test is if length > N, then try for a word
      22:  * copy.  This routine will fail if N < 8.  10 is a good value for N:
      23:  *
      24:  *	Algorithm			Cost (in instructions)
      25:  *	byte loop cost			2 * length
      26:  *	word loop setup [worst case]	14 (instructions)
      27:  *	word loop cost			0.625 * length, for length > 10
      28:  *
      29:  *	N * 2 > 14 N * 0.625
      30:  *	N > 10
      31:  */
      32: #undef  N
      33: #define N       10.
      34:
      35: ENTRY(bcopy)
      36:         mov     6(sp),r0        / if ((r0 = length) == 0)
      37:         beq     3f              /	return
      38:         mov     r2,-(sp)        / reserve a register for our use
      39:         mov     6(sp),r2        / r2 = dst
      40:         mov     4(sp),r1        / r1 = src
      41:         cmp     r2,r1           / if (dst == src)
      42:         beq     2f              / 	return
      43:         bhi     9f              / if (dst > src)
      44:                                 /	do backwards copy
      45:
      46: /*
      47:  * copy memory from src:r1 to dst:r2 for length:r0 bytes, FORWARDS ...
      48:  */
      49:         cmp     r0,$N           / if (length >= N)
      50:         bhi     4f              /	try words
      51: 1:
      52:         movb    (r1)+,(r2)+     / do  *dst++ = *src++
      53:         sob     r0,1b           / while (--length)
      54: 2:
      55:         mov     (sp)+,r2        / and return
      56: 3:
      57:         rts     pc
      58:
      59: /*
      60:  * The length of the copy justifies trying a word by word copy.  If src and
      61:  * dst are of the same parity, we can do a word copy by handling any leading
      62:  * and trailing odd bytes separately.
      63:  */
      64: 4:
      65:         bit     $1,r1           / if (src&1 != dst&1)
      66:         beq     5f              /	do bytes
      67:         bit     $1,r2
      68:         beq     1b              / (src odd, dst even - do bytes)
      69:         movb    (r1)+,(r2)+     / copy leading odd byte
      70:         dec     r0
      71:         br      6f
      72: 5:
      73:         bit     $1,r2
      74:         bne     1b              / (src even, dst odd - do bytes)
      75: 6:
      76:         mov     r0,-(sp)        / save trailing byte indicator
      77:         asr     r0              / length >>= 1 (unsigned)
      78:         bic     $0100000,r0     / (length is now in remaining words to copy)
      79:         asr     r0              / if (length >>= 1, wasodd(length))
      80:         bcc     7f              /	handle leading non multiple of four
      81:         mov     (r1)+,(r2)+
      82: 7:
      83:         asr     r0              / if (length >>= 1, wasodd(length))
      84:         bcc     8f              /	handle leading non multiple of eight
      85:         mov     (r1)+,(r2)+
      86:         mov     (r1)+,(r2)+
      87: 8:
      88:         mov     (r1)+,(r2)+     / do
      89:         mov     (r1)+,(r2)+     /	move eight bytes
      90:         mov     (r1)+,(r2)+
      91:         mov     (r1)+,(r2)+
      92:         sob     r0,8b           / while (--length)
      93:         bit     $1,(sp)+        / if (odd trailing byte)
      94:         beq     2b
      95:         movb    (r1)+,(r2)+     /	copy it
      96:         br      2b              / and return
      97:
      98: /*
      99:  * copy memory from src:r1 to dst:r2 for length:r0 bytes, BACKWARDS ...
     100:  */
     101: 9:
     102:         add     r0,r1           / src += length
     103:         add     r0,r2           / dst += length
     104:
     105:         cmp     r0,$N           / if (length >= N)
     106:         bhi     4f              /	try words
     107: 1:
     108:         movb    -(r1),-(r2)     / do  *--dst = *--src
     109:         sob     r0,1b           / while (--length)
     110: 2:
     111:         mov     (sp)+,r2        / and return
     112: 3:
     113:         rts     pc
     114:
     115: /*
     116:  * The length of the copy justifies trying a word by word copy.  If src and
     117:  * dst are of the same parity, we can do a word copy by handling any leading
     118:  * and trailing odd bytes separately.
     119:  */
     120: 4:
     121:         bit     $1,r1           / if (src&1 != dst&1)
     122:         beq     5f              /	do bytes
     123:         bit     $1,r2
     124:         beq     1b              / (src odd, dst even - do bytes)
     125:         movb    -(r1),-(r2)     / copy leading odd byte
     126:         dec     r0
     127:         br      6f
     128: 5:
     129:         bit     $1,r2
     130:         bne     1b              / (src even, dst odd - do bytes)
     131: 6:
     132:         mov     r0,-(sp)        / save trailing byte indicator
     133:         asr     r0              / length >>= 1 (unsigned)
     134:         bic     $0100000,r0     / (length is now in remaining words to copy)
     135:         asr     r0              / if (length >>= 1, wasodd(length))
     136:         bcc     7f              /	handle leading non multiple of four
     137:         mov     -(r1),-(r2)
     138: 7:
     139:         asr     r0              / if (length >>= 1, wasodd(length))
     140:         bcc     8f              /	handle leading non multiple of eight
     141:         mov     -(r1),-(r2)
     142:         mov     -(r1),-(r2)
     143: 8:
     144:         mov     -(r1),-(r2)     / do
     145:         mov     -(r1),-(r2)     /	move eight bytes
     146:         mov     -(r1),-(r2)
     147:         mov     -(r1),-(r2)
     148:         sob     r0,8b           / while (--length)
     149:         bit     $1,(sp)+        / if (odd trailing byte)
     150:         beq     2b
     151:         movb    -(r1),-(r2)     /	copy it
     152:         br      2b              / and return

#### Defined functions

_bcopy defined in line 35; used 461 times

- in /usr/src/bin/ar/archive.c line 117, 179
- in /usr/src/bin/ar/misc.c line 71
- in /usr/src/bin/chpass/chpass.c line 216-225(5)
- in /usr/src/bin/csh/alloc.c line 321
- in /usr/src/bin/csh/sh.local.h line 46
- in /usr/src/bin/df.c line 263-264(2)
- in /usr/src/bin/hostid.c line 38
- in /usr/src/bin/ld/ld.c line 1688, 2039, 2093
- in /usr/src/bin/mail.c line 585
- in /usr/src/bin/make/files.c line 489, 545
- in /usr/src/bin/nm/nm.c line 303, 357
- in /usr/src/bin/passwd/passwd.c line 146-155(5)
- in /usr/src/bin/ping/ping.c line 255, 603
- in /usr/src/bin/tar.c line 1162, 1228
- in /usr/src/games/hunt/answer.c line 148
- in /usr/src/games/hunt/driver.c line 218, 520, 557
- in /usr/src/games/hunt/hunt.c line 264, 380
- in /usr/src/games/hunt/makemaze.c line 144
- in /usr/src/games/hunt/playit.c line 328, 356
- in /usr/src/lib/libc/gen/getpwent.c line 242-246(3), 252
- in /usr/src/lib/libc/gen/ndbm.c line 474, 503-505(2)
- in /usr/src/lib/libc/gen/setenv.c line 59
- in /usr/src/lib/libc/gen/strdup.c line 35
- in /usr/src/lib/libc/gen/strftime.c line 95, 111
- in /usr/src/lib/libc/net/hosttable/gethnamadr.c line 52, 61-63(2), 71
- in /usr/src/lib/libc/net/named/gethnamadr.c line 186
- in /usr/src/lib/libc/net/rcmd.c line 74, 96
- in /usr/src/lib/libc/net/res_debug.c line 220, 311
- in /usr/src/lib/libc/net/res_mkquery.c line 134, 168, 191
- in /usr/src/lib/libc/net/res_query.c line 205
- in /usr/src/lib/libc/net/rexec.c line 49
- in /usr/src/lib/libc/stdio/fread.c line 25, 39
- in /usr/src/lib/libc/stdio/fwrite.c line 32, 42
- in /usr/src/libexec/rlogind/rlogind.c line 339, 428
- in /usr/src/libexec/tcpd/environ.c line 25
- in /usr/src/libexec/telnetd/telnetd.c line 216, 225, 429-433(3), 1156
- in /usr/src/local/mtools/expand.c line 111
- in /usr/src/new/PORT/hexdump/display.c line 58-62(2), 76-80(2), 106-110(2)
- in /usr/src/new/PORT/perl.1.0.0/malloc.c line 280
- in /usr/src/new/PORT/perl.1.0.0/perly.c line 1326-1328(2), 2325
- in /usr/src/new/PORT/perl.1.0.0/x2p/str.c line 85, 102, 115, 128, 157
- in /usr/src/new/PORT/perl.1.0.10/perly.c line 1356-1358(2), 2359
- in /usr/src/new/PORT/perl.1.0.16/perly.c line 1357-1359(2), 2360
- in /usr/src/new/kermit5.188/ckustr.c line 285
- in /usr/src/new/nntp/common/clientlib.c line 222, 266, 319, 330
- in /usr/src/new/nntp/xfer/nntpxfer.c line 169-172(2), 200
- in /usr/src/new/vmsbackup/vmsbackup.c line 398, 412-413(2)
- in /usr/src/sbin/dump/dumpdir.c line 290, 337
- in /usr/src/sbin/dump/dumptape.c line 79
- in /usr/src/sbin/fsck/dir.c line 92, 99, 264, 368, 378, 452-465(4), 502-506(2)
- in /usr/src/sbin/fsck/inode.c line 167
- in /usr/src/sbin/fsck/pass2.c line 120, 126, 171, 202
- in /usr/src/sbin/fsck/pass5.c line 32-37(2)
- in /usr/src/sbin/fsck/utilities.c line 287, 295
- in /usr/src/sbin/ifconfig/ifconfig.c line 442
- in /usr/src/sbin/mkfs/mkfs.c line 297, 331-336(2)
- in /usr/src/sbin/mkpasswd/mkpasswd.c line 122-126(3), 132, 173-177(3)
- in /usr/src/sbin/quotacheck/quotacheck.c line 456
- in /usr/src/sbin/restor/restor.c line 431, 594, 672, 701, 721, 1087, 1167, 1209, 1223
- in /usr/src/sbin/route/route.c line 405, 516
- in /usr/src/sbin/routed/startup.c line 333, 349
- in /usr/src/sbin/routed/tools/query.c line 114
- in /usr/src/sbin/routed/tools/trace.c line 90
- in /usr/src/sbin/routed/trace.c line 110
- in /usr/src/sys/net/if.c line 342
- in /usr/src/sys/net/if_sl.c line 321, 437
- in /usr/src/sys/net/raw_cb.c line 133, 148
- in /usr/src/sys/net/raw_usrreq.c line 297, 303
- in /usr/src/sys/netinet/if_ether.c line 118, 126-130(3), 165, 191, 200, 218, 308-309(2), 331, 347, 381-383(2), 389-397(4), 413, 535, 547
- in /usr/src/sys/netinet/ip_icmp.c line 104, 119
- in /usr/src/sys/netinet/ip_input.c line 596, 606, 627, 637, 663, 672, 683, 754, 787, 821-824(2)
- in /usr/src/sys/netinet/ip_output.c line 37, 290, 297, 328, 371, 470
- in /usr/src/sys/netinet/raw_ip.c line 162
- in /usr/src/sys/netinet/tcp_input.c line 257-259(2), 1227
- in /usr/src/sys/netinet/tcp_output.c line 244, 282
- in /usr/src/sys/netns/ns_error.c line 127
- in /usr/src/sys/pdp/mch_click.s line 161
- in /usr/src/sys/pdpif/if_de.c line 218, 237, 798, 806, 872-874(2), 1110-1111(2), 1118-1121(2), 1137, 1154, 1395-1400(2)
- in /usr/src/sys/pdpif/if_ec.c line 520, 534, 577-578(2), 758
- in /usr/src/sys/pdpif/if_il.c line 175, 263, 595, 603, 635-636(2), 771
- in /usr/src/sys/pdpif/if_qe.c line 606, 616, 648-649(2), 792
- in /usr/src/sys/pdpif/if_qt.c line 296, 635, 643, 677-678(2), 769-770(2)
- in /usr/src/sys/pdpstand/boot.c line 205-206(2)
- in /usr/src/sys/pdpstand/label.c line 55
- in /usr/src/sys/pdpstand/sys.c line 88
- in /usr/src/sys/pdpuba/hk.c line 281, 320-322(2)
- in /usr/src/sys/pdpuba/ra.c line 548, 590-592(2)
- in /usr/src/sys/pdpuba/rl.c line 274, 314-316(2)
- in /usr/src/sys/pdpuba/xp.c line 338, 374-376(2)
- in /usr/src/sys/sys/ingreslock.c line 297
- in /usr/src/sys/sys/init_main.c line 87, 388, 398, 414
- in /usr/src/sys/sys/kern_acct.c line 34
- in /usr/src/sys/sys/kern_exec.c line 173, 182, 374-376(2)
- in /usr/src/sys/sys/kern_prot.c line 211
- in /usr/src/sys/sys/kern_subr.c line 70-72(2)
- in /usr/src/sys/sys/subr_log.c line 167, 337
- in /usr/src/sys/sys/sys_kern.c line 106, 138
- in /usr/src/sys/sys/tty.c line 498-511(4)
- in /usr/src/sys/sys/tty_subr.c line 119, 371
- in /usr/src/sys/sys/ufs_disksubr.c line 99, 146, 182, 284, 290, 326-328(2), 345-347(2)
- in /usr/src/sys/sys/ufs_inode.c line 236, 412, 708
- in /usr/src/sys/sys/ufs_mount.c line 147-153(3), 220
- in /usr/src/sys/sys/ufs_namei.c line 750, 792-793(2), 970, 987
- in /usr/src/sys/sys/ufs_syscalls2.c line 79-80(2), 155
- in /usr/src/sys/sys/uipc_mbuf.c line 266, 293, 391
- in /usr/src/sys/sys/uipc_socket2.c line 540
- in /usr/src/sys/sys/uipc_usrreq.c line 99, 248
- in /usr/src/ucb/Mail/aux.c line 59, 198
- in /usr/src/ucb/Mail/vars.c line 99
- in /usr/src/ucb/PORT/systat/vmstat.c line 666-670(5)
- in /usr/src/ucb/colcrt.c line 193
- in /usr/src/ucb/ex/ex_temp.c line 218-221(2)
- in /usr/src/ucb/finger/finger.c line 133
- in /usr/src/ucb/finger/net.c line 69
- in /usr/src/ucb/finger/util.c line 165-167(2), 180-182(2)
- in /usr/src/ucb/ftp/ftp.c line 116, 137
- in /usr/src/ucb/indent/indent.c line 982
- in /usr/src/ucb/ruptime.c line 108
- in /usr/src/ucb/symcompact.c line 167
- in /usr/src/ucb/talk/get_addrs.c line 29, 42
- in /usr/src/ucb/telnet.c line 444, 2043-2046(2), 2104
- in /usr/src/ucb/tftp/main.c line 173, 304, 397
- in /usr/src/ucb/tn3270/tn3270.c line 239, 647, 904
- in /usr/src/ucb/tset/tset.c line 396-398(2)
- in /usr/src/ucb/vacation.c line 292
- in /usr/src/ucb/whois.c line 65
- in /usr/src/ucb/window/ttoutput.c line 102
- in /usr/src/usr.bin/printf/printf.c line 247
- in /usr/src/usr.bin/ranlib/build.c line 190
- in /usr/src/usr.bin/ranlib/misc.c line 59
- in /usr/src/usr.bin/uucp/aculib/bsdtcp.c line 65
- in /usr/src/usr.bin/xargs/xargs.c line 254
- in /usr/src/usr.lib/libcurses/deleteln.c line 34
- in /usr/src/usr.lib/libcurses/insertln.c line 35
- in /usr/src/usr.lib/libcurses/overlay.c line 42
- in /usr/src/usr.lib/libcurses/overwrite.c line 41
- in /usr/src/usr.lib/libstubs/stubs.c line 134
- in /usr/src/usr.sbin/arp/arp.c line 123, 177, 228
- in /usr/src/usr.sbin/catman/catman.c line 200
- in /usr/src/usr.sbin/dev_mkdb/dev_mkdb.c line 127
- in /usr/src/usr.sbin/gettable/gettable.c line 81
- in /usr/src/usr.sbin/inetd/inetd.c line 163
- in /usr/src/usr.sbin/lpr/common.c line 90
- in /usr/src/usr.sbin/mkhosts/mkhosts.c line 90-96(4), 180-185(2), 194-196(2)
- in /usr/src/usr.sbin/mkproto/mkproto.c line 355
- in /usr/src/usr.sbin/named/named/db_load.c line 292, 304, 829
- in /usr/src/usr.sbin/named/named/db_save.c line 84
- in /usr/src/usr.sbin/named/named/ns_forw.c line 117
- in /usr/src/usr.sbin/named/named/ns_req.c line 329, 425, 476, 746, 759, 779
- in /usr/src/usr.sbin/named/named/ns_resp.c line 454-457(2), 807, 817
- in /usr/src/usr.sbin/named/named/ns_sort.c line 111, 122-123(2)
- in /usr/src/usr.sbin/named/tools/nslookup/debug.c line 262, 396
- in /usr/src/usr.sbin/named/tools/nslookup/getinfo.c line 234, 264, 274, 294, 302, 355, 373, 440, 537, 621, 648, 700
- in /usr/src/usr.sbin/named/tools/nslookup/list.c line 610, 850
- in /usr/src/usr.sbin/named/tools/nslookup/main.c line 222-226(2)
- in /usr/src/usr.sbin/named/tools/nslookup/res_debug.c line 220, 323
- in /usr/src/usr.sbin/ntp/ntp.c line 188
- in /usr/src/usr.sbin/ntp/ntpd.c line 1097
- in /usr/src/usr.sbin/ntp/ntpdc.c line 278
- in /usr/src/usr.sbin/repquota/repquota.c line 315
- in /usr/src/usr.sbin/rwhod/rwhod.c line 275-277(2), 382, 401, 411
- in /usr/src/usr.sbin/sendmail.MX/aux/mconnect.c line 98
- in /usr/src/usr.sbin/sendmail.MX/src/daemon.c line 347
- in /usr/src/usr.sbin/sendmail.MX/src/envelope.c line 54-56(2), 209
- in /usr/src/usr.sbin/sendmail.MX/src/headers.c line 138
- in /usr/src/usr.sbin/sendmail.MX/src/macro.c line 141
- in /usr/src/usr.sbin/sendmail.MX/src/parseaddr.c line 768, 806, 816
- in /usr/src/usr.sbin/sendmail.MX/src/readcf.c line 587
- in /usr/src/usr.sbin/sendmail.MX/src/stats.c line 98
- in /usr/src/usr.sbin/sendmail.MX/src/util.c line 188
- in /usr/src/usr.sbin/sendmail/aux/mconnect.c line 104
- in /usr/src/usr.sbin/syslogd/syslogd.c line 1030
- in /usr/src/usr.sbin/timed/cmds.c line 74, 148, 232, 285
- in /usr/src/usr.sbin/traceroute/traceroute.c line 368
- in /usr/src/usr.sbin/vipw/vipw.c line 135-144(5)

#### Defined macros

N defined in line 33; used 2 times

- in line 49, 105

Last modified: 1987-08-22 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1439 |