DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/cpu/core_full/save.h
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 /* Write the data from the opcode */
00020 switch (inst.code.save) {
00021 /* Byte */
00022         case S_C_Eb:
00023                 inst_op1_b=inst.cond ? 1 : 0;
00024         case S_Eb:
00025                 if (inst.rm<0xc0) SaveMb(inst.rm_eaa,inst_op1_b);
00026                 else reg_8(inst.rm_eai)=inst_op1_b;
00027                 break;  
00028         case S_Gb:
00029                 reg_8(inst.rm_index)=inst_op1_b;
00030                 break;  
00031         case S_EbGb:
00032                 if (inst.rm<0xc0) SaveMb(inst.rm_eaa,inst_op1_b);
00033                 else reg_8(inst.rm_eai)=inst_op1_b;
00034                 reg_8(inst.rm_index)=inst_op2_b;
00035                 break;  
00036 /* Word */
00037         case S_Ew:
00038                 if (inst.rm<0xc0) SaveMw(inst.rm_eaa,inst_op1_w);
00039                 else reg_16(inst.rm_eai)=inst_op1_w;
00040                 break;  
00041         case S_Gw:
00042                 reg_16(inst.rm_index)=inst_op1_w;
00043                 break;  
00044         case S_EwGw:
00045                 if (inst.rm<0xc0) SaveMw(inst.rm_eaa,inst_op1_w);
00046                 else reg_16(inst.rm_eai)=inst_op1_w;
00047                 reg_16(inst.rm_index)=inst_op2_w;
00048                 break;  
00049 /* Dword */
00050         case S_Ed:
00051                 if (inst.rm<0xc0) SaveMd(inst.rm_eaa,inst_op1_d);
00052                 else reg_32(inst.rm_eai)=inst_op1_d;
00053                 break;  
00054         case S_EdMw:            /* Special one 16 to memory, 32 zero extend to reg */
00055                 if (inst.rm<0xc0) SaveMw(inst.rm_eaa,inst_op1_w);
00056                 else reg_32(inst.rm_eai)=inst_op1_d;
00057                 break;
00058         case S_Gd:
00059                 reg_32(inst.rm_index)=inst_op1_d;
00060                 break;  
00061         case S_EdGd:
00062                 if (inst.rm<0xc0) SaveMd(inst.rm_eaa,inst_op1_d);
00063                 else reg_32(inst.rm_eai)=inst_op1_d;
00064                 reg_32(inst.rm_index)=inst_op2_d;
00065                 break;  
00066 
00067         case S_REGb:
00068                 reg_8(inst.code.extra)=inst_op1_b;
00069                 break;
00070         case S_REGw:
00071                 reg_16(inst.code.extra)=inst_op1_w;
00072                 break;
00073         case S_REGd:
00074                 reg_32(inst.code.extra)=inst_op1_d;
00075                 break;  
00076         case S_SEGm:
00077                 if (CPU_SetSegGeneral((SegNames)inst.rm_index,inst_op1_w)) RunException();
00078                 break;
00079         case S_SEGGw:
00080                 if (CPU_SetSegGeneral((SegNames)inst.code.extra,inst_op2_w)) RunException();
00081                 reg_16(inst.rm_index)=inst_op1_w;
00082                 break;
00083         case S_SEGGd:
00084                 if (CPU_SetSegGeneral((SegNames)inst.code.extra,inst_op2_w)) RunException();
00085                 reg_32(inst.rm_index)=inst_op1_d;
00086                 break;
00087         case S_PUSHw:
00088                 Push_16(inst_op1_w);
00089                 break;
00090         case S_PUSHd:
00091                 Push_32(inst_op1_d);
00092                 break;
00093 
00094         case S_C_AIPw:
00095                 if (!inst.cond) goto nextopcode;
00096         case S_AIPw:
00097                 SaveIP();
00098                 reg_eip+=inst_op1_d;
00099                 reg_eip&=0xffff;
00100                 continue;
00101         case S_C_AIPd:
00102                 if (!inst.cond) goto nextopcode;
00103         case S_AIPd:
00104                 SaveIP();
00105                 reg_eip+=inst_op1_d;
00106                 continue;
00107         case S_IPIw:
00108                 reg_esp+=Fetchw();
00109         case S_IP:
00110                 SaveIP();
00111                 reg_eip=inst_op1_d;
00112                 continue;
00113         case 0:
00114                 break;
00115         default:
00116                 LOG(LOG_CPU,LOG_ERROR)("SAVE:Unhandled code %d entry %lx",inst.code.save,(unsigned long)inst.entry);
00117 }