Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /*---------------------------------------------------------------------------+ |
| 2 | | fpu_arith.c | |
| 3 | | | |
| 4 | | Code to implement the FPU register/register arithmetic instructions | |
| 5 | | | |
| 6 | | Copyright (C) 1992,1993,1997 | |
| 7 | | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, Australia | |
| 8 | | E-mail billm@suburbia.net | |
| 9 | | | |
| 10 | | | |
| 11 | +---------------------------------------------------------------------------*/ |
| 12 | |
| 13 | #include "fpu_system.h" |
| 14 | #include "fpu_emu.h" |
| 15 | #include "control_w.h" |
| 16 | #include "status_w.h" |
| 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | void fadd__(void) |
| 19 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 20 | /* fadd st,st(i) */ |
| 21 | int i = FPU_rm; |
| 22 | clear_C1(); |
| 23 | FPU_add(&st(i), FPU_gettagi(i), 0, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | } |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | void fmul__(void) |
| 27 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 28 | /* fmul st,st(i) */ |
| 29 | int i = FPU_rm; |
| 30 | clear_C1(); |
| 31 | FPU_mul(&st(i), FPU_gettagi(i), 0, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | } |
| 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | void fsub__(void) |
| 35 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 36 | /* fsub st,st(i) */ |
| 37 | clear_C1(); |
| 38 | FPU_sub(0, FPU_rm, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | } |
| 40 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | void fsubr_(void) |
| 42 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 43 | /* fsubr st,st(i) */ |
| 44 | clear_C1(); |
| 45 | FPU_sub(REV, FPU_rm, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | } |
| 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | void fdiv__(void) |
| 49 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 50 | /* fdiv st,st(i) */ |
| 51 | clear_C1(); |
| 52 | FPU_div(0, FPU_rm, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | void fdivr_(void) |
| 56 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 57 | /* fdivr st,st(i) */ |
| 58 | clear_C1(); |
| 59 | FPU_div(REV, FPU_rm, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | void fadd_i(void) |
| 63 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 64 | /* fadd st(i),st */ |
| 65 | int i = FPU_rm; |
| 66 | clear_C1(); |
| 67 | FPU_add(&st(i), FPU_gettagi(i), i, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | void fmul_i(void) |
| 71 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 72 | /* fmul st(i),st */ |
| 73 | clear_C1(); |
| 74 | FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | } |
| 76 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | void fsubri(void) |
| 78 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 79 | /* fsubr st(i),st */ |
| 80 | clear_C1(); |
| 81 | FPU_sub(DEST_RM, FPU_rm, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | } |
| 83 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | void fsub_i(void) |
| 85 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 86 | /* fsub st(i),st */ |
| 87 | clear_C1(); |
| 88 | FPU_sub(REV | DEST_RM, FPU_rm, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | } |
| 90 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | void fdivri(void) |
| 92 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 93 | /* fdivr st(i),st */ |
| 94 | clear_C1(); |
| 95 | FPU_div(DEST_RM, FPU_rm, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | } |
| 97 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | void fdiv_i(void) |
| 99 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 100 | /* fdiv st(i),st */ |
| 101 | clear_C1(); |
| 102 | FPU_div(REV | DEST_RM, FPU_rm, control_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | } |
| 104 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | void faddp_(void) |
| 106 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 107 | /* faddp st(i),st */ |
| 108 | int i = FPU_rm; |
| 109 | clear_C1(); |
| 110 | if (FPU_add(&st(i), FPU_gettagi(i), i, control_word) >= 0) |
| 111 | FPU_pop(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | } |
| 113 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | void fmulp_(void) |
| 115 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 116 | /* fmulp st(i),st */ |
| 117 | clear_C1(); |
| 118 | if (FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word) >= 0) |
| 119 | FPU_pop(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | } |
| 121 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | void fsubrp(void) |
| 123 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 124 | /* fsubrp st(i),st */ |
| 125 | clear_C1(); |
| 126 | if (FPU_sub(DEST_RM, FPU_rm, control_word) >= 0) |
| 127 | FPU_pop(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | } |
| 129 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | void fsubp_(void) |
| 131 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 132 | /* fsubp st(i),st */ |
| 133 | clear_C1(); |
| 134 | if (FPU_sub(REV | DEST_RM, FPU_rm, control_word) >= 0) |
| 135 | FPU_pop(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | } |
| 137 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | void fdivrp(void) |
| 139 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 140 | /* fdivrp st(i),st */ |
| 141 | clear_C1(); |
| 142 | if (FPU_div(DEST_RM, FPU_rm, control_word) >= 0) |
| 143 | FPU_pop(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | } |
| 145 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | void fdivp_(void) |
| 147 | { |
Ingo Molnar | 3d0d14f | 2008-01-30 13:30:11 +0100 | [diff] [blame] | 148 | /* fdivp st(i),st */ |
| 149 | clear_C1(); |
| 150 | if (FPU_div(REV | DEST_RM, FPU_rm, control_word) >= 0) |
| 151 | FPU_pop(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | } |