Simon Programs:
Maximum of Two 4-bit Values

Description: Select the greater of two positive 4-bit values.
Input: Two values (A and B) entered from the front panel
Output: The greater of A and B is displayed on the output lamps.
Written by: bhilpert (2006 Sep)
Assembled:
Ref  Tape      Assembly
---  --------  --------------------------------------------------
000: 12.10.00  SR1=*        / wait for first value (A)
001: 03.00.01  SR2=^        / save high bits as well

002: 14.10.00  SR3=*        / wait for second value (B)
003: 05.00.01  SR4=^

004: 08.00.04  CR1=SR3      / negate B
005: 1B.01.00  NEG          /   and save in SR5 & 6
006: 06.00.0C  SR5=CR5
007: 08.00.05  CR1=SR4
008: 1B.09.00  NGC
009: 07.00.0C  SR6=CR5

010: 18.00.00  CR1=0        / save carry (5th bit) in CR3
011: 19.00.00  CR2=0
012: 1B.08.00  ADC
013: 0A.00.0C  CR3=CR5

014: 08.00.02  CR1=SR1      / subtract: A + -B
015: 09.00.06  CR2=SR5
016: 1B.00.00  ADD
017: 08.00.03  CR1=SR2
018: 09.00.07  CR2=SR6
019: 1B.08.00  ADC
020: 08.00.0A  CR1=CR3
021: 19.00.00  CR2=0
022: 1B.08.00  ADC          / result = B>A
023: 0A.00.0C  CR3=CR5      / move result to CR3

024: 08.00.02  CR1=SR1      / select lower bits
025: 09.00.04  CR2=SR3      /   for display
026: 1B.03.00  SEL
027: 0D.00.0C  OR1=CR5

028: 08.00.03  CR1=SR2      / select upper bits
029: 09.00.05  CR2=SR4      /   for display
030: 1B.03.00  SEL
031: 0E.00.0C  OR2=CR5



  Programs
Simon
bhilpert
2006 Sep