Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<math.h>
- static int nbval=0;
- void printvalue(int* buffer,int nbval)
- {
- for (int i=0;i<nbval;i++)
- {
- printf("%d ",buffer[i]);
- }
- }
- double convRad(int index,int max)
- {
- return (index*2.0*3.14159265358979/max);
- }
- void addtodc(int value)
- {
- if (nbval==0)
- {
- printf("\t\tdc.w %d",value);
- }
- else if (nbval==7)
- {
- printf(",%d\n",value);
- }
- else
- {
- printf(",%d",value);
- }
- nbval++;
- nbval&=7;
- }
- void flushdc()
- {
- if (nbval!=0)
- {
- printf("\n");
- }
- nbval=0;
- }
- void paragraphe(const char* label)
- {
- printf("\n%s:",label);
- printf("\n");
- }
- int main()
- {
- paragraphe("cos900");
- for (int i=0;i<900;i++)
- {
- addtodc((int)(32766.0*cos(convRad(i,900))));
- }
- flushdc();
- paragraphe("sin900");
- for (int i=0;i<900;i++)
- {
- addtodc((int)(32766.0*sin(convRad(i,900))));
- }
- flushdc();
- paragraphe("sinsin900");
- for (int i=0;i<900;i++)
- {
- addtodc((int)(32766.0* sin( 3.14159265358979* sin(convRad(i,900))) ));
- }
- flushdc();
- paragraphe("cossin900");
- for (int i=0;i<900;i++)
- {
- addtodc((int)(32766.0* cos( 3.14159265358979* sin(convRad(i,900))) ));
- }
- flushdc();
- return 0;
- }
- /*
- compilation: gcc -o toto thiscode.c -lm
- execution: ./toto>newfile.s
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement