-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path8080.min.js
129 lines (129 loc) · 30.8 KB
/
8080.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
(function(b){var d=[["NOP",1],["LXI B,#1",3],["STAX B",1],["INX B",1],["INR B",1],["DCR B",1],["MVI B, %1",2],["RLC",1],["-",0],["DAD B",1],["LDAX B",1],["DCX B",1],["INR C",1],["DCR C",1],["MVI C,%1",2],["RRC",1],["-",0],["LXI D,#1",3],["STAX D",1],["INX D",1],["INR D",1],["DCR D",1],["MVI D, %1",2],["RAL",1],["-",0],["DAD D",1],["LDAX D",1],["DCX D",1],["INR E",1],["DCR E",1],["MVI E,%1",2],["RAR",1],["RIM",1],["LXI H,#1",3],["SHLD #1",3],["INX H",1],["INR H",1],["DCR H",1],["MVI H,%1",2],["DAA",1],["-",0],["DAD H",1],["LHLD #1",3],["DCX H",1],["INR L",1],["DCR L",1],["MVI L, %1",2],["CMA",1],["SIM",1],["LXI SP, #1",3],["STA #1",3],["INX SP",1],["INR M",1],["DCR M",1],["MVI M,%1",2],["STC",1],["-",0],["DAD SP",1],["LDA #1",3],["DCX SP",1],["INR A",1],["DCR A",1],["MVI A,%1",2],["CMC",1],["MOV B,B",1],["MOV B,C",1],["MOV B,D",1],["MOV B,E",1],["MOV B,H",1],["MOV B,L",1],["MOV B,M",1],["MOV B,A",1],["MOV C,B",1],["MOV C,C",1],["MOV C,D",1],["MOV C,E",1],["MOV C,H",1],["MOV C,L",1],["MOV C,M",1],["MOV C,A",1],["MOV D,B",1],["MOV D,C",1],["MOV D,D",1],["MOV D,E",1],["MOV D,H",1],["MOV D,L",1],["MOV D,M",1],["MOV D,A",1],["MOV E,B",1],["MOV E,C",1],["MOV E,D",1],["MOV E,E",1],["MOV E,H",1],["MOV E,L",1],["MOV E,M",1],["MOV E,A",1],["MOV H,B",1],["MOV H,C",1],["MOV H,D",1],["MOV H,E",1],["MOV H,H",1],["MOV H,L",1],["MOV H,M",1],["MOV H,A",1],["MOV L,B",1],["MOV L,C",1],["MOV L,D",1],["MOV L,E",1],["MOV L,H",1],["MOV L,L",1],["MOV L,M",1],["MOV L,A",1],["MOV M,B",1],["MOV M,C",1],["MOV M,D",1],["MOV M,E",1],["MOV M,H",1],["MOV M,L",1],["HLT",1],["MOV M,A",1],["MOV A,B",1],["MOV A,C",1],["MOV A,D",1],["MOV A,E",1],["MOV A,H",1],["MOV A,L",1],["MOV A,M",1],["MOV A,A",1],["ADD B",1],["ADD C",1],["ADD D",1],["ADD E",1],["ADD H",1],["ADD L",1],["ADD M",1],["ADD A",1],["ADC B",1],["ADC C",1],["ADC D",1],["ADC E",1],["ADC H",1],["ADC L",1],["ADC M",1],["ADC A",1],["SUB B",1],["SUB C",1],["SUB D",1],["SUB E",1],["SUB H",1],["SUB L",1],["SUB M",1],["SUB A",1],["SBB B",1],["SBB C",1],["SBB D",1],["SBB E",1],["SBB H",1],["SBB L",1],["SBB M",1],["SBB A",1],["ANA B",1],["ANA C",1],["ANA D",1],["ANA E",1],["ANA H",1],["ANA L",1],["ANA M",1],["ANA A",1],["XRA B",1],["XRA C",1],["XRA D",1],["XRA E",1],["XRA H",1],["XRA L",1],["XRA M",1],["XRA A",1],["ORA B",1],["ORA C",1],["ORA D",1],["ORA E",1],["ORA H",1],["ORA L",1],["ORA M",1],["ORA A",1],["CMP B",1],["CMP C",1],["CMP D",1],["CMP E",1],["CMP H",1],["CMP L",1],["CMP M",1],["CMP A",1],["RNZ",1],["POP B",1],["JNZ #1",3],["JMP #1",3],["CNZ #1",3],["PUSH B",1],["ADI %1",2],["RST 0",1],["RZ",1],["RET",1],["JZ #1",3],["-",0],["CZ #1",3],["CALL #1",3],["ACI %1",2],["RST 1",1],["RNC",1],["POP D",1],["JNC #1",3],["OUT %1",2],["CNC #1",3],["PUSH D",1],["SUI %1",2],["RST 2",1],["RC",1],["-",0],["JC #1",3],["IN %1",2],["CC #1",3],["-",0],["SBI %1",2],["RST 3",1],["RPO",1],["POP H",1],["JPO #1",3],["XTHL",1],["CPO #1",3],["PUSH H",1],["ANI %1",2],["RST 4",1],["RPE",1],["PCHL",1],["JPE #1",3],["XCHG",1],["CPE #1",3],["-",0],["XRI %1",2],["RST 5",1],["RP",1],["POP PSW",1],["JP #1",3],["DI",1],["CP #1",3],["PUSH PSW",1],["ORI %1",2],["RST 6",1],["RM",1],["SPHL",1],["JM #1",3],["EI",1],["CM #1",3],["-",0],["CPI %1",2],["RST 7",1]];
var c=function(h,g){var f=h.toString(16);while(f.length<g){f="0"+f;}return f.toUpperCase();};var a=function(f){return c(f&255,2);};var e=function(f){return c(f,4);
};b.disasm=function(g,m,k,j,h){var l=d[g];var o=l[0];var n=a(m);o=o.replace("%1","$"+n);var f=a(k)+a(m);o=o.replace("#1","$"+f);return[o,l[1]];};})(typeof exports==="undefined"?this["CPUD8080"]={}:exports);
(function(r){var f=[70,2,2,6,2,6,6,2,2,6,6,2,6,2,2,6,2,6,6,2,6,2,2,6,6,2,2,6,2,6,6,2,2,6,6,2,6,2,2,6,6,2,2,6,2,6,6,2,6,2,2,6,2,6,6,2,2,6,6,2,6,2,2,6,2,6,6,2,6,2,2,6,6,2,2,6,2,6,6,2,6,2,2,6,2,6,6,2,2,6,6,2,6,2,2,6,6,2,2,6,2,6,6,2,2,6,6,2,6,2,2,6,2,6,6,2,6,2,2,6,6,2,2,6,2,6,6,2,130,134,134,130,134,130,130,134,134,130,130,134,130,134,134,130,134,130,130,134,130,134,134,130,130,134,134,130,134,130,130,134,134,130,130,134,130,134,134,130,130,134,134,130,134,130,130,134,130,134,134,130,134,130,130,134,134,130,130,134,130,134,134,130,134,130,130,134,130,134,134,130,130,134,134,130,134,130,130,134,130,134,134,130,134,130,130,134,134,130,130,134,130,134,134,130,130,134,134,130,134,130,130,134,134,130,130,134,130,134,134,130,134,130,130,134,130,134,134,130,130,134,134,130,134,130,130,134];
var c=[70,258,514,774,1026,1286,1542,1794,2050,2310,4114,4374,4630,4882,5142,5394,4098,4358,4614,4866,5126,5378,5634,5894,6150,6402,8210,8470,8726,8978,9238,9490,8194,8454,8710,8962,9222,9474,9730,9990,10246,10498,12310,12562,12818,13078,13330,13590,12294,12546,12802,13062,13314,13574,13830,14082,14338,14598,16402,16662,16918,17170,17430,17682,16386,16646,16902,17154,17414,17666,17922,18182,18438,18690,20502,20754,21010,21270,21522,21782,20486,20738,20994,21254,21506,21766,22022,22274,22530,22790,24598,24850,25106,25366,25618,25878,24582,24834,25090,25350,25602,25862,26118,26370,26626,26886,28690,28950,29206,29458,29718,29970,28674,28934,29190,29442,29702,29954,30210,30470,30726,30978,32914,33174,33430,33682,33942,34194,32898,33158,33414,33666,33926,34178,34434,34694,34950,35202,37014,37266,37522,37782,38034,38294,36998,37250,37506,37766,38018,38278,38534,38786,39042,39302,65623,65811,66067,66327,66579,66839,65607,65795,66051,66311,66563,66823,67079,67331,67587,67847,69651,69911,70167,70419,70679,70931,69635,69895,70151,70403,70663,70915,71171,71431,71687,71939,73747,74007,74263,74515,74775,75027,73731,73991,74247,74499,74759,75011,75267,75527,75783,76035,77847,78099,78355,78615,78867,79127,77831,78083,78339,78599,78851,79111,79367,79619,79875,80135,81939,82199,82455,82707,82967,83219,81923,82183,82439,82691,82951,83203,83459,83719,83975,84227,86039,86291,86547,86807,87059,87319,86023,86275,86531,86791,87043,87303,87559,87811,88067,88327,90135,90387,90643,90903,91155,91415,24583,24835,25091,25351,25603,25863,26119,26371,26627,26887,28691,28951,29207,29459,29719,29971,28675,28935,29191,29443,29703,29955,30211,30471,30727,30979,32915,33175,33431,33683,33943,34195,32899,33159,33415,33667,33927,34179,34435,34695,34951,35203,37015,37267,37523,37783,38035,38295,36999,37251,37507,37767,38019,38279,38535,38787,39043,39303,41111,41363,41619,41879,42131,42391,41095,41347,41603,41863,42115,42375,42631,42883,43139,43399,45203,45463,45719,45971,46231,46483,45187,45447,45703,45955,46215,46467,46723,46983,47239,47491,49303,49555,49811,50071,50323,50583,49287,49539,49795,50055,50307,50567,50823,51075,51331,51591,53395,53655,53911,54163,54423,54675,53379,53639,53895,54147,54407,54659,54915,55175,55431,55683,57491,57751,58007,58259,58519,58771,57475,57735,57991,58243,58503,58755,59011,59271,59527,59779,61591,61843,62099,62359,62611,62871,61575,61827,62083,62343,62595,62855,63111,63363,63619,63879,65623,65811,66067,66327,66579,66839,65607,65795,66051,66311,66563,66823,67079,67331,67587,67847,69651,69911,70167,70419,70679,70931,69635,69895,70151,70403,70663,70915,71171,71431,71687,71939,73747,74007,74263,74515,74775,75027,73731,73991,74247,74499,74759,75011,75267,75527,75783,76035,77847,78099,78355,78615,78867,79127,77831,78083,78339,78599,78851,79111,79367,79619,79875,80135,81939,82199,82455,82707,82967,83219,81923,82183,82439,82691,82951,83203,83459,83719,83975,84227,86039,86291,86547,86807,87059,87319,86023,86275,86531,86791,87043,87303,87559,87811,88067,88327,90135,90387,90643,90903,91155,91415,1542,1794,2050,2310,2566,2818,3078,3330,3586,3846,4114,4374,4630,4882,5142,5394,5634,5894,6150,6402,6658,6918,7170,7430,7686,7938,8210,8470,8726,8978,9238,9490,9730,9990,10246,10498,10754,11014,11266,11526,11782,12034,12310,12562,12818,13078,13330,13590,13830,14082,14338,14598,14854,15106,15366,15618,15874,16134,16402,16662,16918,17170,17430,17682,17922,18182,18438,18690,18946,19206,19458,19718,19974,20226,20502,20754,21010,21270,21522,21782,22022,22274,22530,22790,23046,23298,23558,23810,24066,24326,24598,24850,25106,25366,25618,25878,26118,26370,26626,26886,27142,27394,27654,27906,28162,28422,28690,28950,29206,29458,29718,29970,30210,30470,30726,30978,31234,31494,31746,32006,32262,32514,32914,33174,33430,33682,33942,34194,34434,34694,34950,35202,35458,35718,35970,36230,36486,36738,37014,37266,37522,37782,38034,38294,38534,38786,39042,39302,39558,39810,40070,40322,40578,40838,65623,65811,66067,66327,66579,66839,67079,67331,67587,67847,68103,68355,68615,68867,69123,69383,69651,69911,70167,70419,70679,70931,71171,71431,71687,71939,72195,72455,72707,72967,73223,73475,73747,74007,74263,74515,74775,75027,75267,75527,75783,76035,76291,76551,76803,77063,77319,77571,77847,78099,78355,78615,78867,79127,79367,79619,79875,80135,80391,80643,80903,81155,81411,81671,81939,82199,82455,82707,82967,83219,83459,83719,83975,84227,84483,84743,84995,85255,85511,85763,86039,86291,86547,86807,87059,87319,87559,87811,88067,88327,88583,88835,89095,89347,89603,89863,90135,90387,90643,90903,91155,91415,26119,26371,26627,26887,27143,27395,27655,27907,28163,28423,28691,28951,29207,29459,29719,29971,30211,30471,30727,30979,31235,31495,31747,32007,32263,32515,32915,33175,33431,33683,33943,34195,34435,34695,34951,35203,35459,35719,35971,36231,36487,36739,37015,37267,37523,37783,38035,38295,38535,38787,39043,39303,39559,39811,40071,40323,40579,40839,41111,41363,41619,41879,42131,42391,42631,42883,43139,43399,43655,43907,44167,44419,44675,44935,45203,45463,45719,45971,46231,46483,46723,46983,47239,47491,47747,48007,48259,48519,48775,49027,49303,49555,49811,50071,50323,50583,50823,51075,51331,51591,51847,52099,52359,52611,52867,53127,53395,53655,53911,54163,54423,54675,54915,55175,55431,55683,55939,56199,56451,56711,56967,57219,57491,57751,58007,58259,58519,58771,59011,59271,59527,59779,60035,60295,60547,60807,61063,61315,61591,61843,62099,62359,62611,62871,63111,63363,63619,63879,64135,64387,64647,64899,65155,65415,65623,65811,66067,66327,66579,66839,67079,67331,67587,67847,68103,68355,68615,68867,69123,69383,69651,69911,70167,70419,70679,70931,71171,71431,71687,71939,72195,72455,72707,72967,73223,73475,73747,74007,74263,74515,74775,75027,75267,75527,75783,76035,76291,76551,76803,77063,77319,77571,77847,78099,78355,78615,78867,79127,79367,79619,79875,80135,80391,80643,80903,81155,81411,81671,81939,82199,82455,82707,82967,83219,83459,83719,83975,84227,84483,84743,84995,85255,85511,85763,86039,86291,86547,86807,87059,87319,87559,87811,88067,88327,88583,88835,89095,89347,89603,89863,90135,90387,90643,90903,91155,91415];
function n(w,x){var v=[];for(var u=0;u<(x-w.length);++u){v.push("0");}v.push(w);return v.join("");}var e=1;var a=4;var s=16;var j=0;var m=64;var d=128;
var t,h,b,o,q;var k=function(){this.b=0;this.c=0;this.d=0;this.e=0;this.f=0;this.h=0;this.l=0;this.a=0;this.pc=0;this.inte=0;this.halted=0;this.sp=61440;
this.cycles=0;this.ram=[];};k.prototype.af=function(){return this.a<<8|this.f;};k.prototype.AF=function(u){this.a=u>>8&255;this.f=u&255;};k.prototype.bc=function(){return((this.b&255)<<8)|(this.c&255);
};k.prototype.BC=function(u){this.b=(u>>8)&255;this.c=u&255;};k.prototype.de=function(){return this.d<<8|this.e;};k.prototype.DE=function(u){this.d=u>>8&255;
this.e=u&255;};k.prototype.hl=function(){return this.h<<8|this.l;};k.prototype.HL=function(u){this.h=u>>8&255;this.l=u&255;};k.prototype.set=function(u){this.f|=u;
};k.prototype.clear=function(u){this.f&=~u&255;};k.prototype.toString=function(){return"{ af: "+n(this.af().toString(16),4)+" bc: "+n(this.bc().toString(16),4)+" de: "+n(this.de().toString(16),4)+" hl: "+n(this.hl().toString(16),4)+" pc: "+n(this.pc.toString(16),4)+" sp: "+n(this.sp.toString(16),4)+" flags: "+(this.f&m?"z":".")+(this.f&d?"s":".")+(this.f&a?"p":".")+(this.f&e?"c":".")+" }";
};k.prototype.step=function(){if(this.halted===1){this.cycles++;return 1;}var v=h(this.pc++);var u=this.cycles;this.execute(v);this.pc&=65535;return this.cycles-u;
};k.prototype.writePort=function(w,u){if(b){b(w&255,u);}};k.prototype.readPort=function(u){if(o){return o(u&255);}return 255;};k.prototype.getByte=function(u){return h(u&65535);
};k.prototype.getWord=function(w){var u=h(w&65535);var v=h((w+1)&65535);return v<<8|u;};k.prototype.nextByte=function(){var v=this.pc;var u=h(v&65535);
this.pc=(v+1)&65535;return u;};k.prototype.nextWord=function(){var v=this.pc;var u=h(v&65535);var w=h((v+1)&65535);this.pc=(v+2)&65535;return w<<8|u;};
k.prototype.writeByte=function(x,w){var u=w&255;t(x&65535,u);};k.prototype.writeWord=function(x,w){var u=w;var v=w>>8;this.writeByte(x&65535,u);this.writeByte((x+1)&65535,v);
};k.prototype.calcFlags=function(y,w,z){var u=y&255;if(y>=256||y<0){this.f|=e;}else{this.f&=~e&255;}this.f=f[u];if(y>=256||y<0){this.f|=e;}else{this.f&=~e&255;
}return u;};k.prototype.acADD=function(w,v,z){var u=[0,s,s,s,0,0,0,s];var x=(z&8)>>1|(v&8)>>2|(w&8)>>3;var y=u[x];this.f=this.f&~s|y;};k.prototype.acSUB=function(w,v,z){var u=[s,s,0,s,0,s,0,0];
var x=(z&8)>>1|(v&8)>>2|(w&8)>>3;var y=u[x];this.f=this.f&~s|y;};k.prototype.incrementByte=function(v){var w=this.f&e;var u=this.calcFlags(v+1,v,1);this.f=(this.f&~e&255)|w;
if((u&15)===0){this.f=this.f|s;}else{this.f&=~s&255;}return u;};k.prototype.decrementByte=function(v){var w=this.f&e;var u=this.calcFlags(v-1,v,1);this.f=(this.f&~e&255)|w;
if((v&15)>0){this.f=this.f|s;}else{this.f&=~s&255;}return u;};k.prototype.addByte=function(u,w){var v=this.calcFlags(u+w,u,w);this.acADD(u,w,v);return v;
};k.prototype.addByteWithCarry=function(u,w){var v=this.addByte(u,w+((this.f&e)?1:0));this.acADD(u,w,v);return v;};k.prototype.subtractByte=function(u,w){var v=this.calcFlags(u-w,u,w);
this.acSUB(u,w,v);return v;};k.prototype.subtractByteWithCarry=function(u,x){var w=x+((this.f&e)?1:0);var v=this.calcFlags(u-w,u,w);this.acSUB(u,x,v);return v;
};k.prototype.andByte=function(v,y){var u=this.calcFlags(v&y,v,y);var w=(v&8)|(y&8);if(w>0){this.f|=s;}else{this.f&=~s;}this.f&=~e&255;return u;};k.prototype.xorByte=function(v,w){var u=this.calcFlags(v^w,v,w);
this.f&=~s;this.f&=~e&255;return u;};k.prototype.orByte=function(v,w){var u=this.calcFlags(v|w,v,w);this.f&=~s;this.f&=~e&255;return u;};k.prototype.addWord=function(u,w){var v=u+w;
if(v>65535){this.f|=e;}else{this.f&=~e;}return v&65535;};k.prototype.pop=function(){var u=this.getWord(this.sp);this.sp=(this.sp+2)&65535;return u;};k.prototype.push=function(u){this.sp=(this.sp-2)&65535;
this.writeWord(this.sp,u);};k.prototype.processInterrupts=function(){};k.prototype.execute=function(y){var A,D,B;this.f&=215;this.f|=2;switch(y){case 0:case 8:case 16:case 24:case 32:case 40:case 48:case 56:this.cycles+=4;
break;case 1:this.BC(this.nextWord());this.cycles+=10;break;case 2:this.writeByte(this.bc(),this.a);this.cycles+=7;break;case 3:this.BC((this.bc()+1)&65535);
this.cycles+=6;break;case 4:this.b=this.incrementByte(this.b);this.cycles+=5;break;case 5:this.b=this.decrementByte(this.b);this.cycles+=5;break;case 6:this.b=this.nextByte();
this.cycles+=7;break;case 7:var v=(this.a&128)>>7;if(v){this.f|=e;}else{this.f&=~e&255;}this.a=((this.a<<1)&254)|v;this.cycles+=4;break;case 9:this.HL(this.addWord(this.hl(),this.bc()));
this.cycles+=11;break;case 10:this.a=h(this.bc());this.cycles+=7;break;case 11:this.BC((this.bc()+65535)&65535);this.cycles+=6;break;case 12:this.c=this.incrementByte(this.c);
this.cycles+=5;break;case 13:this.c=this.decrementByte(this.c);this.cycles+=5;break;case 14:this.c=this.nextByte();this.cycles+=7;break;case 15:var z=(this.a&1)<<7;
if(z){this.f|=e;}else{this.f&=~e&255;}this.a=((this.a>>1)&127)|z;this.cycles+=4;break;case 17:this.DE(this.nextWord());this.cycles+=10;break;case 18:this.writeByte(this.de(),this.a);
this.cycles+=7;break;case 19:this.DE((this.de()+1)&65535);this.cycles+=6;break;case 20:this.d=this.incrementByte(this.d);this.cycles+=5;break;case 21:this.d=this.decrementByte(this.d);
this.cycles+=5;break;case 22:this.d=this.nextByte();this.cycles+=7;break;case 23:B=(this.f&e)?1:0;if(this.a&128){this.f|=e;}else{this.f&=~e&255;}this.a=((this.a<<1)&254)|B;
this.cycles+=4;break;case 25:this.HL(this.addWord(this.hl(),this.de()));this.cycles+=11;break;case 26:this.a=h(this.de());this.cycles+=7;break;case 27:this.DE((this.de()-1)&65535);
this.cycles+=6;break;case 28:this.e=this.incrementByte(this.e);this.cycles+=5;break;case 29:this.e=this.decrementByte(this.e);this.cycles+=5;break;case 30:this.e=this.nextByte();
this.cycles+=7;break;case 31:var u=(this.f&e)?128:0;if(this.a&1){this.f|=e;}else{this.f&=~e&255;}this.a=((this.a>>1)&127)|u;this.cycles+=4;break;case 33:this.HL(this.nextWord());
this.cycles+=10;break;case 34:this.writeWord(this.nextWord(),this.hl());this.cycles+=16;break;case 35:this.HL((this.hl()+1)&65535);this.cycles+=6;break;
case 36:this.h=this.incrementByte(this.h);this.cycles+=5;break;case 37:this.h=this.decrementByte(this.h);this.cycles+=5;break;case 38:this.h=this.nextByte();
this.cycles+=7;break;case 39:var E=this.a;if(this.f&e){E|=256;}if(this.f&s){E|=512;}var x=c[E];this.a=(x>>8)&255;this.f=x&215|2;this.cycles+=4;break;case 41:this.HL(this.addWord(this.hl(),this.hl()));
this.cycles+=11;break;case 42:this.HL(this.getWord(this.nextWord()));this.cycles+=16;break;case 43:this.HL((this.hl()-1)&65535);this.cycles+=6;break;case 44:this.l=this.incrementByte(this.l);
this.cycles+=5;break;case 45:this.l=this.decrementByte(this.l);this.cycles+=5;break;case 46:this.l=this.nextByte();this.cycles+=7;break;case 47:this.a^=255;
this.cycles+=4;break;case 49:this.sp=this.nextWord();this.cycles+=10;break;case 50:this.writeByte(this.nextWord(),this.a);this.cycles+=13;break;case 51:this.sp=((this.sp+1)&65535);
this.cycles+=6;break;case 52:A=this.hl();this.writeByte(A,this.incrementByte(h(A)));this.cycles+=10;break;case 53:A=this.hl();this.writeByte(A,this.decrementByte(h(A)));
this.cycles+=10;break;case 54:this.writeByte(this.hl(),this.nextByte());this.cycles+=10;break;case 55:this.f|=e;this.cycles+=4;break;case 57:this.HL(this.addWord(this.hl(),this.sp));
this.cycles+=11;break;case 58:this.a=h(this.nextWord());this.cycles+=13;break;case 59:this.sp=(this.sp-1)&65535;this.cycles+=6;break;case 60:this.a=this.incrementByte(this.a);
this.cycles+=5;break;case 61:this.a=this.decrementByte(this.a);this.cycles+=5;break;case 62:this.a=this.nextByte();this.cycles+=7;break;case 63:this.f^=e;
this.cycles+=4;break;case 64:this.b=this.b;this.cycles+=5;break;case 65:this.b=this.c;this.cycles+=5;break;case 66:this.b=this.d;this.cycles+=5;break;case 67:this.b=this.e;
this.cycles+=5;break;case 68:this.b=this.h;this.cycles+=5;break;case 69:this.b=this.l;this.cycles+=5;break;case 70:this.b=h(this.hl());this.cycles+=7;break;
case 71:this.b=this.a;this.cycles+=5;break;case 72:this.c=this.b;this.cycles+=5;break;case 73:this.c=this.c;this.cycles+=5;break;case 74:this.c=this.d;
this.cycles+=5;break;case 75:this.c=this.e;this.cycles+=5;break;case 76:this.c=this.h;this.cycles+=5;break;case 77:this.c=this.l;this.cycles+=5;break;case 78:this.c=h(this.hl());
this.cycles+=7;break;case 79:this.c=this.a;this.cycles+=5;break;case 80:this.d=this.b;this.cycles+=5;break;case 81:this.d=this.c;this.cycles+=5;break;case 82:this.d=this.d;
this.cycles+=5;break;case 83:this.d=this.e;this.cycles+=5;break;case 84:this.d=this.h;this.cycles+=5;break;case 85:this.d=this.l;this.cycles+=5;break;case 86:this.d=h(this.hl());
this.cycles+=7;break;case 87:this.d=this.a;this.cycles+=5;break;case 88:this.e=this.b;this.cycles+=5;break;case 89:this.e=this.c;this.cycles+=5;break;case 90:this.e=this.d;
this.cycles+=5;break;case 91:this.e=this.e;this.cycles+=5;break;case 92:this.e=this.h;this.cycles+=5;break;case 93:this.e=this.l;this.cycles+=5;break;case 94:this.e=h(this.hl());
this.cycles+=7;break;case 95:this.e=this.a;this.cycles+=5;break;case 96:this.h=this.b;this.cycles+=5;break;case 97:this.h=this.c;this.cycles+=5;break;case 98:this.h=this.d;
this.cycles+=5;break;case 99:this.h=this.e;this.cycles+=5;break;case 100:this.h=this.h;this.cycles+=5;break;case 101:this.h=this.l;this.cycles+=5;break;
case 102:this.h=h(this.hl());this.cycles+=7;break;case 103:this.h=this.a;this.cycles+=5;break;case 104:this.l=this.b;this.cycles+=5;break;case 105:this.l=this.c;
this.cycles+=5;break;case 106:this.l=this.d;this.cycles+=5;break;case 107:this.l=this.e;this.cycles+=5;break;case 108:this.l=this.h;this.cycles+=5;break;
case 109:this.l=this.l;this.cycles+=5;break;case 110:this.l=h(this.hl());this.cycles+=7;break;case 111:this.l=this.a;this.cycles+=5;break;case 112:this.writeByte(this.hl(),this.b);
this.cycles+=7;break;case 113:this.writeByte(this.hl(),this.c);this.cycles+=7;break;case 114:this.writeByte(this.hl(),this.d);this.cycles+=7;break;case 115:this.writeByte(this.hl(),this.e);
this.cycles+=7;break;case 116:this.writeByte(this.hl(),this.h);this.cycles+=7;break;case 117:this.writeByte(this.hl(),this.l);this.cycles+=7;break;case 118:this.cycles+=7;
this.halted=1;break;case 119:this.writeByte(this.hl(),this.a);this.cycles+=7;break;case 120:this.a=this.b;this.cycles+=5;break;case 121:this.a=this.c;this.cycles+=5;
break;case 122:this.a=this.d;this.cycles+=5;break;case 123:this.a=this.e;this.cycles+=5;break;case 124:this.a=this.h;this.cycles+=5;break;case 125:this.a=this.l;
this.cycles+=5;break;case 126:this.a=h(this.hl());this.cycles+=7;break;case 127:this.a=this.a;this.cycles+=5;break;case 128:this.a=this.addByte(this.a,this.b);
this.cycles+=4;break;case 129:this.a=this.addByte(this.a,this.c);this.cycles+=4;break;case 130:this.a=this.addByte(this.a,this.d);this.cycles+=4;break;
case 131:this.a=this.addByte(this.a,this.e);this.cycles+=4;break;case 132:this.a=this.addByte(this.a,this.h);this.cycles+=4;break;case 133:this.a=this.addByte(this.a,this.l);
this.cycles+=4;break;case 134:this.a=this.addByte(this.a,h(this.hl()));this.cycles+=7;break;case 135:this.a=this.addByte(this.a,this.a);this.cycles+=4;
break;case 136:this.a=this.addByteWithCarry(this.a,this.b);this.cycles+=4;break;case 137:this.a=this.addByteWithCarry(this.a,this.c);this.cycles+=4;break;
case 138:this.a=this.addByteWithCarry(this.a,this.d);this.cycles+=4;break;case 139:this.a=this.addByteWithCarry(this.a,this.e);this.cycles+=4;break;case 140:this.a=this.addByteWithCarry(this.a,this.h);
this.cycles+=4;break;case 141:this.a=this.addByteWithCarry(this.a,this.l);this.cycles+=4;break;case 142:this.a=this.addByteWithCarry(this.a,h(this.hl()));
this.cycles+=7;break;case 143:this.a=this.addByteWithCarry(this.a,this.a);this.cycles+=4;break;case 144:this.a=this.subtractByte(this.a,this.b);this.cycles+=4;
break;case 145:this.a=this.subtractByte(this.a,this.c);this.cycles+=4;break;case 146:this.a=this.subtractByte(this.a,this.d);this.cycles+=4;break;case 147:this.a=this.subtractByte(this.a,this.e);
this.cycles+=4;break;case 148:this.a=this.subtractByte(this.a,this.h);this.cycles+=4;break;case 149:this.a=this.subtractByte(this.a,this.l);this.cycles+=4;
break;case 150:this.a=this.subtractByte(this.a,h(this.hl()));this.cycles+=7;break;case 151:this.a=this.subtractByte(this.a,this.a);this.cycles+=4;break;
case 152:this.a=this.subtractByteWithCarry(this.a,this.b);this.cycles+=4;break;case 153:this.a=this.subtractByteWithCarry(this.a,this.c);this.cycles+=4;
break;case 154:this.a=this.subtractByteWithCarry(this.a,this.d);this.cycles+=4;break;case 155:this.a=this.subtractByteWithCarry(this.a,this.e);this.cycles+=4;
break;case 156:this.a=this.subtractByteWithCarry(this.a,this.h);this.cycles+=4;break;case 157:this.a=this.subtractByteWithCarry(this.a,this.l);this.cycles+=4;
break;case 158:this.a=this.subtractByteWithCarry(this.a,h(this.hl()));this.cycles+=7;break;case 159:this.a=this.subtractByteWithCarry(this.a,this.a);this.cycles+=4;
break;case 160:this.a=this.andByte(this.a,this.b);this.cycles+=4;break;case 161:this.a=this.andByte(this.a,this.c);this.cycles+=4;break;case 162:this.a=this.andByte(this.a,this.d);
this.cycles+=4;break;case 163:this.a=this.andByte(this.a,this.e);this.cycles+=4;break;case 164:this.a=this.andByte(this.a,this.h);this.cycles+=4;break;
case 165:this.a=this.andByte(this.a,this.l);this.cycles+=4;break;case 166:this.a=this.andByte(this.a,h(this.hl()));this.cycles+=7;break;case 167:this.a=this.andByte(this.a,this.a);
this.cycles+=4;break;case 168:this.a=this.xorByte(this.a,this.b);this.cycles+=4;break;case 169:this.a=this.xorByte(this.a,this.c);this.cycles+=4;break;
case 170:this.a=this.xorByte(this.a,this.d);this.cycles+=4;break;case 171:this.a=this.xorByte(this.a,this.e);this.cycles+=4;break;case 172:this.a=this.xorByte(this.a,this.h);
this.cycles+=4;break;case 173:this.a=this.xorByte(this.a,this.l);this.cycles+=4;break;case 174:this.a=this.xorByte(this.a,h(this.hl()));this.cycles+=7;
break;case 175:this.a=this.xorByte(this.a,this.a);this.cycles+=4;break;case 176:this.a=this.orByte(this.a,this.b);this.cycles+=4;break;case 177:this.a=this.orByte(this.a,this.c);
this.cycles+=4;break;case 178:this.a=this.orByte(this.a,this.d);this.cycles+=4;break;case 179:this.a=this.orByte(this.a,this.e);this.cycles+=4;break;case 180:this.a=this.orByte(this.a,this.h);
this.cycles+=4;break;case 181:this.a=this.orByte(this.a,this.l);this.cycles+=4;break;case 182:this.a=this.orByte(this.a,h(this.hl()));this.cycles+=7;break;
case 183:this.a=this.orByte(this.a,this.a);this.cycles+=4;break;case 184:this.subtractByte(this.a,this.b);this.cycles+=4;break;case 185:this.subtractByte(this.a,this.c);
this.cycles+=4;break;case 186:this.subtractByte(this.a,this.d);this.cycles+=4;break;case 187:this.subtractByte(this.a,this.e);this.cycles+=4;break;case 188:this.subtractByte(this.a,this.h);
this.cycles+=4;break;case 189:this.subtractByte(this.a,this.l);this.cycles+=4;break;case 190:this.subtractByte(this.a,h(this.hl()));this.cycles+=7;break;
case 191:this.subtractByte(this.a,this.a);this.cycles+=4;break;case 192:if(this.f&m){this.cycles+=5;}else{this.pc=this.pop();this.cycles+=11;}break;case 193:this.BC(this.pop());
this.cycles+=10;break;case 194:if(this.f&m){this.pc=(this.pc+2)&65535;}else{this.pc=this.nextWord();}this.cycles+=10;break;case 195:case 203:this.pc=this.getWord(this.pc);
this.cycles+=10;break;case 196:if(this.f&m){this.cycles+=11;this.pc=(this.pc+2)&65535;}else{this.cycles+=17;D=this.nextWord();this.push(this.pc);this.pc=D;
}break;case 197:this.push(this.bc());this.cycles+=11;break;case 198:this.a=this.addByte(this.a,this.nextByte());this.cycles+=7;break;case 199:this.push(this.pc);
this.pc=0;this.cycles+=11;break;case 200:if(this.f&m){this.pc=this.pop();this.cycles+=11;}else{this.cycles+=5;}break;case 201:case 217:this.pc=this.pop();
this.cycles+=10;break;case 202:if(this.f&m){this.pc=this.nextWord();}else{this.pc=(this.pc+2)&65535;}this.cycles+=10;break;case 204:if(this.f&m){this.cycles+=17;
D=this.nextWord();this.push(this.pc);this.pc=D;}else{this.cycles+=11;this.pc=(this.pc+2)&65535;}break;case 205:case 221:case 237:case 253:D=this.nextWord();
this.push(this.pc);this.pc=D;this.cycles+=17;break;case 206:this.a=this.addByteWithCarry(this.a,this.nextByte());this.cycles+=7;break;case 207:this.push(this.pc);
this.pc=8;this.cycles+=11;break;case 208:if(this.f&e){this.cycles+=5;}else{this.pc=this.pop();this.cycles+=11;}break;case 209:this.DE(this.pop());this.cycles+=10;
break;case 210:if(this.f&e){this.pc=(this.pc+2)&65535;}else{this.pc=this.nextWord();}this.cycles+=10;break;case 211:this.writePort(this.nextByte(),this.a);
this.cycles+=10;break;case 212:if(this.f&e){this.cycles+=11;this.pc=(this.pc+2)&65535;}else{this.cycles+=17;D=this.nextWord();this.push(this.pc);this.pc=D;
}break;case 213:this.push(this.de());this.cycles+=11;break;case 214:this.a=this.subtractByte(this.a,this.nextByte());this.cycles+=7;break;case 215:this.push(this.pc);
this.pc=16;this.cycles+=11;break;case 216:if(this.f&e){this.pc=this.pop();this.cycles+=11;}else{this.cycles+=5;}break;case 218:if(this.f&e){this.pc=this.nextWord();
}else{this.pc=(this.pc+2)&65535;}this.cycles+=10;break;case 219:this.a=this.readPort(this.nextByte());this.cycles+=10;break;case 220:if(this.f&e){this.cycles+=17;
D=this.nextWord();this.push(this.pc);this.pc=D;}else{this.cycles+=11;this.pc=(this.pc+2)&65535;}break;case 222:this.a=this.subtractByteWithCarry(this.a,this.nextByte());
this.cycles+=7;break;case 223:this.push(this.pc);this.pc=24;this.cycles+=11;break;case 224:if(this.f&a){this.cycles+=5;}else{this.pc=this.pop();this.cycles+=11;
}break;case 225:this.HL(this.pop());this.cycles+=10;break;case 226:if(this.f&a){this.pc=(this.pc+2)&65535;}else{this.pc=this.nextWord();}this.cycles+=10;
break;case 227:var C=this.getWord(this.sp);this.writeWord(this.sp,this.hl());this.HL(C);this.cycles+=4;break;case 228:if(this.f&a){this.cycles+=11;this.pc=(this.pc+2)&65535;
}else{this.cycles+=17;D=this.nextWord();this.push(this.pc);this.pc=D;}break;case 229:this.push(this.hl());this.cycles+=11;break;case 230:this.a=this.andByte(this.a,this.nextByte());
this.cycles+=7;break;case 231:this.push(this.pc);this.pc=32;this.cycles+=11;break;case 232:if(this.f&a){this.pc=this.pop();this.cycles+=11;}else{this.cycles+=5;
}break;case 233:this.pc=this.hl();this.cycles+=4;break;case 234:if(this.f&a){this.pc=this.nextWord();}else{this.pc=(this.pc+2)&65535;}this.cycles+=10;break;
case 235:D=this.de();this.DE(this.hl());this.HL(D);this.cycles+=4;break;case 236:if(this.f&a){this.cycles+=17;D=this.nextWord();this.push(this.pc);this.pc=D;
}else{this.cycles+=11;this.pc=(this.pc+2)&65535;}break;case 238:this.a=this.xorByte(this.a,this.nextByte());this.cycles+=7;break;case 239:this.push(this.pc);
this.pc=40;this.cycles+=11;break;case 240:if(this.f&d){this.cycles+=5;}else{this.pc=this.pop();this.cycles+=11;}break;case 241:this.AF(this.pop());this.cycles+=10;
break;case 242:if(this.f&d){this.pc=(this.pc+2)&65535;}else{this.pc=this.nextWord();}this.cycles+=10;break;case 243:this.inte=0;this.cycles+=4;break;case 244:if(this.f&d){this.cycles+=11;
this.pc=(this.pc+2)&65535;}else{this.cycles+=17;D=this.nextWord();this.push(this.pc);this.pc=D;}break;case 245:this.push(this.af());this.cycles+=11;break;
case 246:this.a=this.orByte(this.a,this.nextByte());this.cycles+=7;break;case 247:this.push(this.pc);this.pc=48;this.cycles+=11;break;case 248:if(this.f&d){this.pc=this.pop();
this.cycles+=11;}else{this.cycles+=5;}break;case 249:this.sp=this.hl();this.cycles+=6;break;case 250:if(this.f&d){this.pc=this.nextWord();}else{this.pc=(this.pc+2)&65535;
}this.cycles+=10;break;case 251:this.inte=1;this.cycles+=4;break;case 252:if(this.f&d){this.cycles+=17;D=this.nextWord();this.push(this.pc);this.pc=D;}else{this.cycles+=11;
this.pc=(this.pc+2)&65535;}break;case 254:this.subtractByte(this.a,this.nextByte());this.cycles+=7;break;case 255:this.push(this.pc);this.pc=56;this.cycles+=11;
break;default:this.cycles+=4;break;}this.f&=215;this.f|=2;};var g,l=false;var p=function(){g.pc=0;g.sp=0;g.halted=0;g.a=g.b=g.c=g.d=g.e=g.h=g.l=0;g.f=2;
g.inte=0;g.cycles=0;};var i=function(u){console.log(toHex4(u.pc));};r.trace=function(u){l=u;};r.steps=function(u){T=0;while(u>0){u-=g.step();if(l){i(g);
}}};r.T=function(){return g.cycles;};r.reset=p;r.init=function(v,y,u,w,x){t=v;h=y;q=u;b=w;o=x;g=new k();p();};r.status=function(){return{pc:g.pc,sp:g.sp,a:g.a,b:g.b,c:g.c,d:g.d,e:g.e,f:g.f,h:g.h,l:g.l};
};r.interrupt=function(u){if(g.inte){g.halted=0;g.push(g.pc);g.pc=u||56;}};r.set=function(u,v){u=u.toUpperCase();switch(u){case"PC":g.pc=v;return;case"A":g.a=v;
return;case"B":g.b=v;return;case"C":g.c=v;return;case"D":g.d=v;return;case"E":g.e=v;return;case"H":g.h=v;return;case"L":g.l=v;return;case"F":g.f=v;return;
case"SP":g.sp=v;return;}};r.flagsToString=function(){var w="",v="SZ0A0P1C";for(var u=0;u<8;u++){var x=g.f&(128>>u);if(x===0){w+=v[u].toLowerCase();}else{w+=v[u];
}}return w;};})(typeof exports==="undefined"?this["CPU8080"]={}:exports);