下面的fe_add(fe h,fe f,fe g)本来是汇编写的,因为需要移植到stm32里,2个片子寄存器结构不一样,怕改错,因此想改成c.
能否请看下这样改是否可以?
typedef unsigned int fe[16];
fe x1;
fe x2;
fe z2;
void fe_add(fe h,fe f,fe g); //->见下面汇编
//是否能改成下面c函数
void fe_add(unsigned int *h,unsigned int *f,unsigned int *g)
{
u8 i;
for(i=0;i<16;i++)
{
h[i]=g[i]+f[i];
}
}
//汇编
; h = g + f
; R12 holds pointer to h
; R13 holds pointer to f
; R14 holds pointer to g
mov 30(R14),R15
add 30(R13),R15
clr R11
adc R11
rla R15
rlc R11
clrc
rrc R15
mov R15,30(R12)
mov R11,&MPY
mov #19,&OP2
mov @R14+,R11
add @R13+,R11
clr R15
adc R15
add &RESLO,R11
mov R11,0(R12)
addc @R14+,R15
clr R11
adc R11
add @R13+,R15
mov R15,2(R12)
addc @R14+,R11
clr R15
adc R15
add @R13+,R11
mov R11,4(R12)
addc @R14+,R15
clr R11
adc R11
add @R13+,R15
mov R15,6(R12)
addc @R14+,R11
clr R15
adc R15
add @R13+,R11
mov R11,8(R12)
addc @R14+,R15
clr R11
adc R11
add @R13+,R15
mov R15,10(R12)
addc @R14+,R11
clr R15
adc R15
add @R13+,R11
mov R11,12(R12)
addc @R14+,R15
clr R11
adc R11
add @R13+,R15
mov R15,14(R12)
addc @R14+,R11
clr R15
adc R15
add @R13+,R11
mov R11,16(R12)
addc @R14+,R15
clr R11
adc R11
add @R13+,R15
mov R15,18(R12)
addc @R14+,R11
clr R15
adc R15
add @R13+,R11
mov R11,20(R12)
addc @R14+,R15
clr R11
adc R11
add @R13+,R15
mov R15,22(R12)
addc @R14+,R11
clr R15
adc R15
add @R13+,R11
mov R11,24(R12)
addc @R14+,R15
clr R11
adc R11
add @R13+,R15
mov R15,26(R12)
addc @R14+,R11
clr R15
adc R15
add @R13+,R11
mov R11,28(R12)
addc R15,30(R12)
pop.w R11
eint
reta
END
一周热门 更多>