1*1da177e4SLinus Torvalds/* 2*1da177e4SLinus Torvalds * fp_cond.S 3*1da177e4SLinus Torvalds * 4*1da177e4SLinus Torvalds * Copyright Roman Zippel, 1997. All rights reserved. 5*1da177e4SLinus Torvalds * 6*1da177e4SLinus Torvalds * Redistribution and use in source and binary forms, with or without 7*1da177e4SLinus Torvalds * modification, are permitted provided that the following conditions 8*1da177e4SLinus Torvalds * are met: 9*1da177e4SLinus Torvalds * 1. Redistributions of source code must retain the above copyright 10*1da177e4SLinus Torvalds * notice, and the entire permission notice in its entirety, 11*1da177e4SLinus Torvalds * including the disclaimer of warranties. 12*1da177e4SLinus Torvalds * 2. Redistributions in binary form must reproduce the above copyright 13*1da177e4SLinus Torvalds * notice, this list of conditions and the following disclaimer in the 14*1da177e4SLinus Torvalds * documentation and/or other materials provided with the distribution. 15*1da177e4SLinus Torvalds * 3. The name of the author may not be used to endorse or promote 16*1da177e4SLinus Torvalds * products derived from this software without specific prior 17*1da177e4SLinus Torvalds * written permission. 18*1da177e4SLinus Torvalds * 19*1da177e4SLinus Torvalds * ALTERNATIVELY, this product may be distributed under the terms of 20*1da177e4SLinus Torvalds * the GNU General Public License, in which case the provisions of the GPL are 21*1da177e4SLinus Torvalds * required INSTEAD OF the above restrictions. (This clause is 22*1da177e4SLinus Torvalds * necessary due to a potential bad interaction between the GPL and 23*1da177e4SLinus Torvalds * the restrictions contained in a BSD-style copyright.) 24*1da177e4SLinus Torvalds * 25*1da177e4SLinus Torvalds * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 26*1da177e4SLinus Torvalds * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 27*1da177e4SLinus Torvalds * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28*1da177e4SLinus Torvalds * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 29*1da177e4SLinus Torvalds * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 30*1da177e4SLinus Torvalds * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31*1da177e4SLinus Torvalds * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32*1da177e4SLinus Torvalds * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 33*1da177e4SLinus Torvalds * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34*1da177e4SLinus Torvalds * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 35*1da177e4SLinus Torvalds * OF THE POSSIBILITY OF SUCH DAMAGE. 36*1da177e4SLinus Torvalds */ 37*1da177e4SLinus Torvalds 38*1da177e4SLinus Torvalds#include "fp_emu.h" 39*1da177e4SLinus Torvalds#include "fp_decode.h" 40*1da177e4SLinus Torvalds 41*1da177e4SLinus Torvalds .globl fp_fscc, fp_fbccw, fp_fbccl 42*1da177e4SLinus Torvalds 43*1da177e4SLinus Torvalds#ifdef FPU_EMU_DEBUG 44*1da177e4SLinus Torvaldsfp_fnop: 45*1da177e4SLinus Torvalds printf PDECODE,"fnop\n" 46*1da177e4SLinus Torvalds jra fp_end 47*1da177e4SLinus Torvalds#else 48*1da177e4SLinus Torvalds#define fp_fnop fp_end 49*1da177e4SLinus Torvalds#endif 50*1da177e4SLinus Torvalds 51*1da177e4SLinus Torvaldsfp_fbccw: 52*1da177e4SLinus Torvalds tst.w %d2 53*1da177e4SLinus Torvalds jeq fp_fnop 54*1da177e4SLinus Torvalds printf PDECODE,"fbccw " 55*1da177e4SLinus Torvalds fp_get_pc %a0 56*1da177e4SLinus Torvalds lea (-2,%a0,%d2.w),%a0 57*1da177e4SLinus Torvalds jra 1f 58*1da177e4SLinus Torvalds 59*1da177e4SLinus Torvaldsfp_fbccl: 60*1da177e4SLinus Torvalds printf PDECODE,"fbccl " 61*1da177e4SLinus Torvalds fp_get_pc %a0 62*1da177e4SLinus Torvalds move.l %d2,%d0 63*1da177e4SLinus Torvalds swap %d0 64*1da177e4SLinus Torvalds fp_get_instr_word %d0,fp_err_ua1 65*1da177e4SLinus Torvalds lea (-2,%a0,%d0.l),%a0 66*1da177e4SLinus Torvalds1: printf PDECODE,"%x",1,%a0 67*1da177e4SLinus Torvalds move.l %d2,%d0 68*1da177e4SLinus Torvalds swap %d0 69*1da177e4SLinus Torvalds jsr fp_compute_cond 70*1da177e4SLinus Torvalds tst.l %d0 71*1da177e4SLinus Torvalds jeq 1f 72*1da177e4SLinus Torvalds fp_put_pc %a0,1 73*1da177e4SLinus Torvalds1: printf PDECODE,"\n" 74*1da177e4SLinus Torvalds jra fp_end 75*1da177e4SLinus Torvalds 76*1da177e4SLinus Torvaldsfp_fdbcc: 77*1da177e4SLinus Torvalds printf PDECODE,"fdbcc " 78*1da177e4SLinus Torvalds fp_get_pc %a1 | calculate new pc 79*1da177e4SLinus Torvalds fp_get_instr_word %d0,fp_err_ua1 80*1da177e4SLinus Torvalds add.w %d0,%a1 81*1da177e4SLinus Torvalds fp_decode_addr_reg 82*1da177e4SLinus Torvalds printf PDECODE,"d%d,%x\n",2,%d0,%a1 83*1da177e4SLinus Torvalds swap %d1 | test condition in %d1 84*1da177e4SLinus Torvalds tst.w %d1 85*1da177e4SLinus Torvalds jne 2f 86*1da177e4SLinus Torvalds move.l %d0,%d1 87*1da177e4SLinus Torvalds jsr fp_get_data_reg 88*1da177e4SLinus Torvalds subq.w #1,%d0 89*1da177e4SLinus Torvalds jcs 1f 90*1da177e4SLinus Torvalds fp_put_pc %a1,1 91*1da177e4SLinus Torvalds1: jsr fp_put_data_reg 92*1da177e4SLinus Torvalds2: jra fp_end 93*1da177e4SLinus Torvalds 94*1da177e4SLinus Torvalds| set flags for decode macros for fs<cc> 95*1da177e4SLinus Torvaldsdo_fscc=1 96*1da177e4SLinus Torvaldsdo_no_pc_mode=1 97*1da177e4SLinus Torvalds 98*1da177e4SLinus Torvaldsfp_fscc: 99*1da177e4SLinus Torvalds printf PDECODE,"fscc " 100*1da177e4SLinus Torvalds move.l %d2,%d0 101*1da177e4SLinus Torvalds jsr fp_compute_cond 102*1da177e4SLinus Torvalds move.w %d0,%d1 103*1da177e4SLinus Torvalds swap %d1 104*1da177e4SLinus Torvalds 105*1da177e4SLinus Torvalds | decode addressing mode 106*1da177e4SLinus Torvalds fp_decode_addr_mode 107*1da177e4SLinus Torvalds 108*1da177e4SLinus Torvalds .long fp_data, fp_fdbcc 109*1da177e4SLinus Torvalds .long fp_indirect, fp_postinc 110*1da177e4SLinus Torvalds .long fp_predecr, fp_disp16 111*1da177e4SLinus Torvalds .long fp_extmode0, fp_extmode1 112*1da177e4SLinus Torvalds 113*1da177e4SLinus Torvalds | addressing mode: data register direct 114*1da177e4SLinus Torvaldsfp_data: 115*1da177e4SLinus Torvalds fp_mode_data_direct 116*1da177e4SLinus Torvalds move.w %d0,%d1 | save register nr 117*1da177e4SLinus Torvalds jsr fp_get_data_reg 118*1da177e4SLinus Torvalds swap %d1 119*1da177e4SLinus Torvalds move.b %d1,%d0 120*1da177e4SLinus Torvalds swap %d1 121*1da177e4SLinus Torvalds jsr fp_put_data_reg 122*1da177e4SLinus Torvalds printf PDECODE,"\n" 123*1da177e4SLinus Torvalds jra fp_end 124*1da177e4SLinus Torvalds 125*1da177e4SLinus Torvaldsfp_indirect: 126*1da177e4SLinus Torvalds fp_mode_addr_indirect 127*1da177e4SLinus Torvalds jra fp_do_scc 128*1da177e4SLinus Torvalds 129*1da177e4SLinus Torvaldsfp_postinc: 130*1da177e4SLinus Torvalds fp_mode_addr_indirect_postinc 131*1da177e4SLinus Torvalds jra fp_do_scc 132*1da177e4SLinus Torvalds 133*1da177e4SLinus Torvaldsfp_predecr: 134*1da177e4SLinus Torvalds fp_mode_addr_indirect_predec 135*1da177e4SLinus Torvalds jra fp_do_scc 136*1da177e4SLinus Torvalds 137*1da177e4SLinus Torvaldsfp_disp16: 138*1da177e4SLinus Torvalds fp_mode_addr_indirect_disp16 139*1da177e4SLinus Torvalds jra fp_do_scc 140*1da177e4SLinus Torvalds 141*1da177e4SLinus Torvaldsfp_extmode0: 142*1da177e4SLinus Torvalds fp_mode_addr_indirect_extmode0 143*1da177e4SLinus Torvalds jra fp_do_scc 144*1da177e4SLinus Torvalds 145*1da177e4SLinus Torvaldsfp_extmode1: 146*1da177e4SLinus Torvalds bfextu %d2{#13,#3},%d0 147*1da177e4SLinus Torvalds jmp ([0f:w,%pc,%d0*4]) 148*1da177e4SLinus Torvalds 149*1da177e4SLinus Torvalds .align 4 150*1da177e4SLinus Torvalds0: 151*1da177e4SLinus Torvalds .long fp_absolute_short, fp_absolute_long 152*1da177e4SLinus Torvalds .long fp_ill, fp_ill | NOTE: jump here to ftrap.x 153*1da177e4SLinus Torvalds .long fp_ill, fp_ill 154*1da177e4SLinus Torvalds .long fp_ill, fp_ill 155*1da177e4SLinus Torvalds 156*1da177e4SLinus Torvaldsfp_absolute_short: 157*1da177e4SLinus Torvalds fp_mode_abs_short 158*1da177e4SLinus Torvalds jra fp_do_scc 159*1da177e4SLinus Torvalds 160*1da177e4SLinus Torvaldsfp_absolute_long: 161*1da177e4SLinus Torvalds fp_mode_abs_long 162*1da177e4SLinus Torvalds| jra fp_do_scc 163*1da177e4SLinus Torvalds 164*1da177e4SLinus Torvaldsfp_do_scc: 165*1da177e4SLinus Torvalds swap %d1 166*1da177e4SLinus Torvalds putuser.b %d1,(%a0),fp_err_ua1,%a0 167*1da177e4SLinus Torvalds printf PDECODE,"\n" 168*1da177e4SLinus Torvalds jra fp_end 169*1da177e4SLinus Torvalds 170*1da177e4SLinus Torvalds 171*1da177e4SLinus Torvalds#define tst_NAN btst #24,%d1 172*1da177e4SLinus Torvalds#define tst_Z btst #26,%d1 173*1da177e4SLinus Torvalds#define tst_N btst #27,%d1 174*1da177e4SLinus Torvalds 175*1da177e4SLinus Torvaldsfp_compute_cond: 176*1da177e4SLinus Torvalds move.l (FPD_FPSR,FPDATA),%d1 177*1da177e4SLinus Torvalds btst #4,%d0 178*1da177e4SLinus Torvalds jeq 1f 179*1da177e4SLinus Torvalds tst_NAN 180*1da177e4SLinus Torvalds jeq 1f 181*1da177e4SLinus Torvalds bset #15,%d1 182*1da177e4SLinus Torvalds bset #7,%d1 183*1da177e4SLinus Torvalds move.l %d1,(FPD_FPSR,FPDATA) 184*1da177e4SLinus Torvalds1: and.w #0xf,%d0 185*1da177e4SLinus Torvalds jmp ([0f:w,%pc,%d0.w*4]) 186*1da177e4SLinus Torvalds 187*1da177e4SLinus Torvalds .align 4 188*1da177e4SLinus Torvalds0: 189*1da177e4SLinus Torvalds .long fp_f , fp_eq , fp_ogt, fp_oge 190*1da177e4SLinus Torvalds .long fp_olt, fp_ole, fp_ogl, fp_or 191*1da177e4SLinus Torvalds .long fp_un , fp_ueq, fp_ugt, fp_uge 192*1da177e4SLinus Torvalds .long fp_ult, fp_ule, fp_ne , fp_t 193*1da177e4SLinus Torvalds 194*1da177e4SLinus Torvaldsfp_f: 195*1da177e4SLinus Torvalds moveq #0,%d0 196*1da177e4SLinus Torvalds rts 197*1da177e4SLinus Torvalds 198*1da177e4SLinus Torvaldsfp_eq: 199*1da177e4SLinus Torvalds moveq #0,%d0 200*1da177e4SLinus Torvalds tst_Z 201*1da177e4SLinus Torvalds jeq 1f 202*1da177e4SLinus Torvalds moveq #-1,%d0 203*1da177e4SLinus Torvalds1: rts 204*1da177e4SLinus Torvalds 205*1da177e4SLinus Torvaldsfp_ogt: 206*1da177e4SLinus Torvalds moveq #0,%d0 207*1da177e4SLinus Torvalds tst_NAN 208*1da177e4SLinus Torvalds jne 1f 209*1da177e4SLinus Torvalds tst_Z 210*1da177e4SLinus Torvalds jne 1f 211*1da177e4SLinus Torvalds tst_N 212*1da177e4SLinus Torvalds jne 1f 213*1da177e4SLinus Torvalds moveq #-1,%d0 214*1da177e4SLinus Torvalds1: rts 215*1da177e4SLinus Torvalds 216*1da177e4SLinus Torvaldsfp_oge: 217*1da177e4SLinus Torvalds moveq #-1,%d0 218*1da177e4SLinus Torvalds tst_Z 219*1da177e4SLinus Torvalds jne 2f 220*1da177e4SLinus Torvalds tst_NAN 221*1da177e4SLinus Torvalds jne 1f 222*1da177e4SLinus Torvalds tst_N 223*1da177e4SLinus Torvalds jeq 2f 224*1da177e4SLinus Torvalds1: moveq #0,%d0 225*1da177e4SLinus Torvalds2: rts 226*1da177e4SLinus Torvalds 227*1da177e4SLinus Torvaldsfp_olt: 228*1da177e4SLinus Torvalds moveq #0,%d0 229*1da177e4SLinus Torvalds tst_NAN 230*1da177e4SLinus Torvalds jne 1f 231*1da177e4SLinus Torvalds tst_Z 232*1da177e4SLinus Torvalds jne 1f 233*1da177e4SLinus Torvalds tst_N 234*1da177e4SLinus Torvalds jeq 1f 235*1da177e4SLinus Torvalds moveq #-1,%d0 236*1da177e4SLinus Torvalds1: rts 237*1da177e4SLinus Torvalds 238*1da177e4SLinus Torvaldsfp_ole: 239*1da177e4SLinus Torvalds moveq #-1,%d0 240*1da177e4SLinus Torvalds tst_Z 241*1da177e4SLinus Torvalds jne 2f 242*1da177e4SLinus Torvalds tst_NAN 243*1da177e4SLinus Torvalds jne 1f 244*1da177e4SLinus Torvalds tst_N 245*1da177e4SLinus Torvalds jne 2f 246*1da177e4SLinus Torvalds1: moveq #0,%d0 247*1da177e4SLinus Torvalds2: rts 248*1da177e4SLinus Torvalds 249*1da177e4SLinus Torvaldsfp_ogl: 250*1da177e4SLinus Torvalds moveq #0,%d0 251*1da177e4SLinus Torvalds tst_NAN 252*1da177e4SLinus Torvalds jne 1f 253*1da177e4SLinus Torvalds tst_Z 254*1da177e4SLinus Torvalds jne 1f 255*1da177e4SLinus Torvalds moveq #-1,%d0 256*1da177e4SLinus Torvalds1: rts 257*1da177e4SLinus Torvalds 258*1da177e4SLinus Torvaldsfp_or: 259*1da177e4SLinus Torvalds moveq #0,%d0 260*1da177e4SLinus Torvalds tst_NAN 261*1da177e4SLinus Torvalds jne 1f 262*1da177e4SLinus Torvalds moveq #-1,%d0 263*1da177e4SLinus Torvalds1: rts 264*1da177e4SLinus Torvalds 265*1da177e4SLinus Torvaldsfp_un: 266*1da177e4SLinus Torvalds moveq #0,%d0 267*1da177e4SLinus Torvalds tst_NAN 268*1da177e4SLinus Torvalds jeq 1f 269*1da177e4SLinus Torvalds moveq #-1,%d0 270*1da177e4SLinus Torvalds rts 271*1da177e4SLinus Torvalds 272*1da177e4SLinus Torvaldsfp_ueq: 273*1da177e4SLinus Torvalds moveq #-1,%d0 274*1da177e4SLinus Torvalds tst_NAN 275*1da177e4SLinus Torvalds jne 1f 276*1da177e4SLinus Torvalds tst_Z 277*1da177e4SLinus Torvalds jne 1f 278*1da177e4SLinus Torvalds moveq #0,%d0 279*1da177e4SLinus Torvalds1: rts 280*1da177e4SLinus Torvalds 281*1da177e4SLinus Torvaldsfp_ugt: 282*1da177e4SLinus Torvalds moveq #-1,%d0 283*1da177e4SLinus Torvalds tst_NAN 284*1da177e4SLinus Torvalds jne 2f 285*1da177e4SLinus Torvalds tst_N 286*1da177e4SLinus Torvalds jne 1f 287*1da177e4SLinus Torvalds tst_Z 288*1da177e4SLinus Torvalds jeq 2f 289*1da177e4SLinus Torvalds1: moveq #0,%d0 290*1da177e4SLinus Torvalds2: rts 291*1da177e4SLinus Torvalds 292*1da177e4SLinus Torvaldsfp_uge: 293*1da177e4SLinus Torvalds moveq #-1,%d0 294*1da177e4SLinus Torvalds tst_NAN 295*1da177e4SLinus Torvalds jne 1f 296*1da177e4SLinus Torvalds tst_Z 297*1da177e4SLinus Torvalds jne 1f 298*1da177e4SLinus Torvalds tst_N 299*1da177e4SLinus Torvalds jeq 1f 300*1da177e4SLinus Torvalds moveq #0,%d0 301*1da177e4SLinus Torvalds1: rts 302*1da177e4SLinus Torvalds 303*1da177e4SLinus Torvaldsfp_ult: 304*1da177e4SLinus Torvalds moveq #-1,%d0 305*1da177e4SLinus Torvalds tst_NAN 306*1da177e4SLinus Torvalds jne 2f 307*1da177e4SLinus Torvalds tst_Z 308*1da177e4SLinus Torvalds jne 1f 309*1da177e4SLinus Torvalds tst_N 310*1da177e4SLinus Torvalds jne 2f 311*1da177e4SLinus Torvalds1: moveq #0,%d0 312*1da177e4SLinus Torvalds2: rts 313*1da177e4SLinus Torvalds 314*1da177e4SLinus Torvaldsfp_ule: 315*1da177e4SLinus Torvalds moveq #-1,%d0 316*1da177e4SLinus Torvalds tst_NAN 317*1da177e4SLinus Torvalds jne 1f 318*1da177e4SLinus Torvalds tst_Z 319*1da177e4SLinus Torvalds jne 1f 320*1da177e4SLinus Torvalds tst_N 321*1da177e4SLinus Torvalds jne 1f 322*1da177e4SLinus Torvalds moveq #0,%d0 323*1da177e4SLinus Torvalds1: rts 324*1da177e4SLinus Torvalds 325*1da177e4SLinus Torvaldsfp_ne: 326*1da177e4SLinus Torvalds moveq #0,%d0 327*1da177e4SLinus Torvalds tst_Z 328*1da177e4SLinus Torvalds jne 1f 329*1da177e4SLinus Torvalds moveq #-1,%d0 330*1da177e4SLinus Torvalds1: rts 331*1da177e4SLinus Torvalds 332*1da177e4SLinus Torvaldsfp_t: 333*1da177e4SLinus Torvalds moveq #-1,%d0 334*1da177e4SLinus Torvalds rts 335