- initial import
git-svn-id: http://moon:8086/svn/mips@1 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <math.h>
|
||||
#include "utils.h"
|
||||
|
||||
float constf = 0.8765f;
|
||||
double constd = 1.0;
|
||||
|
||||
void test_vararg1 (int cnt, ... );
|
||||
void test_vararg2 (int cnt, ... );
|
||||
|
||||
#define REPORT_INTERVAL 10000
|
||||
|
||||
int main(void)
|
||||
{
|
||||
volatile int *pReg = (int*)sys_led_port;
|
||||
int v1, v2;
|
||||
float curr, res;
|
||||
char buf[32];
|
||||
|
||||
|
||||
// *pReg = 0xFF;
|
||||
/*
|
||||
printf("sizeof(char) = %d\n", sizeof(char));
|
||||
printf("sizeof(short) = %d\n", sizeof(short));
|
||||
printf("sizeof(int) = %d\n", sizeof(int));
|
||||
printf("sizeof(long) = %d\n", sizeof(long));
|
||||
printf("sizeof(long long) = %d\n", sizeof(long long));
|
||||
printf("sizeof(float) = %d\n", sizeof(float));
|
||||
printf("sizeof(double) = %d\n", sizeof(double));
|
||||
*/
|
||||
v2 = 1;
|
||||
res = 0;
|
||||
while(1)
|
||||
{
|
||||
curr = 2.0f*(0.5f-(float)rand()/RAND_MAX);
|
||||
res += curr;
|
||||
v2++;
|
||||
if (!(v2%REPORT_INTERVAL))
|
||||
{
|
||||
printf("%d = %f\n", v2, res/v2);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void test_vararg1 (int cnt, ... )
|
||||
{
|
||||
|
||||
int arg, i;
|
||||
va_list args;
|
||||
|
||||
va_start(args, cnt);
|
||||
|
||||
for (i=0; i < cnt; i++)
|
||||
{
|
||||
arg = va_arg(args, int);
|
||||
printf ("Arg[%d] = %d\n", i, arg);
|
||||
};
|
||||
|
||||
va_end(args);
|
||||
|
||||
}
|
||||
|
||||
void test_vararg2 (int cnt, ... )
|
||||
{
|
||||
|
||||
double arg;
|
||||
float f;
|
||||
int i, *t;
|
||||
va_list args;
|
||||
|
||||
va_start(args, cnt);
|
||||
|
||||
for (i=0; i < 2*cnt+2; i++)
|
||||
{
|
||||
arg = va_arg(args, double);
|
||||
f = (float)arg;
|
||||
t = (int*)&arg;
|
||||
// print_word(*t);
|
||||
printf ("Arg[%d] = %8.8X\n", i, *t);
|
||||
printf ("Arg[%d] = %f\n", i, arg);
|
||||
};
|
||||
|
||||
va_end(args);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user