Exemplo n.º 1
0
void el1_sync(void)
{
    printf("ELF-LOADER: Synchronous exception received:\n");
    print_register(esr_el1);
    print_register(elr_el1);
    print_register(spsr_el1);
    print_register(far_el1);
    abort();
}
Exemplo n.º 2
0
int main(int argc, char **argv)
{
	int fd = -1;
	int idx = 0;
	int eq, fg, sw;
	uint8_t data;
	int mode = MODE_INVALID;

	printf("===== PI3EQX8908A i2c configuration =====\n");

	if (argc == 2 && !strcmp(argv[1], "read")) {
		mode = MODE_READ;
		goto START;
	}

	if (argc != 4) {
		print_usage();
		return -2;
	}
	mode = MODE_WRITE;

	eq = atoi(argv[1]);
	fg = atoi(argv[2]);
	sw = atoi(argv[3]);
	if (eq < 0 || eq > 15 || fg < 0 || fg > 3 || sw < 0 || sw > 1) {
		print_usage();
		return -3;
	}
	data = (uint8_t)((eq << 4) | (fg << 2) | sw);

	printf("EQ: %d\n", eq);
	printf("FG: %d\n", fg);
	printf("SW: %d\n", sw);
	printf("data = 0x%02x\n\n", data);

START:
	fd = i2cdev_open(I2CDEV_PATH, O_RDWR | O_SYNC);
	if (fd < 0) {
		printf("i2cdev_open failed: %s\n", strerror(errno));
		return -1;
	}

	print_register(fd);

	if (mode == MODE_WRITE) {
		for (idx = IDX_A0; idx <= IDX_B3; idx++)
			write_register(fd, idx, data);
		print_register(fd);
	}

	i2cdev_close(fd);

	return 0;
}
Exemplo n.º 3
0
/*!
 * \param instr l'instruction à imprimer
 * \param addr son adresse
 */
void print_instruction(Instruction instr, unsigned addr) {
	printf("%s ", cop_names[instr.instr_generic._cop]);
	switch (instr.instr_generic._cop) {
		case ILLOP:
		case NOP:
		case RET:
		case HALT:
			break;
		case LOAD:
		case STORE:
		case ADD:
		case SUB:
			print_register(instr); 
			print_op(instr);
			break;
		case BRANCH:
		case CALL:
			print_condition(instr);
			print_op(instr);
			break;
		case PUSH:
		case POP:
			print_op(instr);
			break;
	}
}
Exemplo n.º 4
0
void print_port(volatile uint32_t *gpio_base, int port)
{
	print_register("PXPIN", gpio_base[GPIO_PXPIN(port)]);
	print_register("PXDAT", gpio_base[GPIO_PXDAT(port)]);
	print_register("PXIM", gpio_base[GPIO_PXIM(port)]);
	print_register("PXPE", gpio_base[GPIO_PXPE(port)]);
	print_register("PXFUN", gpio_base[GPIO_PXFUN(port)]);
	print_register("PXSEL", gpio_base[GPIO_PXSEL(port)]);
	print_register("PXDIR", gpio_base[GPIO_PXDIR(port)]);
	print_register("PXTRG", gpio_base[GPIO_PXTRG(port)]);
}
Exemplo n.º 5
0
static void	print_fatal_info(CONTEXT *pctx)
{
	zabbix_log(LOG_LEVEL_CRIT, "====== Fatal information: ======");

	zabbix_log(LOG_LEVEL_CRIT, "Program counter: 0x%04x", pctx->Eip);
	zabbix_log(LOG_LEVEL_CRIT, "=== Registers: ===");

	print_register("edi", pctx->Edi);
	print_register("esi", pctx->Esi);
	print_register("ebp", pctx->Ebp);

	print_register("ebx", pctx->Ebx);
	print_register("edx", pctx->Edx);
	print_register("eax", pctx->Eax);
	print_register("ecx", pctx->Ecx);

	print_register("esp", pctx->Esp);
	print_register("efl", pctx->EFlags);
	print_register("csgsfs", ZBX_LSHIFT(pctx->SegCs, 24) | ZBX_LSHIFT(pctx->SegGs, 16) | ZBX_LSHIFT(pctx->SegFs, 8));
}
Exemplo n.º 6
0
int main()
{
	
	put_structure("h", 2, 3);	/* ?- X3 = h              */
	set_variable(2);			/*          (Z,           */
	set_variable(5);			/*             W),        */
	put_structure("f", 1, 4);	/*    X4 = f              */
	set_value(5);				/*          (W),          */
	put_structure("p", 3, 1);	/*    X1 = p              */
	set_value(2);				/*          (Z,           */
	set_value(3);				/*             X3,        */
	set_value(4);				/*                X4).    */

	print_register(1);			/* drukowanie X1          */

	dump_heap();
	
	fail = false;
	get_structure("p", 3, 1);	/* X1 = p                 */
	unify_variable(2);			/*       (X2,             */
	unify_variable(3);			/*           X3,          */
	unify_variable(4);			/*              Y),       */
	get_structure("f", 1, 2);	/* X2 = f                 */
	unify_variable(5);			/*       (X),             */
	get_structure("h", 2, 3);	/* X3 = h                 */
	unify_value(4);				/*       (Y,              */
	unify_variable(6);			/*          X6),          */
	get_structure("f", 1, 6);	/* X6 = f                 */
	unify_variable(7);			/*       (X7),            */
	get_structure("a", 0, 7);	/* X7 = a                 */

	printf("fail = %d\n", (int)fail);
	
	print_register(1);			/* drukowanie X1          */
	
	dump_heap();
	
	return 0;
}
Exemplo n.º 7
0
void print_instr(instr_t *instr) {
    //printf("%ld: ",instr->id);

    if (instr->label) { printf("%-22s: ",instr->label); }
    else { printf("\t\t\t"); }

    printf("%-8s ",instr->mips_instr->name);

    switch (instr->mips_instr->fmt) {
    case FMT_RD_RS_RT:
        print_register(instr->Rd); COMMA();
        print_register(instr->Rs); COMMA();
        print_register(instr->Rt);
        break;
    case FMT_RD_RS:
        print_register(instr->Rd); COMMA();
        print_register(instr->Rs);
        break;
    case FMT_RS_RT:
        print_register(instr->Rs); COMMA();
        print_register(instr->Rt);
        break;
    case FMT_RD_RS_IMM_IMM:
        printf("__implement_me__");
        break;
    case FMT_RD:
        print_register(instr->Rd);
        break;
    case FMT_RD_IMM:
        print_register(instr->Rd); COMMA();
        printf("%d",instr->ival);
        break;
    case FMT_RD_IMM32:
        print_register(instr->Rd); COMMA();
        printf("%d",instr->ival);
        break;

#if (USE_PSEUDO_INSTR_LA==1)
    case FMT_RD_LABEL:
        print_register(instr->Rd); COMMA();
        printf("%s",instr->lval_name);
        break;
#endif

    case FMT_RS:
        print_register(instr->Rs);
        break;
    case FMT_RD_RS_SHIFT:
        print_register(instr->Rd); COMMA();
        print_register(instr->Rs); COMMA();
        printf("%d",instr->ival);
        break;
    case FMT_RD_RS_IMM:
        print_register(instr->Rd); COMMA();
        print_register(instr->Rs); COMMA();
        printf("%d",instr->ival);
        break;
    case FMT_LOAD:
        print_register(instr->Rd); COMMA();
        printf("%d",instr->ival);

        printf("(");
        print_register(instr->Rs);
        printf(")");
        break;
    case FMT_STORE:
        print_register(instr->Rs); COMMA();
        printf("%d",instr->ival);

        printf("(");
        print_register(instr->Rt);
        printf(")");
        break;
    case FMT_RS_RT_OFFSET:
        print_register(instr->Rs); COMMA();
        print_register(instr->Rt); COMMA();
        printf("%s",instr->goto_label);
        break;
    case FMT_RS_OFFSET:
        print_register(instr->Rs); COMMA();
        printf("%s",instr->goto_label);
        break;
    case FMT_ADDR:
        printf("%s",instr->goto_label);
        break;
    case FMT_OFFSET:
        printf("%s",instr->goto_label);
        break;
    case FMT_EMPTY:
        break;
    }

    /*
    if (instr->Rd && instr->Rd->live == instr)
        printf("\t\t\t@%ld -> lines : %ld..%ld",instr->Rd->virtual, instr->Rd->live->id, instr->Rd->die->id);

    if (instr->Rs && instr->Rs->live == instr)
        printf("\t\t\t@%ld -> lines : %ld..%ld",instr->Rs->virtual, instr->Rs->live->id, instr->Rs->die->id);

    if (instr->Rt && instr->Rt->live == instr)
        printf("\t\t\t@%ld -> lines : %ld..%ld",instr->Rt->virtual, instr->Rt->live->id, instr->Rt->die->id);
    */

    printf("\n");
}
Exemplo n.º 8
0
static void	print_fatal_info(CONTEXT *pctx)
{
	zabbix_log(LOG_LEVEL_CRIT, "====== Fatal information: ======");

	zabbix_log(LOG_LEVEL_CRIT, "Program counter: 0x%08lx", pctx->Rip);
	zabbix_log(LOG_LEVEL_CRIT, "=== Registers: ===");

	print_register("r8", pctx->R8);
	print_register("r9", pctx->R9);
	print_register("r10", pctx->R10);
	print_register("r11", pctx->R11);
	print_register("r12", pctx->R12);
	print_register("r13", pctx->R13);
	print_register("r14", pctx->R14);
	print_register("r15", pctx->R15);

	print_register("rdi", pctx->Rdi);
	print_register("rsi", pctx->Rsi);
	print_register("rbp", pctx->Rbp);

	print_register("rbx", pctx->Rbx);
	print_register("rdx", pctx->Rdx);
	print_register("rax", pctx->Rax);
	print_register("rcx", pctx->Rcx);

	print_register("rsp", pctx->Rsp);
	print_register("efl", pctx->EFlags);
	print_register("csgsfs", ZBX_LSHIFT(pctx->SegCs, 24) | ZBX_LSHIFT(pctx->SegGs, 16) | ZBX_LSHIFT(pctx->SegFs, 8));
}
Exemplo n.º 9
0
int main(int argc, char *argv[])
{
  FILE *fp, *fp2;
  char buf[100000][100];	/*命令 読み込み用バッファ */
  char fpt[FPT_MAX_COUNT][20] = { 0 };
  char ofname[1000] = "result";
  int i = 0, j, k;
  //メモリ上の浮動小数点テーブルの位置
  int fpmemoffset = 0;
  int result;
  bool doprintregs = false, doprintmem = false;
  program *answer;
  program2 *answer2;
  double t2, t1;
  int ll = 0;

  while ((result = getopt(argc, argv, "rmo:")) != -1) {
    switch (result) {

      /* 値をとらないオプション */
    case 'r':
      /* getoptの返り値は見付けたオプションである. */
      doprintregs = true;
      break;
    case 'm':
      doprintmem = true;
      break;

    case 'o':
      /* 値を取る引数の場合は外部変数optargにその値を格納する. */
      strcpy(ofname, optarg);
      break;
    }
  }
  argc -= optind;
  argv += optind;


  /*assembler-file open and read */
  fp = fopen(argv[0], "r");
  if (fp == NULL) {
    printf("%sが開けませんaa\n", argv[0]);
    return 1;
  }

  if (argc > 1) {
    fp2 = fopen(argv[1], "r");
    if (fp2 == NULL) {
      printf("%sが開けません\n", argv[1]);
      return 1;
    }
    for (i = 0; i < FPT_MAX_COUNT; ++i) {
      if (fgets(fpt[i], 20, fp2) == NULL) {	/* 1行読み込み */
	break;		/* 末尾まで完了したか、エラー発生で終了 */
      }
    }

    for (j = 0; j < i; ++j) {
      //エラーが起こっても関係ない
      //printf("%s\n", fpt[j]);
      memory[j + fpmemoffset].i = (int) strtoll(fpt[j], NULL, 16);
    }
    //print_memory();
  }

  i = 0;
  while (1) {
    if (fgets(buf[i], 81, fp) == NULL) {	/* 1行読み込み */
      break;		/* 末尾まで完了したか、エラー発生で終了 */
    }
    i++;
  }

  out_fp = fopen(ofname, "w");

  answer = parse_all(buf, i);
  answer2 = parse_all2(parse_all(buf, i));
  
  //print_program(answer);

  t1 = gettimeofday_sec();
  do_assemble2(answer, answer2);
  t2 = gettimeofday_sec();
  
  printf("%lf\n", t2 - t1);
  printf("%lld\n", cnt);

  if (doprintregs)
    print_register();
  if (doprintmem)
    print_memory();

  fclose(fp);
  fclose(fp2);
  fclose(out_fp);
    
  return 0;
}
Exemplo n.º 10
0
int do_assemble2(program *program, program2 * program2)
{
  int pc = 0;
  int nextpc = 0;
  long long counter = 0;
  instruction2 ist;
  int iname, arg1, arg2, arg3;
    
  while (1) {
    pc = nextpc;

    
    ist = program2->insts[pc];
    iname = ist.name[0];
    arg1 = ist.name[1];
    arg2 = ist.name[2];
    arg3 = ist.name[3];

    /*
      ++counter;

      if(counter > 575600 && counter < 575719)
      {
      print_label_from_index(program, pc);
      print_instruction(program->insts[pc]);
      print_register();
      }
    */
	
    if (iname == 0) {
      // printf("this is nop\n");
    }
    DO_INST_1(1, +)
      DO_INST_1(2, -)
      DO_INST_1(3, *)
      DO_INST_1(4, &)
      DO_INST_1(5, |)
      /*ALU命令 */
    else if (iname == 6) {
      regist[ist.name[1]] = ~(regist[ist.name[2]] | regist[ist.name[3]]);
    }
    else if (iname == 7) {
      regist[ist.name[1]] = regist[ist.name[2]] ^ regist[ist.name[3]];
    }
    else if (iname == 8) {
      regist[ist.name[1]] = regist[ist.name[2]] + ist.name[3];
    }
    else if (iname == 9) {
      regist[ist.name[1]] = regist[ist.name[2]] - ist.name[3];
    }
    else if (iname == 10) {
      regist[ist.name[1]] = regist[ist.name[2]] * ist.name[3];
    }
    else if (iname == 11) {
      regist[ist.name[1]] = regist[ist.name[2]] & ist.name[3];
    }
    else if (iname == 12) {
      regist[ist.name[1]] = regist[ist.name[2]] | ist.name[3];
    }
    else if (iname == 13) {
      regist[ist.name[1]] = ~(regist[ist.name[2]] | ist.name[3]);
    }
    else if (iname == 14) {
      regist[ist.name[1]] = regist[ist.name[2]] ^ ist.name[3];
    }
    /*FPU命令 */
    else if (iname == 15) {
      freg[ist.name[1]] = freg[ist.name[2]] + freg[ist.name[3]];
    }
    else if (iname == 16) {
      freg[ist.name[1]] = freg[ist.name[2]] - freg[ist.name[3]];
    }
    else if (iname == 17) {
      freg[ist.name[1]] = freg[ist.name[2]] * freg[ist.name[3]];
    }
    else if (iname == 18) {
      freg[ist.name[1]] = freg[ist.name[2]] / freg[ist.name[3]];
    }
    else if (iname == 19) {
      freg[ist.name[1]] = 1 / freg[ist.name[2]];
    }
    else if (iname == 20) {
      freg[ist.name[1]] = sqrt(freg[ist.name[2]]);
    }
    else if (iname == 21) {
      freg[ist.name[1]] = floor(freg[ist.name[2]]);
    }
    else if (iname == 22) {
      freg[ist.name[1]] = (float) (regist[ist.name[2]]);
    }


    /*MEM ACSESS命令 */
    else if (iname == 23) {
      //memory_check
      if (check_memory(regist[ist.name[2]] + ist.name[3]) == ACSESS_BAD) {
	printf("Error:ACSESS_BAD :\n");
	//	 printf("%d\n", iname);
	//printf("%lld\n", counter);
	exit(1);
      }
      regist[ist.name[1]] = memory[regist[ist.name[2]] + ist.name[3]].i;
    }

    else if (iname == 24) {
      //memory_check
      if (check_memory(regist[ist.name[2]] + ist.name[3]) == ACSESS_BAD) {
	printf("Error:ACSESS_BAD :\n");
	//printf("%d\n", iname);
	exit(1);
      }
      memory[regist[ist.name[2]] + ist.name[3]].i =  regist[ist.name[1]];
    }

    else if (iname == 25) {
      //memory_check
      if (check_memory(regist[ist.name[2]] + ist.name[3])
	  == ACSESS_BAD) {
	printf("Error:ACSESS_BAD :\n");
	//printf("%d\n", iname);
	exit(1);
      }
      freg[ist.name[1]] =
	memory[regist[ist.name[2]] + ist.name[3]].d;
    }

    else if (iname == 26) {
      //memory_check
      if (check_memory(regist[ist.name[2]] + ist.name[3])
	  == ACSESS_BAD) {
	printf("Error:ACSESS_BAD :\n");
	// printf("%d\n", iname);
	exit(1);
      }
      memory[regist[ist.name[2]] + ist.name[3]].d =
	freg[ist.name[1]];
    }


    /*BRANCH命令 */
    else if (iname == 27) {
      if (regist[ist.name[1]] == regist[ist.name[2]]) {
	nextpc = pc + ist.name[3] - 1;
      }
    }

    else if (iname == 28) {
      if (regist[ist.name[1]] != regist[ist.name[2]]) {
	nextpc = pc + ist.name[3] - 1;
      }
    }
    else if (iname == 29) {
      if (regist[ist.name[1]] > regist[ist.name[2]]) {
	nextpc = pc + ist.name[3] - 1;
      }
    }

    else if (iname == 30) {
      if (regist[ist.name[1]] < regist[ist.name[2]]) {
	nextpc = pc + ist.name[3] - 1;
      }
    }

    else if (iname == 31) {
      if (regist[ist.name[1]] >= regist[ist.name[2]]) {
	nextpc = pc + ist.name[3] - 1;
      }
    }

    else if (iname == 32) {
      if (regist[ist.name[1]] <= regist[ist.name[2]]) {
	nextpc = pc + ist.name[3] - 1;
      }

    } else if (iname == 33) {
      if (freg[ist.name[1]] == freg[ist.name[2]]) {
	nextpc = pc + ist.name[3] - 1;
      }
    }

    else if (iname == 34) {
      if (freg[ist.name[1]] != freg[ist.name[2]]) {
	nextpc = pc + ist.name[3] - 1;
      }
    }

    else if (iname == 35) {
      if (freg[ist.name[1]] > freg[ist.name[2]]) {
	nextpc = pc + ist.name[3] - 1;
      }
    }

    else if (iname == 36) {
      if (freg[ist.name[1]] < freg[ist.name[2]]) {
	nextpc = pc + ist.name[3] - 1;
      }
    }

    else if (iname == 37) {
      if (freg[ist.name[1]] >= freg[ist.name[2]]) {
	nextpc = pc + ist.name[3] - 1;
      }
    }

    else if (iname == 38) {
      if (freg[ist.name[1]] <= freg[ist.name[2]]) {
	nextpc = pc + ist.name[3] - 1;
      }
    }


    /*JUMP命令 */
    else if (iname == 39) {
      if (ist.name[1] == -100) {
	freg[2] = atanf(freg[2]);
	nextpc = pop(&call_stack) - 1;
      } else if (ist.name[1] == -200) {
	freg[2] = sqrtf(freg[2]);
	nextpc = pop(&call_stack) - 1;
      } else if (ist.name[1] == -300) {
	regist[4] = read_int();
	printf("read_int: %d\n", regist[4]);
	nextpc = pop(&call_stack) - 1;
      } else if (ist.name[1] == -400) {
	freg[2] = read_float();
	printf("read_float: %f\n", freg[2]);
	nextpc = pop(&call_stack) - 1;
      } else if (ist.name[1] == -500) {
	printf("aaa\n");
	if(ppp < freg[2])
	  {
	    ppp = freg[2];
	  }
	if(nnn > freg[2])
	  {
	    nnn = freg[2];
	  }
	//print_register();
	nextpc = label_trans(program->insts[pc].name[1], program) - 1;
	//freg[2] = sinf(freg[2]);
	//printf("read_float: %f\n", freg[2]);
	//nextpc = pop(&call_stack) - 1;
      } else if (ist.name[1] == -600) {
	freg[2] = cosf(freg[2]);
	//printf("read_float: %f\n", freg[2]);
	nextpc = pop(&call_stack) - 1;
      } else if (ist.name[1] == -700) {
	//print_int
	print_int();
	nextpc = pop(&call_stack) - 1;
      } else if (ist.name[1] == -800) {
	print_float();
	nextpc = pop(&call_stack) - 1;
      }
      else
	{
	  nextpc = ist.name[1] - 1;
	}
      /*
	if(strncmp(program->insts[pc].name[1] , "L_main", 6) == 0)
	{
	print_memory();
	}
      */
    }


    else if (iname == 40) {
          
      nextpc = ist.name[1] - 1;
      /*特殊ラベル*/
      if (ist.name[1] == -100) {
	freg[2] = atanf(freg[2]);
	nextpc = pc;
      } else if (ist.name[1] == -200) {
	freg[2] = sqrtf(freg[2]);
	nextpc = pc;
      } else if (ist.name[1] == -300) {
	regist[4] = read_int();
	printf("read_int: %d\n", regist[4]);
	nextpc = pc;
      } else if (ist.name[1] == -400) {
	freg[2] = read_float();
	printf("read_float: %f\n", freg[2]);
	nextpc = pc;
      } else if (ist.name[1] == -500) {
	printf("aab\n");
	kkk = 1;
	if(ppp < freg[2])
	  {
	    ppp = freg[2];
	  }
	if(nnn > freg[2])
	  {
	    nnn = freg[2];
	  }
	push(&call_stack, (pc + 1));
	nextpc = label_trans(program->insts[pc].name[1], program) - 1;
	
	//freg[2] = sinf(freg[2]);
	//printf("read_float: %f\n", freg[2]);
	//nextpc = pc;
      } else if (ist.name[1] == -600) {
	freg[2] = cosf(freg[2]);
	//printf("read_float: %f\n", freg[2]);
	nextpc = pc;
      } else if (ist.name[1] == -700) {
	//print_int
	print_int();
	nextpc = pc;
      } else if (ist.name[1] == -800) {
	print_float();
	nextpc = pc;
      } else {
	push(&call_stack, (pc + 1));
      }


    }

    else if (iname == 41) {
      nextpc = pop(&call_stack) - 1;
    }

    else if (iname = 42) {
      print_register();
      print_memory();
    }
    //命令が存在しなかった場合error parseでやっているのでいらない。
    //printf("ist = %d\n",iname);

    nextpc++;


    /*命令がラストの行まで行けば処理を終了する */
    if (nextpc >= program2->inst_count) {
      break;
    }
  }

  return 0;
}
Exemplo n.º 11
0
int main(int argc, char *argv[])
{
  FILE *fp, *fp2;
  char buf[100000][100];	/*命令 読み込み用バッファ */
  char fpt[FPT_MAX_COUNT][20] = { 0 };
  char ofname[1000] = "result";
  int i = 0, j, k;
  //メモリ上の浮動小数点テーブルの位置
  int fpmemoffset = 0;
  int result;
  bool doprintregs = false, doprintmem = false;
  program *answer;
  program2 *answer2;
  double t2, t1;
  int ll = 0;

  while ((result = getopt(argc, argv, "rmo:")) != -1) {
    switch (result) {

      /* 値をとらないオプション */
    case 'r':
      /* getoptの返り値は見付けたオプションである. */
      doprintregs = true;
      break;
    case 'm':
      doprintmem = true;
      break;

    case 'o':
      /* 値を取る引数の場合は外部変数optargにその値を格納する. */
      strcpy(ofname, optarg);
      break;

      /* 以下二つのcaseは意味がないようだ.
	 getoptが直接エラーを出力してくれるから.
	 プログラムを終了するなら意味があるかも知れない */
    case ':':
      /* 値を取る引数に値がなかった場合:を返す. */
      fprintf(stdout, "%c needs value\n", result);
      break;

      /* getoptの引数で指定されなかったオプションを受け取ると?を返す. */
    case '?':
      fprintf(stdout, "unknown\n");
      break;
    }
  }
  argc -= optind;
  argv += optind;
    

  /*
    if (argc < 3) {
    fprintf(stderr, "<Useage>:%s assembler-file fp-table-file\n",
    argv[0]);
    return 1;
    }
  */


  /*assembler-file open and read */
  fp = fopen(argv[0], "r");
  if (fp == NULL) {
    printf("%sが開けませんaa\n", argv[0]);
    return 1;
  }

  if (argc > 1) {
    fp2 = fopen(argv[1], "r");
    if (fp2 == NULL) {
      printf("%sが開けません\n", argv[1]);
      return 1;
    }
    for (i = 0; i < FPT_MAX_COUNT; ++i) {
      if (fgets(fpt[i], 20, fp2) == NULL) {	/* 1行読み込み */
	break;		/* 末尾まで完了したか、エラー発生で終了 */
      }
    }

    for (j = 0; j < i; ++j) {
      //エラーが起こっても関係ない
      //printf("%s\n", fpt[j]);
      memory[j + fpmemoffset].i = (int) strtoll(fpt[j], NULL, 16);
    }
    //print_memory();
  }

  i = 0;
  while (1) {
    if (fgets(buf[i], 81, fp) == NULL) {	/* 1行読み込み */
      break;		/* 末尾まで完了したか、エラー発生で終了 */
    }
    i++;
  }

  out_fp = fopen(ofname, "w");

  answer = parse_all(buf, i);

  answer2 = parse_all2(answer);
  //print_program(answer);

  t1 = gettimeofday_sec();
  //do_assemble(answer);
  do_assemble2(answer, answer2);
  t2 = gettimeofday_sec();
  printf("%lf\n", t2 - t1);

  if (doprintregs)
    print_register();
  if (doprintmem)
    print_memory();

  fclose(fp);
  fclose(fp2);
  fclose(out_fp);

  printf("%f\n", ppp);
  printf("%f\n", nnn);
  /*
    fprintf(fp, "P3\n%d %d %d\n", memory[8193].i, memory[8194].i,
    memory[8195].i);
    for (i = 8196; i < memory[8192].i; i = i + 3) {
    fprintf(fp, "%d %d %d\n", (int) memory[i].d,
    (int) memory[i + 1].d, (int) memory[i + 2].d);
    }
  */

    
  return 0;
}
Exemplo n.º 12
0
/**
 * @print registers
 */
int cmd_print_regs(int argc, char **argv)
{
    (void) argc;
    (void) argv;

    printf("################## Print Registers ###################\n");


    puts("REG_CONFIG: ");
    print_register(REG_CONFIG, 1);

    puts("REG_EN_AA: ");
    print_register(REG_EN_AA, 1);

    puts("REG_EN_RXADDR: ");
    print_register(REG_EN_RXADDR, 1);

    puts("REG_SETUP_AW: ");
    print_register(REG_SETUP_AW, 1);

    puts("REG_SETUP_RETR: ");
    print_register(REG_SETUP_RETR, 1);

    puts("REG_RF_CH: ");
    print_register(REG_RF_CH, 1);

    puts("REG_RF_SETUP: ");
    print_register(REG_RF_SETUP, 1);

    puts("REG_STATUS: ");
    print_register(REG_STATUS, 1);

    puts("REG_OBSERVE_TX: ");
    print_register(REG_OBSERVE_TX, 1);

    puts("REG_RPD: ");
    print_register(REG_RPD, 1);

    puts("REG_RX_ADDR_P0: ");
    print_register(REG_RX_ADDR_P0, INITIAL_ADDRESS_WIDTH);

    puts("REG_TX_ADDR: ");
    print_register(REG_TX_ADDR, INITIAL_ADDRESS_WIDTH);

    puts("REG_RX_PW_P0: ");
    print_register(REG_RX_PW_P0, 1);

    puts("REG_FIFO_STATUS: ");
    print_register(REG_FIFO_STATUS, 1);

    puts("REG_DYNPD: ");
    print_register(REG_DYNPD, 1);

    puts("REG_FEATURE: ");
    print_register(REG_FEATURE, 1);

    return 0;
}