Simulator.cpp
void opSUB(string sDireccionamiento, string sExtra) {
	int iDir, iTemp, iTemp2;
  string sContenido;

  switch (sDireccionamiento[0]) {
    // Absoluto
    case '1': {
     	MAR = sExtra;
      displayChanges();
      iDir = atoi(MAR.c_str());
      MDR = data[iDir]; // MMRead
      displayChanges();
      iTemp = atoi(MDR.c_str());
      iTemp2 = atoi(AC.c_str());
      if (iTemp2 - iTemp > 99999 || iTemp2 - iTemp < -99999) {
       	cout << "OVERFLOW" << endl;
      }
      else {
        AC = completeAC(iTemp2 - iTemp);
        displayChanges();
      }
      break;
    }
    // Indirecto
    case '2': {
    	MAR = sExtra;
      displayChanges();
    	iDir = atoi(MAR.c_str());
      MDR = data[iDir]; // MMRead
      displayChanges();
      MAR = MDR;
      displayChanges();
      iDir = atoi(MAR.c_str());
      MDR = data[iDir]; // MMRead
      displayChanges();
      iTemp = atoi(MDR.c_str());
      iTemp2 = atoi(AC.c_str());
      if (iTemp2 - iTemp > 99999 || iTemp2 - iTemp < -99999) {
       	cout << "OVERFLOW" << endl;
      }
      else {
        AC = completeAC(iTemp2 - iTemp);
        displayChanges();
      }
      break;
    }
    // Inmediato
    case '3': {
      iTemp = atoi(sExtra.c_str());
      iTemp2 = atoi(AC.c_str());
      if (iTemp2 - iTemp > 99999 || iTemp2 - iTemp < -99999) {
       	cout << "OVERFLOW" << endl;
      }
      else {
        AC = completeAC(iTemp2 - iTemp);
        displayChanges();
      }
      break;
    }
    // Relativo
    case '4': {
     	iTemp = atoi(sExtra.c_str());
      if (PC + iTemp < 0 || PC + iTemp > 999) {
       	cout << "OUT OF BOUNDS" << endl;
      }
      else {
        if (PC + iTemp < 100) {
          if (PC + iTemp < 10) {
            MAR = "00" + toString(PC + iTemp);
          }
          else {
            MAR = "0" + toString(PC + iTemp);
          }
        }
        else {
          MAR = toString(PC + iTemp);
        }
        displayChanges();
        MDR = data[PC + iTemp]; // MMRead
        displayChanges();
        iTemp = atoi(MDR.c_str());
        iTemp2 = atoi(AC.c_str());
        AC = completeAC(iTemp2 - iTemp);
        displayChanges();
      }
      break;
    }
    default: {
     	cout << "INSTRUCCION NO VALIDA" << endl;
    }
  }
}
/*
  Funcion que realiza la operacion SUB.
  Parametros: el tipo de direccionamiento y el parametro de la instruccion ([IR]2-0).
  Valor de retorno: ninguno.
*/
Funcion que realiza la operacion SUB.
Parametros: el tipo de direccionamiento y el parametro de la instruccion ([IR]2-0).
Valor de retorno: ninguno.
Funcion que realiza la operacion SUB . Parametros : el tipo de direccionamiento y el parametro de la instruccion ( [ IR ] 2 - 0 ) . Valor de retorno : ninguno .
void opSUB(string sDireccionamiento, string sExtra) {
	int iDir, iTemp, iTemp2;
  string sContenido;
  switch (sDireccionamiento[0]) {
    case '1': {
     	MAR = sExtra;
      displayChanges();
      iDir = atoi(MAR.c_str());
      MDR = data[iDir]; 
      displayChanges();
      iTemp = atoi(MDR.c_str());
      iTemp2 = atoi(AC.c_str());
      if (iTemp2 - iTemp > 99999 || iTemp2 - iTemp < -99999) {
       	cout << "OVERFLOW" << endl;
      }
      else {
        AC = completeAC(iTemp2 - iTemp);
        displayChanges();
      }
      break;
    }
    case '2': {
    	MAR = sExtra;
      displayChanges();
    	iDir = atoi(MAR.c_str());
      MDR = data[iDir]; 
      displayChanges();
      MAR = MDR;
      displayChanges();
      iDir = atoi(MAR.c_str());
      MDR = data[iDir]; 
      displayChanges();
      iTemp = atoi(MDR.c_str());
      iTemp2 = atoi(AC.c_str());
      if (iTemp2 - iTemp > 99999 || iTemp2 - iTemp < -99999) {
       	cout << "OVERFLOW" << endl;
      }
      else {
        AC = completeAC(iTemp2 - iTemp);
        displayChanges();
      }
      break;
    }
    case '3': {
      iTemp = atoi(sExtra.c_str());
      iTemp2 = atoi(AC.c_str());
      if (iTemp2 - iTemp > 99999 || iTemp2 - iTemp < -99999) {
       	cout << "OVERFLOW" << endl;
      }
      else {
        AC = completeAC(iTemp2 - iTemp);
        displayChanges();
      }
      break;
    }
    case '4': {
     	iTemp = atoi(sExtra.c_str());
      if (PC + iTemp < 0 || PC + iTemp > 999) {
       	cout << "OUT OF BOUNDS" << endl;
      }
      else {
        if (PC + iTemp < 100) {
          if (PC + iTemp < 10) {
            MAR = "00" + toString(PC + iTemp);
          }
          else {
            MAR = "0" + toString(PC + iTemp);
          }
        }
        else {
          MAR = toString(PC + iTemp);
        }
        displayChanges();
        MDR = data[PC + iTemp]; 
        displayChanges();
        iTemp = atoi(MDR.c_str());
        iTemp2 = atoi(AC.c_str());
        AC = completeAC(iTemp2 - iTemp);
        displayChanges();
      }
      break;
    }
    default: {
     	cout << "INSTRUCCION NO VALIDA" << endl;
    }
  }
}
void opSUB ( string sDireccionamiento , string sExtra ) { int iDir , iTemp , iTemp2 ; string sContenido ; switch ( sDireccionamiento [ 0 ] ) { case ' ' : { MAR = sExtra ; displayChanges ( ) ; iDir = atoi ( MAR . c_str ( ) ) ; MDR = data [ iDir ] ; displayChanges ( ) ; iTemp = atoi ( MDR . c_str ( ) ) ; iTemp2 = atoi ( AC . c_str ( ) ) ; if ( iTemp2 - iTemp > 99999 || iTemp2 - iTemp < -99999 ) { cout << " " << endl ; } else { AC = completeAC ( iTemp2 - iTemp ) ; displayChanges ( ) ; } break ; } case ' ' : { MAR = sExtra ; displayChanges ( ) ; iDir = atoi ( MAR . c_str ( ) ) ; MDR = data [ iDir ] ; displayChanges ( ) ; MAR = MDR ; displayChanges ( ) ; iDir = atoi ( MAR . c_str ( ) ) ; MDR = data [ iDir ] ; displayChanges ( ) ; iTemp = atoi ( MDR . c_str ( ) ) ; iTemp2 = atoi ( AC . c_str ( ) ) ; if ( iTemp2 - iTemp > 99999 || iTemp2 - iTemp < -99999 ) { cout << " " << endl ; } else { AC = completeAC ( iTemp2 - iTemp ) ; displayChanges ( ) ; } break ; } case ' ' : { iTemp = atoi ( sExtra . c_str ( ) ) ; iTemp2 = atoi ( AC . c_str ( ) ) ; if ( iTemp2 - iTemp > 99999 || iTemp2 - iTemp < -99999 ) { cout << " " << endl ; } else { AC = completeAC ( iTemp2 - iTemp ) ; displayChanges ( ) ; } break ; } case ' ' : { iTemp = atoi ( sExtra . c_str ( ) ) ; if ( PC + iTemp < 0 || PC + iTemp > 999 ) { cout << " " << endl ; } else { if ( PC + iTemp < 100 ) { if ( PC + iTemp < 10 ) { MAR = " " + toString ( PC + iTemp ) ; } else { MAR = " " + toString ( PC + iTemp ) ; } } else { MAR = toString ( PC + iTemp ) ; } displayChanges ( ) ; MDR = data [ PC + iTemp ] ; displayChanges ( ) ; iTemp = atoi ( MDR . c_str ( ) ) ; iTemp2 = atoi ( AC . c_str ( ) ) ; AC = completeAC ( iTemp2 - iTemp ) ; displayChanges ( ) ; } break ; } default : { cout << " " << endl ; } } }
Funcion que realiza la operacion SUB.
Funcion que realiza la operacion SUB .
// Absoluto // MMRead // Indirecto // MMRead // MMRead // Inmediato // Relativo // MMRead