Close

loops without jumps

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 09/09/2022 at 13:020 Comments

Jelly must have some external logic to complement FSM eeproms.

The way found to simulate an "IF" or "ELSE" was to change the "page", depending on external conditions.

Circuits define "check and clear" logic. For bob, one, two signals, when two are active they are used to validate the conditions. For signals fw, bk, rd, wr, which cannot be active simultaneously.

The one and two signals are used to activate the swap signal, which works like a toggle switch that inverts the selection between one and two.

The bob and one signals are used to activate the move signal, which works like a toggle switch that inverts the selection between move forward or backward. This is needed to simplify the loop logic.

The bob and two signals are used with the zero signal to select "page one" by activating a  toggle switch for address a08. In the "page one" commands just executes a next opcode, else [ and ], that increase or decrease a counter.

The pseudo code for processing [ and ] loops in "page one" :

for ( ; ; ) {
      if (c==[) cnt++;
      if (c==]) cnt--;
      if (cnt == 0) break;
      c = next();
}

PS.

the next action is a tape bob sequence of  move and read. move could be forward or backward. the move signal toggles setup direction and both could be coded as a single operation move.

the logic circuit is showed in file jelly-two-halt.dig

-- this still a stub ---

the conditions table of loops [ and ] could be resumed as

case
page
loop
conditionaction
10[zero == NO
next
20[zero  == YES
go page 1
31[zero == NO
inc count, next
41[zero == YES
inc count, next
50]zero == NO
go page 1
60]zero == YES
next
71]zero == NO
dec count,  prev
81]zero == YES
go page 0

Discussions