const char *apps_lst[] = { "", "reboot", "osver", "time", "place", "cls", "memory", "help", "cpu_info", "memstat" }; int apps_count = 10; unsigned int atox(const char* str) { unsigned int temp = 0; int i; unsigned int digit = 0; for (i = 0; str[i]!=0; i++) { if (str[i] >= '0' && str[i] <= '9') digit = str[i] - '0'; else if (str[i] >= 'A' && str[i] <= 'F') digit = str[i] - 'A' + 10; else if (str[i] >= 'a' && str[i] <= 'f') digit = str[i] - 'a' + 10; else break; temp = temp*16 + digit; } return temp; } unsigned int atoui(const char* str) { unsigned int temp = 0; int i; for (i = 0; str[i] >= '0' && str[i] <= '9' ; i++) temp = temp*10 + (str[i] - '0'); return temp; } void apps_osver() { printf ("CTA 32bit Operating System v0.1"); printf ("\n(c) CTA 2010\n"); } void apps_time() { printf ("Today is %s, %u of %s, %u%u.\n", clock_weekdays[_internal_clock.weekday], (unsigned int) _internal_clock.day, clock_months[_internal_clock.month], (unsigned int) _internal_clock.century, (unsigned int) _internal_clock.year); printf ("Now is %u:%u:%u.\n", (unsigned int) _internal_clock.hours, (unsigned int) _internal_clock.minutes, (unsigned int) _internal_clock.seconds); } void apps_place() { printf ("On your desk, if you didn't notice... \n"); } void apps_clrscr() { clrscr(); } void apps_memory(const int pn, const char* param[]) { if (pn<3) { printf ("Correct syntax: memory [start_address] [end_address] (in hex)\n"); return; } byte *start, *end; start = (byte *) atox (param[1]); end = (byte *) atox (param[2]); byte* count; while (start <= end) { put_hex ((unsigned int) start); puts(": "); for (count = start; count < start+16; count++) { putc(hex[*count/16]); putc(hex[*count%16]); putc(' '); } puts(" "); for (count = start; count < start+16; count++) { if (*count < 32) putc('.'); else putc(*count); } putc('\n'); start+=16; } } void apps_help(const int pn, const char* param[]) { int i; puts ("\n"); if (pn==1) { puts("[BeTA]\n"); puts("Available commands:"); for (i = 1; i < apps_count; i++) { puts("\n \t "); puts((char*)apps_lst[i]); } puts("\n\nUse help [command] for help on individual commands.\n"); return; } for (i = 0; strcmp(apps_lst[i], param[1])!=0 && i