|
Message
From: Matjaz Breskvar<phoenix@o...>
Date: Fri Sep 17 12:55:14 CEST 2004
Subject: [openrisc] how to make the division?
* beyoelf@1... (beyoelf@1...) wrote: > I met some questions when compiling a C file: > In one function ,I had to make recursion as follows: > int schur( > int * ac, int * ref) > { > int i,m,r,energy = ac[0]; > int G[2][P_MAX]; > > if (ac[0] == 0) > { for (i = 0; i < P_MAX; i++) ref[i] = 0; > return 0; > } > > for (i = 0; i < P_MAX; i++) G[0][i] = G[1][i] = ac[i + 1]; > > for (i = 0;;) > { ref[i] = r = -G[1][0]*/energy; // Here is the mistake!!!! > > energy += (G[1][0] * r); > > if (++i >= P_MAX) return error; > > for (m = 0; m < P_MAX - i; m++) > { G[1][m] = G[1][m + 1] + r * G[0][m]; > G[0][m] = G[1][m + 1] * r+ G[0][m]; > } > } > } > because the variable "energy" isn't the power of 2, the error comes > when compiling: recorder.o :in function'__schur': > recorder.o(.text+0x7b0): undefined referrence to '___divsi3' > make ***(recorder) error 1 > but the variable 'energy ' changes every recursion, it's hard to set the > power of 2 to approach 'energy'. How can i do ? Is it has some *.lib or > *.h to be included to solve the problem? thank you
simple, you need to link with libgcc.a (the or32 version of course). iy you have hardware division you can also pass -mhard-div option to compiler and it will generate l.div instruction instead of using ___div* functions.
best reagards, p.
|
 |