#include <stdio.h>
#define count 4
int x[count]={1,2,3,4};
int y[count]={6,6,7,8};
int result=0;
int main()
{
result=abs_4(x,y,count);
printf("result=%d decimal \n",result);
}
.def abs_4
abs_4: .cproc ap, bp, count
.reg a, b, c, diff, sum
zero sum
loop: ldh *ap++, a ;
ldh *bp++, b
sub a, b, diff
abs diff, c
add c, sum, sum
[count] b loop
.return sum
.endproc
这是是c调用汇编,c那部分应该不会错,可能是线性汇编那部分错了,谢谢
