Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* This file is part of RexOS!.
- *
- * RexOS! is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * RexOS! is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with RexOS!. If not, see <https://www.gnu.org/licenses/>.
- */
- #include <stdint.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- uint8_t tape[30000] = {0};
- void _interpret(char *edx)
- {
- uint8_t *edi = tape;
- uint32_t eax = 0;
- uint16_t ch = 1;
- uint32_t cl = 0;
- size_t rax = -1;
- loop:
- rax++;
- cl = edx[rax];
- if (cl == 0)
- goto exit;
- if (cl == '>')
- goto pinc;
- if (cl == '<')
- goto pdec;
- if (cl == '+')
- goto vinc;
- if (cl == '-')
- goto vdec;
- if (cl == '.')
- goto prnt;
- if (cl == ']')
- goto bend;
- goto loop;
- pinc:
- ++edi;
- goto loop;
- pdec:
- --edi;
- goto loop;
- vinc:
- ++*edi;
- goto loop;
- vdec:
- --*edi;
- goto loop;
- prnt:
- putchar(*edi);
- goto loop;
- bend:
- if (*edi == 0)
- goto loop;
- ch = 1;
- ilst:
- if (ch <= 0)
- goto loop;
- rax--;
- cl = edx[rax];
- if (cl == '[')
- goto dclp;
- if (cl == ']')
- goto inlp;
- goto ilst;
- dclp:
- ch--;
- goto ilst;
- inlp:
- ch++;
- goto ilst;
- exit:
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement