diff options
author | MITSUNARI Shigeo <[email protected]> | 2018-09-04 11:41:11 +0900 |
---|---|---|
committer | MITSUNARI Shigeo <[email protected]> | 2018-09-04 11:48:56 +0900 |
commit | 1de435ed04c8e74775804da944d176baf0ce56e2 (patch) | |
tree | 03656be62319e8cf46892901d2ba4ba7e845b4e9 | |
parent | 613922bda3b1b789fc0c28ed060b3bf9fab4ffb2 (diff) | |
download | xbyak-1de435ed04c8e74775804da944d176baf0ce56e2.tar.gz xbyak-1de435ed04c8e74775804da944d176baf0ce56e2.zip |
bf uses Label classv5.71
-rw-r--r-- | sample/bf.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/sample/bf.cpp b/sample/bf.cpp index ce5c12e..6968920 100644 --- a/sample/bf.cpp +++ b/sample/bf.cpp @@ -10,12 +10,6 @@ #endif class Brainfuck : public Xbyak::CodeGenerator { -private: - enum Direction { B, F }; - std::string toStr(int labelNo, Direction dir) - { - return Xbyak::Label::toStr(labelNo) + (dir == B ? 'B' : 'F'); - } public: int getContinuousChar(std::istream& is, char c) { @@ -67,8 +61,7 @@ public: mov(pGetchar, rsi); // getchar mov(stack, rdx); // stack #endif - int labelNo = 0; - std::stack<int> keepLabelNo; + std::stack<Label> labelF, labelB; char c; while (is >> c) { switch (c) { @@ -116,17 +109,22 @@ public: mov(cur, eax); break; case '[': - L(toStr(labelNo, B)); - mov(eax, cur); - test(eax, eax); - jz(toStr(labelNo, F), T_NEAR); - keepLabelNo.push(labelNo++); + { + Label B = L(); + labelB.push(B); + mov(eax, cur); + test(eax, eax); + Label F; + jz(F, T_NEAR); + labelF.push(F); + } break; case ']': { - int no = keepLabelNo.top(); keepLabelNo.pop(); - jmp(toStr(no, B)); - L(toStr(no, F)); + Label B = labelB.top(); labelB.pop(); + jmp(B); + Label F = labelF.top(); labelF.pop(); + L(F); } break; default: |