DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/cpu/mmx.cpp
00001 /*
00002  *  Copyright (C) 2002-2020  The DOSBox Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License along
00015  *  with this program; if not, write to the Free Software Foundation, Inc.,
00016  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 
00020 #include "dosbox.h"
00021 
00022 #include "mem.h"
00023 #include "mmx.h"
00024 #include "cpu.h"
00025 #include "fpu.h"
00026 
00027 #if C_FPU
00028 
00029 MMX_reg *reg_mmx[8] = {
00030 #if defined(HAS_LONG_DOUBLE)
00031         &fpu._do_not_use__regs[0].reg_mmx,
00032         &fpu._do_not_use__regs[1].reg_mmx,
00033         &fpu._do_not_use__regs[2].reg_mmx,
00034         &fpu._do_not_use__regs[3].reg_mmx,
00035         &fpu._do_not_use__regs[4].reg_mmx,
00036         &fpu._do_not_use__regs[5].reg_mmx,
00037         &fpu._do_not_use__regs[6].reg_mmx,
00038         &fpu._do_not_use__regs[7].reg_mmx,
00039 #else
00040         &fpu.regs[0].reg_mmx,
00041         &fpu.regs[1].reg_mmx,
00042         &fpu.regs[2].reg_mmx,
00043         &fpu.regs[3].reg_mmx,
00044         &fpu.regs[4].reg_mmx,
00045         &fpu.regs[5].reg_mmx,
00046         &fpu.regs[6].reg_mmx,
00047         &fpu.regs[7].reg_mmx,
00048 #endif
00049 };
00050 
00051 MMX_reg * lookupRMregMM[256]={
00052         reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],
00053         reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],
00054         reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],
00055         reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],
00056         reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],
00057         reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],
00058         reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],
00059         reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],
00060 
00061         reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],
00062         reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],
00063         reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],
00064         reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],
00065         reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],
00066         reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],
00067         reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],
00068         reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],
00069 
00070         reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],
00071         reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],
00072         reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],
00073         reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],
00074         reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],
00075         reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],
00076         reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],
00077         reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],
00078 
00079         reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],reg_mmx[0],
00080         reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],reg_mmx[1],
00081         reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],reg_mmx[2],
00082         reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],reg_mmx[3],
00083         reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],reg_mmx[4],
00084         reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],reg_mmx[5],
00085         reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],reg_mmx[6],
00086         reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],reg_mmx[7],
00087 };
00088 
00089 
00090 Bit8s SaturateWordSToByteS(Bit16s value)
00091 {
00092   if(value < -128) return -128;
00093   if(value >  127) return  127;
00094   return (Bit8s) value;
00095 }
00096 
00097 Bit16s SaturateDwordSToWordS(Bit32s value)
00098 {
00099   if(value < -32768) return -32768;
00100   if(value >  32767) return  32767;
00101   return (Bit16s) value;
00102 }
00103 
00104 Bit8u SaturateWordSToByteU(Bit16s value)
00105 {
00106   if(value < 0) return 0;
00107   if(value > 255) return 255;
00108   return (Bit8u) value;
00109 }
00110 
00111 Bit16u SaturateDwordSToWordU(Bit32s value)
00112 {
00113   if(value < 0) return 0;
00114   if(value > 65535) return 65535;
00115   return (Bit16u) value;
00116 }
00117 
00118 void setFPUTagEmpty() {
00119         FPU_SetCW(0x37F);
00120         fpu.sw = 0;
00121         TOP = FPU_GET_TOP();
00122         fpu.tags[0] = TAG_Empty;
00123         fpu.tags[1] = TAG_Empty;
00124         fpu.tags[2] = TAG_Empty;
00125         fpu.tags[3] = TAG_Empty;
00126         fpu.tags[4] = TAG_Empty;
00127         fpu.tags[5] = TAG_Empty;
00128         fpu.tags[6] = TAG_Empty;
00129         fpu.tags[7] = TAG_Empty;
00130         fpu.tags[8] = TAG_Valid; // is only used by us
00131 }
00132 
00133 #endif
00134