How To
All Jelly opcodes are easy implemented except loops. the [ and ], refered as begin and again, keep me in a round-robin by months without a feasible solution.
As pseudo-code, there are three groups of actions, for simplify, I call as page zero, page one and page two.
In page zero, all opcodes are executed and when a begin occurs and data is zero that clear a counter and change to page one, when a again occurs and data is not zero that clear a counter and change to page two.
In page one, when found a begin increase a counter, when found a again decrease a counter, then moves code tape forward and if counter is zero change to page 0.
In page two, when found a begin increase a counter, when found a again decrease a counter, then moves code tape backward and if counter is zero change to page 0.
Since no data is read while in page one or two, the circuit of U7, U2, U8 is used as counter
Make It
the solution was make true-table for lines and states.
begin is a line set high when code is [
again is a line set high when code is ]
zero is a line set high when data is non zero
page 1 is the address A9 line for eeproms U1 and U2
page 2 is the address A10 line for eeproms U1 and U2
flip 1 is the clock for D-Flip-FLop the control the address A9 line
flip 2 is the clock for D-Flip-FLop the control the address A10 line
when page 2 is set the movement is backward.
Table 1 - lines and states for loops
output | output | ||||||
begin [ | ] again | zero | page 1 | page 2 | FLIP 1 | FLIP 2 | results |
0 | 0 | 0 | 1 | 0 | 1 | 0 | toggle page 1 |
0 | 0 | 0 | 0 | 1 | 0 | 1 | toggle page 2 |
1 | 0 | 0 | 0 | 0 | 1 | 0 | toggle page 1 |
0 | 1 | 1 | 0 | 0 | 0 | 1 | toggle page 2 |
0 | 0 | 1 | 1 | 0 | 0 | 0 | forward |
0 | 0 | 1 | 0 | 1 | 0 | 0 | backward |
1 | 0 | 0 | 1 | 0 | 0 | 0 | count + 1 |
1 | 0 | 1 | 1 | 0 | 0 | 0 | count + 1 |
0 | 1 | 0 | 1 | 0 | 0 | 0 | count - 1 |
0 | 1 | 1 | 1 | 0 | 0 | 0 | count - 1 |
1 | 0 | 0 | 0 | 1 | 0 | 0 | count + 1 |
1 | 0 | 1 | 0 | 1 | 0 | 0 | count + 1 |
0 | 1 | 0 | 0 | 1 | 0 | 0 | count - 1 |
0 | 1 | 1 | 0 | 1 | 0 | 0 | count - 1 |
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.