Integer comparison: Difference between revisions

Content added Content deleted
(Added EDSAC order code)
Line 700: Line 700:
</lang>
</lang>


=={{header|EDSAC order code}}==
The EDSAC offers two conditional branching orders, <tt>E</tt> (branch if the accumulator >= 0) and <tt>G</tt> (branch if the accumulator < 0). Testing for equality thus requires two operations.
<lang edsac>[ Integer comparison
==================
A program for the EDSAC
Illustrates the use of the E
(branch on accumulator sign
bit clear) and G (branch on
accumulator sign bit set)
orders
The integers to be tested, x
and y, should be stored in
addresses 13@ and 14@
Output: the program causes the
machine to print
'+' if x > y,
'=' if x = y,
'-' if x < y.
Works with Initial Orders 2 ]


T56K [ load point ]
GK [ base address ]
O15@ [ figure shift ]
A13@ [ a = x ]
S14@ [ a -= y ]
G10@ [ if a<0 go to 10 ]
S12@ [ a -= 1 ]
E8@ [ if a>=0 go to 8 ]
O17@ [ write '=' ]
ZF [ halt ]
[ 8 ] O16@ [ write '+' ]
ZF [ halt ]
[ 10 ] O18@ [ write '-' ]
ZF [ halt ]
[ 12 ] P0D [ const: 1 ]
[ 13 ] P16D [ x = 37 ]
[ 14 ] P14F [ y = 28 ]
[ 15 ] #F [ figure shift ]
[ 16 ] ZF [ + character ]
[ 17 ] VF [ = character ]
[ 18 ] AF [ - character ]
EZPF [ begin execution ]</lang>


=={{header|Efene}}==
=={{header|Efene}}==