Close

begin and again as loop

A project log for Jelly

A minimal DIY 8-bit CPU made with TTL chips, to perform native brainfu*k language, extended to use three sequential access tapes.

alvaro-barcellosAlvaro Barcellos 06/20/2023 at 22:100 Comments

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

outputoutput
begin [
] againzeropage 1
page 2
 FLIP  1
FLIP 2
results
0001010toggle page 1
0000101toggle page 2
1000010toggle page 1
0110001toggle page 2
0011000forward
0010100backward
1001000count + 1
1011000count + 1
0101000count - 1
0111000count - 1
1000100count + 1
1010100count + 1
0100100count - 1
01101

00count - 1

Discussions