1: /
   2: /  Sendmail
   3: /  Copyright (c) 1983  Eric P. Allman
   4: /  Berkeley, California
   5: /
   6: /  Copyright (c) 1983 Regents of the University of California.
   7: /  All rights reserved.  The Berkeley software License Agreement
   8: /  specifies the terms and conditions for redistribution.
   9: /
  10: /	@(#)bmove.11.s	4.2 (Berkeley) 6/7/85
  11: /
  12: /
  13: /  BMOVE -- block move
  14: /
  15: /
  16: /	This is a highly optimized version of the old C-language
  17: /	bmove routine; it's function (should be) identical.
  18: /	It uses a fancy algorithm to move words instead of bytes
  19: /	whenever possible.
  20: /
  21: /	In C the routine is:
  22: /		char *bmove(a, b, l)
  23: /		char	*a, *b;
  24: /		int	l;
  25: /		{
  26: /			register int	n;
  27: /			register char	*p, *q;
  28: /			p = a;
  29: /			q = b;
  30: /			n = l;
  31: /			while (n--)
  32: /				*q++ = *p++;
  33: /			return (q);
  34: /		}
  35: /
  36: /	Parameters:
  37: /		a [4(sp)] -- source area
  38: /		b [6(sp)] -- target area
  39: /		l [10(sp)] -- byte count
  40: /
  41: /	Returns:
  42: /		Pointer to end of target area.
  43: /
  44: /	History:
  45: /		3/14/79 [rse] -- added odd to odd case
  46: /		2/9/78 [bob] -- converted from "C"
  47: /
  48: /
  49: 
  50: .globl  _bmove
  51: 
  52: _bmove:
  53:         mov     r2,-(sp)        / save r2
  54:         mov     4(sp),r1        / get src address
  55:         mov     6(sp),r0        / get dst address
  56: 
  57:         / determine whether to use word or byte move
  58:         mov     r0,r2           / r2 will reflect the three cases
  59:         bic     $177776,r2      / keep only last bit of dst
  60:         ror     4(sp)           / get least significant bit of src
  61:         adc     r2              / add it in.
  62:         beq     wordm           / both on even boundary
  63:         dec     r2              / check for odd case
  64:         bgt     wordodd         / both on odd boundary
  65: 
  66:         mov     10(sp),r2       / get count
  67:         beq     done
  68: bytem:
  69:         movb    (r1)+,(r0)+     / copy next byte
  70:         sob     r2,bytem        / branch until done
  71:         br      done
  72: 
  73: wordm:
  74:         mov     10(sp),r2       / get count
  75: wordt:
  76:         beq     done
  77:         asr     r2              / get word count
  78:         bcs     odd             / count was odd
  79: even:
  80:         mov     (r1)+,(r0)+     / copy word
  81:         sob     r2,even         / more to do if non-zero
  82:         br      done
  83: 
  84: wordodd:
  85:         mov     10(sp),r2       / get count
  86:         beq     done
  87:         movb    (r1)+,(r0)+     / copy byte
  88:         dec     r2              / dec count
  89:         br      wordt           / now treat as an even word move
  90: 
  91: odd:
  92:         beq     odd2            / special case of count = 1
  93: odd1:
  94:         mov     (r1)+,(r0)+     / copy word
  95:         sob     r2,odd1         / continue
  96: odd2:
  97:         movb    (r1)+,(r0)+     / count was odd. do last one
  98: 
  99: done:
 100:         mov     (sp)+,r2        / restore r2
 101:         rts     pc              / return

Defined functions

_bmove declared in line 50; defined in line 52; used 1 times
  • in line 50
bytem defined in line 68; used 1 times
  • in line 70
done defined in line 99; used 5 times
even defined in line 79; used 1 times
  • in line 81
odd defined in line 91; used 1 times
  • in line 78
odd1 defined in line 93; used 1 times
  • in line 95
odd2 defined in line 96; used 1 times
  • in line 92
wordm defined in line 73; used 1 times
  • in line 62
wordodd defined in line 84; used 1 times
  • in line 64
wordt defined in line 75; used 1 times
  • in line 89
Last modified: 1987-02-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1402
Valid CSS Valid XHTML 1.0 Strict