BTW: What character is on position 06 of the mentioned code?
Is it's ascii 31? OK, it must be ... I like the idea <>+- are almost the same command with parameters (-1,0),(1,0),(0,1),(0,-1) ... (computed from opcodes rather than tabulated). I must say I am a bit confused by the PC going the central path in both directions ... I really cannot imagine how you could invent it. I have not studied the memory layout thoroughly ... of course I know the 00-0X is the simulated brainfuck code (with ! or \0 at the end) and (10-) are brainfuck registers. As the PC and MP are on stack, you must do rather uneffective 3v3v3v and 2v2v sequences.
I don't know if the only problem is the cycle limit.
Small Brainfuck
Nested loops
I think I may have found a simpler way to compile nested loops:Hippo wrote:Oh OK simple is relative . Your compiller cycle solution was hard to extend to nested loops, my original layout works for arbitrary level of nesting (level 4 is max, but starting on line 9 would allow levels upto 9).
Code: Select all
[/?x [/?x \s0 \s0
%00 }1+}1+}1+ x?s\ }1+ x?s\ 1-{1+1+1+} x?/ {{ x?/ }xp !
1s\ 1s\ x1:? x1:?
Code: Select all
>+>+>+[>+[-<+++>]<<]>.
Single-line loops
I have been thinking about it, but even with this restriction single-line loops are not possible. However, I have found a way to compile even nested loops in just two lines:Hippo wrote:One liner for general while cycle is impossible. Oneliners are possible for cycles of known maximal number of repetitions. ... oh there is 300 brainfuck rounds limit ... so may be ...
Code: Select all
... s/x?@s\x?s\ ... s/x?@s\x?s\ ... $/ ... $/ ...
s\ss1s/ s\ s\ss1s/ s\ x1:? x1:?
Re: Single-line loops
I must say I like it it simplifies the compiler as it does not need threads to fill empty space.a.goth wrote:Is it possible to simplify this further?Code: Select all
... s/x?@s\x?s\ ... s/x?@s\x?s\ ... $/ ... $/ ... s\ss1s/ s\ s\ss1s/ s\ x1:? x1:?
And it even saves time as it skips walks back in cycles.
Thanks to $' it would be even possible to incorporate computed speedups on the fly.
([->++++<] compilation which adds to > 4 times . and clears . and so)
I just don't think theses speedups would be interesting in cases with at most 300 brainfuck cycles.