bmove.11.s
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· S 代码 · 共 92 行
S
92 行
// BMOVE -- block move// @(#)bmove.11.s 4.1 7/25/83// This is a highly optimized version of the old C-language/ bmove routine; it's function (should be) identical./ It uses a fancy algorithm to move words instead of bytes/ whenever possible.// In C the routine is:/ char *bmove(a, b, l)/ char *a, *b;/ int l;/ {/ register int n;/ register char *p, *q;/ p = a;/ q = b;/ n = l;/ while (n--)/ *q++ = *p++;/ return (q);/ }// Parameters:/ a [4(sp)] -- source area/ b [6(sp)] -- target area/ l [10(sp)] -- byte count// Returns:/ Pointer to end of target area.// History:/ 3/14/79 [rse] -- added odd to odd case/ 2/9/78 [bob] -- converted from "C"//.globl _bmove_bmove: mov r2,-(sp) / save r2 mov 4(sp),r1 / get src address mov 6(sp),r0 / get dst address / determine whether to use word or byte move mov r0,r2 / r2 will reflect the three cases bic $177776,r2 / keep only last bit of dst ror 4(sp) / get least significant bit of src adc r2 / add it in. beq wordm / both on even boundary dec r2 / check for odd case bgt wordodd / both on odd boundary mov 10(sp),r2 / get count beq donebytem: movb (r1)+,(r0)+ / copy next byte sob r2,bytem / branch until done br donewordm: mov 10(sp),r2 / get countwordt: beq done asr r2 / get word count bcs odd / count was oddeven: mov (r1)+,(r0)+ / copy word sob r2,even / more to do if non-zero br donewordodd: mov 10(sp),r2 / get count beq done movb (r1)+,(r0)+ / copy byte dec r2 / dec count br wordt / now treat as an even word moveodd: beq odd2 / special case of count = 1odd1: mov (r1)+,(r0)+ / copy word sob r2,odd1 / continueodd2: movb (r1)+,(r0)+ / count was odd. do last onedone: mov (sp)+,r2 / restore r2 rts pc / return
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?