Browse Source

目前的问题是sin求错,乘法求对了。

git-svn-id: file:///svn/pmon-all/pmon-all@52 214b0138-1524-0410-9122-e5cb4b5bc56c
master
root 18 years ago
parent
commit
19928a994b
  1. 6
      examples/math/Makefile
  2. 20
      examples/math/hello.c
  3. BIN
      examples/math/libgcc.a
  4. BIN
      examples/math/libm.a

6
examples/math/Makefile

@ -20,12 +20,12 @@ OBJDUMP = $(CROSS_COMPILE)objdump
SIZE = $(CROSS_COMPILE)size
hello: hello.o
${CC} -G 0 -O2 -EL -mips2 -mcpu=r4000 -Ttext=0x80200000 -N -o hello hello.o -nostdlib -e main libm.a
${CC} -G 0 -O2 -EL -mips3 -mcpu=r4000 -Ttext=0x80200000 -N -o hello hello.o -nostdlib -e main libm.a libgcc.a
cp hello /tftpboot
.S.o:
mipsel-linux-gcc -G 0 -c $< -mno-abicalls -fno-pic
mipsel-linux-gcc -mips3 -G 0 -c $< -mno-abicalls -fno-pic
.c.o:
mipsel-linux-gcc -EL -c $< -G 0 -mno-abicalls -fno-pic
mipsel-linux-gcc -mips3 -EL -c $< -G 0 -mno-abicalls -fno-pic
clean:
rm -f hello *.o

20
examples/math/hello.c

@ -56,20 +56,32 @@ struct callvectors *callvec;
void __gccmain(void);
void __gccmain(void){}
double x=1.1;
double y=1.2;
static double x=1.12;
static double y=1.34;
static double z;
double sin(double x);
int
main(int argc, char **argv, char **env, struct callvectors *cv)
{
char str[256];
char **ev;
int i;
callvec = cv;
#if 0
z=sin(x);
printf("sin(1.12)=%d\n",(int)(z*1000));
z=sin(x)*y;
printf("sin(1.12)*1.34=%d\n",(int)(z*1000));
z=x*y;
printf("1.12*1.34=%d\n",(int)(z*1000));
printf("\n\nHello! This is the 'hello' program!\n\n");
printf("sin(y)=%d",(int)(sin(y)*1000));
#else
z=sin(3.14);
printf("sin(3.14)=%d\n",(int)(z*1000));
#endif
return(0);
}

BIN
examples/math/libgcc.a

Binary file not shown.

BIN
examples/math/libm.a

Binary file not shown.
Loading…
Cancel
Save