Home | History | Annotate | Line # | Download | only in or1k
      1      1.1  christos /* Tests the multiply instructions.
      2      1.1  christos 
      3  1.1.1.2  christos    Copyright (C) 2017-2024 Free Software Foundation, Inc.
      4      1.1  christos 
      5      1.1  christos    This program is free software; you can redistribute it and/or modify
      6      1.1  christos    it under the terms of the GNU General Public License as published by
      7      1.1  christos    the Free Software Foundation; either version 3 of the License, or
      8      1.1  christos    (at your option) any later version.
      9      1.1  christos 
     10      1.1  christos    This program is distributed in the hope that it will be useful,
     11      1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     12      1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13      1.1  christos    GNU General Public License for more details.
     14      1.1  christos 
     15      1.1  christos    You should have received a copy of the GNU General Public License
     16      1.1  christos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     17      1.1  christos 
     18      1.1  christos # mach: or1k
     19      1.1  christos # output: report(0x00000002);\n
     20      1.1  christos # output: report(0x00000003);\n
     21      1.1  christos # output: report(0x00000006);\n
     22      1.1  christos # output: report(0x00000000);\n
     23      1.1  christos # output: report(0x00000000);\n
     24      1.1  christos # output: report(0x00000000);\n
     25      1.1  christos # output: \n
     26      1.1  christos # output: report(0x00008001);\n
     27      1.1  christos # output: report(0x0000fffe);\n
     28      1.1  christos # output: report(0x7ffffffe);\n
     29      1.1  christos # output: report(0x00000000);\n
     30      1.1  christos # output: report(0x00000000);\n
     31      1.1  christos # output: report(0x00000000);\n
     32      1.1  christos # output: \n
     33      1.1  christos # output: report(0x00008000);\n
     34      1.1  christos # output: report(0x00010000);\n
     35      1.1  christos # output: report(0x80000000);\n
     36      1.1  christos # output: report(0x00000000);\n
     37      1.1  christos # output: report(0x00000001);\n
     38      1.1  christos # output: report(0x00000000);\n
     39      1.1  christos # output: \n
     40      1.1  christos # output: report(0x00010000);\n
     41      1.1  christos # output: report(0x00010000);\n
     42      1.1  christos # output: report(0x00000000);\n
     43      1.1  christos # output: report(0x00000000);\n
     44      1.1  christos # output: report(0x00000001);\n
     45      1.1  christos # output: report(0x00000000);\n
     46      1.1  christos # output: \n
     47      1.1  christos # output: report(0xfffffffe);\n
     48      1.1  christos # output: report(0xfffffffd);\n
     49      1.1  christos # output: report(0x00000006);\n
     50      1.1  christos # output: report(0x00000000);\n
     51      1.1  christos # output: report(0x00000000);\n
     52      1.1  christos # output: report(0x00000000);\n
     53      1.1  christos # output: \n
     54      1.1  christos # output: report(0xffff7fff);\n
     55      1.1  christos # output: report(0xffff0002);\n
     56      1.1  christos # output: report(0x7ffffffe);\n
     57      1.1  christos # output: report(0x00000000);\n
     58      1.1  christos # output: report(0x00000000);\n
     59      1.1  christos # output: report(0x00000000);\n
     60      1.1  christos # output: \n
     61      1.1  christos # output: report(0xffff7fff);\n
     62      1.1  christos # output: report(0xffff0000);\n
     63      1.1  christos # output: report(0x80010000);\n
     64      1.1  christos # output: report(0x00000000);\n
     65      1.1  christos # output: report(0x00000001);\n
     66      1.1  christos # output: report(0x00000000);\n
     67      1.1  christos # output: \n
     68      1.1  christos # output: report(0xffff0000);\n
     69      1.1  christos # output: report(0xfffeffff);\n
     70      1.1  christos # output: report(0x00010000);\n
     71      1.1  christos # output: report(0x00000000);\n
     72      1.1  christos # output: report(0x00000001);\n
     73      1.1  christos # output: report(0x00000000);\n
     74      1.1  christos # output: \n
     75      1.1  christos # output: report(0x00000002);\n
     76      1.1  christos # output: report(0xfffffffd);\n
     77      1.1  christos # output: report(0xfffffffa);\n
     78      1.1  christos # output: report(0x00000000);\n
     79      1.1  christos # output: report(0x00000000);\n
     80      1.1  christos # output: report(0x00000000);\n
     81      1.1  christos # output: \n
     82      1.1  christos # output: report(0xffff8000);\n
     83      1.1  christos # output: report(0x00010000);\n
     84      1.1  christos # output: report(0x80000000);\n
     85      1.1  christos # output: report(0x00000000);\n
     86      1.1  christos # output: report(0x00000000);\n
     87      1.1  christos # output: report(0x00000000);\n
     88      1.1  christos # output: \n
     89      1.1  christos # output: report(0xffff7fff);\n
     90      1.1  christos # output: report(0x00010000);\n
     91      1.1  christos # output: report(0x7fff0000);\n
     92      1.1  christos # output: report(0x00000000);\n
     93      1.1  christos # output: report(0x00000001);\n
     94      1.1  christos # output: report(0x00000000);\n
     95      1.1  christos # output: \n
     96      1.1  christos # output: report(0x80000000);\n
     97      1.1  christos # output: report(0x00000001);\n
     98      1.1  christos # output: report(0x80000000);\n
     99      1.1  christos # output: report(0x00000000);\n
    100      1.1  christos # output: report(0x00000000);\n
    101      1.1  christos # output: report(0x00000000);\n
    102      1.1  christos # output: \n
    103      1.1  christos # output: report(0x00008000);\n
    104      1.1  christos # output: report(0x00010000);\n
    105      1.1  christos # output: report(0x80000000);\n
    106      1.1  christos # output: report(0x00000000);\n
    107      1.1  christos # output: report(0x00000001);\n
    108      1.1  christos # output: report(0x00000001);\n
    109      1.1  christos # output: \n
    110      1.1  christos # output: report(0x00000002);\n
    111      1.1  christos # output: report(0xfffffffd);\n
    112      1.1  christos # output: report(0xfffffffa);\n
    113      1.1  christos # output: report(0x00000000);\n
    114      1.1  christos # output: report(0x00000000);\n
    115      1.1  christos # output: report(0x00000000);\n
    116      1.1  christos # output: \n
    117      1.1  christos # output: report(0xffff7fff);\n
    118      1.1  christos # output: report(0xffff0000);\n
    119      1.1  christos # output: report(0x80010000);\n
    120      1.1  christos # output: report(0x00000000);\n
    121      1.1  christos # output: report(0x00000001);\n
    122      1.1  christos # output: report(0x00000001);\n
    123      1.1  christos # output: \n
    124      1.1  christos # output: report(0x00000002);\n
    125      1.1  christos # output: report(0x00000003);\n
    126      1.1  christos # output: report(0x00000006);\n
    127      1.1  christos # output: report(0x00000000);\n
    128      1.1  christos # output: report(0x00000000);\n
    129      1.1  christos # output: report(0x00000000);\n
    130      1.1  christos # output: \n
    131      1.1  christos # output: report(0x00010002);\n
    132      1.1  christos # output: report(0x00007fff);\n
    133      1.1  christos # output: report(0x7ffffffe);\n
    134      1.1  christos # output: report(0x00000000);\n
    135      1.1  christos # output: report(0x00000000);\n
    136      1.1  christos # output: report(0x00000000);\n
    137      1.1  christos # output: \n
    138      1.1  christos # output: report(0x00020000);\n
    139      1.1  christos # output: report(0x00004000);\n
    140      1.1  christos # output: report(0x80000000);\n
    141      1.1  christos # output: report(0x00000000);\n
    142      1.1  christos # output: report(0x00000001);\n
    143      1.1  christos # output: report(0x00000000);\n
    144      1.1  christos # output: \n
    145      1.1  christos # output: report(0x00040000);\n
    146      1.1  christos # output: report(0x00004000);\n
    147      1.1  christos # output: report(0x00000000);\n
    148      1.1  christos # output: report(0x00000000);\n
    149      1.1  christos # output: report(0x00000001);\n
    150      1.1  christos # output: report(0x00000000);\n
    151      1.1  christos # output: \n
    152      1.1  christos # output: report(0xfffffffe);\n
    153      1.1  christos # output: report(0x0000fffd);\n
    154      1.1  christos # output: report(0x00000006);\n
    155      1.1  christos # output: report(0x00000000);\n
    156      1.1  christos # output: report(0x00000000);\n
    157      1.1  christos # output: report(0x00000000);\n
    158      1.1  christos # output: \n
    159      1.1  christos # output: report(0xfffefffe);\n
    160      1.1  christos # output: report(0x00008001);\n
    161      1.1  christos # output: report(0x7ffffffe);\n
    162      1.1  christos # output: report(0x00000000);\n
    163      1.1  christos # output: report(0x00000000);\n
    164      1.1  christos # output: report(0x00000000);\n
    165      1.1  christos # output: \n
    166      1.1  christos # output: report(0xfffe0000);\n
    167      1.1  christos # output: report(0x0000bfff);\n
    168      1.1  christos # output: report(0x80020000);\n
    169      1.1  christos # output: report(0x00000000);\n
    170      1.1  christos # output: report(0x00000001);\n
    171      1.1  christos # output: report(0x00000000);\n
    172      1.1  christos # output: \n
    173      1.1  christos # output: report(0xfffdfffe);\n
    174      1.1  christos # output: report(0x00008000);\n
    175      1.1  christos # output: report(0x00010000);\n
    176      1.1  christos # output: report(0x00000000);\n
    177      1.1  christos # output: report(0x00000001);\n
    178      1.1  christos # output: report(0x00000000);\n
    179      1.1  christos # output: \n
    180      1.1  christos # output: report(0x00000002);\n
    181      1.1  christos # output: report(0x0000fffd);\n
    182      1.1  christos # output: report(0xfffffffa);\n
    183      1.1  christos # output: report(0x00000000);\n
    184      1.1  christos # output: report(0x00000000);\n
    185      1.1  christos # output: report(0x00000000);\n
    186      1.1  christos # output: \n
    187      1.1  christos # output: report(0x00010000);\n
    188      1.1  christos # output: report(0x00008000);\n
    189      1.1  christos # output: report(0x80000000);\n
    190      1.1  christos # output: report(0x00000000);\n
    191      1.1  christos # output: report(0x00000000);\n
    192      1.1  christos # output: report(0x00000000);\n
    193      1.1  christos # output: \n
    194      1.1  christos # output: report(0xfffdfffc);\n
    195      1.1  christos # output: report(0x00004000);\n
    196      1.1  christos # output: report(0x7fff0000);\n
    197      1.1  christos # output: report(0x00000000);\n
    198      1.1  christos # output: report(0x00000001);\n
    199      1.1  christos # output: report(0x00000000);\n
    200      1.1  christos # output: \n
    201      1.1  christos # output: report(0x80000000);\n
    202      1.1  christos # output: report(0x00000001);\n
    203      1.1  christos # output: report(0x80000000);\n
    204      1.1  christos # output: report(0x00000000);\n
    205      1.1  christos # output: report(0x00000000);\n
    206      1.1  christos # output: report(0x00000000);\n
    207      1.1  christos # output: \n
    208      1.1  christos # output: report(0x00020000);\n
    209      1.1  christos # output: report(0x00004000);\n
    210      1.1  christos # output: report(0x80000000);\n
    211      1.1  christos # output: report(0x00000000);\n
    212      1.1  christos # output: report(0x00000001);\n
    213      1.1  christos # output: report(0x00000001);\n
    214      1.1  christos # output: \n
    215      1.1  christos # output: report(0xfffffffe);\n
    216      1.1  christos # output: report(0x0000fffd);\n
    217      1.1  christos # output: report(0x00000006);\n
    218      1.1  christos # output: report(0x00000000);\n
    219      1.1  christos # output: report(0x00000000);\n
    220      1.1  christos # output: report(0x00000000);\n
    221      1.1  christos # output: \n
    222      1.1  christos # output: report(0xfffdfffe);\n
    223      1.1  christos # output: report(0x00008000);\n
    224      1.1  christos # output: report(0x00010000);\n
    225      1.1  christos # output: report(0x00000000);\n
    226      1.1  christos # output: report(0x00000001);\n
    227      1.1  christos # output: report(0x00000001);\n
    228      1.1  christos # output: \n
    229      1.1  christos # output: report(0x00000002);\n
    230      1.1  christos # output: report(0x00000003);\n
    231      1.1  christos # output: report(0x00000006);\n
    232      1.1  christos # output: report(0x00000000);\n
    233      1.1  christos # output: report(0x00000000);\n
    234      1.1  christos # output: report(0x00000000);\n
    235      1.1  christos # output: \n
    236      1.1  christos # output: report(0x00008001);\n
    237      1.1  christos # output: report(0x0000fffe);\n
    238      1.1  christos # output: report(0x7ffffffe);\n
    239      1.1  christos # output: report(0x00000000);\n
    240      1.1  christos # output: report(0x00000000);\n
    241      1.1  christos # output: report(0x00000000);\n
    242      1.1  christos # output: \n
    243      1.1  christos # output: report(0x00008000);\n
    244      1.1  christos # output: report(0x00010000);\n
    245      1.1  christos # output: report(0x80000000);\n
    246      1.1  christos # output: report(0x00000000);\n
    247      1.1  christos # output: report(0x00000000);\n
    248      1.1  christos # output: report(0x00000000);\n
    249      1.1  christos # output: \n
    250      1.1  christos # output: report(0x00010000);\n
    251      1.1  christos # output: report(0x00010000);\n
    252      1.1  christos # output: report(0x00000000);\n
    253      1.1  christos # output: report(0x00000001);\n
    254      1.1  christos # output: report(0x00000000);\n
    255      1.1  christos # output: report(0x00000000);\n
    256      1.1  christos # output: \n
    257      1.1  christos # output: report(0xfffffffe);\n
    258      1.1  christos # output: report(0xfffffffd);\n
    259      1.1  christos # output: report(0x00000006);\n
    260      1.1  christos # output: report(0x00000001);\n
    261      1.1  christos # output: report(0x00000000);\n
    262      1.1  christos # output: report(0x00000000);\n
    263      1.1  christos # output: \n
    264      1.1  christos # output: report(0xffff7fff);\n
    265      1.1  christos # output: report(0xffff0002);\n
    266      1.1  christos # output: report(0x7ffffffe);\n
    267      1.1  christos # output: report(0x00000001);\n
    268      1.1  christos # output: report(0x00000000);\n
    269      1.1  christos # output: report(0x00000000);\n
    270      1.1  christos # output: \n
    271      1.1  christos # output: report(0xffff7fff);\n
    272      1.1  christos # output: report(0xffff0000);\n
    273      1.1  christos # output: report(0x80010000);\n
    274      1.1  christos # output: report(0x00000001);\n
    275      1.1  christos # output: report(0x00000000);\n
    276      1.1  christos # output: report(0x00000000);\n
    277      1.1  christos # output: \n
    278      1.1  christos # output: report(0xffff0000);\n
    279      1.1  christos # output: report(0xfffeffff);\n
    280      1.1  christos # output: report(0x00010000);\n
    281      1.1  christos # output: report(0x00000001);\n
    282      1.1  christos # output: report(0x00000000);\n
    283      1.1  christos # output: report(0x00000000);\n
    284      1.1  christos # output: \n
    285      1.1  christos # output: report(0x00000002);\n
    286      1.1  christos # output: report(0xfffffffd);\n
    287      1.1  christos # output: report(0xfffffffa);\n
    288      1.1  christos # output: report(0x00000001);\n
    289      1.1  christos # output: report(0x00000000);\n
    290      1.1  christos # output: report(0x00000000);\n
    291      1.1  christos # output: \n
    292      1.1  christos # output: report(0xffff8000);\n
    293      1.1  christos # output: report(0x00010000);\n
    294      1.1  christos # output: report(0x80000000);\n
    295      1.1  christos # output: report(0x00000001);\n
    296      1.1  christos # output: report(0x00000000);\n
    297      1.1  christos # output: report(0x00000000);\n
    298      1.1  christos # output: \n
    299      1.1  christos # output: report(0xffff7fff);\n
    300      1.1  christos # output: report(0x00010000);\n
    301      1.1  christos # output: report(0x7fff0000);\n
    302      1.1  christos # output: report(0x00000001);\n
    303      1.1  christos # output: report(0x00000000);\n
    304      1.1  christos # output: report(0x00000000);\n
    305      1.1  christos # output: \n
    306      1.1  christos # output: report(0x80000000);\n
    307      1.1  christos # output: report(0x00000001);\n
    308      1.1  christos # output: report(0x80000000);\n
    309      1.1  christos # output: report(0x00000000);\n
    310      1.1  christos # output: report(0x00000000);\n
    311      1.1  christos # output: report(0x00000000);\n
    312      1.1  christos # output: \n
    313      1.1  christos # output: report(0x00008000);\n
    314      1.1  christos # output: report(0x00010000);\n
    315      1.1  christos # output: report(0x80000000);\n
    316      1.1  christos # output: report(0x00000000);\n
    317      1.1  christos # output: report(0x00000000);\n
    318      1.1  christos # output: report(0x00000000);\n
    319      1.1  christos # output: \n
    320      1.1  christos # output: report(0x00000002);\n
    321      1.1  christos # output: report(0xfffffffd);\n
    322      1.1  christos # output: report(0xfffffffa);\n
    323      1.1  christos # output: report(0x00000001);\n
    324      1.1  christos # output: report(0x00000000);\n
    325      1.1  christos # output: report(0x00000001);\n
    326      1.1  christos # output: \n
    327      1.1  christos # output: report(0xffff7fff);\n
    328      1.1  christos # output: report(0xffff0000);\n
    329      1.1  christos # output: report(0x80010000);\n
    330      1.1  christos # output: report(0x00000001);\n
    331      1.1  christos # output: report(0x00000000);\n
    332      1.1  christos # output: report(0x00000001);\n
    333      1.1  christos # output: \n
    334      1.1  christos # output: exit(0)\n
    335      1.1  christos 
    336      1.1  christos #include "or1k-asm-test-helpers.h"
    337      1.1  christos 
    338      1.1  christos 	STANDARD_TEST_ENVIRONMENT
    339      1.1  christos 
    340      1.1  christos 	.section .exception_vectors
    341      1.1  christos 
    342      1.1  christos 	/* Range exception.  */
    343      1.1  christos 	.org	0xb00
    344      1.1  christos 
    345      1.1  christos 	/* The handling is a bit dubious at present.  We just patch the
    346      1.1  christos 	   instruction with l.nop and restart.  This will go wrong in branch
    347      1.1  christos 	   delay slots, but we are not testing that here.  */
    348      1.1  christos 	l.addi r1, r1, -EXCEPTION_STACK_SKIP_SIZE
    349      1.1  christos 	PUSH r2
    350      1.1  christos 	PUSH r3
    351      1.1  christos 	/* Save the address of the instruction that caused the problem.  */
    352      1.1  christos 	MOVE_FROM_SPR r2, SPR_EPCR_BASE
    353      1.1  christos 	LOAD_IMMEDIATE r3, 0x15000000 /* Opcode for l.nop  */
    354      1.1  christos 	l.sw	0(r2), r3
    355      1.1  christos 	POP r3
    356      1.1  christos 	POP r2
    357      1.1  christos 	l.addi r1, r1, EXCEPTION_STACK_SKIP_SIZE
    358      1.1  christos 	l.rfe
    359      1.1  christos 
    360      1.1  christos 	.section .text
    361      1.1  christos start_tests:
    362      1.1  christos 	PUSH LINK_REGISTER_R9
    363      1.1  christos 
    364      1.1  christos 	/* Test l.mul  */
    365      1.1  christos 
    366      1.1  christos 	/* Multiply two small positive numbers.  This should set no flags.
    367      1.1  christos 	   */
    368      1.1  christos 	TEST_INST_I32_I32 l.mul, 0x00000002, 0x00000003
    369      1.1  christos 
    370      1.1  christos 	/* Multiply two quite large positive numbers.  This should set no
    371      1.1  christos 	   flags  */
    372      1.1  christos 	TEST_INST_I32_I32 l.mul, 0x00008001, 0x0000fffe
    373      1.1  christos 
    374      1.1  christos 	/* Multiply two slightly too large positive numbers.  This should
    375      1.1  christos 	   set the overflow, but not the carry flag .  */
    376      1.1  christos 	TEST_INST_I32_I32 l.mul, 0x00008000, 0x00010000
    377      1.1  christos 
    378      1.1  christos 	/* Multiply two large positive numbers.  This should set the
    379      1.1  christos 	   overflow flags (even though the result is not a negative
    380      1.1  christos 	   number.  */
    381      1.1  christos 	TEST_INST_I32_I32 l.mul, 0x00010000, 0x00010000
    382      1.1  christos 
    383      1.1  christos 	/* Multiply two small negative numbers.  This will set no flags.  */
    384      1.1  christos 	TEST_INST_I32_I32 l.mul, 0xfffffffe, 0xfffffffd
    385      1.1  christos 
    386      1.1  christos 	/* Multiply two quite large negative numbers.  This will no flags.  */
    387      1.1  christos 	TEST_INST_I32_I32 l.mul, 0xffff7fff, 0xffff0002
    388      1.1  christos 
    389      1.1  christos 	/* Multiply two slightly too large negative numbers.  This should
    390      1.1  christos 	   set the overflow flag.  */
    391      1.1  christos 	TEST_INST_I32_I32 l.mul, 0xffff7fff, 0xffff0000
    392      1.1  christos 
    393      1.1  christos 	/* Multiply two large negative numbers.  This should set the
    394      1.1  christos 	   both the carry and overflow flags (even though the result is a
    395      1.1  christos 	   positive number.  */
    396      1.1  christos 	TEST_INST_I32_I32 l.mul, 0xffff0000, 0xfffeffff
    397      1.1  christos 
    398      1.1  christos 	/* Multiply one small negative number and one small positive
    399      1.1  christos 	   number.  This will set the no flags.  */
    400      1.1  christos 	TEST_INST_I32_I32 l.mul, 0x00000002, 0xfffffffd
    401      1.1  christos 
    402      1.1  christos 	/* Multiply one quite large negative number and one quite large
    403      1.1  christos 	   positive number.  This will set no flags.  */
    404      1.1  christos 	TEST_INST_I32_I32 l.mul, 0xffff8000, 0x00010000
    405      1.1  christos 
    406      1.1  christos 	/* Multiply one slightly too large negative number and one slightly
    407      1.1  christos 	   too large positive number.  This should set the overflow flag.  */
    408      1.1  christos 	TEST_INST_I32_I32 l.mul, 0xffff7fff, 0x00010000
    409      1.1  christos 
    410      1.1  christos 	/* Multiply the largest negative number by positive unity.  This
    411      1.1  christos 	   should set neither carry, nor overflow flag.  */
    412      1.1  christos 	TEST_INST_I32_I32 l.mul, 0x80000000, 0x00000001
    413      1.1  christos 
    414      1.1  christos 	/* Check that range exceptions are triggered.  */
    415      1.1  christos 
    416      1.1  christos 	SET_SPR_SR_FLAGS SPR_SR_OVE, r2, r3
    417      1.1  christos 
    418      1.1  christos 	/* Check that an overflow alone causes a RANGE Exception.  */
    419      1.1  christos 	TEST_INST_I32_I32 l.mul, 0x00008000, 0x00010000
    420      1.1  christos 
    421      1.1  christos 	/* Check multiply of a negative and positive does not cause a RANGE
    422      1.1  christos 	   Exception.  */
    423      1.1  christos 	TEST_INST_I32_I32 l.mul, 0x00000002, 0xfffffffd
    424      1.1  christos 
    425      1.1  christos 	/* Check that negative overflow causes a RANGE exception.  */
    426      1.1  christos 	TEST_INST_I32_I32 l.mul, 0xffff7fff, 0xffff0000
    427      1.1  christos 
    428      1.1  christos 	CLEAR_SPR_SR_FLAGS SPR_SR_OVE, r2, r3
    429      1.1  christos 
    430      1.1  christos 
    431      1.1  christos 	/* Test l.muli  */
    432      1.1  christos 
    433      1.1  christos 	/* Multiply two small positive numbers.  This should set no flags.  */
    434      1.1  christos 	TEST_INST_I32_I16 l.muli, 0x00000002, 0x0003
    435      1.1  christos 
    436      1.1  christos 	/* Multiply two quite large positive numbers.  This should set no
    437      1.1  christos 	   flags */
    438      1.1  christos 	TEST_INST_I32_I16 l.muli, 0x00010002, 0x7fff
    439      1.1  christos 
    440      1.1  christos 	/* Multiply two slightly too large positive numbers.  This should
    441      1.1  christos 	   set the overflow, but not the carry flag.  */
    442      1.1  christos 	TEST_INST_I32_I16 l.muli, 0x00020000, 0x4000
    443      1.1  christos 
    444      1.1  christos 	/* Multiply two large positive numbers.  This should set the
    445      1.1  christos 	   overflow flag, even though the result is not a negative number.  */
    446      1.1  christos 	TEST_INST_I32_I16 l.muli, 0x00040000, 0x4000
    447      1.1  christos 
    448      1.1  christos 	/* Multiply two small negative numbers.  This should set no flags.  */
    449      1.1  christos 	TEST_INST_I32_I16 l.muli, 0xfffffffe, 0xfffd
    450      1.1  christos 
    451      1.1  christos 	/* Multiply two quite large negative numbers.  This will set no
    452      1.1  christos 	   flags.  */
    453      1.1  christos 	TEST_INST_I32_I16 l.muli, 0xfffefffe, 0x8001
    454      1.1  christos 
    455      1.1  christos 	/* Multiply two slightly too large negative numbers.  This should
    456      1.1  christos 	   set the overflow flag.  */
    457      1.1  christos 	TEST_INST_I32_I16 l.muli, 0xfffe0000, 0xbfff
    458      1.1  christos 
    459      1.1  christos 	/* Multiply two large negative numbers.  This should set the
    460      1.1  christos 	   overflow flag, even though the result is a positive number.  */
    461      1.1  christos 	TEST_INST_I32_I16 l.muli, 0xfffdfffe, 0x8000
    462      1.1  christos 
    463      1.1  christos 	/* Multiply one small negative number and one small positive
    464      1.1  christos 	   number.  This will set no flags.  */
    465      1.1  christos 	TEST_INST_I32_I16 l.muli, 0x00000002, 0xfffd
    466      1.1  christos 
    467      1.1  christos 	/* Multiply one quite large negative number and one quite large
    468      1.1  christos 	   positive number.  This will set no flags.  */
    469      1.1  christos 	TEST_INST_I32_I16 l.muli, 0x00010000, 0x8000
    470      1.1  christos 
    471      1.1  christos 	/* Multiply one slightly too large negative number and one slightly
    472      1.1  christos 	   too large positive number.  This will set the overflow flag.  */
    473      1.1  christos 	TEST_INST_I32_I16 l.muli, 0xfffdfffc, 0x4000
    474      1.1  christos 
    475      1.1  christos 	/* Multiply the largest negative number by positive unity.  Should
    476      1.1  christos 	   set neither carry, nor overflow flag.  */
    477      1.1  christos 	TEST_INST_I32_I16 l.muli, 0x80000000, 0x0001
    478      1.1  christos 
    479      1.1  christos 	/* Check that range exceptions are triggered.  */
    480      1.1  christos 
    481      1.1  christos 	SET_SPR_SR_FLAGS SPR_SR_OVE, r2, r3
    482      1.1  christos 
    483      1.1  christos 	/* Check that an overflow alone causes a RANGE Exception.  */
    484      1.1  christos 	TEST_INST_I32_I16 l.muli, 0x00020000, 0x4000
    485      1.1  christos 
    486      1.1  christos 	/* Check that two negatives will not cause a RANGE Exception.  */
    487      1.1  christos 	TEST_INST_I32_I16 l.muli, 0xfffffffe, 0xfffd
    488      1.1  christos 
    489      1.1  christos 	/* Check that multiply of larget negative and positive numbers causes
    490      1.1  christos 	   a RANGE exception and overflow.  */
    491      1.1  christos 	TEST_INST_I32_I16 l.muli, 0xfffdfffe, 0x8000
    492      1.1  christos 
    493      1.1  christos 	CLEAR_SPR_SR_FLAGS SPR_SR_OVE, r2, r3
    494      1.1  christos 
    495      1.1  christos 	/* Test l.mulu  */
    496      1.1  christos 
    497      1.1  christos 	/* Multiply two small positive numbers.  This should set no flags.  */
    498      1.1  christos 	TEST_INST_I32_I32 l.mulu, 0x00000002, 0x00000003
    499      1.1  christos 
    500      1.1  christos 	/* Multiply two quite large positive numbers.  This should set no
    501      1.1  christos 	   flags.  */
    502      1.1  christos 	TEST_INST_I32_I32 l.mulu, 0x00008001, 0x0000fffe
    503      1.1  christos 
    504      1.1  christos 	/* Multiply two slightly too large positive numbers.  This will set
    505      1.1  christos 	   no flags.  */
    506      1.1  christos 	TEST_INST_I32_I32 l.mulu, 0x00008000, 0x00010000
    507      1.1  christos 
    508      1.1  christos 	/* Multiply two large positive numbers.  This will set the overflow
    509      1.1  christos 	   flag.  */
    510      1.1  christos 	TEST_INST_I32_I32 l.mulu, 0x00010000, 0x00010000
    511      1.1  christos 
    512      1.1  christos 	/* Multiply two small negative numbers.  This will set the
    513      1.1  christos 	   carry flag, but not the overflow flag.  */
    514      1.1  christos 	TEST_INST_I32_I32 l.mulu, 0xfffffffe, 0xfffffffd
    515      1.1  christos 
    516      1.1  christos 	/* Multiply two quite large negative numbers.  This will set the
    517      1.1  christos 	   carry flag, but not the overflow flag.  */
    518      1.1  christos 	TEST_INST_I32_I32 l.mulu, 0xffff7fff, 0xffff0002
    519      1.1  christos 
    520      1.1  christos 	/* Multiply two slightly too large negative numbers.  This will set
    521      1.1  christos 	   the carry flag, and not the overflow flag  */
    522      1.1  christos 	TEST_INST_I32_I32 l.mulu, 0xffff7fff, 0xffff0000
    523      1.1  christos 
    524      1.1  christos 	/* Multiply two large negative numbers.  This will set the both the
    525      1.1  christos 	   carry flag (even though the result is a positive number.)  */
    526      1.1  christos 	TEST_INST_I32_I32 l.mulu, 0xffff0000, 0xfffeffff
    527      1.1  christos 
    528      1.1  christos 	/* Multiply one small negative number and one small positive
    529      1.1  christos 	   number.  This will set the carry flag, but not the overflow
    530      1.1  christos 	   flag.  */
    531      1.1  christos 	TEST_INST_I32_I32 l.mulu, 0x00000002, 0xfffffffd
    532      1.1  christos 
    533      1.1  christos 	/* Multiply one quite large negative number and one quite large
    534      1.1  christos 	   positive number.  This will set the carry flag, but not the
    535      1.1  christos 	   overflow flag.  */
    536      1.1  christos 	TEST_INST_I32_I32 l.mulu, 0xffff8000, 0x00010000
    537      1.1  christos 
    538      1.1  christos 	/* Multiply one slightly too large negative number and one slightly
    539      1.1  christos 	   too large positive number.  This will set the carry flag, but
    540      1.1  christos 	   not the overflow flag.  */
    541      1.1  christos 	TEST_INST_I32_I32 l.mulu, 0xffff7fff, 0x00010000
    542      1.1  christos 
    543      1.1  christos 	/* Multiply the largest negative number by positive unity.  Should
    544      1.1  christos 	   set neither carry, nor overflow flag.  */
    545      1.1  christos 	TEST_INST_I32_I32 l.mulu, 0x80000000, 0x00000001
    546      1.1  christos 
    547      1.1  christos 	/* Check that range exceptions are never triggered.  */
    548      1.1  christos 
    549      1.1  christos 	SET_SPR_SR_FLAGS SPR_SR_OVE, r2, r3
    550      1.1  christos 
    551      1.1  christos 	/* Check that what would cause an overflow alone in 2's complement
    552      1.1  christos 	   does not cause a RANGE Exception.  */
    553      1.1  christos 	TEST_INST_I32_I32 l.mulu, 0x00008000, 0x00010000
    554      1.1  christos 
    555      1.1  christos 	/* Check that a carry causes a RANGE Exception.  */
    556      1.1  christos 	TEST_INST_I32_I32 l.mulu, 0x00000002, 0xfffffffd
    557      1.1  christos 
    558      1.1  christos 	/* Check that what would cause an overflow and carry in 2's
    559      1.1  christos 	   complement causes a RANGE Exception.  */
    560      1.1  christos 	TEST_INST_I32_I32 l.mulu, 0xffff7fff, 0xffff0000
    561      1.1  christos 
    562      1.1  christos 	CLEAR_SPR_SR_FLAGS SPR_SR_OVE, r2, r3
    563      1.1  christos 
    564      1.1  christos 	POP LINK_REGISTER_R9
    565      1.1  christos 	RETURN_TO_LINK_REGISTER_R9
    566