Author Topic: Conditional logic  (Read 384 times)

Offline Glom

  • Jupiter
  • ***
  • Posts: 986
Conditional logic
« on: October 04, 2018, 04:29:23 PM »
Everyone check out Ben Eater's channel on YouTube and his playlist of building an 8 bit computer on a breadboard (or more like a dozen breadboards).

It brilliantly demonstrates how computers are not elven magic, but the results of logical result of assembling the atomic components of transisters, capacitors and resistors.

Also, his wires are a work of art. That thing needs displaying in the Louvre.

Here's my issue though and it happened right at the end when he introduced conditional logic in the last video.

This was done by using the flags to inform the microcode selection. The flags, a carry flag for when the adder overflowed, and a zero flag for when the adder was zero, are used as bits in the address on the ROM chips programmed with the micro-instructions for the computer. This means that for the other instructions that aren't conditional, they are duplicated four times.

If the computer gets more sophisticated and you have more flags, this will ridiculous. If you have a 32 bit flags register, your ROM with the microcode will need to be 4 billion times bigger than it needs to be.

How is this conditional logic done really?

Offline bknight

  • Neptune
  • ****
  • Posts: 2534
Re: Conditional logic
« Reply #1 on: October 04, 2018, 06:56:43 PM »
It has been a long time since my programming days, but I seem to remember two flags one for false and one for true, then branches from there.
Zero in many cases is trivial so I'm not sure that one is necessary, unless it might be a math question.  In that case then add an additional flag on either true or false to handle zero.
Truth needs no defense.  Nobody can take those footsteps I made on the surface of the moon away from me.
Eugene Cernan

Offline ka9q

  • Neptune
  • ****
  • Posts: 2871
Re: Conditional logic
« Reply #2 on: October 05, 2018, 06:53:10 AM »
It's common to use lookup tables this way, at least for small numbers of flags. If he had 32 separate flag bits then that might be a problem, but he doesn't.