From 2420f286a2cc1aa69eb94eb4711ddd2b1ff78db1 Mon Sep 17 00:00:00 2001 From: Andrei Date: Fri, 18 Aug 2023 23:33:32 +0400 Subject: [PATCH] Task 3: replace AGAINBRK with UNTIL --- contracts/3.fc | 51 ++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/contracts/3.fc b/contracts/3.fc index 867789c..9b113c1 100644 --- a/contracts/3.fc +++ b/contracts/3.fc @@ -62,30 +62,33 @@ builder solve_asm(int flat, slice text) asm """ NEWC // next f t fl blds res AGAINBRK:<{ - AGAINBRK:<{ - // f t fl blds res - 2OVER PLDUXQ IFNOTRETALT - // f t fl blds res x - - s5 PUSH // f t fl blds res x f - - EQUAL // f t fl blds res _15 - IF:<{ // f t fl blds res - 2OVER SDSKIPFIRST // f t fl blds res t' - s4 POP // f t' fl blds res - value GETGLOB // f t fl blds res v - }>ELSE<{ // f t fl blds res - s0 s3 XCHG // f res fl blds t - 1 LDSLICE // f res fl blds v t - s4 s4 XCHG2 // f t fl blds res v - }> - - // f t fl blds res v - STSLICERQ // .. res v -1 or res' 0 - IF:<{ - // .. next f t fl blds res v - NEWC STSLICE // .. next f t fl blds res res' - SWAP 6 ROLLREV // .. res next f t fl blds res' + // f t fl blds res + 2OVER PLDUXQ IF:<{ + UNTIL:<{ + // f t fl blds res x + + s5 PUSH // f t fl blds res x f + + EQUAL // f t fl blds res _15 + IF:<{ // f t fl blds res + 2OVER SDSKIPFIRST // f t fl blds res t' + s4 POP // f t' fl blds res + value GETGLOB // f t fl blds res v + }>ELSE<{ // f t fl blds res + s0 s3 XCHG // f res fl blds t + 1 LDSLICE // f res fl blds v t + s4 s4 XCHG2 // f t fl blds res v + }> + + // f t fl blds res v + STSLICERQ // .. res v -1 or res' 0 + IF:<{ + // .. next f t fl blds res v + NEWC STSLICE // .. next f t fl blds res res' + SWAP 6 ROLLREV // .. res next f t fl blds res' + }> + + 2OVER PLDUXQ NOT }> }> // .. next f t fl blds res