Exemplo n.º 1
0
int main() {
  int *array = (int*)malloc(10 * sizeof(int));
  int *array1 = (int*)malloc(20 * sizeof(int));
  setArrays(array, array1);
  free(array);
  free(array1);
  return 0;
}
Exemplo n.º 2
0
    void _reset(int numBodies, NBodyConfig config)
    {
        randomizeBodies(config, m_hPos, m_hVel, m_hColor, 
            activeParams.m_clusterScale, 
            activeParams.m_velocityScale, 
            numBodies, true);

        setArrays(m_hPos, m_hVel);
    }
Exemplo n.º 3
0
 void _reset(int numBodies, NBodyConfig config)
 {
     if (tipsyFile == "")
     {
         randomizeBodies(config, m_hPos, m_hVel, m_hColor,
                         activeParams.m_clusterScale,
                         activeParams.m_velocityScale,
                         numBodies, true);
         setArrays(m_hPos, m_hVel);
     }
     else
     {
         m_nbody->loadTipsyFile(tipsyFile);
         ::numBodies = m_nbody->getNumBodies();
     }
 }
Exemplo n.º 4
0
int main() {
  setArrays();
  return 0;
}
Exemplo n.º 5
0
int main() {
    basePointers[0] = 1; basePointers[1] = 0; basePointers[2] = 0; /*Initializing the array tracking the base pointers*/
    setArrays(); /*Setting the values of the isa for printing*/
    sp = 0; bp = 1; pc = 0; /*initializing the sp, bp and pc*/
    stack[1] = 0; stack[2] = 0; stack[3] = 0; /*initializing the first part of the stack*/
    count = 0; /*initializing size of code[] array of struct*/
    int i = 0;

    FILE *readFile;
    FILE *writeFile;
    char line[20];
    /*readFile is the input, writefile is the stacktrace output */
    readFile = fopen("mcode.txt", "r");
    writeFile = fopen("stacktrace.txt", "w");

    /*reading in the contents of the file to the array of struct instruction */
    while(fgets(line, sizeof(line), readFile)) {
        sscanf(line, "%d %d %d ", &code[count].op, &code[count].l, &code[count].m);
        count++;
    }
    fclose(readFile);

    /*writing initial part of stack trace*/
    fprintf(writeFile,"line\tOP\tL\tM\n");
    for (i = 0; i < count; i++) {
        fprintf(writeFile,"%d\t%s\t%d\t%d\n", i, isas[code[i].op-1], code[i].l, code[i].m );
    }
    fprintf(writeFile, "  \t  \t  \t  \tPC\tBP\tSP\tstack\n");
    fprintf(writeFile, "Initial values\t\t\t%d\t%d\t%d\n", pc, bp, sp);

    int counter = 0; /*counter used for first line of output in stacktrace*/
    int theCount = 0; /*Counter used for storing the bp in the bp array*/
    int firstCount = 0; /*Counter checking if this is the first time bp is at this next level, so to skip |*/
    /*Stops running when halt is 0 or bp is 0*/
    while(bp!= 0 && halt == 1 ) {
        fetch();

        /*printing the first half of the stacktrace line*/
        int temp = pc-1;
        fprintf(writeFile, "%d\t%s\t%d\t%d\t",temp, isas[ir.op-1], ir.l, ir.m);

        execute();
        /*This is checking for the first bp higher than 1 */
        if(bp>1 && theCount == 0) {
            basePointers[1] = bp;
            theCount++;
        }
        /*This is checking for the second bp higher than 1*/
        if(bp>1 && theCount == 1 && basePointers[1] != bp) {
            basePointers[2] = bp;
            theCount++;
        }

        fprintf(writeFile, "%d\t%d\t%d", pc, bp, sp); /*This prints the values of them after execute */

        /*This skips the first stacktrace line if the instruction is JMP*/
        if(counter == 0 && isas[ir.op-1] == "JMP") {
            counter = 1;
            fprintf(writeFile, "\n");
            continue;
        }

        fprintf(writeFile, "\t");
        int bpCount = 0; /*Counter used to check which level the bp is at to print the |*/
        /*Used to iterate through the stack up to the sp and print it*/
        for(i=1; i<=sp; i++) {
            fprintf(writeFile, "%d ", stack[i]);
            /*If the next basepointer is not 0, bp is greater than 1, the counter is first, and i is 1 before the bp
            then print the |*/
            if(basePointers[1] != 0 && bp>1 && bpCount == 0 && i == basePointers[1]-1) {
                if (firstCount != 0) {
                fprintf(writeFile, "| "); }
                firstCount = 1;
                bpCount++;
            }
            /*If the next next basepointer is not 0, bp is greater than 1, the sp is greater than the bp
            the counter is second, and i is 1 before the bp then print the |*/
            if(basePointers[2] != 0 && bp>1 && sp>bp && bpCount == 1 && i == basePointers[2]-1) {
                if (ir.op != 2 && ir.m !=0){
                fprintf(writeFile, "| "); }
                bpCount++;
            }
        }
        fprintf(writeFile, "\n");

    }

return 0;
}
Exemplo n.º 6
0
 void _reset(int numBodies, T* pos, T* vel)
 {
     setArrays(pos, vel);
 }