Skip to content

Commit

Permalink
Corr. de interpretación de desplazamientos
Browse files Browse the repository at this point in the history
  • Loading branch information
twilight1794 committed Nov 19, 2024
1 parent 25b8afc commit b595749
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
19 changes: 16 additions & 3 deletions public/programa_asm.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ class ProgramaAsm {
if (v.registro != "bc") throw new NoEsTipoExcepcion();
break;
case TipoParam.DDE:
if (v.tipo != TipoVal.REGISTRO) throw new NoEsTipoExcepcion();
if (v.tipo != TipoVal.DESPLAZAMIENTO) throw new NoEsTipoExcepcion();
if (v.valor != 0) throw new NoEsTipoExcepcion();
if (v.registro != "de") throw new NoEsTipoExcepcion();
break;
Expand Down Expand Up @@ -893,7 +893,7 @@ class ProgramaAsm {
break;
} catch {}
try {
this.esTipo(TipoParam.RR, lop[1]);
this.esTipo(TipoParam.RRR, lop[1]);
bytes.push(0xed, 0x5f);
break;
} catch {}
Expand Down Expand Up @@ -2171,7 +2171,7 @@ class ProgramaAsm {
});
else throw new TipoParametrosIncorrectoError("fix"); // FIX: fix
break;
}
}/*z
} else if (sim.tipo == TipoVal.DESPLAZAMIENTO_CI){
op1 = simsp.pop();
op2 = simsp.pop();
Expand All @@ -2180,6 +2180,19 @@ class ProgramaAsm {
else if (op2.tipo == TipoVal.DESPLAZAMIENTO) op2.valor = op1.valor*((op2.sentido)?1:-1);
else throw new TipoParametrosIncorrectoError("fix"); // FIX: fix
simsp.push(op2);
} else throw new TipoParametrosIncorrectoError("fix"); // FIX: fix*/
} else if (sim.tipo == TipoVal.DESPLAZAMIENTO_CI){
op1 = simsp.pop();
if (op1.tipo == TipoVal.NUMERO){
op2 = simsp.pop();
if (op1 && op2){
if (op2.tipo == TipoVal.DIRECCION) op2.valor = op1.valor;
else if (op2.tipo == TipoVal.DESPLAZAMIENTO) op2.valor = op1.valor*((op2.sentido)?1:-1);
else throw new TipoParametrosIncorrectoError("fix"); // FIX: fix
simsp.push(op2);
} else throw new TipoParametrosIncorrectoError("fix"); // FIX: fix
} else if (op1.tipo == TipoVal.DESPLAZAMIENTO){
simsp.push(op1);
} else throw new TipoParametrosIncorrectoError("fix"); // FIX: fix
} else if (sim.tipo == TipoVal.ETIQUETA){
op1 = plat.obtenerEtiqueta((this.caseRelevante)?sim.nombre:sim.nombre.toUpperCase());
Expand Down
10 changes: 5 additions & 5 deletions public/programa_hex16.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class programHex {
this.asmCode.push("IM 2");
this.removeNumBytes(1, bytes);
break;
//LD A, I
//LD A, I
case /^57$/.test(bytes[0]):
this.hexCode.push("ED57");
this.asmCode.push("LD A,I");
Expand Down Expand Up @@ -385,7 +385,7 @@ class programHex {
this.removeNumBytes(1,bytes);
break;
// ADC HL,ss
case /^[4567]A$/.test(bytes[0]):
case /^[4567]A$/.test(bytes[0]):
this.hexCode.push(`${moreSignificant}${bytes[0]}`);
this.asmCode.push(`ADC HL,${this.getOperand(bytes[0],[2,4],this.ValSS)}`);
this.removeNumBytes(1,bytes);
Expand Down Expand Up @@ -519,14 +519,14 @@ class programHex {
this.hexCode.push(`${moreSignificant}${bytes[0]}`);
this.asmCode.push(`SET ${this.getOperand(bytes[0],[2,5],this.ValB)},${this.getOperand(bytes[0],[5,8],this.ValR)}`)
this.removeNumBytes(1, bytes);
break;
break;
// BIT b,r
case (parseInt(bytes[0],16) >= 64 && parseInt(bytes[0],16) <= 127):
this.hexCode.push(`${moreSignificant}${bytes[0]}`);
this.asmCode.push(`BIT ${this.getOperand(bytes[0],[2,5],this.ValB)},${this.getOperand(bytes[0],[5,8],this.ValR)}`)
this.removeNumBytes(1,bytes);
break;
//RL r
//RL r
case (parseInt(bytes[0],16)>= 16 && parseInt(bytes[0],16)<=23):
this.hexCode.push(`${moreSignificant}${bytes[0]}`);
this.asmCode.push(`RL ${this.getOperand(bytes[0],[5,8],this.ValR)}`)
Expand Down Expand Up @@ -571,7 +571,7 @@ class programHex {
default:
console.log("NO EXISTE LA INSTRUCCIÓN");
break;
}
}
break;
// CP r
case /^B[89ABCDEF]$/.test(moreSignificant):
Expand Down

0 comments on commit b595749

Please sign in to comment.