@@ -227,7 +227,7 @@ class Plataforma {
227
227
*/
228
228
cargarArchivoEnsamblador ( nom ) {
229
229
let t = localStorage . getItem ( "archivo_" + nom ) || "" ;
230
- t = buscarMacros ( t ) ;
230
+ // t = buscarMacros(t);
231
231
return t . split ( "\n" ) ;
232
232
}
233
233
@@ -361,7 +361,10 @@ class Plataforma {
361
361
* @memberof Plataforma
362
362
*/
363
363
escribirRegistro ( reg , val ) {
364
- if ( val instanceof Array ) val = decodificarValor ( val , val . length , true , false ) ;
364
+ if ( val instanceof Array ) {
365
+ console . log ( "Array!" )
366
+ val = decodificarValor ( val , val . length , true , false ) ;
367
+ }
365
368
reg = reg . toLowerCase ( ) ;
366
369
switch ( reg ) {
367
370
case "a" :
@@ -380,14 +383,14 @@ class Plataforma {
380
383
case "ex" :
381
384
case "hx" :
382
385
case "lx" :
383
- if ( val > 255 ) throw new ValorTamanoError ( val , 1 ) ;
386
+ if ( val > 255 ) throw new ValorTamanoError ( 2 ) ;
384
387
document . getElementById ( "v-" + reg ) . textContent = val . toString ( 16 ) . toUpperCase ( ) . padStart ( 2 , "0" ) ;
385
388
break ;
386
389
case "ix" :
387
390
case "iy" :
388
391
case "sp" :
389
392
case "pc" :
390
- if ( val > 65535 ) throw new ValorTamanoError ( val , 1 ) ;
393
+ if ( val > 65535 ) throw new ValorTamanoError ( 2 ) ;
391
394
document . getElementById ( "v-" + reg ) . textContent = val . toString ( 16 ) . toUpperCase ( ) . padStart ( 4 , "0" ) ;
392
395
break ;
393
396
case "bc" :
@@ -396,14 +399,15 @@ class Plataforma {
396
399
case "bcx" :
397
400
case "dex" :
398
401
case "hlx" :
399
- if ( val > 65535 ) throw new ValorTamanoError ( val , 1 ) ;
402
+ if ( val > 65535 ) throw new ValorTamanoError ( 2 ) ;
400
403
let va = val . toString ( 16 ) . padStart ( 4 , "0" ) . substring ( 0 , 2 ) ;
401
404
let vb = val . toString ( 16 ) . padStart ( 4 , "0" ) . substring ( 2 , 4 ) ;
402
- document . getElementById ( "v-" + reg [ 0 ] + ( ( reg . length == 3 ) ?"x" :"" ) ) . textContent = vb ;
403
- document . getElementById ( "v-" + reg [ 1 ] + ( ( reg . length == 3 ) ?"x" :"" ) ) . textContent = va ;
405
+ document . getElementById ( "v-" + reg [ 0 ] + ( ( reg . length == 3 ) ?"x" :"" ) ) . textContent = va ;
406
+ document . getElementById ( "v-" + reg [ 1 ] + ( ( reg . length == 3 ) ?"x" :"" ) ) . textContent = vb ;
407
+ break ;
404
408
case "f" :
405
409
case "fx" :
406
- if ( val > 255 ) throw new ValorTamanoError ( val , 1 ) ;
410
+ if ( val > 255 ) throw new ValorTamanoError ( 1 ) ;
407
411
Array . from ( val . toString ( 2 ) . padStart ( 8 , "0" ) ) . forEach ( ( e , i ) => {
408
412
let it = document . querySelector ( "#r-f tr:nth-child(" + ( i + 2 ) + ") td:nth-child(" + ( ( reg == "f" ) ?2 :4 ) + ")" ) ;
409
413
if ( e == "1" ) it . classList . add ( "activo" ) ;
@@ -911,26 +915,25 @@ class Plataforma {
911
915
} ] ] ;
912
916
case 0xf :
913
917
this . escribirRegistro ( "pc" , dir + 1 ) ;
914
-
915
918
op1 = this . leerRegistro ( "a" ) ;
916
919
auxv1 = Plataforma . obtRRC ( op1 ) ;
917
920
this . escribirRegistro ( "a" , auxv1 [ 0 ] ) ;
918
921
this . estBanderasOp ( "RRCA" , auxv1 ) ;
919
922
return [ "RRCA" , 4 , 1 , 1 , [ ] ] ;
920
923
case 0x10 :
921
- //op1 = decodificarValor([this.leerMemoria(dir+1)], 1, true, true);
922
- op1 = this . leerMemoria ( dir + 1 ) ;
924
+ op1 = decodificarValor ( [ this . leerMemoria ( dir + 1 ) ] , 1 , true , true ) ;
923
925
auxv1 = this . leerRegistro ( "b" ) ;
924
- if ( auxv1 > 0 ) {
925
- this . escribirRegistro ( "b" , auxv1 - 1 ) ;
926
+ this . escribirRegistro ( "b" , auxv1 - 1 ) ;
927
+ if ( auxv1 - 1 > 0 ) {
926
928
this . escribirRegistro ( "pc" , dir + op1 + 2 ) ;
927
929
tt = 13 ;
928
930
tm = 3 ;
929
931
} else {
932
+ this . escribirRegistro ( "pc" , dir + 2 ) ;
930
933
tt = 8 ;
931
934
tm = 2 ;
932
935
}
933
- return [ "DJNZ" , tt , tm , [ {
936
+ return [ "DJNZ" , tt , tm , 2 , [ {
934
937
"tipo" : TipoOpEns . DESPLAZAMIENTO ,
935
938
"texto" : this . imprimirValor ( TipoOpEns . DESPLAZAMIENTO , op1 + 2 )
936
939
} ] ] ;
@@ -1062,7 +1065,7 @@ class Plataforma {
1062
1065
"texto" : "HL"
1063
1066
} , {
1064
1067
"tipo" : TipoOpEns . DIRECCION ,
1065
- "texto" : this . imprimirValor ( TipoOpEns . DIRECCION , dir1 )
1068
+ "texto" : this . imprimirValor ( TipoOpEns . DIRECCION , dir2 )
1066
1069
} ] ] ;
1067
1070
case 0x2f :
1068
1071
this . escribirRegistro ( "pc" , dir + 1 ) ;
@@ -1128,8 +1131,8 @@ class Plataforma {
1128
1131
dir2 = this . leerRegistro ( "hl" ) ;
1129
1132
op2 = this . escribirMemoria ( dir2 , op1 ) ;
1130
1133
return [ "LD" , 10 , 3 , 2 , [ {
1131
- "tipo" : TipoOpEns . DESPLAZAMIENTO ,
1132
- "texto" : "(HL" + this . imprimirValor ( TipoOpEns . DESPLAZAMIENTO , op1 ) + " )"
1134
+ "tipo" : TipoOpEns . DIRECCION_R ,
1135
+ "texto" : "(HL)"
1133
1136
} , {
1134
1137
"tipo" : TipoOpEns . NUMERO ,
1135
1138
"texto" : this . imprimirValor ( TipoOpEns . NUMERO , op2 )
@@ -1501,15 +1504,16 @@ class Plataforma {
1501
1504
/* Compuestos */
1502
1505
/** 00dd0001 **/
1503
1506
case 1 : case 17 : case 33 : case 49 :
1507
+ this . escribirRegistro ( "pc" , dir + 3 ) ;
1504
1508
dir1 = ( cod - 1 ) >> 4 ;
1505
1509
op2 = this . leerPalabra ( dir + 1 ) ;
1506
1510
this . escribirRegistro ( this . ValsSS [ dir1 ] , op2 ) ;
1507
1511
return [ "LD" , 10 , 2 , 1 , [ {
1508
1512
"tipo" : TipoOpEns . REGISTRO ,
1509
1513
"texto" : this . ValsSS [ dir1 ]
1510
1514
} , {
1511
- "tipo" : TipoOpEns . DIRECCION ,
1512
- "texto" : this . imprimirValor ( TipoOpEns . DIRECCION , op2 )
1515
+ "tipo" : TipoOpEns . NUMERO ,
1516
+ "texto" : this . imprimirValor ( TipoOpEns . NUMERO , op2 )
1513
1517
} ] ] ;
1514
1518
/** 00rrr100 **/
1515
1519
case 4 : case 12 : case 20 : case 28 : case 36 : case 44 : case 60 :
@@ -1558,12 +1562,12 @@ class Plataforma {
1558
1562
} ] ] ;
1559
1563
/** 00ss1001 **/
1560
1564
case 9 : case 25 : case 41 : case 57 :
1561
- this . escribirRegistro ( "pc" , dir + 2 ) ;
1565
+ this . escribirRegistro ( "pc" , dir + 1 ) ;
1562
1566
dir2 = ( cod - 3 ) >> 4 ;
1563
1567
op1 = this . leerRegistro ( "hl" ) ;
1564
1568
op2 = this . leerRegistro ( this . ValsSS [ dir2 ] ) ;
1565
- res = op1 + op2 ;
1566
- this . escribirRegistro ( this . ValsSS [ dir2 ] , res ) ;
1569
+ res = op1 + op2 ;
1570
+ this . escribirRegistro ( "hl" , res ) ;
1567
1571
this . estBanderasOp ( "ADD" , [ res , op1 , op2 ] ) ;
1568
1572
return [ "ADD" , 11 , 3 , 1 , [ {
1569
1573
"tipo" : TipoOpEns . REGISTRO_PAR ,
@@ -1798,6 +1802,7 @@ class Plataforma {
1798
1802
} ] ] ;
1799
1803
/** 11qq0001 **/
1800
1804
case 193 : case 209 : case 225 : case 241 :
1805
+ this . escribirRegistro ( "pc" , dir + 1 ) ;
1801
1806
dir1 = ( cod - 193 ) >> 4 ;
1802
1807
op1 = this . leerPila ( ) ;
1803
1808
this . retirarPila ( ) ;
@@ -1808,6 +1813,7 @@ class Plataforma {
1808
1813
} ] ] ;
1809
1814
/** 11qq0101 **/
1810
1815
case 197 : case 213 : case 229 : case 245 :
1816
+ this . escribirRegistro ( "pc" , dir + 1 ) ;
1811
1817
dir1 = ( cod - 197 ) >> 4 ;
1812
1818
op1 = this . leerRegistro ( this . ValsQQ [ dir1 ] ) ;
1813
1819
this . insertarPila ( op1 ) ;
0 commit comments