+ fprintf(fout, " %s = %s %c %s;", float_st0,
+ out_src_opr_float(buf2, sizeof(buf2), po, &po->operand[1],
+ need_float_stack),
+ po->op == OP_FIDIVR ? '/' : '-', float_st0);
+ break;
+
+ case OP_FCOM: {
+ int mask, z_check;
+ ferr_assert(po, po->datap != NULL);
+ mask = (long)po->datap & 0xffff;
+ z_check = ((long)po->datap >> 16) & 1;
+ out_src_opr_float(buf1, sizeof(buf1), po, &po->operand[0],
+ need_float_stack);
+ if (mask == 0x0100) { // C0 -> <
+ fprintf(fout, " f_sw = %s < %s ? 0x0100 : 0;",
+ float_st0, buf1);
+ }
+ else if (mask == 0x4000) { // C3 -> =
+ fprintf(fout, " f_sw = %s == %s ? 0x4000 : 0;",
+ float_st0, buf1);
+ }
+ else if (mask == 0x4100) { // C3, C0
+ if (z_check) {
+ fprintf(fout, " f_sw = %s <= %s ? 0x4100 : 0;",
+ float_st0, buf1);
+ strcat(g_comment, " z_chk_det");
+ }
+ else {
+ fprintf(fout, " f_sw = %s == %s ? 0x4000 : "
+ "(%s < %s ? 0x0100 : 0);",
+ float_st0, buf1, float_st0, buf1);
+ }
+ }
+ else
+ ferr(po, "unhandled sw mask: %x\n", mask);
+ if (po->flags & OPF_FSHIFT) {
+ if (need_float_stack)
+ fprintf(fout, " f_stp++;");
+ else
+ fprintf(fout, " f_st0 = f_st1;");
+ }
+ break;
+ }
+
+ case OP_FNSTSW:
+ fprintf(fout, " %s = f_sw;",
+ out_dst_opr(buf1, sizeof(buf1), po, &po->operand[0]));
+ break;
+
+ case OP_FCHS:
+ fprintf(fout, " %s = -%s;", float_st0, float_st0);
+ break;
+
+ case OP_FCOS:
+ fprintf(fout, " %s = cos%s(%s);", float_st0,
+ need_double ? "" : "f", float_st0);
+ break;
+
+ case OP_FPATAN:
+ if (need_float_stack) {
+ fprintf(fout, " %s = atan%s(%s / %s);", float_st1,
+ need_double ? "" : "f", float_st1, float_st0);
+ fprintf(fout, " f_stp++;");
+ }
+ else {
+ fprintf(fout, " f_st0 = atan%s(f_st1 / f_st0);",
+ need_double ? "" : "f");
+ }
+ break;
+
+ case OP_FYL2X:
+ if (need_float_stack) {
+ fprintf(fout, " %s = %s * log2%s(%s);", float_st1,
+ float_st1, need_double ? "" : "f", float_st0);
+ fprintf(fout, " f_stp++;");
+ }
+ else {
+ fprintf(fout, " f_st0 = f_st1 * log2%s(f_st0);",
+ need_double ? "" : "f");
+ }
+ break;
+
+ case OP_FSIN:
+ fprintf(fout, " %s = sin%s(%s);", float_st0,
+ need_double ? "" : "f", float_st0);
+ break;
+
+ case OP_FSQRT:
+ fprintf(fout, " %s = sqrt%s(%s);", float_st0,
+ need_double ? "" : "f", float_st0);
+ break;
+
+ case OP_FXCH:
+ dead_dst = po->operand[0].type == OPT_REG
+ && po->operand[0].reg == xST0;
+ if (!dead_dst) {
+ out_src_opr_float(buf1, sizeof(buf1), po, &po->operand[0],
+ need_float_stack);
+ fprintf(fout, " { %s t = %s; %s = %s; %s = t; }", float_type,
+ float_st0, float_st0, buf1, buf1);
+ strcat(g_comment, " fxch");
+ }
+ else
+ no_output = 1;