2 * Copyright 2014 Martin Peres <martin.peres@free.fr>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the folloing conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
22 * Authors: Martin Peres
25 /******************************************************************************
27 *****************************************************************************/
34 /******************************************************************************
36 *****************************************************************************/
39 // does a 32x32 -> 64 multiplication
41 // A * B = A_lo * B_lo
42 // + ( A_hi * B_lo ) << 16
43 // + ( A_lo * B_hi ) << 16
44 // + ( A_hi * B_hi ) << 32
49 // $r12 - mul_lo (return)
50 // $r11 - mul_hi (return)
67 // ( A_hi * B_lo ) << 16
68 mulu $r3 $r1 $r13 // tmp0 = A_hi * B_lo
70 and $r3 0xffff // tmp0 = tmp0_lo
72 shr b32 $r4 16 // tmp1 = tmp0_hi
76 // ( A_lo * B_hi ) << 16
77 mulu $r3 $r14 $r2 // tmp0 = A_lo * B_hi
79 and $r3 0xffff // tmp0 = tmp0_lo
81 shr b32 $r4 16 // tmp1 = tmp0_hi
85 // ( A_hi * B_hi ) << 32
86 mulu $r3 $r1 $r2 // tmp0 = A_hi * B_hi