kernels: merge bf to demo

This commit is contained in:
Zihao Yu 2023-07-22 22:10:07 +08:00
parent c5bcf378e8
commit 4707aefcc5
4 changed files with 28 additions and 11 deletions

98
kernels/demo/src/bf/bf.c Normal file
View file

@ -0,0 +1,98 @@
/* from http://rosettacode.org/wiki/Execute_Brain****#C */
/* This is the Neutron brainfuck interpreter.
* It's rather small and dense, but still readable, more or less.
*
* Robert de Bath -- 2013.
*/
#include <am.h>
#include <klib.h>
#include <io.h>
static const char *prog =
#include "mandelbrot.h"
;
struct bfi { char cmd; struct bfi *next, *jmp; };
struct mem { char val; struct mem *next, *prev; };
static inline void putch2(char c) {
static int x = 0, y = 0;
if (c == '\n') {
y ++;
x = 0;
} else {
if (x % 2 == 0) {
print_char(c, y, x / 2);
screen_refresh();
}
x ++;
}
}
void bf() {
int ch;
struct bfi *p=0, *n=0, *j=0, *pgm = 0;
struct mem *m = malloc(sizeof(*m));
memset(m, 0, sizeof(*m));
screen_clear();
/*
* 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");
halt(1);
}
memset(n, 0, sizeof(*n));
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 = ' '; }
/* Execute the loaded BF program */
for(n=pgm; n; n=n->next) {
switch(n->cmd) {
case '+': m->val++; break;
case '-': m->val--; break;
case '.': putch2(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");
halt(1);
}
break;
case '>':
if (m->next == 0) {
if ((m->next = malloc(sizeof(*m))) == NULL) {
printf("malloc failed! exiting...\n");
halt(1);
}
memset(m->next, 0, sizeof(*m));
m->next->prev = m;
}
m=m->next;
break;
}
}
}

View file

@ -0,0 +1,146 @@
"\
A mandelbrot set fractal viewer in brainf*** written by Erik Bosman \
+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[ \
>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+ \
<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>> \
>+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+[>>>>>>[>>>>>>>[-]>>]<<<<<<<<<[<<<<<<<<<]>> \
>>>>>[-]+<<<<<<++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<+++++++[-[->>> \
>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[[-]>>>>>>[>>>>> \
>>[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<+<<<+<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>> \
[>>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<+<<]>>>>>>>>]<<<<<<<<<[<<<<<<< \
<<]>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<<<]>>>>>>>>>+++++++++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<<<]>>>>>>>>>[>>>>>>[-<<<<<<->>>>>>]+< \
<<<<<[->>>>>>->>[-<<<<<<<<+>>>>>>>>]<<<<<<<<[->>>>>>>>+<<<<<<<<<<<<<<<<<[<<<<<<< \
<<]>>>>[-]+>>>>>[>>>>>>>>>]>+<]]+>>>>>>>>[-<<<<<<<<->>>>>>>>]+<<<<<<<<[->>>>>>>> \
-<<[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+>>>>>>[>>>>>> \
>>>]>[-]+<]]+>[-<[>>>>>>>>>]<<<<<<<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>[-]<<<++++ \
+[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>->>>>>>>>>>>>>>>>>>>>>>>>>>>-<<<<<<[<<<< \
<<<<<]]>>>]"

View file

@ -9,6 +9,7 @@ void game_of_life();
void aclock();
void cmatrix();
void donut();
void bf();
int main(const char *args) {
ioe_init();
@ -21,6 +22,7 @@ int main(const char *args) {
case '5': aclock(); break;
case '6': cmatrix(); break;
case '7': donut(); break;
case '8': bf(); break;
default:
printf("Usage: make run mainargs=*\n");
printf(" 1: ant\n");
@ -30,6 +32,7 @@ int main(const char *args) {
printf(" 5: aclock\n");
printf(" 6: cmatrix\n");
printf(" 7: donut\n");
printf(" 8: bf\n");
}
printf("Press Q to Exit\n");