Skip to content

Commit

Permalink
Task 3: store builders on the stack
Browse files Browse the repository at this point in the history
  • Loading branch information
akifoq committed Aug 18, 2023
1 parent 6c4b2f7 commit 70f4489
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions contracts/3.fc
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ builder solve_asm(int flat, slice text) asm """
// f t fl blds res v
STSLICERQ // .. res v -1 or res' 0
IF:<{
s0 s2 XCHG CONS // v blds
SWAP NEWC // .. blds v res
STSLICE // blds res
// .. 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
}> // .. next f t fl blds res

// next f t fl blds res
s5 PUSH ISNULL IFRETALT
Expand All @@ -100,29 +100,21 @@ builder solve_asm(int flat, slice text) asm """

}> // next f t fl blds res
// next f t fl blds res
NIP
// ... next f t fl res

s2 POP s4 POP s2 POP // blds res t
STSLICERQ // .. res v -1 or res' 0
NIP s3 POP NIP
// .. res t

STSLICERQ // .. res t -1 or res' 0
IF:<{
s0 s2 XCHG CONS // v blds
SWAP NEWC // .. blds v res
STSLICE // blds res
// .. res t
NEWC STSLICE // .. res res'
}>

DEPTH DEC REPEAT:<{
STBREFR
}>
// blds res

WHILE:<{
OVER // blds res blds
ISNULL // blds res _38
NOT // blds res _39
}>DO<{ // blds res
SWAP // res blds
UNCONS // res res' blds
s0 s2 XCHG // blds res' res
ENDC // blds res' _43
SWAP // blds _43 res'
STREF // blds res
}> // blds res
NIP // res
""";

builder solve(int flag, slice text) {
Expand Down

0 comments on commit 70f4489

Please sign in to comment.