Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- using namespace std;
- struct Interpreter
- {
- char MEM[30'000];
- char PC;
- char SP = 0;
- void increment()
- {
- if (MEM[SP] < 255)
- {
- MEM[SP] = MEM[SP] + 1;
- }
- else
- MEM[SP] = 0;
- }
- void Interpret(string code)
- {
- for(char c: code)
- {
- switch (c)
- {
- case '+':
- increment();
- break;
- case '-':
- printf("-\n");
- break;
- default:
- break;
- }
- }
- }
- };
- void increment(Interpreter& BF)
- // increment the memory @ stackPointer by 1 and wrap to 0 if > 255
- {
- }
- int main (int argc, char* argsv[])
- {
- string code = "+++";
- Interpreter BF;
- BF.Interpret(code);
- printf("Now SP is %d", BF.MEM[BF.SP]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement