1# mach: bfin 2 3.include "testutils.inc" 4 start 5 6// This function computes an integer 32x32 multiply, 7// and returns the upper 32 bits of the result. 8// If the complete 64 bit result is required, one must 9// write the partial results as they are computed. 10// To change this code for a fractional 32x32, one needs 11// to adjust the shifts for magnitude of -15, and use a 12// fractional multiply at the end for the upper word halves 13// (instead of the integer one). 14 15 loadsym P0, input_a; 16 loadsym P1, input_b; 17 loadsym P2, output; 18 P4 = 10; 19 LSETUP ( loop1 , loop1end ) LC0 = P4; 20loop1: 21 R0 = [ P0 ++ ]; 22 R1 = [ P1 ++ ]; 23 24 // begin integer double precision routine 25 // 32 x 32 -> 32 26 27 A1 = R0.H * R1.L (M), A0 = R0.L * R1.L (FU); 28 A1 += R1.H * R0.L (M,IS); 29 A0 = A0 >>> 16; 30 A0 += A1; 31 A0 = A0 >>> 16; 32 A0 += R0.H * R1.H (IS); 33 R7 = A0.w; 34 35loop1end: 36 [ P2 ++ ] = R7; // store 32 bit output 37 38 // test results 39 loadsym P1, output; 40 R0 = [ P1 ++ ]; DBGA ( R0.H , 0xfeae ); DBGA ( R0.L , 0xab6b ); 41 R0 = [ P1 ++ ]; DBGA ( R0.H , 0xfeae ); DBGA ( R0.L , 0xa627 ); 42 R0 = [ P1 ++ ]; DBGA ( R0.H , 0xfeae ); DBGA ( R0.L , 0xa0e3 ); 43 R0 = [ P1 ++ ]; DBGA ( R0.H , 0xfeae ); DBGA ( R0.L , 0x9b9f ); 44 pass 45 46 .data 47input_a: 48 .dw 0x0000 49 .dw 0xfabc 50 .dw 0x0000 51 .dw 0xfabc 52 .dw 0x0000 53 .dw 0xfabc 54 .dw 0x0000 55 .dw 0xfabc 56 .dw 0x0000 57 .dw 0xfabc 58 .dw 0x0000 59 .dw 0xfabc 60 .dw 0x0000 61 .dw 0xfabc 62 .dw 0x0000 63 .dw 0xfabc 64 .dw 0x0000 65 .dw 0xfabc 66 .dw 0x0000 67 .dw 0xfabc 68 .align 4; 69input_b: 70 .dw 0x1000 71 .dw 0x4010 72 .dw 0x1000 73 .dw 0x4011 74 .dw 0x1000 75 .dw 0x4012 76 .dw 0x1000 77 .dw 0x4013 78 .dw 0x1000 79 .dw 0x4014 80 .dw 0x1000 81 .dw 0x4015 82 .dw 0x1000 83 .dw 0x4016 84 .dw 0x1000 85 .dw 0x4017 86 .dw 0x1000 87 .dw 0x4018 88 .dw 0x1000 89 .dw 0x4019 90 .align 4; 91output: 92 .space (40); 93