URL
https://opencores.org/ocsvn/eco32/eco32/trunk
Subversion Repositories eco32
[/] [eco32/] [trunk/] [stdalone/] [twotasks-2/] [task1/] [task1.c] - Rev 130
Go to most recent revision | Compare with Previous | Blame | View Log
/* * task1.c -- a simple task */ #include "putchar.h" #include "stdarg.h" /**************************************************************/ void puts(char *s) { char c; while ((c = *s++) != '\0') { putchar(c); } } void printn(int n) { int a; if (n < 0) { putchar('-'); n = -n; } a = n / 10; if (a != 0) { printn(a); } putchar(n % 10 + '0'); } void printu(unsigned int n, unsigned int b) { unsigned int a; a = n / b; if (a != 0) { printu(a, b); } putchar("0123456789ABCDEF"[n % b]); } void printf(char *fmt, ...) { va_list ap; char c; int n; unsigned int u; char *s; va_start(ap, fmt); while (1) { while ((c = *fmt++) != '%') { if (c == '\0') { va_end(ap); return; } putchar(c); } c = *fmt++; if (c == 'd') { n = va_arg(ap, int); printn(n); } else if (c == 'u' || c == 'o' || c == 'x') { u = va_arg(ap, int); printu(u, c == 'o' ? 8 : (c == 'x' ? 16 : 10)); } else if (c == 's') { s = va_arg(ap, char *); puts(s); } else { putchar(c); } } } /**************************************************************/ void main(void) { int i; printf("TASK1: executing...\n"); i = 0; while (1) { printf("TASK1: %d\n", i); i++; } }
Go to most recent revision | Compare with Previous | Blame | View Log