コード例 #1
0
ファイル: return.c プロジェクト: kw-udon/ucc
int main()
{
  print_int(2);
  foo();
  print_int(5);
  return 0;
}
コード例 #2
0
ファイル: bitwise.c プロジェクト: kw-udon/ucc
int main () {
  print_int(13 & 6); // 4
  print_int(13 | 6); // 15
  print_int(~13);    // -14
  print_int(13 ^ 6); // 11
  return 0;
}
コード例 #3
0
ファイル: tools.c プロジェクト: SoildFaker/stm32-quadrocopter
void check_type(char type)  
{  
  switch(type)
  {  
    case 'd':
    {  
      int num = va_arg(args, int);  
  
      if(num < 0){  
        UsartPut('-');  
        num = num * (-1);  
      }  
  
      print_int(num, 10, 0);  
      break;  
    }  
  
    case 'c':
    {  
      char ch = (char)va_arg(args, int);  
      UsartPut(ch);  
      break;  
    }  
    
    case 's':
    {  
      char *str = va_arg(args, char *);  
      print_str(str);  
      break;  
    }  
    
    case 'f':
    {  
      float num = (float)va_arg(args, double);  
    
      if(num < 0)  {  
        UsartPut('-');  
        num = num * (-1);  
      }  
    
      print_float(num);  
      break;  
    }  
    
    case 'p':
    {  
      int num = va_arg(args, int);  
      UsartPut('0');  
      UsartPut('x');  
      print_int(num, 16, 0);  
      break;  
    }  
    
    default:
    {  
      UsartPut('%');  
      UsartPut(type);  
    }  
  }  
}  
コード例 #4
0
ファイル: specs_mmap.c プロジェクト: charla-n/strace
static void	specs_mmap_flags(ulli param_reg[MAX_ARG])
{
  int		i;
  char		put_pipe;

  put_pipe = 0;
  i = 0;
  dprintf(2, ", ");
  while (g_flags[i].flags != -1)
    {
      if (((long)param_reg[3] & g_flags[i].flags) == g_flags[i].flags)
	{
	  if (put_pipe == 1)
	    {
	      dprintf(2, "|");
	      put_pipe = 0;
	    }
	  dprintf(2, "%s", g_flags[i].name);
	  put_pipe++;
	}
      i++;
    }
  dprintf(2, ", ");
  print_int(param_reg[4]);
  dprintf(2, ", ");
  print_int(param_reg[5]);
}
コード例 #5
0
ファイル: ultrasonic.c プロジェクト: alkyl1978/stm32samples
void poll_ultrasonic() {
    uint32_t L;
    if(US_mode == US_MODE_OFF) {
        start_ultrasonic();
        return;
    }//else if(ultrasonic_ms != DIDNT_TRIGGERED) return;
    if(ultrasonic_get(&L)) { // measurements done, check event
        if(!overcapture) {
            if(!last_us_val) {
                last_us_val = L;
            } else {
                uint32_t diff = (last_us_val > L) ? last_us_val - L : L - last_us_val;
                if(diff > MAX_LEN_DIFF) {
                    if(last_us_val > L) { // someone move in front of sensor
                        ultrasonic_ms = Timer;
                        memcpy(&ultrasonic_time, &current_time, sizeof(curtime));
                        P("Pass! Was: ");
                        print_int(last_us_val);
                        P(", become: ");
                        print_int(L);
                        P("!!!\n");
                    } else { // free space - check for noices (signal should be at least 10ms)
                        diff = (ultrasonic_ms < Timer) ? Timer - ultrasonic_ms : ultrasonic_ms - Timer;
                        if(diff < ULTRASONIC_TIMEOUT)
                            ultrasonic_ms = DIDNT_TRIGGERED;
                    }
                    last_us_val = L;
                }
            }
        }
        start_ultrasonic();
    }
}
コード例 #6
0
ファイル: printing.c プロジェクト: clerkma/texlive-mobile
void log_banner(const char*v)
{
const char*months[]= {"   ",
"JAN","FEB","MAR","APR","MAY","JUN",
"JUL","AUG","SEP","OCT","NOV","DEC"
};
unsigned month= (unsigned)month_par;
if(month> 12)
month= 0;
fprintf(log_file,"This is "MyName", Version %s%s ",v,WEB2CVERSION);
print(format_ident);
print_char(' ');
print_char(' ');
print_int(day_par);
print_char(' ');
fprintf(log_file,"%s",months[month]);
print_char(' ');
print_int(year_par);
print_char(' ');
print_two(time_par/60);
print_char(':');
print_two(time_par%60);
if(shellenabledp){
wlog_cr();
wlog(' ');
if(restrictedshell)
fprintf(log_file,"restricted ");
fprintf(log_file,"system commands enabled.");
}
if(filelineerrorstylep){
wlog_cr();
fprintf(log_file," file:line:error style messages enabled.");
}
}
コード例 #7
0
ファイル: stepper_motors.c プロジェクト: eddyem/IR-controller
/**
 * displays periods of both generators
 */
void show_motors_period(sendfun s){
	P("[ " STR_SHOW_PERIOD " ", s);
	print_int((int32_t)Motor_period[0],s);
	s(' ');
	print_int((int32_t)Motor_period[1],s);
	P(" ]\n", s);
}
コード例 #8
0
ファイル: page.c プロジェクト: syntheticpp/cpptex
void tex::show_page_stats(int b, int pi, int c)
	{
	begin_diagnostic();
	print_nl("%");
	print(" t=");
	print_totals();
	print(" g=");
	print_scaled(page_goal);
	print(" b=");
	if (b == AWFUL_BAD) {
		print_char('*');
		} 
	else {
		print_int(b);
		}
	print(" p=");
	print_int(pi);
	print(" c=");
	if (c == AWFUL_BAD) {
		print("*");
	} else {
		print_int(c);
	}
	if (c <= least_page_cost) {
		print("#");
	}
	end_diagnostic(FALSE);
}
コード例 #9
0
ファイル: even_odd.c プロジェクト: DSrcl/c2mips
void main()
{
	print_int(odd(42)); // 0
	print_str("\n");
	print_int(even(42)); // 1
	print_str("\n");
} 
コード例 #10
0
ファイル: fct_print_game.c プロジェクト: Ustarroz/Tetris
int	print_game(t_game *game)
{
  int	j;

  j = 0;
  print_line(game->y + j, game->x, game->width);
  j = j + 1;
  print_int(game, j, game->high_score, "| High Score ");
  j = j + 1;
  print_int(game, j, game->score, "| Score ");
  j = j + 1;
  mvprintw(game->y + j, game->x + game->width, "|");
  mvprintw(game->y + j, game->x, "|");
  j = j + 1;
  print_int(game, j, game->lvl, "| Level ");
  j = j + 1;
  print_int(game, j, game->line, "| Line ");
  j = j + 1;
  mvprintw(game->y + j, game->x + game->width, "|");
  mvprintw(game->y + j, game->x, "|");
  j = j + 1;
  print_time(game, j);
  j = j + 1;
  print_line(game->y + j, game->x, game->width);
  j = j + 1;
  return (0);
}
コード例 #11
0
ファイル: user_fib.c プロジェクト: davidhesselbom/dv8
void
fib(void)
{
    msg_t msg_struct;
    msg_t *msg = &msg_struct;
    int n = 0;
    int i = 0;

    read_message_by_type(msg, MSG_TYPE_ARGUMENT, 100);
    if (msg_type_is_invalid(msg))
    {
        print_usage();
        return;
    }

    n = atoi(msg_data_get_string(msg));
    if (n <= 0)
    {
        print_usage();
        return;
    }

    for (i = 0; i <= n; ++i)
    {
        sleep(100);

        print_str("fib(");
        print_int(i);
        print_str(") = ");
        print_int(fib_rec(i));
        print_strln("");
    }
}
コード例 #12
0
ファイル: debug_int.c プロジェクト: agincel/SIT
void debug_int(struct s_node* head)
{
	assert(head != NULL);
	if(head != NULL)
	{
		while(head != NULL)
		{
			my_char('(');
			if(head->prev == NULL)
				my_str("NULL <- ");
			else
			{
				print_int(head->prev);
				my_str(" <- ");
			}

			print_int(head);

			if(head->next == NULL)
				my_str(" -> NULL)");
			else
			{
				my_str(" -> ");
				print_int(head->next);
				my_str("), ");
			}

			head = head->next;
		}
	}
}
コード例 #13
0
ファイル: print_to_console.cpp プロジェクト: 41i/hpx
int main()
{
    hpx::naming::id_type console = hpx::find_root_locality();

    // print something to the console
    {
        print_action<std::string> print_string;
        print_action<int> print_int;
        print_action<double> print_double;

        print_string(console, "Hello World!");
        print_int(console, 42);
        print_double(console, 3.1415);
    }

    // print something to the console using a direct action
    {
        print_direct_action<std::string> print_string;
        print_direct_action<int> print_int;
        print_direct_action<double> print_double;

        print_string(console, "Hello World!");
        print_int(console, 42);
        print_double(console, 3.1415);
    }

    return 0;
}
コード例 #14
0
ファイル: shift.c プロジェクト: nyuichi/ucc
int main () {
  print_int(1<<1);
  print_int(1<<2);
  print_int(1<<3);
  print_int(18>>1);
  print_int(18>>2);
  print_int(18>>3);
}
コード例 #15
0
ファイル: void-pointer.c プロジェクト: kw-udon/ucc
int main () {
  long a[3] = {1,2,3};
  int *p;
  p = (int*)(void*)a;
  print_int(p[0]);
  print_int(p[1]);
  print_int(p[2]);
}
コード例 #16
0
ファイル: switch.c プロジェクト: tomykaira/mips
int main() {
    print_int(callee(0));
    print_int(callee(1));
    print_int(callee(2));
    print_int(callee(3));

    return 0;
}
コード例 #17
0
ファイル: typedef.c プロジェクト: nyuichi/ucc
myInt main () {
  pair p;
  p.x = 1;
  p.y = 2;
  print_int(p.x);
  print_int(p.y);
  return 0;
}
コード例 #18
0
ファイル: div_minus.c プロジェクト: kw-udon/ucc
int main () {
  int x = 23;
  print_int(x / 3);
  print_int(-x / 3);
  print_int(x / -3);
  print_int(-x / -3);
  return 0;
}
コード例 #19
0
ファイル: main.c プロジェクト: eddyem/IR-controller
/**
 * print current time in milliseconds: 4 bytes for ovrvlow + 4 bytes for time
 * with ' ' as delimeter
 */
void print_time(sendfun s){
	if(mode == LINE_MODE) P("[ " STR_PRINT_TIME " ", s);
	print_int(tOVRFL, s);
	s(' ');
	print_int(Timer, s);
	if(mode == LINE_MODE) P(" ]\n", s);
	else if(mode == BYTE_MODE) s(' ');
}
コード例 #20
0
ファイル: xfile.c プロジェクト: nyuichi/xfile
int xvfprintf(xFILE *stream, const char *fmt, va_list ap) {
  const char *p;
  char *sval;
  int ival;
  double dval;
  void *vp;
  int cnt = 0;

  for (p = fmt; *p; p++) {
    if (*p != '%') {
      xputc(*p, stream);
      cnt++;
      continue;
    }
    switch (*++p) {
    case 'd':
    case 'i':
      ival = va_arg(ap, int);
      cnt += print_int(stream, ival, 10);
      break;
    case 'f':
      dval = va_arg(ap, double);
      cnt += print_int(stream, dval, 10);
      xputc('.', stream);
      cnt++;
      if ((ival = fabs((dval - floor(dval)) * 1e4) + 0.5) == 0) {
        cnt += xfputs("0000", stream);
      } else {
        int i;
        for (i = 0; i < 3 - (int)log10(ival); ++i) {
          xputc('0', stream);
          cnt++;
        }
        cnt += print_int(stream, ival, 10);
      }
      break;
    case 's':
      sval = va_arg(ap, char*);
      cnt += xfputs(sval, stream);
      break;
    case 'p':
      vp = va_arg(ap, void*);
      cnt += xfputs("0x", stream);
      cnt += print_int(stream, (long)vp, 16);
      break;
    case '%':
      xputc(*(p-1), stream);
      cnt++;
      break;
    default:
      xputc('%', stream);
      xputc(*(p-1), stream);
      cnt += 2;
      break;
    }
  }
  return cnt;
}
コード例 #21
0
ファイル: run-lvl1.c プロジェクト: nmav/cspim
int main(void)
{
	unsigned last_branch = 0;
	enum mips_exception err;
	Elf32_Sym *sym;
	const char *symname;
	int opcode;

	/* Prepare the code */

	l2_memory = sbrk(MEMSZ);
	if(!l2_memory)
		BREAK(1);
	mips_init();
	pcpu = mips_init_cpu(l2_memory, MEMSZ, STKSZ);
	if(mips_elf_load(pcpu, l2_elf, l2_elf_size) < 0)
		BREAK(2);

	/* Execute it */

	while(1) {
		if(pcpu->delay_slot)
			last_branch = pcpu->delay_slot-4;
		
		/* Print all labels as they are encountered. */
		if((sym = mips_elf_find_address(pcpu, pcpu->pc)) && 
		   (sym->st_value == pcpu->pc) &&
		   (symname = mips_elf_get_symname(pcpu, sym))) {
			printaddr("PC=", pcpu->pc);
			printaddr(",last_branch=", last_branch);
			print_char('\n');
		}
	
		if((err = mips_execute(pcpu)) == MIPS_E_OK)
			continue;
		if(err == MIPS_E_BREAK)
			break;
		
		/* Expected exceptions must exactly match PC. */
		if((sym = mips_elf_find_address(pcpu, pcpu->pc)) && 
		   (sym->st_value == pcpu->pc) &&
		   (symname = mips_elf_get_symname(pcpu, sym)) &&
		   (beginswith(symname, "EXN") == 0)) {
			pcpu->pc += 8;	
		} else {
			break;
		}
	}
	
	print_string("L1 FINISHED: exception="); print_int(err);
	print_string(", code="); print_int(mips_break_code(pcpu, &opcode));
	print_string(", "); printaddr("last_branch=", last_branch);
	print_char('\n');
	printaddr("PC=", pcpu->pc);
	print_char('\n');
	
	return 0;
}
コード例 #22
0
ファイル: tools.c プロジェクト: SoildFaker/stm32-quadrocopter
void print_float(float num)  
{  
  int part = (int)num/1;  
  
  print_int(part, 10, 0);  
  UsartPut('.');  
  part=num*1000000-part*1000000;  
  print_int(part, 10, 0);  
}  
コード例 #23
0
ファイル: test22.c プロジェクト: gizmo385/C-Minus-Minus
void main(void)
{
  x = 123456;
  y = x;
  print_int(x);
  print_string("\n");
  print_int(y);
  print_string("\n");
}
コード例 #24
0
ファイル: test.c プロジェクト: agusbauer/ProyectoCompiladores
// invoca varias funciones
void test(){
    float aux;
    aux = 2.0; 
    print_int(gcd(factorial(3),factorial(4)));
    print_int(nthprimeArray(gcd(factorial(3),factorial(4))));
    
    aux = potenciaR(aux,nthprimeArray(gcd(factorial(3),factorial(4))));
    print_float(aux);
}
コード例 #25
0
ファイル: dates.c プロジェクト: arashmahdian/samples
void print_date (date_type date) {
    
    print_int(date.month,0);
    print_str("/");
    print_int(date.day, 0);
    print_str("/");
    print_int(date.year, 0);
    
}
コード例 #26
0
ファイル: map.c プロジェクト: trainman419/Roborodentia-2011
int main(void)
{
	struct heading result;
	/*u08 k=0;
	u08 b=0;
	u08 choice=0;
	u08 button=0;*/
	u08 ir=0;
	u08 i=0;

	x = 64;
	y = 48;
	initialize();
	motor_init();
	servo_init();
	set_motor_power(0,0);
	set_motor_power(1,0);
	set_motor_power(2,0);
	set_motor_power(3,0);
	compass_init();
	sonar_init();

	calCompass();
	while(1)
	{
		clear_screen();
		result = compass();

		/* use calibration data */
		result.x -= compZero.x;
		result.y -= compZero.y;

		print_string("x ");     /*  2 */
		print_int(result.x);    /*  3 */
		print_string(" y ");    /*  3 */
		print_int(result.y);    /*  3 */
		/* print_string(" s ");  */ /*  3 */
		/* print_int(getSonar(0)); */ /*  3 */
					 /*  =17 */
		next_line();
		/* print_string("a "); */ /*  2 */
		/* print_int(IR(0)); */ /*  3 */
		/* print_string(" b "); */ /*  3 */
		/* print_int(analog(1)); */ /*  3 */
		/* print_string(" c "); */ /*  3 */
		/* print_int(analog(2)); */ /*  3 */
		/* print_int(i++); */ /*  =17 */
		/* print_int(distance(0));
		print_string(" "); */
		print_int(sizeof(int));
		delay_ms(200);
		/* print_int(i);
		i=sweep(); */

	}
}
コード例 #27
0
ファイル: static.cpp プロジェクト: crdelozier/CIS190Fall2015
int main(){
  print_int(5);
  print_int(10);
  print_int(15);

  Foo::x = 5;
  Foo::setX(6);

  return 0;
}
コード例 #28
0
ファイル: serial.c プロジェクト: zcweisman/arduino_os
//Set the cursor position
void set_cursor(uint8_t row, uint8_t col)
{
   //<ESC>[{ROW};{COLUMN}H
   write_byte(ESC);
   write_byte('[');
   print_int(row);
   write_byte(';');
   print_int(col);
   write_byte('H');
}
コード例 #29
0
ファイル: putint.c プロジェクト: eustachy/NachOS
int
main()
{
	print_int(5);
	print_int(423423);
	print_int(111111111);

	// Halt();
	return 7;
}
コード例 #30
0
ファイル: t01.c プロジェクト: JianpingZeng/minice
int test_const(int* a)
{
  int c1,c2,c3;
  c1 = 1; c2 = 2; c3 = 3;
  a[1] = 5;
  a[a[c3-c1*c2]] = 1;
  print_int (a[5]);
  print_string ("\nresult\n");
  print_int ( c3 * c2 );
}