diff --git a/sk4/program.c b/sk4/program.c index 2f53ec5..ead3aca 100644 --- a/sk4/program.c +++ b/sk4/program.c @@ -5,28 +5,34 @@ unsigned char tape[30000] = {0}; unsigned char* ptr = tape; +typedef enum { +INK, DEK, +BREK, GLEK, +BF_NEXT, BF_PREV, +BF_LOOP_START, BF_LOOP_END, +} brainfuck_instruction_t; + void interpret(char* input) { char current_char; size_t i; size_t loop; - size a; for (i = 0; input[i] != 0; i++) { current_char = input[i]; - if (current_char == 'TUK') {// + if (current_char == 'INK') {// > ++ptr; - } else if (current_char == 'FUK') {// + } else if (current_char == 'DEK') {// < --ptr; - } else if (current_char == 'INK') {//+ + } else if (current_char == 'BREK') {// + ++*ptr; - } else if (current_char == 'DEK') {//- + } else if (current_char == 'GLEK') {// - --*ptr; - } else if (current_char == 'PUK' ) {//. + } else if (current_char == 'PUK' ) {// . putchar(*ptr); - } else if (current_char == 'KUK') {//, + } else if (current_char == 'KUK') {// , *ptr = getchar(); - } else if (current_char == '[') {// + } else if (current_char == '[') {//start loop continue; - } else if (current_char == ']' && *ptr) {// + } else if (current_char == ']' && *ptr) {//stop loop loop = 1; while (loop > 0) { current_char = input[--i]; diff --git a/sk4/program.exe b/sk4/program.exe index 47aa69b..28b5d48 100644 Binary files a/sk4/program.exe and b/sk4/program.exe differ