Browse Source

functioning hello world

canon
Hazel Levine 2 years ago
parent
commit
9296ecab9b
2 changed files with 7 additions and 4 deletions
  1. +1
    -1
      Makefile
  2. +6
    -3
      src/brainfuck.cpp

+ 1
- 1
Makefile View File

@ -7,7 +7,7 @@ TARGET := bin/bfi
SRCEXT := cpp
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o))
CFLAGS := -g -Wall
CFLAGS := -g -Wall -std=c++11
LIB := -pthread
INC := -I include


+ 6
- 3
src/brainfuck.cpp View File

@ -12,11 +12,14 @@ void Interpreter::run() {
// gamers, let's get this bread
for (std::size_t i = 0; i < prog.size(); i++) {
processIndex(i);
int j = 0;
j = i;
if ((prog[i] == OpCode::LoopEnd) && (data_tape[ptr] == '\0')) { // we might have to make a jump!
i = jump.top();
if ((prog[i] == OpCode::LoopEnd) && (data_tape[ptr] != '\0')) { // we might have to make a jump!
i = jump.top() - 1; // account for i++?
}
processIndex(j);
}
if (!jump.empty()) { // levels of brackets don't match


Loading…
Cancel
Save