Skip to content

Commit

Permalink
Missing functionality in binary VMs.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkskeller committed Apr 8, 2024
1 parent 90024e5 commit bec7265
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions GC/Processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class Processor : public ::ProcessorBase, public GC::RuntimeBranching
void print_str(int n);
void print_float(const vector<int>& args);
void print_float_prec(int n);

void incint(const BaseInstruction& instruction);
};

template <class T>
Expand Down
13 changes: 13 additions & 0 deletions GC/Processor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,19 @@ void Processor<T>::print_float_prec(int n)
out << setprecision(n);
}

template<class T>
void Processor<T>::incint(const BaseInstruction& instruction)
{
auto dest = &I[instruction.get_r(0)];
auto base = I[instruction.get_r(1)];
auto& start = instruction.get_start();
for (int i = 0; i < instruction.get_size(); i++)
{
int inc = (i / start[0]) % start[1];
*dest++ = base + inc * int(instruction.get_n());
}
}

} /* namespace GC */

#endif
1 change: 1 addition & 0 deletions GC/instructions.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
X(SUBINT, I0 = PI1 - PI2) \
X(MULINT, I0 = PI1 * PI2) \
X(DIVINT, I0 = PI1 / PI2) \
X(INCINT, PROC.incint(instruction)) \
X(JMP, PROC.PC += IMM) \
X(JMPNZ, if (I0 != 0) PROC.PC += IMM) \
X(JMPEQZ, if (I0 == 0) PROC.PC += IMM) \
Expand Down

0 comments on commit bec7265

Please sign in to comment.