4 #define DFP_BINOP(type, opc, binop, op1, op2, round) \
8 asm("cr 0,0\n\t" /* clear CC */ \
9 ".insn rrf," #opc "0000,%[res],%[r1],%[r2],%[mode]\n\t" \
12 : [res] "=f"(result), [cc] "=d"(cc) \
13 : [r1] "f"(op1.f), [r2] "f"(op2.f), [mode] "i"(round) \
15 DFP_VAL_PRINT(op1.f, reg_##type); \
16 printf(" " binop " "); \
17 DFP_VAL_PRINT(op2.f, reg_##type); \
19 DFP_VAL_PRINT(result, reg_##type); \
20 printf(" cc = %d\n", cc); \
23 static const pun_d64 dd_3_14
= {0x2230000000000194}; /* 3.14DD */
24 static const pun_d64 dd_m3_14
= {0xa230000000000194}; /* -3.14DD */
25 static const pun_d64 dd_0_005
= {0x222c000000000005}; /* 0.005DD */
26 static const pun_d64 dd_7
= {0x2238000000000007}; /* 7.DD */
27 static const pun_d64 dd_0
= {0x2238000000000000}; /* 0.DD */
28 static const pun_d64 dd_22
= {0x2238000000000022}; /* 22.DD */
29 static const pun_d64 dd_m22
= {0xa238000000000022}; /* -22.DD */
31 static const pun_d128 dl_3_14
= {{0x2207800000000000, 0x0000000000000194}};
32 static const pun_d128 dl_m3_14
= {{0xa207800000000000, 0x0000000000000194}};
33 static const pun_d128 dl_0_005
= {{0x2207400000000000, 0x0000000000000005}};
34 static const pun_d128 dl_7
= {{0x2208000000000000, 0x0000000000000007}};
35 static const pun_d128 dl_0
= {{0x2208000000000000, 0x0000000000000000}};
36 static const pun_d128 dl_22
= {{0x2208000000000000, 0x0000000000000022}};
37 static const pun_d128 dl_m22
= {{0xa208000000000000, 0x0000000000000022}};
41 printf("Decimal floating point arithmetic\n");
43 printf("64-bit ADD\n");
44 DFP_BINOP(d64
, 0xb3d2, "+", dd_3_14
, dd_0_005
, 1); /* cc = 2 */
45 DFP_BINOP(d64
, 0xb3d2, "+", dd_m3_14
, dd_0_005
, 1); /* cc = 1 */
46 DFP_BINOP(d64
, 0xb3d2, "+", dd_3_14
, dd_m3_14
, 3); /* cc = 0 */
48 printf("64-bit SUBTRACT\n");
49 DFP_BINOP(d64
, 0xb3d3, "-", dd_3_14
, dd_0_005
, 1); /* cc = 2 */
50 DFP_BINOP(d64
, 0xb3d3, "-", dd_m3_14
, dd_0_005
, 1); /* cc = 1 */
51 DFP_BINOP(d64
, 0xb3d3, "-", dd_3_14
, dd_3_14
, 3); /* cc = 0 */
53 printf("64-bit MULTIPLY\n");
54 DFP_BINOP(d64
, 0xb3d0, "*", dd_3_14
, dd_7
, 6);
55 DFP_BINOP(d64
, 0xb3d0, "*", dd_m3_14
, dd_7
, 7);
56 DFP_BINOP(d64
, 0xb3d0, "*", dd_m3_14
, dd_0
, 7);
58 printf("64-bit DIVIDE\n");
59 DFP_BINOP(d64
, 0xb3d1, "/", dd_22
, dd_7
, 13);
60 DFP_BINOP(d64
, 0xb3d1, "/", dd_m22
, dd_7
, 14);
61 DFP_BINOP(d64
, 0xb3d1, "/", dd_0
, dd_7
, 14);
63 printf("128-bit ADD\n");
64 DFP_BINOP(d128
, 0xb3da, "+", dl_3_14
, dl_0_005
, 1); /* cc = 2 */
65 DFP_BINOP(d128
, 0xb3da, "+", dl_m3_14
, dl_0_005
, 1); /* cc = 1 */
66 DFP_BINOP(d128
, 0xb3da, "+", dl_3_14
, dl_m3_14
, 1); /* cc = 0 */
68 printf("128-bit SUBTRACT\n");
69 DFP_BINOP(d128
, 0xb3db, "-", dl_3_14
, dl_0_005
, 1); /* cc = 2 */
70 DFP_BINOP(d128
, 0xb3db, "-", dl_m3_14
, dl_0_005
, 1); /* cc = 1 */
71 DFP_BINOP(d128
, 0xb3db, "-", dl_3_14
, dl_3_14
, 1); /* cc = 0 */
73 printf("128-bit MULTIPLY\n");
74 DFP_BINOP(d128
, 0xb3d8, "*", dl_3_14
, dl_7
, 6);
75 DFP_BINOP(d128
, 0xb3d8, "*", dl_m3_14
, dl_7
, 7);
76 DFP_BINOP(d128
, 0xb3d8, "*", dl_3_14
, dl_0
, 7);
78 printf("128-bit DIVIDE\n");
79 DFP_BINOP(d128
, 0xb3d9, "/", dl_22
, dl_7
, 13);
80 DFP_BINOP(d128
, 0xb3d9, "/", dl_m22
, dl_7
, 14);
81 DFP_BINOP(d128
, 0xb3d9, "/", dl_0
, dl_7
, 14);