Example #1
0
        GPUAPI void operator () (const int thread_in_system) 
          { 
	    pass_one(thread_in_system);
	    pass_two(thread_in_system);
	    if(need_to_log_system() && (thread_in_system==0) )
	      _monitor1.log_system();
	  }
Example #2
0
        GPUAPI void operator () (const int thread_in_system) 
          { 
	    pass_one(thread_in_system);
	    pass_two(thread_in_system);
	    if(need_to_log_system() && (thread_in_system()==0) )
	      log::system(_log, _sys);
	  }
Example #3
0
int main(int argc, char **argv)
{
     
     SymbolTable* symtbl = create_table(SYMTBL_UNIQUE_NAME);
     SymbolTable* reltbl = create_table(SYMTBL_UNIQUE_NAME);

     FILE* input1  = fopen("myinstr.txt", "r");
     FILE* output1 = fopen("res.txt", "w");
     pass_one(input1, output1, symtbl);

     fclose(input1);
     fclose(output1);
     FILE* input2 = fopen("res.txt", "r");
     FILE* output2 = fopen("final.txt", "w");
     
     pass_two(input2, output2,  symtbl, reltbl);
     
     // int ret = translate_inst(stdout, "addu", args,  3 , 0,  tb1, tb2);
     
     printf("symtbl:\n");
     write_table(symtbl, stdout);
     printf("reltbl:\n");
     write_table(reltbl, stdout);

     free_table(symtbl);
     free_table(reltbl);
     
     fclose(input2);
     fclose(output2);
     return 0;
}
Example #4
0
void
mkmap(lev_init *init_lev)
{
    schar	bg_typ = init_lev->bg,
            fg_typ = init_lev->fg;
    boolean smooth = init_lev->smoothed,
            join = init_lev->joined;
    xchar   lit = init_lev->lit,
            walled = init_lev->walled;
    int i;

    if(lit < 0)
        lit = (rnd(1+abs(depth(&u.uz))) < 11 && rn2(77)) ? 1 : 0;

    new_locations = (char *)alloc((WIDTH+1) * HEIGHT);

    if (bg_typ < MAX_TYPE)
        init_map(bg_typ);
    init_fill(bg_typ, fg_typ);

    for(i = 0; i < N_P1_ITER; i++)
        pass_one(bg_typ, fg_typ);

    for(i = 0; i < N_P2_ITER; i++)
        pass_two(bg_typ, fg_typ);

    if(smooth)
        for(i = 0; i < N_P3_ITER; i++)
            pass_three(bg_typ, fg_typ);

    if(join)
        join_map(bg_typ, fg_typ);

    finish_map(fg_typ, bg_typ, (boolean)lit, (boolean)walled);
    /* a walled, joined level is cavernous, not mazelike -dlc
     *
     * also, caverns have a defined "inside" and "outside"; the outside
     * doesn't _have_ to be stone, say, for hell.  so if the player
     * defined a maze filler originally, go ahead and backfill the
     * background in with that filler - DSR */
    if (walled && join && (init_lev->filling > -1)) {
        level.flags.is_maze_lev = FALSE;
        level.flags.is_cavernous_lev = TRUE;
        backfill(bg_typ,init_lev->filling);
    }
    free(new_locations);
}
Example #5
0
/* Runs the two-pass assembler. Most of the actual work is done in pass_one()
   and pass_two().
 */
int assemble(const char* in_name, const char* tmp_name, const char* out_name) {
    FILE *src, *dst;
    int err = 0;
    SymbolTable* symtbl = create_table(SYMTBL_UNIQUE_NAME);
    SymbolTable* reltbl = create_table(SYMTBL_NON_UNIQUE);

    if (in_name) {
        printf("Running pass one: %s -> %s\n", in_name, tmp_name);
        if (open_files(&src, &dst, in_name, tmp_name) != 0) {
            free_table(symtbl);
            free_table(reltbl);
            exit(1);
        }

        if (pass_one(src, dst, symtbl) != 0) {
            err = 1;
        }
        close_files(src, dst);
    }

    if (out_name) {
        printf("Running pass two: %s -> %s\n", tmp_name, out_name);
        if (open_files(&src, &dst, tmp_name, out_name) != 0) {
            free_table(symtbl);
            free_table(reltbl);
            exit(1);
        }

        fprintf(dst, ".text\n");
        if (pass_two(src, dst, symtbl, reltbl) != 0) {
            err = 1;
        }
        
        fprintf(dst, "\n.symbol\n");
        write_table(symtbl, dst);

        fprintf(dst, "\n.relocation\n");
        write_table(reltbl, dst);

        close_files(src, dst);
    }
    
    free_table(symtbl);
    free_table(reltbl);
    return err;
}
Example #6
0
void
mkmap(struct level *lev, lev_init *init_lev)
{
    schar bg_typ = init_lev->bg, fg_typ = init_lev->fg;
    boolean smooth = init_lev->smoothed, join = init_lev->joined;
    xchar lit = init_lev->lit, walled = init_lev->walled;
    int i;

    if (lit < 0)
        lit = (mklev_rn2(1 + abs(depth(&u.uz)), lev) < 10 &&
               mklev_rn2(77, lev)) ? 1 : 0;

    new_locations = malloc((WIDTH + 1) * HEIGHT);

    init_map(lev, bg_typ);
    init_fill(lev, bg_typ, fg_typ);

    for (i = 0; i < N_P1_ITER; i++)
        pass_one(lev, bg_typ, fg_typ);

    for (i = 0; i < N_P2_ITER; i++)
        pass_two(lev, bg_typ, fg_typ);

    if (smooth)
        for (i = 0; i < N_P3_ITER; i++)
            pass_three(lev, bg_typ, fg_typ);

    if (join)
        join_map(lev, bg_typ, fg_typ);

    finish_map(lev, fg_typ, bg_typ, (boolean) lit, (boolean) walled);
    /* a walled, joined level is cavernous, not mazelike -dlc */
    if (walled && join) {
        lev->flags.is_maze_lev = FALSE;
        lev->flags.is_cavernous_lev = TRUE;
    }
    free(new_locations);
}