From 1cf8c67eb673d2e344b1ae874c3d51f1e7c23d96 Mon Sep 17 00:00:00 2001 From: Zihao Yu Date: Sat, 1 Jul 2023 01:25:46 +0800 Subject: [PATCH] kernels,bf: port to AM --- kernels/bf/Makefile | 3 + kernels/bf/bf.c | 143 +++++++++++++++++++-------------------- kernels/bf/mandelbrot.h | 146 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 219 insertions(+), 73 deletions(-) create mode 100644 kernels/bf/Makefile create mode 100644 kernels/bf/mandelbrot.h diff --git a/kernels/bf/Makefile b/kernels/bf/Makefile new file mode 100644 index 0000000..32656d4 --- /dev/null +++ b/kernels/bf/Makefile @@ -0,0 +1,3 @@ +NAME = bf +SRCS = bf.c +include $(AM_HOME)/Makefile diff --git a/kernels/bf/bf.c b/kernels/bf/bf.c index 3d32806..6804895 100644 --- a/kernels/bf/bf.c +++ b/kernels/bf/bf.c @@ -4,81 +4,78 @@ * * Robert de Bath -- 2013. */ -#include -#include -#include - +#include +#include + +const char *prog = +#include "mandelbrot.h" +; + struct bfi { char cmd; struct bfi *next, *jmp; }; struct mem { char val; struct mem *next, *prev; }; - -int main(int argc, char **argv) -{ - FILE * ifd; - int ch; - struct bfi *p=0, *n=0, *j=0, *pgm = 0; - struct mem *m = calloc(1,sizeof*m); - setbuf(stdout, NULL); - - /* Open the file from the command line or stdin */ - if (argc < 2 || strcmp(argv[1], "-") == 0) ifd = stdin; - else if ((ifd = fopen(argv[1], "r")) == 0) { perror(argv[1]); exit(1); } - - /* - * For each character, if it's a valid BF command add it onto the - * end of the program. If the input is stdin use the '!' character - * to mark the end of the program and the start of the data, but - * only if we have a complete program. The 'j' variable points - * at the list of currently open '[' commands, one is matched off - * by each ']'. A ']' without a matching '[' is not a legal BF - * command and so is ignored. If there are any '[' commands left - * over at the end they are not valid BF commands and so are ignored. - */ - while((ch = getc(ifd)) != EOF && (ifd!=stdin || ch != '!' || j || !pgm)) { - if (ch == '<' || ch == '>' || ch == '+' || ch == '-' || - ch == ',' || ch == '.' || ch == '[' || (ch == ']' && j)) { - if ((n = calloc(1, sizeof*n)) == 0) { - perror(argv[0]); exit(1); - } - if (p) p->next = n; else pgm = n; - n->cmd = ch; p = n; - if (n->cmd == '[') { n->jmp=j; j = n; } - else if (n->cmd == ']') { - n->jmp = j; j = j->jmp; n->jmp->jmp = n; - } - } + +int main() { + int ch; + struct bfi *p=0, *n=0, *j=0, *pgm = 0; + struct mem *m = malloc(sizeof(*m)); + + /* + * For each character, if it's a valid BF command add it onto the + * end of the program. If the input is stdin use the '!' character + * to mark the end of the program and the start of the data, but + * only if we have a complete program. The 'j' variable points + * at the list of currently open '[' commands, one is matched off + * by each ']'. A ']' without a matching '[' is not a legal BF + * command and so is ignored. If there are any '[' commands left + * over at the end they are not valid BF commands and so are ignored. + */ + const char *s = prog; + while((ch = *(s ++)) != '\0') { + if (ch == '<' || ch == '>' || ch == '+' || ch == '-' || + ch == ',' || ch == '.' || ch == '[' || (ch == ']' && j)) { + if ((n = malloc(sizeof(*n))) == NULL) { + printf("malloc failed! exiting...\n"); + return 1; + } + if (p) p->next = n; else pgm = n; + n->cmd = ch; p = n; + if (n->cmd == '[') { n->jmp=j; j = n; } + else if (n->cmd == ']') { + n->jmp = j; j = j->jmp; n->jmp->jmp = n; + } } - - /* Ignore any left over '[' commands */ - while(j) { p = j; j = j->jmp; p->jmp = 0; p->cmd = ' '; } - - if (ifd!=stdin) fclose(ifd); - - /* Execute the loaded BF program */ - for(n=pgm; n; n=n->next) - switch(n->cmd) - { - case '+': m->val++; break; - case '-': m->val--; break; - case '.': putchar(m->val); break; - case ',': if((ch=getchar())!=EOF) m->val=ch; break; - case '[': if (m->val == 0) n=n->jmp; break; - case ']': if (m->val != 0) n=n->jmp; break; - case '<': - if (!(m=m->prev)) { - fprintf(stderr, "%s: Hit start of tape\n", argv[0]); - exit(1); - } - break; - case '>': - if (m->next == 0) { - if ((m->next = calloc(1,sizeof*m)) == 0) { - perror(argv[0]); exit(1); - } - m->next->prev = m; - } - m=m->next; - break; + } + + /* Ignore any left over '[' commands */ + while(j) { p = j; j = j->jmp; p->jmp = 0; p->cmd = ' '; } + + /* Execute the loaded BF program */ + for(n=pgm; n; n=n->next) { + switch(n->cmd) { + case '+': m->val++; break; + case '-': m->val--; break; + case '.': putch(m->val); break; + case ',': if((ch=*(s ++))!='\0') m->val=ch; break; + case '[': if (m->val == 0) n=n->jmp; break; + case ']': if (m->val != 0) n=n->jmp; break; + case '<': + if (!(m=m->prev)) { + printf("Hit start of tape\n"); + return 1; } - - return 0; + break; + case '>': + if (m->next == 0) { + if ((m->next = malloc(sizeof(*m))) == NULL) { + printf("malloc failed! exiting...\n"); + return 1; + } + m->next->prev = m; + } + m=m->next; + break; + } + } + + return 0; } diff --git a/kernels/bf/mandelbrot.h b/kernels/bf/mandelbrot.h new file mode 100644 index 0000000..0b211a8 --- /dev/null +++ b/kernels/bf/mandelbrot.h @@ -0,0 +1,146 @@ +"\ + A mandelbrot set fractal viewer in brainf*** written by Erik Bosman \ ++++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[ \ +>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+ \ +<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>> \ +>+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+[>>>>>>[>>>>>>>[-]>>]<<<<<<<<<[<<<<<<<<<]>> \ +>>>>>[-]+<<<<<<++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<+++++++[-[->>> \ +>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[[-]>>>>>>[>>>>> \ +>>[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<+<<<+<]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