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