From: mdw Date: Tue, 15 Oct 2002 19:19:08 +0000 (+0000) Subject: New script to create binop table for 2c operations. X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/commitdiff_plain/78db49fa393678358756a82ccb2d4d02edc55d41 New script to create binop table for 2c operations. --- diff --git a/binctab b/binctab new file mode 100644 index 0000000..64dc9c2 --- /dev/null +++ b/binctab @@ -0,0 +1,11 @@ +#! /usr/bin/perl + +sub tobin { my ($x) = @_; my $s = ($x & 8 ? "1" : "0") . ($x & 4 ? "1" : "0") +. ($x & 2 ? "1" : "0") . ($x & 1 ? "1" : "0"); return $s; } for ($i = 0; $i +< 16; $i++) { $p_base = $p_an = $p_bn = $p_abn = "POS"; $base = $i; $an = +(($i & 3) << 2) | (($i & 12) >> 2); $bn = (($i & 5) << 1) | (($i & 10) >> 1); +$abn = (($an & 5) << 1) | (($an & 10) >> 1); if ($base & 8) { $base ^= 15; +$p_base = "NEG"; } if ($an & 8) { $an ^= 15; $p_an = "NEG"; } if ($bn & 8) { +$bn ^= 15; $p_bn = "NEG"; } if ($abn & 8) { $abn ^= 15; $p_abn = "NEG"; } +print "MP_BIT2CBINOP(" . join(", ", tobin($base), tobin($an), tobin($bn), +tobin($abn), $p_base, $p_an, $p_bn, $p_abn) . ")\n"; }