Simon Programs:
4-bit Addition

Description: A simple program to add two 4-bit numbers together and display the 5-bit sum.
Input: Two 4-bit values from tape.
Output: The 5-bit sum is displayed on the output lamps.
Written by: bhilpert (2006 Sep)
Assembled:
Ref  Tape      Assembly
---  --------  --------------------------------------------------
000: 18.0D.00  CR1 IR1 13   / load first operand
001: 02.00.01  SR1 IR2 ^    / save high bits as well

002: 19.05.00  CR2 IR1 5    / load second operand
003: 03.00.01  SR2 IR2 ^    / save high bits as well

004: 1B.00.00  CR4 IR  ADD  / add low bits, no carry-in
005: 0D.00.0C  OR1 CR5      / display low bits

006: 08.00.02  CR1 SR1      / retrieve upper bits
007: 09.00.03  CR2 SR2      /  of both operands

008: 1B.08.00  CR4 IR  ADC  / add upper bits, with carry-in
009: 0E.00.0C  OR2 CR5      / display high bits

010: 18.00.00  CR1 IR1 0    / clear CR1
011: 19.00.00  CR2 IR1 0    / clear CR2
012: 1B.08.00  CR4 IR  ADC  / add 0+0+carry
013: 0F.00.0C  OR3 CR5      / display 5th bit of result



  Programs
Simon
bhilpert
2006 Sep