Ticket #796: integer.t_to_pir.patch

File integer.t_to_pir.patch, 44.3 KB (added by flh, 13 years ago)

Rewrite integer.t

  • t/op/integer.t

     
    1 #!perl 
    2 # Copyright (C) 2001-2008, Parrot Foundation. 
     1#!parrot 
     2# Copyright (C) 2001-2009, Parrot Foundation. 
    33# $Id$ 
    44 
    5 use strict; 
    6 use warnings; 
    7 use lib qw( . lib ../lib ../../lib ); 
    8 use Test::More; 
    9 use Parrot::Test tests => 56; 
    10  
    115=head1 NAME 
    126 
    137t/op/integer.t - Integer Registers 
     
    2216 
    2317=cut 
    2418 
    25 pasm_output_is( <<CODE, <<OUTPUT, "set_i_ic" ); 
    26         # XXX: Need a test for writing outside the set of available 
    27         # registers.  Parrot doesn't check for this at the moment. 
    28         set     I0, 0 
    29         set     I1, 1 
    30         set     I2, 2 
    31         set     I3, 3 
    32         set     I4, 4 
    33         set     I5, 5 
    34         set     I6, 6 
    35         set     I7, 7 
    36         set     I8, 8 
    37         set     I9, 9 
    38         set     I10, 10 
    39         set     I11, 11 
    40         set     I12, 12 
    41         set     I13, 13 
    42         set     I14, 14 
    43         set     I15, 15 
    44         set     I16, 16 
    45         set     I17, 17 
    46         set     I18, 18 
    47         set     I19, 19 
    48         set     I20, 20 
    49         set     I21, 21 
    50         set     I22, 22 
    51         set     I23, 23 
    52         set     I24, 24 
    53         set     I25, 25 
    54         set     I26, 26 
    55         set     I27, 27 
    56         set     I28, 28 
    57         set     I29, 29 
    58         set     I30, 30 
    59         set     I31, 31 
     19.const int TESTS = 202 
    6020 
    61         print   I0 
    62         print   "\\n" 
    63         print   I1 
    64         print   "\\n" 
    65         print   I2 
    66         print   "\\n" 
    67         print   I3 
    68         print   "\\n" 
    69         print   I4 
    70         print   "\\n" 
    71         print   I5 
    72         print   "\\n" 
    73         print   I6 
    74         print   "\\n" 
    75         print   I7 
    76         print   "\\n" 
    77         print   I8 
    78         print   "\\n" 
    79         print   I9 
    80         print   "\\n" 
    81         print   I10 
    82         print   "\\n" 
    83         print   I11 
    84         print   "\\n" 
    85         print   I12 
    86         print   "\\n" 
    87         print   I13 
    88         print   "\\n" 
    89         print   I14 
    90         print   "\\n" 
    91         print   I15 
    92         print   "\\n" 
    93         print   I16 
    94         print   "\\n" 
    95         print   I17 
    96         print   "\\n" 
    97         print   I18 
    98         print   "\\n" 
    99         print   I19 
    100         print   "\\n" 
    101         print   I20 
    102         print   "\\n" 
    103         print   I21 
    104         print   "\\n" 
    105         print   I22 
    106         print   "\\n" 
    107         print   I23 
    108         print   "\\n" 
    109         print   I24 
    110         print   "\\n" 
    111         print   I25 
    112         print   "\\n" 
    113         print   I26 
    114         print   "\\n" 
    115         print   I27 
    116         print   "\\n" 
    117         print   I28 
    118         print   "\\n" 
    119         print   I29 
    120         print   "\\n" 
    121         print   I30 
    122         print   "\\n" 
    123         print   I31 
    124         print   "\\n" 
    125         end 
    126         set     I0, 0 
    127         end 
    128 CODE 
    129 0 
    130 1 
    131 2 
    132 3 
    133 4 
    134 5 
    135 6 
    136 7 
    137 8 
    138 9 
    139 10 
    140 11 
    141 12 
    142 13 
    143 14 
    144 15 
    145 16 
    146 17 
    147 18 
    148 19 
    149 20 
    150 21 
    151 22 
    152 23 
    153 24 
    154 25 
    155 26 
    156 27 
    157 28 
    158 29 
    159 30 
    160 31 
    161 OUTPUT 
     21.sub 'test' :main 
     22    .include 'test_more.pir' 
    16223 
    163 pasm_output_is( <<CODE, <<OUTPUT, "set_i" ); 
    164         set     I0, 42 
    165         set     I1, I0 
    166         print   I1 
    167         print   "\\n" 
    168         end 
    169 CODE 
    170 42 
    171 OUTPUT 
     24    plan(TESTS) 
     25    test_set_ic() 
     26    test_set() 
     27    test_add_i_i_i() 
     28    test_add_i_i() 
     29    test_abs() 
     30    test_sub() 
     31    test_mul() 
     32    test_div() 
     33    test_mod() 
     34    mod_negative_zero_rest() 
     35    test_cmod() 
     36    test_eq() 
     37    test_ne() 
     38    test_lt() 
     39    test_le() 
     40    test_gt() 
     41    test_ge() 
     42    test_not() 
     43    test_and() 
     44    test_or() 
     45    test_xor() 
     46    test_inc() 
     47    test_dec() 
     48    test_sub_i_i() 
     49    test_set_n() 
     50    test_cleari() 
     51    test_neg() 
     52    test_fact() 
     53    test_mul_i_i() 
     54    test_exchange() 
     55    test_null() 
     56    test_div_i_i_by_zero() 
     57    test_div_i_ic_by_zero() 
     58    test_div_i_i_i_by_zero() 
     59    test_div_i_ic_i_by_zero() 
     60    test_div_i_i_ic_by_zero() 
     61    test_fdiv_i_i_by_zero() 
     62    test_fdiv_i_ic_by_zero() 
     63    test_fdiv_i_i_i_by_zero() 
     64    test_fdiv_i_ic_i_by_zero() 
     65    test_fdiv_i_i_ic_by_zero() 
     66    test_cmod_i_i_i_by_zero() 
     67    test_cmod_i_ic_i_by_zero() 
     68    test_cmod_i_i_ic_by_zero() 
     69    test_mod_i_i_i_by_zero() 
     70    test_mod_i_ic_i_by_zero() 
     71    test_mod_i_i_ic_by_zero() 
     72.end 
    17273 
    173 pasm_output_is( <<CODE, <<OUTPUT, "add_i" ); 
    174         set     I0, 0x11223344 
    175         add     I1, I0, I0 
    176         print   I1 
    177         print   "\\n" 
     74.sub 'test_set_ic' 
     75    $I0 = 0 
     76    $I1 = 1 
     77    $I2 = 2 
     78    $I3 = 3 
     79    $I4 = 4 
     80    $I5 = 5 
     81    $I6 = 6 
     82    $I7 = 7 
     83    $I8 = 8 
     84    $I9 = 9 
     85    $I10 = 10 
     86    $I11 = 11 
     87    $I12 = 12 
     88    $I13 = 13 
     89    $I14 = 14 
     90    $I15 = 15 
     91    $I16 = 16 
     92    $I17 = 17 
     93    $I18 = 18 
     94    $I19 = 19 
     95    $I20 = 20 
     96    $I21 = 21 
     97    $I22 = 22 
     98    $I23 = 23 
     99    $I24 = 24 
     100    $I25 = 25 
     101    $I26 = 26 
     102    $I27 = 27 
     103    $I28 = 28 
     104    $I29 = 29 
     105    $I30 = 30 
     106    $I31 = 31 
    178107 
    179         add     I2, I0, I1 
    180         print   I2 
    181         print   "\\n" 
     108    $S0 = $I0 
     109    is($S0, "0", "set_i_ic with 0") 
     110    $S0 = $I1 
     111    is($S0, "1", "set_i_ic with 1") 
     112    $S0 = $I2 
     113    is($S0, "2", "set_i_ic with 2") 
     114    $S0 = $I3 
     115    is($S0, "3", "set_i_ic with 3") 
     116    $S0 = $I4 
     117    is($S0, "4", "set_i_ic with 4") 
     118    $S0 = $I5 
     119    is($S0, "5", "set_i_ic with 5") 
     120    $S0 = $I6 
     121    is($S0, "6", "set_i_ic with 6") 
     122    $S0 = $I7 
     123    is($S0, "7", "set_i_ic with 7") 
     124    $S0 = $I8 
     125    is($S0, "8", "set_i_ic with 8") 
     126    $S0 = $I9 
     127    is($S0, "9", "set_i_ic with 9") 
     128    $S0 = $I10 
     129    is($S0, "10", "set_i_ic with 10") 
     130    $S0 = $I11 
     131    is($S0, "11", "set_i_ic with 11") 
     132    $S0 = $I12 
     133    is($S0, "12", "set_i_ic with 12") 
     134    $S0 = $I13 
     135    is($S0, "13", "set_i_ic with 13") 
     136    $S0 = $I14 
     137    is($S0, "14", "set_i_ic with 14") 
     138    $S0 = $I15 
     139    is($S0, "15", "set_i_ic with 15") 
     140    $S0 = $I16 
     141    is($S0, "16", "set_i_ic with 16") 
     142    $S0 = $I17 
     143    is($S0, "17", "set_i_ic with 17") 
     144    $S0 = $I18 
     145    is($S0, "18", "set_i_ic with 18") 
     146    $S0 = $I19 
     147    is($S0, "19", "set_i_ic with 19") 
     148    $S0 = $I20 
     149    is($S0, "20", "set_i_ic with 20") 
     150    $S0 = $I21 
     151    is($S0, "21", "set_i_ic with 21") 
     152    $S0 = $I22 
     153    is($S0, "22", "set_i_ic with 22") 
     154    $S0 = $I23 
     155    is($S0, "23", "set_i_ic with 23") 
     156    $S0 = $I24 
     157    is($S0, "24", "set_i_ic with 24") 
     158    $S0 = $I25 
     159    is($S0, "25", "set_i_ic with 25") 
     160    $S0 = $I26 
     161    is($S0, "26", "set_i_ic with 26") 
     162    $S0 = $I27 
     163    is($S0, "27", "set_i_ic with 27") 
     164    $S0 = $I28 
     165    is($S0, "28", "set_i_ic with 28") 
     166    $S0 = $I29 
     167    is($S0, "29", "set_i_ic with 29") 
     168    $S0 = $I30 
     169    is($S0, "30", "set_i_ic with 30") 
     170    $S0 = $I31 
     171    is($S0, "31", "set_i_ic with 31") 
     172.end 
    182173 
    183         add     I2, I2, I2 
    184         print   I2 
    185         print   "\\n" 
     174.sub 'test_set' 
     175    $I0 = 42 
     176    $I1 = $I0 
     177    $S0 = $I1 
     178    is($S0, '42', 'set_i') 
     179.end 
    186180 
    187         end 
    188 CODE 
    189 574908040 
    190 862362060 
    191 1724724120 
    192 OUTPUT 
     181.sub 'test_add_i_i_i' 
     182    $I0 = 0x11223344 
     183    $I1 = $I0 + $I0 
     184    is($I1, 574908040, 'add_i_i - first') 
    193185 
    194 pasm_output_is( <<'CODE', <<'OUTPUT', "abs(i, i|ic|n|nc)" ); 
    195         set     I0, 1 
    196         abs     I1, -1 
    197         abs     I0, I0 
    198         set     I2, -1 
    199         abs     I2, I2 
    200         print   I0 
    201         print   "\n" 
    202         print   I1 
    203         print   "\n" 
    204         print   I2 
    205         print   "\n" 
     186    $I2 = $I0 + $I1 
     187    is($I2, 862362060, 'add_i_i - second') 
    206188 
    207         end 
    208 CODE 
    209 1 
    210 1 
    211 1 
    212 OUTPUT 
     189    $I2 = $I2 + $I2 
     190    is($I2, 1724724120, 'add_i_i - third') 
     191.end 
    213192 
    214 pasm_output_is( <<CODE, <<OUTPUT, "sub_(i|ic, i|ic)" ); 
    215         set     I0, 0x12345678 
    216         set     I1, 0x01234567 
    217         sub     I2, I0, I1 
    218         print   I2 
    219         print   "\\n" 
     193.sub 'test_add_i_i' 
     194    $I0 = 0 
     195    $I1 = 2 
     196    $I2 = -2 
    220197 
    221         set     I1, 1234 
    222         sub     I0, I1, 1230 
    223         print   I0 
    224         sub     I0, 1244, I1 
    225         print   I0 
    226         sub     I0, 13, 12 
    227         print   I0 
    228         print   "\\n" 
    229         end 
    230 CODE 
    231 286331153 
    232 4101 
    233 OUTPUT 
     198    add $I0, $I1 
     199    is($I0, 2, 'add_i_i - zero is neutral') 
    234200 
    235 pasm_output_is( <<CODE, <<OUTPUT, "mul_i" ); 
    236         set     I0, 7 
    237         set     I1, 29 
    238         mul     I2, I0, I1 
    239         print   I2 
    240         print   "\\n" 
     201    add $I0, $I2 
     202    is($I0, 0, 'add_i_i - inverse') 
    241203 
    242         mul     I2, I0, 29 
    243         print   I2 
    244         print   "\\n" 
    245         end 
    246 CODE 
    247 203 
    248 203 
    249 OUTPUT 
     204    $I0 = 0 
     205    add $I0, 5 
     206    is($I0, 5, 'add_i_ic - zero is neutral') 
    250207 
    251 pasm_output_is( <<CODE, <<OUTPUT, "div_i" ); 
    252         set     I0, 0x33333333 
    253         set     I1, 0x11111111 
    254         div     I2, I0, I1 
    255         print   I2 
    256         print   "\\n" 
     208    add $I0, -10 
     209    is($I0, -5, 'add_i_ic') 
     210.end 
    257211 
    258         set     I0, 11 
    259         set     I1, 2 
    260         div     I2, I0, I1 
    261         print   I2 
    262         print   "\\n" 
     212.sub 'test_abs' 
     213    $I0 = abs 1 
    263214 
    264         set     I0, 9 
    265         set     I1, -4 
    266         div     I2, I0, I1 
    267         print   I2 
    268         print   "\\n" 
     215    $I1 = 1 
     216    $I1 = abs $I1 
    269217 
    270         set     I0, 12 
    271         div     I1, 144, I0 
    272         print   I1 
    273         div     I1, I0, 3 
    274         print   I1 
    275         div     I1, 120, 12 
    276         print   I1 
    277         print   "\\n" 
     218    $I2 = abs -1 
    278219 
    279         end 
    280 CODE 
    281 3 
    282 5 
    283 -2 
    284 12410 
    285 OUTPUT 
     220    $I3 = -1 
     221    $I3 = abs $I3 
    286222 
    287 pasm_output_is( <<CODE, <<OUTPUT, "mod_i" ); 
    288         set     I0, 5 
    289         set     I1, 0 
    290         mod     I2, I0, I1 
    291         print   I2 
    292         print   "\\n" 
     223    is($I0, 1, 'abs_i_ic') 
     224    is($I1, 1, 'abs_i_i') 
     225    is($I2, 1, 'abs_i_nc') 
     226    is($I3, 1, 'abs_i_n') 
     227.end 
    293228 
    294         set     I0, 0 
    295         set     I1, 3 
    296         mod     I2, I0, I1 
    297         print   I2 
    298         print   "\\n" 
     229.sub 'test_sub' 
     230    $I0 = 0x12345678 
     231    $I1 = 0x01234567 
     232    $I2 = $I0 - $I1 
     233    is($I2, 286331153, 'sub_i_i_i') 
    299234 
    300         set     I0, 5 
    301         set     I1, 3 
    302         mod     I2, I0, I1 
    303         print   I2 
    304         print   "\\n" 
     235    $I1 = 1234 
    305236 
    306         set     I0, 5 
    307         set     I1, -3 
    308         mod     I2, I0, I1 
    309         print   I2 
    310         print   "\\n" 
     237    $I0 = $I1 - 1230 
     238    is($I0, 4, 'sub_i_i_ic') 
    311239 
    312         set     I0, -5 
    313         set     I1, 3 
    314         mod     I2, I0, I1 
    315         print   I2 
    316         print   "\\n" 
     240    $I0 = 1244 - $I1 
     241    is($I0, 10, 'sub_i_ic_i') 
    317242 
    318         set     I0, -5 
    319         set     I1, -3 
    320         mod     I2, I0, I1 
    321         print   I2 
    322         print   "\\n" 
     243    $I0 = 13 - 12 
     244    is($I0, 1, 'sub_i_ic_ic') 
     245.end 
    323246 
    324         set     I0, 12 
    325         mod     I1, I0, 10 
    326         print   I1 
    327         mod     I1, 14, I0 
    328         print   I1 
    329         mod     I1, 13, 11 
    330         print   I1 
    331         print   "\\n" 
     247.sub 'test_mul' 
     248    $I0 = 7 
     249    $I1 = 29 
    332250 
    333         end 
    334 CODE 
    335 5 
    336 0 
    337 2 
    338 -1 
    339 1 
    340 -2 
    341 222 
    342 OUTPUT 
     251    $I2 = $I0 * $I1 
     252    is($I2, 203, 'mul_i_i_i') 
    343253 
    344 pir_output_is( <<'CODE', <<'OUTPUT', "mod - negative, zero rest (#36003)" ); 
    345 .sub test :main 
     254    $I2 = $I0 * 29 
     255    is($I2, 203, 'mul_i_i_ic') 
     256.end 
    346257 
    347    $I1 = mod 3, 3 
    348    print "3 mod 3 = " 
    349    print $I1 
    350    print "\n" 
     258.sub 'test_div' 
     259    $I0 = 0x33333333 
     260    $I1 = 0x11111111 
     261    $I2 = $I0 / $I1 
     262    is($I2, 3, 'div_i_i_i - exact') 
    351263 
    352    $I1 = mod -3, 3 
    353    print "-3 mod 3 = " 
    354    print $I1 
    355    print "\n" 
     264    $I0 = 11 
     265    $I1 = 2 
     266    $I2 = $I0 / $I1 
     267    is($I2, 5, 'div_i_i_i - quotient with positive integers') 
    356268 
    357    $I1 = mod 3, -3 
    358    print "3 mod -3 = " 
    359    print $I1 
    360    print "\n" 
     269    $I0 = 9 
     270    $I1 = -4 
     271    $I2 = $I0 / $I1 
     272    is($I2, -2, 'div_i_i_i - quotient with negative divisor') 
    361273 
    362    $I1 = mod -3, -3 
    363    print "-3 mod -3 = " 
    364    print $I1 
    365    print "\n" 
     274    $I0 = 12 
    366275 
    367    end 
     276    $I1 = 144 / $I0 
     277    is($I1, 12, 'div_i_ic_i') 
     278 
     279    $I1 = $I0 / 3 
     280    is($I1, 4, 'div_i_i_ic') 
     281 
     282    $I1 = 120 / 12 
     283    is($I1, 10, 'div_i_ic_ic') 
    368284.end 
    369 CODE 
    370 3 mod 3 = 0 
    371 -3 mod 3 = 0 
    372 3 mod -3 = 0 
    373 -3 mod -3 = 0 
    374 OUTPUT 
    375285 
    376 pasm_output_is( <<CODE, <<OUTPUT, "cmod_i" ); 
    377         set     I0, 5 
    378         set     I1, 3 
    379         cmod    I2, I0, I1 
    380         print   I2 
    381         print   "\\n" 
    382         print   I0 
    383         print   "\\n" 
    384         print   I1 
    385         print   "\\n" 
     286.sub 'test_mod' 
     287    $I0 = 5 
     288    $I1 = 0 
     289    $I2 = mod $I0, $I1 
     290    is($I2, 5, 'mod_i_i_i by 0') 
    386291 
    387         set     I0, 12 
    388         cmod    I1, I0, 10 
    389         print   I1 
    390         cmod    I1, 14, I0 
    391         print   I1 
    392         cmod    I1, 13, 11 
    393         print   I1 
    394         print   "\\n" 
    395         end 
    396 CODE 
    397 2 
    398 5 
    399 3 
    400 222 
    401 OUTPUT 
     292    $I0 = 0 
     293    $I1 = 3 
     294    $I2 = mod $I0, $I1 
     295    is($I2, 0, 'mod_i_i_i of 0') 
    402296 
    403 pasm_output_is( <<CODE, <<OUTPUT, "eq_i_ic" ); 
    404         set     I0, 0x12345678 
    405         set     I1, 0x12345678 
    406         set     I2, 0x76543210 
     297    $I0 = 5 
     298    $I1 = 3 
     299    $I2 = mod $I0, $I1 
     300    is($I2, 2, 'mod_i_i_i - remainder of 5 / 3') 
    407301 
    408         eq      I0, I1, ONE 
    409         branch  ERROR 
    410         print   "bad\\n" 
     302    $I0 = 5 
     303    $I1 = -3 
     304    $I2 = mod $I0, $I1 
     305    is($I2, -1, 'mod_i_i_i - remainder of 5 / -3') 
    411306 
    412 ONE: 
    413         print   "ok 1\\n" 
    414         eq      I1, I2, ERROR 
    415         branch TWO 
    416         print   "bad\\n" 
     307    $I0 = -5 
     308    $I1 = 3 
     309    $I2 = mod $I0, $I1 
     310    is($I2, 1, 'mod_i_i_i - remainder of -5 / 3') 
    417311 
    418 TWO: 
    419         print   "ok 2\\n" 
    420         end 
     312    $I0 = -5 
     313    $I1 = -3 
     314    $I2 = mod $I0, $I1 
     315    is($I2, -2, 'mod_i_i_i - remainder of -5 / -3') 
    421316 
    422 ERROR: 
    423         print   "bad\\n" 
    424         end 
    425 CODE 
    426 ok 1 
    427 ok 2 
    428 OUTPUT 
     317    $I0 = 12 
    429318 
    430 pasm_output_is( <<CODE, <<OUTPUT, "eq_ic_ic" ); 
    431         set     I0, -42 
     319    $I1 = mod $I0, 10 
     320    is($I1, 2, 'mod_i_i_ic') 
    432321 
    433         eq      I0, 42, ERROR 
    434         branch  ONE 
    435         print   "bad\\n" 
     322    $I1 = mod 14, $I0 
     323    is($I1, 2, 'mod_i_ic_i') 
    436324 
    437 ONE: 
    438         print   "ok 1\\n" 
    439         eq      I0, -42, TWO 
    440         branch ERROR 
    441         print   "bad\\n" 
     325    $I1 = mod 13, 11 
     326    is($I1, 2, 'mod_i_ic_ic') 
     327.end 
    442328 
    443 TWO: 
    444         print   "ok 2\\n" 
     329.sub 'mod_negative_zero_rest' 
     330    $I1 = mod 3, 3 
     331    is($I1, 0, 'mod - negative, zero rest (#36003), 3 mod 3 = 0') 
    445332 
    446         set     I0, 12 
    447         eq      I0, 12, THREE 
    448         print   "not good three " 
    449 THREE:  print   "ok 3\\n" 
     333    $I1 = mod -3, 3 
     334    is($I1, 0, 'mod - negative, zero rest (#36003), -3 mod 3 = 0') 
    450335 
    451         eq      12, 12, FOUR 
    452         print   "12 not 12, what? " 
    453 FOUR:   print   "ok 4\\n" 
     336    $I1 = mod 3, -3 
     337    is($I1, 0, 'mod - negative, zero rest (#36003), 3 mod -3 = 0') 
    454338 
    455         end 
     339    $I1 = mod -3, -3 
     340    is($I1, 0, 'mod - negative, zero rest (#36003), -3 mod -3 = 0') 
     341.end 
    456342 
    457 ERROR: 
    458         print   "bad\\n" 
    459         end 
    460 CODE 
    461 ok 1 
    462 ok 2 
    463 ok 3 
    464 ok 4 
    465 OUTPUT 
     343.sub 'test_cmod' 
     344    $I0 = 5 
     345    $I1 = 3 
     346    $I2 = cmod $I0, $I1 
     347    is($I2, 2, 'cmod_i_i_i') 
     348    is($I0, 5, 'cmod_i_i_i - dividend unchanged') 
     349    is($I1, 3, 'cmod_i_i_i - divisor unchanged') 
    466350 
    467 pasm_output_is( <<CODE, <<OUTPUT, "ne_i_ic" ); 
    468         set     I0, 0xa0b0c0d 
    469         set     I1, 0xa0b0c0d 
    470         set     I2, 0 
     351    $I0 = 12 
    471352 
    472         ne      I0, I2, ONE 
    473         branch  ERROR 
    474         print   "bad\\n" 
     353    $I1 = cmod $I0, 10 
     354    is($I1, 2, 'cmod_i_i_ic') 
    475355 
    476 ONE: 
    477         print   "ok 1\\n" 
    478         ne      I0, I1, ERROR 
    479         branch  TWO 
    480         print   "bad\\n" 
     356    $I1 = cmod 14, $I0 
     357    is($I1, 2, 'cmod_i_ic_i') 
    481358 
    482 TWO: 
    483         print   "ok 2\\n" 
    484         end 
     359    $I1 = cmod 13, 11 
     360    is($I1, 2, 'cmod_i_ic_ic') 
     361.end 
    485362 
    486 ERROR: 
    487         print   "bad\\n" 
    488         end 
    489 CODE 
    490 ok 1 
    491 ok 2 
    492 OUTPUT 
     363.sub 'test_eq' 
     364    $I0 = 0x12345678 
     365    $I1 = 0x12345678 
     366    $I2 = 0x76543210 
    493367 
    494 pasm_output_is( <<CODE, <<OUTPUT, "ne_ic_ic" ); 
    495         set     I0, 427034409 
     368    $I3 = 1 
     369    if $I0 == $I1 goto test_eq_1 
     370    $I3 = 0 
     371  test_eq_1: 
     372    ok($I3, 'eq_i_i - equal') 
    496373 
    497         ne      I0, 427034409, ERROR 
    498         branch  ONE 
    499         print   "bad\\n" 
     374    $I3 = 1 
     375    unless $I1 == $I2 goto test_eq_2 
     376    $I3 = 0 
     377  test_eq_2: 
     378    ok($I3, 'eq_i_i - different') 
    500379 
    501 ONE: 
    502         print   "ok 1\\n" 
    503         ne      I0, 427034408, TWO 
    504         branch  ERROR 
    505         print   "bad\\n" 
     380    $I0 = -42 
     381    $I3 = 0 
     382    if $I0 == 42 goto test_eq_3 
     383    $I3 = 1 
     384  test_eq_3: 
     385    ok($I3, 'eq_i_ic - different') 
    506386 
    507 TWO: 
    508         print   "ok 2\\n" 
    509         end 
     387    $I3 = 0 
     388    unless $I0 == -42 goto test_eq_4 
     389    $I3 = 1 
     390  test_eq_4: 
     391    ok($I3, 'eq_i_ic - equal') 
    510392 
    511 ERROR: 
    512         print   "bad\\n" 
    513         end 
    514 CODE 
    515 ok 1 
    516 ok 2 
    517 OUTPUT 
     393    $I0 = 12 
     394    $I3 = 0 
     395    unless $I0 == 12 goto test_eq_5 
     396    $I3 = 1 
     397  test_eq_5: 
     398    ok($I3, 'eq_i_ic - 12 == 12') 
    518399 
    519 pasm_output_is( <<CODE, <<OUTPUT, "lt_i_ic" ); 
    520         set     I0, 2147483647 
    521         set     I1, -2147483648 
    522         set     I2, 0 
    523         set     I3, 0 
     400    $I3 = 0 
     401    unless 12 == 12 goto test_eq_6 
     402    $I3 = 1 
     403  test_eq_6: 
     404    ok($I3, 'eq_ic_ic - equal') 
    524405 
    525         lt      I1, I0, ONE 
    526         branch  ERROR 
    527         print   "bad\\n" 
     406    $I3 = 1 
     407    unless 12 == 21 goto test_eq_7 
     408    $I3 = 0 
     409  test_eq_7: 
     410    ok($I3, 'eq_ic_ic - different') 
     411.end 
    528412 
    529 ONE: 
    530         print   "ok 1\\n" 
    531         lt      I0, I1, ERROR 
    532         branch  TWO 
    533         print   "bad\\n" 
     413.sub 'test_ne' 
     414    $I0 = 0xa0b0c0d 
     415    $I1 = 0xa0b0c0d 
     416    $I2 = 0 
    534417 
    535 TWO: 
    536         print   "ok 2\\n" 
    537         lt      I2, I3, ERROR 
    538         branch  THREE 
    539         print   "bad\\n" 
     418    $I3 = 0 
     419    unless $I0 != $I2 goto test_ne_1 
     420    $I3 = 1 
     421  test_ne_1: 
     422    ok($I3, 'ne_i_i - different') 
    540423 
    541 THREE: 
    542         print   "ok 3\\n" 
    543         end 
     424    $I3 = 0 
     425    if $I0 != $I1 goto test_ne_2 
     426    $I3 = 1 
     427  test_ne_2: 
     428    ok($I3, 'ne_i_i - equal') 
    544429 
    545 ERROR: 
    546         print "bad\\n" 
    547         end 
    548 CODE 
    549 ok 1 
    550 ok 2 
    551 ok 3 
    552 OUTPUT 
     430    $I0 = 427034409 
     431    $I3 = 0 
     432    if $I0 != 427034409 goto test_ne_3 
     433    $I3 = 1 
     434  test_ne_3: 
     435    ok($I3, 'ne_i_ic - equal') 
    553436 
    554 pasm_output_is( <<CODE, <<OUTPUT, "lt_ic_ic" ); 
    555         set     I0, 2147483647 
    556         set     I1, -2147483648 
    557         set     I2, 0 
     437    $I3 = 0 
     438    unless $I0 != 427034408 goto test_ne_4 
     439    $I3 = 1 
     440  test_ne_4: 
     441    ok($I3, 'ne_i_ic - different') 
     442.end 
    558443 
    559         lt      I0, -2147483648, ERROR 
    560         branch  ONE 
    561         print   "bad\\n" 
     444.sub 'test_lt' 
     445    $I0 = 2147483647 
     446    $I1 = -2147483648 
     447    $I2 = 0 
     448    $I3 = 0 
    562449 
    563 ONE: 
    564         print   "ok 1\\n" 
    565         lt      I1, 2147483647, TWO 
    566         branch  ERROR 
    567         print   "bad\\n" 
     450    $I4 = 0 
     451    unless $I1 < $I0 goto test_lt_1 
     452    $I4 = 1 
     453  test_lt_1: 
     454    ok($I4, 'lt_i_i - true inequality') 
    568455 
    569 TWO: 
    570         print   "ok 2\\n" 
    571         lt      I0, 0, ERROR 
    572         branch  THREE 
    573         print   "bad\\n" 
     456    $I4 = 0 
     457    if $I0 < $I1 goto test_lt_2 
     458    $I4 = 1 
     459  test_lt_2: 
     460    ok($I4, 'lt_i_i - false inequality') 
    574461 
    575 THREE: 
    576         print   "ok 3\\n" 
    577         end 
     462    $I4 = 0 
     463    if $I2 < $I3 goto test_lt_3 
     464    $I4 = 1 
     465  test_lt_3: 
     466    ok($I4, 'lt_i_i - irreflexivity') 
    578467 
    579 ERROR: 
    580         print   "bad\\n" 
    581         end 
    582 CODE 
    583 ok 1 
    584 ok 2 
    585 ok 3 
    586 OUTPUT 
     468    $I4 = 0 
     469    if $I0 < -2147483648 goto test_lt_4 
     470    $I4 = 1 
     471  test_lt_4: 
     472    ok($I4, 'lt_i_ic - false inequality') 
    587473 
    588 pasm_output_is( <<CODE, <<OUTPUT, "le_i_ic" ); 
    589         set     I0, 2147483647 
    590         set     I1, -2147483648 
    591         set     I2, 0 
    592         set     I3, 0 
     474    $I4 = 0 
     475    unless $I1 < 2147483647 goto test_lt_5 
     476    $I4 = 1 
     477  test_lt_5: 
     478    ok($I4, 'lt_i_ic - true inequality') 
    593479 
    594         le      I1, I0, ONE 
    595         branch  ERROR 
    596         print   "bad\\n" 
     480    $I4 = 0 
     481    if $I0 < 0 goto test_lt_6 
     482    $I4 = 1 
     483  test_lt_6: 
     484    ok($I4, 'lt_i_ic - irreflexivity') 
     485.end 
    597486 
    598 ONE: 
    599         print   "ok 1\\n" 
    600         le      I0, I1, ERROR 
    601         branch  TWO 
    602         print   "bad\\n" 
     487.sub 'test_le' 
     488    $I0 = 2147483647 
     489    $I1 = -2147483648 
     490    $I2 = 0 
     491    $I3 = 0 
    603492 
    604 TWO: 
    605         print   "ok 2\\n" 
    606         le      I2, I3, THREE 
    607         branch  ERROR 
    608         print   "bad\\n" 
     493    $I4 = 0 
     494    unless $I1 <= $I0 goto test_le_1 
     495    $I4 = 1 
     496  test_le_1: 
     497    ok($I4, 'le_i_i - true inequality') 
    609498 
    610 THREE: 
    611         print   "ok 3\\n" 
    612         end 
     499    $I4 = 0 
     500    if $I0 <= $I1 goto test_le_2 
     501    $I4 = 1 
     502  test_le_2: 
     503    ok($I4, 'le_i_i - false inequality') 
    613504 
    614 ERROR: 
    615         print "bad\\n" 
    616         end 
    617 CODE 
    618 ok 1 
    619 ok 2 
    620 ok 3 
    621 OUTPUT 
     505    $I4 = 0 
     506    unless $I2 <= $I3 goto test_le_3 
     507    $I4 = 1 
     508  test_le_3: 
     509    ok($I4, 'le_i_i - reflexive') 
    622510 
    623 pasm_output_is( <<CODE, <<OUTPUT, "le_ic_ic" ); 
    624         set     I0, 2147483647 
    625         set     I1, -2147483648 
    626         set     I2, 0 
     511    $I4 = 0 
     512    if $I0 <= -2147483648 goto test_le_4 
     513    $I4 = 1 
     514  test_le_4: 
     515    ok($I4, 'le_i_ic - false inequality') 
    627516 
    628         le      I0, -2147483648, ERROR 
    629         branch  ONE 
    630         print   "bad\\n" 
     517    $I4 = 0 
     518    unless $I1 <= 2147483647 goto test_le_5 
     519    $I4 = 1 
     520  test_le_5: 
     521    ok($I4, 'le_i_ic - true inequality') 
    631522 
    632 ONE: 
    633         print   "ok 1\\n" 
    634         le      I1, 2147483647, TWO 
    635         branch  ERROR 
    636         print   "bad\\n" 
     523    $I4 = 0 
     524    unless $I2 <= 0 goto test_le_6 
     525    $I4 = 1 
     526  test_le_6: 
     527    ok($I4, 'le_i_ic - reflexivity') 
     528.end 
    637529 
    638 TWO: 
    639         print   "ok 2\\n" 
    640         le      I2, 0, THREE 
    641         branch  ERROR 
    642         print   "bad\\n" 
     530.sub 'test_gt' 
     531    $I0 = -2147483648 
     532    $I1 = 2147483647 
     533    $I2 = 0 
     534    $I3 = 0 
    643535 
    644 THREE: 
    645         print   "ok 3\\n" 
    646         end 
     536    $I4 = 0 
     537    unless $I1 > $I0 goto test_gt_1 
     538    $I4 = 1 
     539  test_gt_1: 
     540    ok($I4, 'gt_i_i - true inequality') 
    647541 
    648 ERROR: 
    649         print   "bad\\n" 
    650         end 
    651 CODE 
    652 ok 1 
    653 ok 2 
    654 ok 3 
    655 OUTPUT 
     542    $I4 = 0 
     543    if $I0 > $I1 goto test_gt_2 
     544    $I4 = 1 
     545  test_gt_2: 
     546    ok($I4, 'gt_i_i - false inequality') 
    656547 
    657 pasm_output_is( <<CODE, <<OUTPUT, "gt_i_ic" ); 
    658         set     I0, -2147483648 
    659         set     I1, 2147483647 
    660         set     I2, 0 
    661         set     I3, 0 
     548    $I4 = 0 
     549    if $I2 > $I3 goto test_gt_3 
     550    $I4 = 1 
     551  test_gt_3: 
     552    ok($I4, 'gt_i_i - irreflexive') 
    662553 
    663         gt      I1, I0, ONE 
    664         branch  ERROR 
    665         print   "bad\\n" 
     554    $I4 = 0 
     555    if $I0 > 2147483647 goto test_gt_4 
     556    $I4 = 1 
     557  test_gt_4: 
     558    ok($I4, 'gt_i_ic - false inequality') 
    666559 
    667 ONE: 
    668         print   "ok 1\\n" 
    669         gt      I0, I1, ERROR 
    670         branch  TWO 
    671         print   "bad\\n" 
     560    $I4 = 0 
     561    unless $I1 > -2147483648 goto test_gt_5 
     562    $I4 = 1 
     563  test_gt_5: 
     564    ok($I4, 'gt_i_ic - true inequality') 
    672565 
    673 TWO: 
    674         print   "ok 2\\n" 
    675         gt      I2, I3, ERROR 
    676         branch  THREE 
    677         print   "bad\\n" 
     566    $I4 = 0 
     567    if $I0 > 0 goto test_gt_6 
     568    $I4 = 1 
     569  test_gt_6: 
     570    ok($I4, 'gt_i_ic - another false inequality') 
     571.end 
    678572 
    679 THREE: 
    680         print   "ok 3\\n" 
    681         end 
     573.sub 'test_ge' 
     574    $I0 = -2147483648 
     575    $I1 = 2147483647 
     576    $I2 = 0 
     577    $I3 = 0 
    682578 
    683 ERROR: 
    684         print "bad\\n" 
    685         end 
    686 CODE 
    687 ok 1 
    688 ok 2 
    689 ok 3 
    690 OUTPUT 
     579    $I4 = 0 
     580    unless $I1 >= $I0 goto test_ge_1 
     581    $I4 = 1 
     582  test_ge_1: 
     583    ok($I4, 'ge_i_i - true inequality') 
    691584 
    692 pasm_output_is( <<CODE, <<OUTPUT, "gt_ic_ic" ); 
    693         set     I0, -2147483648 
    694         set     I1, 2147483647 
    695         set     I2, 0 
     585    $I4 = 0 
     586    if $I0 >= $I1 goto test_ge_2 
     587    $I4 = 1 
     588  test_ge_2: 
     589    ok($I4, 'ge_i_i - false inequality') 
    696590 
    697         gt      I0, 2147483647, ERROR 
    698         branch  ONE 
    699         print   "bad\\n" 
     591    $I4 = 0 
     592    unless $I2 >= $I3 goto test_ge_3 
     593    $I4 = 1 
     594  test_ge_3: 
     595    ok($I4, 'ge_i_i - reflexive') 
    700596 
    701 ONE: 
    702         print   "ok 1\\n" 
    703         gt      I1, -2147483648, TWO 
    704         branch  ERROR 
    705         print   "bad\\n" 
     597    $I4 = 0 
     598    if $I0 >= 2147483647 goto test_ge_4 
     599    $I4 = 1 
     600  test_ge_4: 
     601    ok($I4, 'ge_i_ic - false inequality') 
    706602 
    707 TWO: 
    708         print   "ok 2\\n" 
    709         gt      I0, 0, ERROR 
    710         branch  THREE 
    711         print   "bad\\n" 
     603    $I4 = 0 
     604    unless $I1 >= -2147483648 goto test_ge_5 
     605    $I4 = 1 
     606  test_ge_5: 
     607    ok($I4, 'ge_i_ic - true inequality') 
    712608 
    713 THREE: 
    714         print   "ok 3\\n" 
    715         end 
     609    $I4 = 0 
     610    unless $I2 >= 0 goto test_ge_6 
     611    $I4 = 1 
     612  test_ge_6: 
     613    ok($I4, 'ge_i_ic - reflexivity') 
     614.end 
    716615 
    717 ERROR: 
    718         print   "bad\\n" 
    719         end 
    720 CODE 
    721 ok 1 
    722 ok 2 
    723 ok 3 
    724 OUTPUT 
     616.sub 'test_not' 
     617    $I0 = 1 
     618    $I1 = not $I0 
     619    is($I1, 0, 'not_i_i - not 1') 
    725620 
    726 pasm_output_is( <<CODE, <<OUTPUT, "ge_i_ic" ); 
    727         set     I0, -2147483648 
    728         set     I1, 2147483647 
    729         set     I2, 0 
    730         set     I3, 0 
     621    $I2 = not $I1 
     622    is($I2, 1, 'not_i_i - not (not 1)') 
    731623 
    732         ge      I1, I0, ONE 
    733         branch  ERROR 
    734         print   "bad\\n" 
     624    $I3 = 12345 
     625    $I4 = not $I3 
     626    is($I4, 0, 'not_i_i of a positive integer') 
    735627 
    736 ONE: 
    737         print   "ok 1\\n" 
    738         ge      I0, I1, ERROR 
    739         branch  TWO 
    740         print   "bad\\n" 
     628    $I5 = -1 
     629    $I6 = not $I5 
     630    is($I6, 0, 'not_i_i of a negative integer') 
    741631 
    742 TWO: 
    743         print   "ok 2\\n" 
    744         ge      I2, I3, THREE 
    745         branch  ERROR 
    746         print   "bad\\n" 
     632    $I7 = 1 
     633    $I7 = not 1 
     634    is($I7, 0, 'not_i_ic') 
     635.end 
    747636 
    748 THREE: 
    749         print   "ok 3\\n" 
    750         end 
     637.sub 'test_and' 
     638    $I0 = 0 
     639    $I1 = 10 
    751640 
    752 ERROR: 
    753         print "bad\\n" 
    754         end 
    755 CODE 
    756 ok 1 
    757 ok 2 
    758 ok 3 
    759 OUTPUT 
     641    $I2 = 1 
     642    $I2 = and $I1, $I0 
     643    is($I2, 0, 'and - zero is right absorbing') 
    760644 
    761 pasm_output_is( <<CODE, <<OUTPUT, "ge_ic_ic" ); 
    762         set     I0, -2147483648 
    763         set     I1, 2147483647 
    764         set     I2, 0 
     645    $I2 = 1 
     646    $I2 = and $I0, $I1 
     647    is($I2, 0, 'and - zero is left absorbing') 
    765648 
    766         ge      I0, 2147483647, ERROR 
    767         branch  ONE 
    768         print   "bad\\n" 
     649    $I2 = 1 
     650    $I2 = and $I0, $I0 
     651    is($I2, 0, 'and - diagonal zero') 
    769652 
    770 ONE: 
    771         print   "ok 1\\n" 
    772         ge      I1, -2147483648, TWO 
    773         branch  ERROR 
    774         print   "bad\\n" 
     653    $I2 = 1 
     654    $I2 = and $I2, $I1 
     655    is($I2, 10, 'and - true operands') 
     656.end 
    775657 
    776 TWO: 
    777         print   "ok 2\\n" 
    778         ge      I2, 0, THREE 
    779         branch  ERROR 
    780         print   "bad\\n" 
     658.sub 'test_or' 
     659    $I0 = 0 
     660    $I1 = 10 
    781661 
    782 THREE: 
    783         print   "ok 3\\n" 
    784         end 
     662    $I2 = 42 
     663    $I2 = or $I1, $I0 
     664    is($I2, 10, 'or_i_i') 
    785665 
    786 ERROR: 
    787         print   "bad\\n" 
    788         end 
    789 CODE 
    790 ok 1 
    791 ok 2 
    792 ok 3 
    793 OUTPUT 
     666    $I2 = 42 
     667    $I2 = or $I0, $I1 
     668    is($I2, 10, 'or_i_i - symmetric case') 
    794669 
    795 pasm_output_is( <<'CODE', <<OUTPUT, "not_i_i" ); 
    796         set I0, 1 
    797         not I1, I0 
    798         print I1 
    799         print "\n" 
     670    $I2 = or $I0, $I0 
     671    is($I2, 0, 'or_i_i - false arguments') 
    800672 
    801         not I2, I1 
    802         print I2 
    803         print "\n" 
     673    $I2 = or $I2, $I1 
     674    is($I2, 10, 'or_i_i - reflexive') 
     675.end 
    804676 
    805         set I3, 12345 
    806         not I4, I3 
    807         print I4 
    808         print "\n" 
     677.sub 'test_xor' 
     678    $I0 = 0 
     679    $I1 = 2 
    809680 
    810         set I5, -1 
    811         not I6, I5 
    812         print I6 
    813         print "\n" 
     681    $I2 = 42 
     682    $I2 = xor $I1, $I0 
     683    is($I2, 2, 'xor - zero is right neutral') 
    814684 
    815         not I7, 0 
    816         print I7 
    817         print "\n" 
    818         not I7, 1 
    819         print I7 
    820         print "\n" 
     685    $I2 = 42 
     686    $I2 = xor $I0, $I1 
     687    is($I2, 2, 'xor - zero is left neutral') 
    821688 
    822         end 
    823 CODE 
    824 0 
    825 1 
    826 0 
    827 0 
    828 1 
    829 0 
    830 OUTPUT 
     689    $I2 = xor $I0, $I0 
     690    is($I2, 0, 'xor - nilpotent on zero') 
    831691 
    832 pasm_output_is( <<'CODE', <<OUTPUT, "and" ); 
    833         set I0, 0 
    834         set I1, 10 
     692    $I2 = xor $I1, $I1 
     693    is($I2, 0, 'xor - nilpotent on 2') 
     694     
     695    $I2 = xor $I2, $I2 
     696    is($I2, 0, 'xor - nilpotent on other') 
     697.end 
    835698 
    836         set I2, 1 
    837         and I2, I1, I0 
    838         print I2 
    839         print "\n" 
     699.sub 'test_inc' 
     700    $I0 = 0 
     701    inc $I0 
     702    is($I0, 1, 'inc_i (first)') 
     703    inc $I0 
     704    inc $I0 
     705    inc $I0 
     706    inc $I0 
     707    is($I0, 5, 'inc_i (second)') 
     708.end 
    840709 
    841         set I2, 1 
    842         and I2, I0, I1 
    843         print I2 
    844         print "\n" 
     710.sub 'test_dec' 
     711    $I0 = 0 
     712    dec $I0 
     713    is($I0, -1, 'dec_i (first)') 
     714    dec $I0 
     715    dec $I0 
     716    dec $I0 
     717    dec $I0 
     718    is($I0, -5, 'dec_i (second)') 
     719.end 
    845720 
    846         set I2, 1 
    847         and I2, I0, I0 
    848         print I2 
    849         print "\n" 
     721.sub 'test_sub_i_i' 
     722    $I0 = 0 
     723    $I1 = 3 
     724    $I2 = -3 
    850725 
    851         set I2, 1 
    852         and I2, I2, I1 
    853         print I2 
    854         print "\n" 
     726    sub $I0, $I1 
     727    is($I0, -3, 'sub_i_i') 
    855728 
    856         end 
    857 CODE 
    858 0 
    859 0 
    860 0 
    861 10 
    862 OUTPUT 
     729    sub $I0, $I2 
     730    is($I0, 0, 'sub_i_i - inverse') 
    863731 
    864 pasm_output_is( <<'CODE', <<OUTPUT, "or" ); 
    865         set I0, 0 
    866         set I1, 10 
     732    $I0 = 0 
     733    sub $I0, 5 
     734    is($I0, -5, 'sub_i_ic - first') 
    867735 
    868         set I2, 42 
    869         or I2, I1, I0 
    870         print I2 
    871         print "\n" 
     736    sub $I0, -10 
     737    is($I0, 5, 'sub_i_ic - second') 
     738.end 
    872739 
    873         set I2, 42 
    874         or I2, I0, I1 
    875         print I2 
    876         print "\n" 
     740.sub 'test_set_n' 
     741    $I0 = 0 
     742    $N0 = $I0 
     743    is($N0, 0.0, 'set_n_i -zero') 
    877744 
    878         or I2, I0, I0 
    879         print I2 
    880         print "\n" 
     745    $I1 = 2147483647 
     746    $N1 = $I1 
     747    is($N1, 2147483647.0, 'set_n_i - positive integer') 
    881748 
    882         or I2, I2, I1 
    883         print I2 
    884         print "\n" 
     749    $I2 = -2147483648 
     750    $N2 = $I2 
     751    is($N2, -2147483648.0, 'set_n_i - negative integer') 
     752.end 
    885753 
    886         end 
    887 CODE 
    888 10 
    889 10 
    890 0 
    891 10 
    892 OUTPUT 
     754.sub 'test_cleari' 
     755    $I0 = 0xdeadbee 
     756    $I1 = 0xdeadbee 
     757    $I2 = 0xdeadbee 
     758    $I3 = 0xdeadbee 
     759    $I4 = 0xdeadbee 
     760    $I5 = 0xdeadbee 
     761    $I6 = 0xdeadbee 
     762    $I7 = 0xdeadbee 
     763    $I8 = 0xdeadbee 
     764    $I9 = 0xdeadbee 
     765    $I10 = 0xdeadbee 
     766    $I11 = 0xdeadbee 
     767    $I12 = 0xdeadbee 
     768    $I13 = 0xdeadbee 
     769    $I14 = 0xdeadbee 
     770    $I15 = 0xdeadbee 
     771    $I16 = 0xdeadbee 
     772    $I17 = 0xdeadbee 
     773    $I18 = 0xdeadbee 
     774    $I19 = 0xdeadbee 
     775    $I20 = 0xdeadbee 
     776    $I21 = 0xdeadbee 
     777    $I22 = 0xdeadbee 
     778    $I23 = 0xdeadbee 
     779    $I24 = 0xdeadbee 
     780    $I25 = 0xdeadbee 
     781    $I26 = 0xdeadbee 
     782    $I27 = 0xdeadbee 
     783    $I28 = 0xdeadbee 
     784    $I29 = 0xdeadbee 
     785    $I30 = 0xdeadbee 
     786    $I31 = 0xdeadbee 
    893787 
    894 pasm_output_is( <<'CODE', <<OUTPUT, "xor" ); 
    895         set I0, 0 
    896         set I1, 2 
     788    cleari 
    897789 
    898         set I2, 42 
    899         xor I2, I1, I0 
    900         print I2 
    901         print "\n" 
     790    is($I0, 0, 'cleari - $I0 cleared') 
     791    is($I1, 0, 'cleari - $I1 cleared') 
     792    is($I2, 0, 'cleari - $I2 cleared') 
     793    is($I3, 0, 'cleari - $I3 cleared') 
     794    is($I4, 0, 'cleari - $I4 cleared') 
     795    is($I5, 0, 'cleari - $I5 cleared') 
     796    is($I6, 0, 'cleari - $I6 cleared') 
     797    is($I7, 0, 'cleari - $I7 cleared') 
     798    is($I8, 0, 'cleari - $I8 cleared') 
     799    is($I9, 0, 'cleari - $I9 cleared') 
     800    is($I10, 0, 'cleari - $I10 cleared') 
     801    is($I11, 0, 'cleari - $I11 cleared') 
     802    is($I12, 0, 'cleari - $I12 cleared') 
     803    is($I13, 0, 'cleari - $I13 cleared') 
     804    is($I14, 0, 'cleari - $I14 cleared') 
     805    is($I15, 0, 'cleari - $I15 cleared') 
     806    is($I16, 0, 'cleari - $I16 cleared') 
     807    is($I17, 0, 'cleari - $I17 cleared') 
     808    is($I18, 0, 'cleari - $I18 cleared') 
     809    is($I19, 0, 'cleari - $I19 cleared') 
     810    is($I20, 0, 'cleari - $I20 cleared') 
     811    is($I21, 0, 'cleari - $I21 cleared') 
     812    is($I22, 0, 'cleari - $I22 cleared') 
     813    is($I23, 0, 'cleari - $I23 cleared') 
     814    is($I24, 0, 'cleari - $I24 cleared') 
     815    is($I25, 0, 'cleari - $I25 cleared') 
     816    is($I26, 0, 'cleari - $I26 cleared') 
     817    is($I27, 0, 'cleari - $I27 cleared') 
     818    is($I28, 0, 'cleari - $I28 cleared') 
     819    is($I29, 0, 'cleari - $I29 cleared') 
     820    is($I30, 0, 'cleari - $I30 cleared') 
     821    is($I31, 0, 'cleari - $I31 cleared') 
     822.end 
    902823 
    903         set I2, 42 
    904         xor I2, I0, I1 
    905         print I2 
    906         print "\n" 
     824.sub 'test_neg' 
     825    $I0 = neg 3 
     826    $I0 = neg $I0 
     827    neg $I0 
    907828 
    908         xor I2, I0, I0 
    909         print I2 
    910         print "\n" 
     829    is($I0, -3, 'neg_i') 
     830.end 
    911831 
    912         xor I2, I1, I1 
    913         print I2 
    914         print "\n" 
     832.sub 'test_mul_i_i' 
     833    $I0 = 3 
     834    $I1 = 4 
     835    mul $I0, $I1 
    915836 
    916         set I2, 1 
    917         xor I2, I2, I2 
    918         print I2 
    919         print "\n" 
     837    is($I0, 12, 'mul_i_i') 
     838.end 
    920839 
    921         end 
    922 CODE 
    923 2 
    924 2 
    925 0 
    926 0 
    927 0 
    928 OUTPUT 
     840.sub 'test_fact' 
     841    $I0 = 3 
     842    $I1 = 11 
     843    $I2 = 0 
     844    $I3 = -563 
    929845 
    930 pasm_output_is( <<CODE, <<OUTPUT, "inc_i" ); 
    931         set     I0, 0 
     846    $I5 = fact $I0 
     847    is($I5, 6, 'fact_i_i - first') 
    932848 
    933         inc     I0 
    934         print   I0 
    935         print   "\\n" 
     849    $I6 = fact $I1 
     850    is($I6, 39916800, 'fact_i_i - second') 
    936851 
    937         inc     I0 
    938         inc     I0 
    939         inc     I0 
    940         inc     I0 
    941         print   I0 
    942         print   "\\n" 
     852    $I7 = fact $I2 
     853    is($I7, 1, 'fact_i_i on zero') 
    943854 
    944         end 
    945 CODE 
    946 1 
    947 5 
    948 OUTPUT 
     855    $I8 = fact $I3 
     856    is($I8, 1, 'fact_i_i on a negative integer') 
    949857 
    950 pasm_output_is( <<CODE, <<OUTPUT, "add_i_i" ); 
    951         set     I0, 0 
    952         set     I1, 2 
    953         set     I2, -2 
     858    # Now run the same tests, with constants instead 
     859    $I5 = fact 3 
     860    is($I5, 6, 'fact_i_ic - first') 
    954861 
    955         add     I0, I1 
    956         print   I0 
    957         print   "\\n" 
     862    $I6 = fact 11 
     863    is($I6, 39916800, 'fact_i_ic - second') 
    958864 
    959         add     I0, I2 
    960         print   I0 
    961         print   "\\n" 
    962         end 
    963 CODE 
    964 2 
    965 0 
    966 OUTPUT 
     865    $I7 = fact 0 
     866    is($I7, 1, 'fact_i_ic on zero') 
    967867 
    968 pasm_output_is( <<CODE, <<OUTPUT, "add_i_ic" ); 
    969         set     I0, 0 
     868    $I8 = fact -563 
     869    is($I8, 1, 'fact_i_ic on a negative integer') 
     870.end 
    970871 
    971         add     I0, 5 
    972         print   I0 
    973         print   "\\n" 
     872.sub 'test_exchange' 
     873    $I10 = 10 
     874    $I20 = 20 
     875    exchange $I10, $I20 
     876    is($I10, 20, 'exchange - first operand ok') 
     877    is($I20, 10, 'exchange - second operand ok') 
    974878 
    975         add     I0, -10 
    976         print   I0 
    977         print   "\\n" 
    978         end 
    979 CODE 
    980 5 
    981 -5 
    982 OUTPUT 
     879    $I30 = 30 
     880    exchange $I30, $I30 
     881    is($I30, 30, 'exchange - reflexive') 
     882.end 
    983883 
    984 pasm_output_is( <<CODE, <<OUTPUT, "dec_i" ); 
    985         set     I0, 0 
     884.sub 'test_null' 
     885    $I1 = 1000 
     886    is($I1, 1000, 'null_i - before null') 
     887    null $I1 
     888    is($I1, 0, 'null_i - after null') 
     889.end 
    986890 
    987         dec     I0 
    988         print   I0 
    989         print   "\\n" 
     891.sub 'test_div_i_i_by_zero' 
     892    $I0 = 0 
     893    $I1 = 10 
     894    push_eh test_div_i_i_by_zero_catch 
     895    div $I1, $I0 
     896    pop_eh 
     897    $I2 = 0 
     898    goto test_div_i_i_by_zero_end 
    990899 
    991         dec     I0 
    992         dec     I0 
    993         dec     I0 
    994         dec     I0 
    995         print   I0 
    996         print   "\\n" 
     900  test_div_i_i_by_zero_catch: 
     901    $I2 = 1 
    997902 
    998         end 
    999 CODE 
    1000 -1 
    1001 -5 
    1002 OUTPUT 
     903  test_div_i_i_by_zero_end: 
     904    ok($I2, 'div_i_i by zero') 
     905.end 
    1003906 
    1004 pasm_output_is( <<CODE, <<OUTPUT, "sub_i_i" ); 
    1005         set     I0, 0 
    1006         set     I1, 3 
    1007         set     I2, -3 
     907.sub 'test_div_i_ic_by_zero' 
     908    $I1 = 10 
     909    push_eh test_div_i_ic_by_zero_catch 
     910    div $I1, 0 
     911    pop_eh 
     912    $I2 = 0 
     913    goto test_div_i_ic_by_zero_end 
    1008914 
    1009         sub     I0, I1 
    1010         print   I0 
    1011         print   "\\n" 
     915  test_div_i_ic_by_zero_catch: 
     916    $I2 = 1 
    1012917 
    1013         sub     I0, I2 
    1014         print   I0 
    1015         print   "\\n" 
    1016         end 
    1017 CODE 
    1018 -3 
    1019 0 
    1020 OUTPUT 
     918  test_div_i_ic_by_zero_end: 
     919    ok($I2, 'div_i_ic by zero') 
     920.end 
    1021921 
    1022 pasm_output_is( <<CODE, <<OUTPUT, "sub_i_ic" ); 
    1023         set     I0, 0 
     922.sub 'test_div_i_i_i_by_zero' 
     923    $I0 = 0 
     924    $I1 = 10 
     925    push_eh test_div_i_i_i_by_zero_catch 
     926    $I2 = div $I1, $I0 
     927    pop_eh 
     928    $I3 = 0 
     929    goto test_div_i_i_i_by_zero_end 
    1024930 
    1025         sub     I0, 5 
    1026         print   I0 
    1027         print   "\\n" 
     931  test_div_i_i_i_by_zero_catch: 
     932    $I3 = 1 
    1028933 
    1029         sub     I0, -10 
    1030         print   I0 
    1031         print   "\\n" 
    1032         end 
    1033 CODE 
    1034 -5 
    1035 5 
    1036 OUTPUT 
     934  test_div_i_i_i_by_zero_end: 
     935    ok($I3, 'div_i_i_i by zero') 
     936.end 
    1037937 
    1038 pasm_output_is( <<CODE, <<OUTPUT, "set_n_i" ); 
    1039         set     I0, 0 
    1040         set     N0, I0 
    1041         print   N0 
    1042         print   "\\n" 
     938.sub 'test_div_i_ic_i_by_zero' 
     939    $I0 = 0 
     940    push_eh test_div_i_ic_i_by_zero_catch 
     941    $I2 = div 10, $I0 
     942    pop_eh 
     943    $I3 = 0 
     944    goto test_div_i_ic_i_by_zero_end 
    1043945 
    1044         set     I1, 2147483647 
    1045         set     N1, I1 
    1046         print   N1 
    1047         print   "\\n" 
     946  test_div_i_ic_i_by_zero_catch: 
     947    $I3 = 1 
    1048948 
    1049         set     I2, -2147483648 
    1050         set     N2, I2 
    1051         print   N2 
    1052         print   "\\n" 
    1053         end 
    1054 CODE 
    1055 0 
    1056 2147483647 
    1057 -2147483648 
    1058 OUTPUT 
     949  test_div_i_ic_i_by_zero_end: 
     950    ok($I3, 'div_i_ic_i by zero') 
     951.end 
    1059952 
    1060 pasm_output_is( <<CODE, <<OUTPUT, "cleari" ); 
    1061         set     I0, 0xdeadbee 
    1062         set     I1, 0xdeadbee 
    1063         set     I2, 0xdeadbee 
    1064         set     I3, 0xdeadbee 
    1065         set     I4, 0xdeadbee 
    1066         set     I5, 0xdeadbee 
    1067         set     I6, 0xdeadbee 
    1068         set     I7, 0xdeadbee 
    1069         set     I8, 0xdeadbee 
    1070         set     I9, 0xdeadbee 
    1071         set     I10, 0xdeadbee 
    1072         set     I11, 0xdeadbee 
    1073         set     I12, 0xdeadbee 
    1074         set     I13, 0xdeadbee 
    1075         set     I14, 0xdeadbee 
    1076         set     I15, 0xdeadbee 
    1077         set     I16, 0xdeadbee 
    1078         set     I17, 0xdeadbee 
    1079         set     I18, 0xdeadbee 
    1080         set     I19, 0xdeadbee 
    1081         set     I20, 0xdeadbee 
    1082         set     I21, 0xdeadbee 
    1083         set     I22, 0xdeadbee 
    1084         set     I23, 0xdeadbee 
    1085         set     I24, 0xdeadbee 
    1086         set     I25, 0xdeadbee 
    1087         set     I26, 0xdeadbee 
    1088         set     I27, 0xdeadbee 
    1089         set     I28, 0xdeadbee 
    1090         set     I29, 0xdeadbee 
    1091         set     I30, 0xdeadbee 
    1092         set     I31, 0xdeadbee 
    1093         cleari 
    1094         print   I0 
    1095         print   I1 
    1096         print   I2 
    1097         print   I3 
    1098         print   I4 
    1099         print   I5 
    1100         print   I6 
    1101         print   I7 
    1102         print   I8 
    1103         print   I9 
    1104         print   I10 
    1105         print   I11 
    1106         print   I12 
    1107         print   I13 
    1108         print   I14 
    1109         print   I15 
    1110         print   I16 
    1111         print   I17 
    1112         print   I18 
    1113         print   I19 
    1114         print   I20 
    1115         print   I21 
    1116         print   I22 
    1117         print   I23 
    1118         print   I24 
    1119         print   I25 
    1120         print   I26 
    1121         print   I27 
    1122         print   I28 
    1123         print   I29 
    1124         print   I30 
    1125         print   I31 
    1126         print   "\\n" 
    1127         end 
    1128 CODE 
    1129 00000000000000000000000000000000 
    1130 OUTPUT 
     953.sub 'test_div_i_i_ic_by_zero' 
     954    $I1 = 10 
     955    push_eh test_div_i_i_ic_by_zero_catch 
     956    $I2 = div $I1, 0 
     957    pop_eh 
     958    $I3 = 0 
     959    goto test_div_i_i_ic_by_zero_end 
    1131960 
    1132 pasm_output_is( <<CODE, <<OUTPUT, "neg_i" ); 
    1133     neg I0,3 
    1134     neg I0,I0 
    1135     neg I0 
    1136     print I0 
    1137     print "\\n" 
    1138     end 
    1139 CODE 
    1140 -3 
    1141 OUTPUT 
     961  test_div_i_i_ic_by_zero_catch: 
     962    $I3 = 1 
    1142963 
    1143 pasm_output_is( <<CODE, <<OUTPUT, "mul_i_i" ); 
    1144     set I0,3 
    1145     set I1,4 
    1146     mul I0,I1 
    1147     print I0 
    1148     print "\\n" 
    1149     end 
    1150 CODE 
    1151 12 
    1152 OUTPUT 
     964  test_div_i_i_ic_by_zero_end: 
     965    ok($I3, 'div_i_i_ic by zero') 
     966.end 
    1153967 
    1154 pasm_output_is( <<CODE, <<OUTPUT, "fact_i_i" ); 
    1155     set I0, 3 
    1156     set I1, 11 
    1157     set I2, 0 
    1158     set I3, -563 
    1159     fact I5, I0 
    1160     print I5 
    1161     print "\\n" 
    1162     fact I6, I1 
    1163     print I6 
    1164     print "\\n" 
    1165     fact I7, I2 
    1166     print I7 
    1167     print "\\n" 
    1168     fact I8, I3 
    1169     print I8 
    1170     print "\\n" 
    1171     end 
    1172 CODE 
    1173 6 
    1174 39916800 
    1175 1 
    1176 1 
    1177 OUTPUT 
     968.sub 'test_fdiv_i_i_by_zero' 
     969    $I0 = 0 
     970    $I1 = 10 
     971    push_eh test_fdiv_i_i_by_zero_catch 
     972    fdiv $I1, $I0 
     973    pop_eh 
     974    $I2 = 0 
     975    goto test_fdiv_i_i_by_zero_end 
    1178976 
    1179 pasm_output_is( <<CODE, <<OUTPUT, "fact_i_ic" ); 
    1180     fact I5, 3 
    1181     print I5 
    1182     print "\\n" 
    1183     fact I6, 11 
    1184     print I6 
    1185     print "\\n" 
    1186     fact I7, 0 
    1187     print I7 
    1188     print "\\n" 
    1189     fact I8, -563 
    1190     print I8 
    1191     print "\\n" 
    1192     end 
    1193 CODE 
    1194 6 
    1195 39916800 
    1196 1 
    1197 1 
    1198 OUTPUT 
     977  test_fdiv_i_i_by_zero_catch: 
     978    $I2 = 1 
    1199979 
    1200 pasm_output_is( <<'CODE', <<OUTPUT, "exchange" ); 
    1201     set I10, 10 
    1202     set I20, 20 
    1203     exchange I10, I20 
    1204     print I10 
    1205     print "\n" 
    1206     print I20 
    1207     print "\n" 
     980  test_fdiv_i_i_by_zero_end: 
     981    ok($I2, 'fdiv_i_i by zero') 
     982.end 
    1208983 
    1209     set I30, 30 
    1210     exchange I30, I30 
    1211     print I30 
    1212     print "\n" 
    1213     end 
    1214 CODE 
    1215 20 
    1216 10 
    1217 30 
    1218 OUTPUT 
     984.sub 'test_fdiv_i_ic_by_zero' 
     985    $I1 = 10 
     986    push_eh test_fdiv_i_ic_by_zero_catch 
     987    fdiv $I1, 0 
     988    pop_eh 
     989    $I2 = 0 
     990    goto test_fdiv_i_ic_by_zero_end 
    1219991 
    1220 pasm_output_is( <<'CODE', <<OUTPUT, "null" ); 
    1221     set I1, 1000 
    1222     print I1 
    1223     print "\n" 
     992  test_fdiv_i_ic_by_zero_catch: 
     993    $I2 = 1 
    1224994 
    1225     null I1 
    1226     print I1 
    1227     print "\n" 
     995  test_fdiv_i_ic_by_zero_end: 
     996    ok($I2, 'fdiv_i_ic by zero') 
     997.end 
    1228998 
    1229     end 
    1230 CODE 
    1231 1000 
    1232 0 
    1233 OUTPUT 
     999.sub 'test_fdiv_i_i_i_by_zero' 
     1000    $I0 = 0 
     1001    $I1 = 10 
     1002    push_eh test_fdiv_i_i_i_by_zero_catch 
     1003    $I2 = fdiv $I1, $I0 
     1004    pop_eh 
     1005    $I3 = 0 
     1006    goto test_fdiv_i_i_i_by_zero_end 
    12341007 
    1235 pasm_error_output_like( <<'CODE', <<OUTPUT, "div_i_i by zero" ); 
    1236         set I0, 0 
    1237         set I1, 10 
    1238         div I1, I0 
    1239         end 
    1240 CODE 
    1241 /.*Divide by zero.*/ 
    1242 OUTPUT 
     1008  test_fdiv_i_i_i_by_zero_catch: 
     1009    $I3 = 1 
    12431010 
    1244 pasm_error_output_like( <<'CODE', <<OUTPUT, "div_i_ic by zero" ); 
    1245         set I1, 10 
    1246         div I1, 0 
    1247         end 
    1248 CODE 
    1249 /.*Divide by zero.*/ 
    1250 OUTPUT 
     1011  test_fdiv_i_i_i_by_zero_end: 
     1012    ok($I3, 'fdiv_i_i_i by zero') 
     1013.end 
    12511014 
    1252 pasm_error_output_like( <<'CODE', <<OUTPUT, "div_i_i_i by zero" ); 
    1253         set I0, 0 
    1254         set I1, 10 
    1255         div I2, I1, I0 
    1256         end 
    1257 CODE 
    1258 /.*Divide by zero.*/ 
    1259 OUTPUT 
     1015.sub 'test_fdiv_i_ic_i_by_zero' 
     1016    $I0 = 0 
     1017    push_eh test_fdiv_i_ic_i_by_zero_catch 
     1018    $I2 = fdiv 10, $I0 
     1019    pop_eh 
     1020    $I3 = 0 
     1021    goto test_fdiv_i_ic_i_by_zero_end 
    12601022 
    1261 pasm_error_output_like( <<'CODE', <<OUTPUT, "div_i_ic_i by zero" ); 
    1262         set I0, 0 
    1263         div I2, 10, I0 
    1264         end 
    1265 CODE 
    1266 /.*Divide by zero.*/ 
    1267 OUTPUT 
     1023  test_fdiv_i_ic_i_by_zero_catch: 
     1024    $I3 = 1 
    12681025 
    1269 pasm_error_output_like( <<'CODE', <<OUTPUT, "div_i_i_ic by zero" ); 
    1270         set I1, 10 
    1271         div I2, I1, 0 
    1272         end 
    1273 CODE 
    1274 /.*Divide by zero.*/ 
    1275 OUTPUT 
     1026  test_fdiv_i_ic_i_by_zero_end: 
     1027    ok($I3, 'fdiv_i_ic_i by zero') 
     1028.end 
    12761029 
    1277 pasm_error_output_like( <<'CODE', <<OUTPUT, "fdiv_i_i by zero" ); 
    1278         set I0, 0 
    1279         set I1, 10 
    1280         fdiv I1, I0 
    1281         end 
    1282 CODE 
    1283 /.*Divide by zero.*/ 
    1284 OUTPUT 
     1030.sub 'test_fdiv_i_i_ic_by_zero' 
     1031    $I1 = 10 
     1032    push_eh test_fdiv_i_i_ic_by_zero_catch 
     1033    $I2 = fdiv $I1, 0 
     1034    pop_eh 
     1035    $I3 = 0 
     1036    goto test_fdiv_i_i_ic_by_zero_end 
    12851037 
    1286 pasm_error_output_like( <<'CODE', <<OUTPUT, "fdiv_i_ic by zero" ); 
    1287         set I1, 10 
    1288         fdiv I1, 0 
    1289         end 
    1290 CODE 
    1291 /.*Divide by zero.*/ 
    1292 OUTPUT 
     1038  test_fdiv_i_i_ic_by_zero_catch: 
     1039    $I3 = 1 
    12931040 
    1294 pasm_error_output_like( <<'CODE', <<OUTPUT, "fdiv_i_i_i by zero" ); 
    1295         set I0, 0 
    1296         set I1, 10 
    1297         fdiv I2, I1, I0 
    1298         end 
    1299 CODE 
    1300 /.*Divide by zero.*/ 
    1301 OUTPUT 
     1041  test_fdiv_i_i_ic_by_zero_end: 
     1042    ok($I3, 'fdiv_i_i_ic by zero') 
     1043.end 
    13021044 
    1303 pasm_error_output_like( <<'CODE', <<OUTPUT, "fdiv_i_ic_i by zero" ); 
    1304         set I0, 0 
    1305         fdiv I2, 10, I0 
    1306         end 
    1307 CODE 
    1308 /.*Divide by zero.*/ 
    1309 OUTPUT 
     1045.sub 'test_cmod_i_i_i_by_zero' 
     1046    $I0 = 0 
     1047    $I1 = 10 
     1048    push_eh test_cmod_i_i_i_by_zero_catch 
     1049    $I2 = cmod $I1, $I0 
     1050    pop_eh 
     1051    $I3 = 0 
     1052    goto test_cmod_i_i_i_by_zero_end 
    13101053 
    1311 pasm_error_output_like( <<'CODE', <<OUTPUT, "fdiv_i_i_ic by zero" ); 
    1312         set I1, 10 
    1313         fdiv I2, I1, 0 
    1314         end 
    1315 CODE 
    1316 /.*Divide by zero.*/ 
    1317 OUTPUT 
     1054  test_cmod_i_i_i_by_zero_catch: 
     1055    $I3 = 1 
    13181056 
    1319 pasm_error_output_like( <<'CODE', <<OUTPUT, "cmod_i_i_i by zero" ); 
    1320         set I0, 0 
    1321         set I1, 10 
    1322         cmod I2, I1, I0 
    1323         end 
    1324 CODE 
    1325 /.*Divide by zero.*/ 
    1326 OUTPUT 
     1057  test_cmod_i_i_i_by_zero_end: 
     1058    ok($I3, 'cmod_i_i_i by zero') 
     1059.end 
    13271060 
    1328 pasm_error_output_like( <<'CODE', <<OUTPUT, "cmod_i_ic_i by zero" ); 
    1329         set I0, 0 
    1330         cmod I2, 10, I0 
    1331         end 
    1332 CODE 
    1333 /.*Divide by zero.*/ 
    1334 OUTPUT 
     1061.sub 'test_cmod_i_ic_i_by_zero' 
     1062    $I0 = 0 
     1063    push_eh test_cmod_i_ic_i_by_zero_catch 
     1064    $I2 = cmod 10, $I0 
     1065    pop_eh 
     1066    $I3 = 0 
     1067    goto test_cmod_i_ic_i_by_zero_end 
    13351068 
    1336 pasm_error_output_like( <<'CODE', <<OUTPUT, "cmod_i_i_ic by zero" ); 
    1337         set I1, 10 
    1338         cmod I2, I1, 0 
    1339         end 
    1340 CODE 
    1341 /.*Divide by zero.*/ 
    1342 OUTPUT 
     1069  test_cmod_i_ic_i_by_zero_catch: 
     1070    $I3 = 1 
    13431071 
    1344 pasm_output_is( <<'CODE', <<OUTPUT, "mod_i_i_i by zero" ); 
    1345         set I0, 0 
    1346         set I1, 10 
    1347         mod I2, I1, I0 
    1348         print I2 
    1349         print "\n" 
    1350         end 
    1351 CODE 
    1352 10 
    1353 OUTPUT 
     1072  test_cmod_i_ic_i_by_zero_end: 
     1073    ok($I3, 'cmod_i_ic_i by zero') 
     1074.end 
    13541075 
    1355 pasm_output_is( <<'CODE', <<OUTPUT, "mod_i_ic_i by zero" ); 
    1356         set I0, 0 
    1357         mod I2, 10, I0 
    1358         print I2 
    1359         print "\n" 
    1360         end 
    1361 CODE 
    1362 10 
    1363 OUTPUT 
     1076.sub 'test_cmod_i_i_ic_by_zero' 
     1077    $I1 = 10 
     1078    push_eh test_cmod_i_i_ic_by_zero_catch 
     1079    $I2 = cmod $I1, 0 
     1080    pop_eh 
     1081    $I3 = 0 
     1082    goto test_cmod_i_i_ic_by_zero_end 
    13641083 
    1365 pasm_output_is( <<'CODE', <<OUTPUT, "mod_i_i_ic by zero" ); 
    1366         set I1, 10 
    1367         mod I2, I1, 0 
    1368         print I2 
    1369         print "\n" 
    1370         end 
    1371 CODE 
    1372 10 
    1373 OUTPUT 
     1084  test_cmod_i_i_ic_by_zero_catch: 
     1085    $I3 = 1 
    13741086 
     1087  test_cmod_i_i_ic_by_zero_end: 
     1088    ok($I3, 'cmod_i_i_ic by zero') 
     1089.end 
     1090 
     1091.sub 'test_mod_i_i_i_by_zero' 
     1092    $I0 = 0 
     1093    $I1 = 10 
     1094    $I2 = mod $I1, $I0 
     1095    is($I2, 10, 'mod_i_i_i by zero') 
     1096.end 
     1097 
     1098.sub 'test_mod_i_ic_i_by_zero' 
     1099    $I0 = 0 
     1100    $I2 = mod 10, $I0 
     1101    is($I2, 10, 'mod_i_ic_i by zero') 
     1102.end 
     1103 
     1104.sub 'test_mod_i_i_ic_by_zero' 
     1105    $I1 = 10 
     1106    $I2 = mod $I1, 0 
     1107    is($I2, 10, 'mod_i_i_ic by zero') 
     1108.end 
     1109 
    13751110# Local Variables: 
    1376 #   mode: cperl 
    1377 #   cperl-indent-level: 4 
     1111#   mode: pir 
    13781112#   fill-column: 100 
    13791113# End: 
    1380 # vim: expandtab shiftwidth=4: 
     1114# vim: expandtab shiftwidth=4 ft=pir: