diff --git a/src/r8asm.cc b/src/r8asm.cc index e90efb7..e6721d6 100644 --- a/src/r8asm.cc +++ b/src/r8asm.cc @@ -281,8 +281,13 @@ r8asm::ast_node r8asm::ast::expand_node_to_ins(const ast_node &node) { // >[< } break; case builtin_t::ENDLOOP: { + // Consume one '1' from the auxiliary cell and pull the next bit down. + // Without the ror, the rnz could only ever see the bit that flb just + // cleared, so a .loop over 0b111 ran once instead of three times + // (SPEC: "consecutive 1s starting from the LSB"). to_return.children.push_back(ROT8_NODE("stp")); to_return.children.push_back(ROT8_NODE("flb")); + to_return.children.push_back(ROT8_NODE("ror")); to_return.children.push_back(ROT8_NODE("rnz")); to_return.children.push_back(ROT8_NODE("btp")); // >-+]<