Skip to content

Commit

Permalink
Task 3: replace AGAINBRK with UNTIL
Browse files Browse the repository at this point in the history
  • Loading branch information
akifoq committed Aug 18, 2023
1 parent 9d057cf commit 2420f28
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions contracts/3.fc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2420f28

Please sign in to comment.