Thursday, January 03, 2013

kragensitaker comments on Programming thought experiment: stuck in a room with a PC without an OS.

kragensitaker comments on Programming thought experiment: stuck in a room with a PC without an OS.: "You'd need a minimal "monitor" to start with — something that would let you enter in some binary code on an input device and jump to it. Here's a C version that lets you enter code in octal:
typedef void (*function)();
char program[32];
int main() {
char *t = program;
unsigned i, n;
for (;;) {
for (i = 3; i; i--) {
n = getch() - '0';
if (n > 7) (*(function)program)();
*t = *t * 8 + n;
}
t++;
}
}"

'via Blog this'