private bool relativoContador(ref string operando, string cpSig) { bool band; long desp; long dir; band = false; if (tabSim.TryGetValue(operando, out dir)) { desp = dir - MetodosAuxiliares.hexadecimalADecimal(cpSig); if (desp >= (-2048) & desp <= 2047) { operando = MetodosAuxiliares.decimalAHexadecimal(desp); if (desp < 0) { operando = MetodosAuxiliares.ajustaOperando(operando, 3, "F"); } else { operando = MetodosAuxiliares.ajustaOperando(operando, 3, "0"); } band = true; } } return band; }
private bool relativoBase(ref string operando) { bool band; long desp; long dir; band = false; if (tabSim.TryGetValue(operando, out dir)) { desp = dir - b; if (desp >= 0 & desp <= 4095) { operando = MetodosAuxiliares.decimalAHexadecimal(desp); operando = MetodosAuxiliares.ajustaOperando(operando, 3, "0"); band = true; } } return band; }
protected override void generaRegistrosT() { int i; int j; string registroT; string aux; string bytes; aux = ""; i = 1; while (!this.archivo[i].Contains("END")) { registroT = "T" + MetodosAuxiliares.ajustaDireccion(this.intermedio[i].Split('\t').First()); for (j = i; j < this.codigoObj.Length - 1; j++) { if (!this.codigoObj[j].Contains("Error")) { if (this.codigoObj[j].Contains("*")) { string cpHex; cpHex = MetodosAuxiliares.decimalAHexadecimal(MetodosAuxiliares.hexadecimalADecimal(this.intermedio[j].Split('\t').First()) +1); this.relocalizables.Add(MetodosAuxiliares.ajustaOperando(cpHex,6,"0")); this.codigoObj[j] = this.codigoObj[j].Replace("*", ""); } if (((aux.Length + this.codigoObj[j].Length) / 2) > 30) { break; } else if (this.codigoObj[j].Equals("---") & !this.archivo[j].Contains("BASE")) { break; } else if(!this.archivo[j].Contains("BASE")) { aux += this.codigoObj[j]; } } } bytes = MetodosAuxiliares.decimalAHexadecimal(aux.Length / 2); if (bytes.Length < 2) { bytes = "0" + bytes; } registroT += bytes; registroT += aux; aux = ""; if (registroT.Length > 9) { this.archivoObj.Add(registroT); } for (int k = j; k < this.codigoObj.Length; k++) { if (!codigoObj[k].Equals("---") | this.intermedio[k].Contains("END")) { i = k; break; } } } }
private string ensamblaInstruccion3(string codOp, string operando, string cpSig) { string codigoObj; char[] nixbpe; codigoObj = ""; nixbpe = new char[6]; codigoObj = MetodosAuxiliares.hexadecimalABinario(this.instruccionesFormato3[codOp]).Substring(4,2); nixbpe[5] = '0'; if (!codOp.Equals("RSUB")) { codOp = this.instruccionesFormato3[codOp][0].ToString(); switch (operando.First()) { case '@'://Direccionamiento Indirecto nixbpe[0] = '1'; nixbpe[1] = '0'; nixbpe[2] = '0'; operando = operando.Replace("@",""); break; case '#'://Direccionamiento Inmediato nixbpe[0] = '0'; nixbpe[1] = '1'; nixbpe[2] = '0'; operando = operando.Replace("#", ""); break; default://Direccionamiento Simple nixbpe[0] = '1'; nixbpe[1] = '1'; if (operando.Contains(",X") | operando.Contains(",x")) { operando = operando.Replace(",X", ""); operando = operando.Replace(",x", ""); nixbpe[2] = '1'; } else { nixbpe[2] = '0'; } break; } if (this.tabSim.Keys.Contains(operando)) { this.determinaBanderas(ref nixbpe, ref operando, cpSig); } else { bool h; h = operando.Last().Equals('H') | operando.Last().Equals('h'); if (h) { operando = operando.Replace("H", ""); operando = operando.Replace("h", ""); } if (Information.IsNumeric(operando)) { if (h) { operando = MetodosAuxiliares.hexadecimalADecimal(operando).ToString(); } int c; c = int.Parse(operando); operando = MetodosAuxiliares.decimalAHexadecimal(c); if (0 <= c & c <= 4095) { nixbpe[3] = '0'; nixbpe[4] = '0'; operando = MetodosAuxiliares.ajustaOperando(operando, 3, "0"); } else { this.determinaBanderas(ref nixbpe, ref operando, cpSig); } } else { nixbpe[3] = '1'; nixbpe[4] = '1'; operando = "FFF"; } } codigoObj += new string(nixbpe); codigoObj = codOp + MetodosAuxiliares.decimalAHexadecimal(MetodosAuxiliares.binarioADecimal(codigoObj)) + operando; } else { codigoObj = "4F0000"; } return codigoObj; }
private string ensamblaInstruccion4(string codOp, string operando) { string codigoObj; char[] nixbpe; codigoObj = ""; long dir; int resto; nixbpe = new char[6]; codigoObj = MetodosAuxiliares.hexadecimalABinario(this.instruccionesFormato4[codOp]).Substring(0, 6); nixbpe[3] = '0'; nixbpe[4] = '0'; nixbpe[5] = '1'; if (!codOp.Equals("RSUB")) { switch (operando.First()) { case '@'://Direccionamiento Indirecto nixbpe[0] = '1'; nixbpe[1] = '0'; nixbpe[2] = '0'; operando = operando.Replace("@", ""); break; case '#'://Direccionamiento Inmediato nixbpe[0] = '0'; nixbpe[1] = '1'; nixbpe[2] = '0'; operando = operando.Replace("#", ""); break; default://Direccionamiento Simple nixbpe[0] = '1'; nixbpe[1] = '1'; if (operando.Contains(",X") | operando.Contains(",x")) { operando = operando.Replace(",X", ""); operando = operando.Replace(",x", ""); nixbpe[2] = '1'; } else { nixbpe[2] = '0'; } break; } if (tabSim.TryGetValue(operando, out dir)) { operando = MetodosAuxiliares.decimalAHexadecimal(dir); } else { bool h; h = operando.Last().Equals('H') | operando.Last().Equals('h'); if (h) { operando = operando.Replace("H", ""); operando = operando.Replace("h", ""); } if (Information.IsNumeric(operando)) { if (h) { operando = MetodosAuxiliares.hexadecimalADecimal(operando).ToString(); } int c; c = int.Parse(operando); if (c > 4095) { operando = MetodosAuxiliares.decimalAHexadecimal(c); } else { operando = "FFFFF"; } } else { operando = "FFFFF"; } } if (MetodosAuxiliares.hexadecimalADecimal(operando) > 0) { operando = MetodosAuxiliares.ajustaOperando(operando, 5, "0"); } else { operando = MetodosAuxiliares.ajustaOperando(operando, 5, "F"); } codigoObj = MetodosAuxiliares.decimalAHexadecimal(MetodosAuxiliares.binarioADecimal(codigoObj + new string(nixbpe))) + operando; codigoObj += "*"; } else { codigoObj = "4F100000*"; } return codigoObj; }