コード例 #1
0
ファイル: main_matrices.c プロジェクト: mtqp/xorga
int main(){
	srand(time(NULL));
	char * ptr_src = malloc(16);
	ptr_src[0]= 10;
	ptr_src[1]= 33;
	ptr_src[2]= 24;
	ptr_src[3]= 4;
	ptr_src[4]= 67;
	ptr_src[5]= 54;
	ptr_src[6]= 34;
	ptr_src[7]= 22;
	ptr_src[8]= 9;
	ptr_src[9]= 80;
	ptr_src[10]= 5;
	ptr_src[11]= 43;
	ptr_src[12]= 2;
	ptr_src[13]= 3;
	ptr_src[14]= 1;
	ptr_src[15]=0;
	int i;
/*	for(i=0;i<16;i+=1){
		if (i<5) {
			ptr_src[i]=2^i;
		}
		if (i<10){
			ptr_src[i]=3*i;
		}
		else {
			ptr_src[i]=2*i;
		}
	}*/
	char * ptr_dst = malloc(16);
	apply_lineX(ptr_src,0);
	printf("paso el apply \n");
	save_mem(ptr_dst);
	for(i=0;i<16;i+=1){
		printf("elemento_%d es: %d\n",i,ptr_dst[i]);
	}
	return 0;
}
コード例 #2
0
ファイル: execute.c プロジェクト: novice555/syssoft
int execute(void)
{
    long long tmp;
    int cmp;
    switch(opcode)
    {
        //add
        case 0x18:
            ra += load_mem(&memory[path],3);
            break;
        //and
        case 0x40:
            ra &= load_mem(&memory[path],3);
            break;
        //comp
        // = -> 0b001
        // > -> 0b010
        // < -> 0b100
        // save status in register sw
        case 0x28:
            cmp = load_mem(&memory[path],3);
            if(ra==cmp)
                rsw = 0x1;
            else if (ra>cmp)
                rsw = 0x2;
            else if (ra<cmp)
                rsw = 0x4;
            else
                rsw = 0;
            break;
        //div
        case 0x24:
            ra /= load_mem(&memory[path],3);
            break;
        //j
        case 0x3C:
            rpc = path;
            break;
        //jeq
        case 0x30:
            if(rsw==0x1)
                rpc = path;
            break;
        //jgt
        case 0x34:
            if(rsw==0x2)
                rpc = path;
            break;
        //jlt
        case 0x38:
            if(rsw==0x4)
                rpc = path;
            break;
        //jsub
        case 0x48:
            rl = rpc;
            rpc = path;
            break;
        //lda
        case 0x00:
            ra = load_mem(&memory[path],3);
            break;
        //ldch
        case 0x50:
            ra = (ra&0xFFFF00) + load_mem(&memory[path], 1);
            break;
        //ldl
        case 0x08:
            rl = load_mem(&memory[path],3);
            break;
        //ldx
        case 0x04:
            rx = load_mem(&memory[path],3);
            break;
        //mul
        case 0x20:
            tmp = (long long) ra * load_mem(&memory[path],3);
            ra = (int) (0xFFFFFF & tmp);
            break;
        //or
        case 0x44:
            ra |= load_mem(&memory[path],3);
            break;
        //rsub
        case 0x4C:
            rpc = rl;
            break;
        //sta
        case 0x0C:
            //incomplete
            save_mem(ra, &memory[path], 3);
            break;
        //stch
        case 0x54:
            save_mem(ra, &memory[path], 1);
            break;
        //stl
        case 0x14:
            save_mem(rl, &memory[path], 3);
            break;
        //stsw
        case 0xE8:
            save_mem(rsw, &memory[path], 3);
            break;
        //stx
        case 0x10:
            save_mem(rx, &memory[path], 3);
            break;
        //sub
        case 0x1C:
            ra -= load_mem(&memory[path], 3);
            break;
        //tix
        case 0x2C:         
            cmp = load_mem(&memory[path],3);
            rx++;
            if(rx==cmp)
                rsw = 0x1;
            else if (rx>cmp)
                rsw = 0x2;
            else if (rx<cmp)
                rsw = 0x4;
            else
                rsw = 0;
            break;

        //td
        case 0xE0:
            rsw = test_device(memory[path]);
            break;
        //rd
        case 0xD8:
            ra = (ra&0xFFFF00) + read_device(memory[path]);
            break;
        //wd
        case 0xDC:
            write_device(memory[path], (ra&0x0000FF));
            break;
       //break
        case 0xFF:
            return 10;
            break;   
        default: 
            printf("CPU Error: Could not found opcode\n");
            printf("rpc= %06X\n", rpc);
            return 11;
            break;
    }
    return 0;
}
コード例 #3
0
int main(int argc, char* argv[])
{
    printf("\n\n\n\n----- Phantom exec test v. 0.5\n\n");


    run_init_functions( INIT_LEVEL_PREPARE );
    run_init_functions( INIT_LEVEL_INIT ); // before video

    //drv_video_win32.mouse = mouse_callback;
    //video_drv = &drv_video_win32;
    //video_drv = &drv_video_x11;

    args(argc,argv);

    pvm_bulk_init( bulk_seek_f, bulk_read_f );

    pvm_video_init();
    video_drv->mouse = mouse_callback;

    drv_video_init_windows();
    init_main_event_q();
    init_new_windows();

    scr_mouse_set_cursor(drv_video_get_default_mouse_bmp());


    mem = malloc(size+1024*10);
    setDiffMem( mem, malloc(size+1024*10), size );

    hal_init( mem, size );
    //pvm_alloc_threaded_init(); // no threads yet - no lock

    run_init_functions( INIT_LEVEL_LATE );

#if 0
    videotest();
    //getchar();
    exit(0);
#endif

#if 0
    new_videotest();
    getchar();
    exit(0);
#endif


    char *dir = getenv("PHANTOM_HOME");
    char *rest = "plib/bin/classes";

    if( dir == NULL )
    {
        dir = "pcode";
        rest = "classes";
    }

    char fn[1024];
    snprintf( fn, 1024, "%s/%s", dir, rest );

    if( load_code( &bulk_code, &bulk_size, fn ) ) //"pcode/classes") )
    {
        printf("No bulk classes file '%s'\n", fn );
        exit(22);
    }
    bulk_read_pos = bulk_code;


    pvm_root_init();


    // TODO use stray catcher in pvm_test too
    //stray();

#if 0
//ui_loop( argc, argv, "test");
    printf("\nPhantom code finished\n" );
    //getchar();
    //{ char c; read( 0, &c, 1 ); }
	sleep(100);
#else
    dbg_init();
    kernel_debugger();
#endif

#if 0
    pvm_memcheck();

    printf("will run GC\n" );
    run_gc();

    printf("press enter\n" );
//    getchar();

    pvm_memcheck();

    save_mem(mem, size);
#endif
    return 0;
}