From 4173aaca3132958a9c10b71634981cdc101fc544 Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Thu, 21 Apr 2016 17:06:26 -0700 Subject: [PATCH] More 8080 opcodes --- modules/pc8080/lib/cpuops.js | 235 +++++++++++++++++++++- modules/pc8080/lib/cpusim.js | 19 +- versions/pc8080/1.21.7/pc8080-dbg.js | 286 ++++++++++++++------------- versions/pc8080/1.21.7/pc8080.js | 155 ++++++++------- 4 files changed, 458 insertions(+), 237 deletions(-) diff --git a/modules/pc8080/lib/cpuops.js b/modules/pc8080/lib/cpuops.js index ca233b01c..951a97bb9 100644 --- a/modules/pc8080/lib/cpuops.js +++ b/modules/pc8080/lib/cpuops.js @@ -121,9 +121,9 @@ CPUDef.opMVIB = function() */ CPUDef.opRLC = function() { - var b = this.regA << 1; - this.regA = (b & 0xff) | (b >> 8); - this.resultZeroCarry = (this.resultZeroCarry & 0xff) | (b & 0x100); + var carry = this.regA << 1; + this.regA = (carry & 0xff) | (carry >> 8); + this.resultZeroCarry = (this.resultZeroCarry & 0xff) | (carry & 0x100); this.nStepCycles -= 4; }; @@ -151,6 +151,223 @@ CPUDef.opLDAXB = function() this.nStepCycles -= 7; }; +/** + * op=0x0B (DCX B) + * + * @this {CPUSim} + */ +CPUDef.opDCXB = function() +{ + this.setBC(this.getBC() - 1); + this.nStepCycles -= 5; +}; + +/** + * op=0x0C (INR C) + * + * @this {CPUSim} + */ +CPUDef.opINRC = function() +{ + this.regC = this.incByte(this.regC); + this.nStepCycles -= 5; +}; + +/** + * op=0x0D (DCR C) + * + * @this {CPUSim} + */ +CPUDef.opDCRC = function() +{ + this.regC = this.decByte(this.regC); + this.nStepCycles -= 5; +}; + +/** + * op=0x0E (MVI C,d8) + * + * @this {CPUSim} + */ +CPUDef.opMVIC = function() +{ + this.regC = this.getPCByte(); + this.nStepCycles -= 7; +}; + +/** + * op=0x0F (RRC) + * + * @this {CPUSim} + */ +CPUDef.opRRC = function() +{ + var carry = (this.regA << 8) & 0x100; + this.regA = (carry | this.regA) >> 1; + this.resultZeroCarry = (this.resultZeroCarry & 0xff) | carry; + this.nStepCycles -= 4; +}; + +/** + * op=0x11 (LXI D,d16) + * + * @this {CPUSim} + */ +CPUDef.opLXID = function() +{ + this.setDE(this.getPCWord()); + this.nStepCycles -= 10; +}; + +/** + * op=0x12 (STAX D) + * + * @this {CPUSim} + */ +CPUDef.opSTAXD = function() +{ + this.setByte(this.getDE(), this.regA); + this.nStepCycles -= 7; +}; + +/** + * op=0x13 (INX D) + * + * @this {CPUSim} + */ +CPUDef.opINXD = function() +{ + this.setDE(this.getDE() + 1); + this.nStepCycles -= 5; +}; + +/** + * op=0x14 (INR D) + * + * @this {CPUSim} + */ +CPUDef.opINRD = function() +{ + this.regD = this.incByte(this.regD); + this.nStepCycles -= 5; +}; + +/** + * op=0x15 (DCR D) + * + * @this {CPUSim} + */ +CPUDef.opDCRD = function() +{ + this.regD = this.decByte(this.regD); + this.nStepCycles -= 5; +}; + +/** + * op=0x16 (MVI D,d8) + * + * @this {CPUSim} + */ +CPUDef.opMVID = function() +{ + this.regD = this.getPCByte(); + this.nStepCycles -= 7; +}; + +/** + * op=0x17 (RAL) + * + * @this {CPUSim} + */ +CPUDef.opRAL = function() +{ + var carry = this.regA << 1; + this.regA = (carry & 0xff) | (this.resultZeroCarry >> 8); + this.resultZeroCarry = (this.resultZeroCarry & 0xff) | (carry & 0x100); + this.nStepCycles -= 4; +}; + +/** + * op=0x19 (DAD D) + * + * @this {CPUSim} + */ +CPUDef.opDADD = function() +{ + var w; + this.setHL(w = this.getHL() + this.getDE()); + this.resultZeroCarry = (this.resultZeroCarry & 0xff) | ((w >> 8) & 0x100); + this.nStepCycles -= 10; +}; + +/** + * op=0x1A (LDAX D) + * + * @this {CPUSim} + */ +CPUDef.opLDAXD = function() +{ + this.regA = this.getByte(this.getDE()); + this.nStepCycles -= 7; +}; + +/** + * op=0x1B (DCX D) + * + * @this {CPUSim} + */ +CPUDef.opDCXD = function() +{ + this.setDE(this.getDE() - 1); + this.nStepCycles -= 5; +}; + +/** + * op=0x1C (INR E) + * + * @this {CPUSim} + */ +CPUDef.opINRE = function() +{ + this.regE = this.incByte(this.regE); + this.nStepCycles -= 5; +}; + +/** + * op=0x1D (DCR E) + * + * @this {CPUSim} + */ +CPUDef.opDCRE = function() +{ + this.regE = this.decByte(this.regE); + this.nStepCycles -= 5; +}; + +/** + * op=0x1E (MVI E,d8) + * + * @this {CPUSim} + */ +CPUDef.opMVIE = function() +{ + this.regE = this.getPCByte(); + this.nStepCycles -= 7; +}; + +/** + * op=0x1F (RAR) + * + * @this {CPUSim} + */ +CPUDef.opRAR = function() +{ + var carry = (this.regA << 8) & 0x100; + this.regA = ((this.resultZeroCarry & 0x100) | this.regA) >> 1; + this.resultZeroCarry = (this.resultZeroCarry & 0xff) | carry; + this.nStepCycles -= 4; +}; + /** * opTBD() * @@ -173,12 +390,12 @@ CPUDef.opTBD = function() CPUDef.aOps = [ /* 0x00-0x03 */ CPUDef.opNOP, CPUDef.opLXIB, CPUDef.opSTAXB, CPUDef.opINXB, /* 0x04-0x07 */ CPUDef.opINRB, CPUDef.opDCRB, CPUDef.opMVIB, CPUDef.opRLC, - /* 0x08-0x0B */ CPUDef.opNOP, CPUDef.opDADB, CPUDef.opLDAXB, CPUDef.opTBD, - /* 0x0C-0x0F */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, - /* 0x10-0x13 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, - /* 0x14-0x17 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, - /* 0x18-0x1B */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, - /* 0x1C-0x1F */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, + /* 0x08-0x0B */ CPUDef.opNOP, CPUDef.opDADB, CPUDef.opLDAXB, CPUDef.opDCXB, + /* 0x0C-0x0F */ CPUDef.opINRC, CPUDef.opDCRC, CPUDef.opMVIC, CPUDef.opRRC, + /* 0x10-0x13 */ CPUDef.opNOP, CPUDef.opLXID, CPUDef.opSTAXD, CPUDef.opINXD, + /* 0x14-0x17 */ CPUDef.opINRD, CPUDef.opDCRD, CPUDef.opMVID, CPUDef.opRAL, + /* 0x18-0x1B */ CPUDef.opNOP, CPUDef.opDADD, CPUDef.opLDAXD, CPUDef.opDCXD, + /* 0x1C-0x1F */ CPUDef.opINRE, CPUDef.opDCRE, CPUDef.opMVIE, CPUDef.opRAR, /* 0x20-0x23 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, /* 0x24-0x27 */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, /* 0x28-0x2B */ CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, CPUDef.opTBD, diff --git a/modules/pc8080/lib/cpusim.js b/modules/pc8080/lib/cpusim.js index 6afaf34b2..afc620e51 100644 --- a/modules/pc8080/lib/cpusim.js +++ b/modules/pc8080/lib/cpusim.js @@ -345,12 +345,11 @@ CPUSim.prototype.setBinding = function(sHTMLType, sBinding, control, sValue) case "SP": case "PC": case "F": - case "CF": - case "PF": - case "AF": - case "ZF": case "SF": - case "VF": + case "ZF": + case "AF": + case "PF": + case "CF": this.bindings[sBinding] = control; this.cLiveRegs++; fBound = true; @@ -915,11 +914,11 @@ CPUSim.prototype.updateStatus = function(fForce) this.updateReg("PC", this.getPC(), 4); var regPS = this.getPS(); this.updateReg("F", regPS, 2); - this.updateReg("S", (regPS & CPUDef.PS.SF), 1); - this.updateReg("Z", (regPS & CPUDef.PS.ZF), 1); - this.updateReg("A", (regPS & CPUDef.PS.AF), 1); - this.updateReg("P", (regPS & CPUDef.PS.PF), 1); - this.updateReg("C", (regPS & CPUDef.PS.CF), 1); + this.updateReg("SF", (regPS & CPUDef.PS.SF), 1); + this.updateReg("ZF", (regPS & CPUDef.PS.ZF), 1); + this.updateReg("AF", (regPS & CPUDef.PS.AF), 1); + this.updateReg("PF", (regPS & CPUDef.PS.PF), 1); + this.updateReg("CF", (regPS & CPUDef.PS.CF), 1); } } var controlSpeed = this.bindings["speed"]; diff --git a/versions/pc8080/1.21.7/pc8080-dbg.js b/versions/pc8080/1.21.7/pc8080-dbg.js index d441d8a0a..805eab7f1 100644 --- a/versions/pc8080/1.21.7/pc8080-dbg.js +++ b/versions/pc8080/1.21.7/pc8080-dbg.js @@ -9,158 +9,160 @@ function ya(){return window?window.navigator.userAgent:""}function v(a){window&& function Ha(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(c){}return b}function Ia(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function Ja(a){if(window){var b=ya();return"iOS"==a&&b.match(/(iPod|iPhone|iPad)/)&&b.match(/AppleWebKit/)||"MSIE"==a&&b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)?!0:!1}return!1}function Ka(a,b,c){function d(){--a;0<=a&&(b()||(a=0));0=this.J?12:24>=this.J?14:15;this.Z=1<>2;this.s=this.Z-1;this.I=this.M/this.Z|0;this.L=this.I-1;this.C=[];this.D=[];this.F=this.H=!1;this.S=[];this.V=[];a=new H;zb(a,this.B);this.A=Array(this.I);for(b=0;b>>a.P;0a.Z?a.Z:c;if(f&&f.size){if(f.type==d){if(b+c<=f.u)return f.gb+=f.u-b,f.u=b,!0;if(b>=f.u+f.gb){h=f.size-(b-k);h>c&&(h=c);f.gb=b-f.u+h;c-=h;b=k+a.Z;continue}}return Bb(1,b,c)}f=a.A[e];b=new H(b,h,a.Z,d);zb(b,a.B,f);a.A[e++]=b;b=k+a.Z;c-=h}return 0>=c?!0:Bb(2,b,c)}function Cb(a,b){return a.A[(b&a.w)>>>a.P].eb(b&a.s,b)} -function Db(a,b){if(void 0===b)return a.F=!a.F,a.F;void 0===a.C[b]&&(a.C[b]=[null,!1]);a.C[b][1]=!a.C[b][1];return a.C[b][1]}function Qb(a,b){if(void 0===b)return a.H=!a.H,a.H;void 0===a.D[b]&&(a.D[b]=[null,!1]);a.D[b][1]=!a.D[b][1];return a.D[b][1]}function Bb(a,b,c){v("Memory block error ("+a+": "+n(b)+","+n(c)+")");return!1}var Rb;if(tb){var Sb=new ArrayBuffer(2);(new DataView(Sb)).setUint16(0,256,!0);Rb=256===(new Uint16Array(Sb))[0]}else Rb=!1;var Tb=Rb; -function H(a,b,c,d){this.id=Ub+=2;this.b=null;this.u=a;this.gb=b;this.size=c||0;this.type=d||Vb;this.F=d==Wb;zb(this);this.sa=this.Ub=!1;if(c)if(tb)this.C=new ArrayBuffer(c),this.D=new DataView(this.C,0,c),this.G=new Uint8Array(this.C,0,c),this.H=new Uint16Array(this.C,0,c>>1),this.b=new Int32Array(this.C,0,c>>2),Xb(this,Tb?Yb:Zb);else{this.b=Array(c>>2);for(a=0;a>2),b=0;b>8,c)},S:function(a){return this.b[a>>2]>>>((a&3)<<3)&255},ia:function(a){var b=a>>2;a=(a&3)<<3;var c=this.b[b]>>a;return 24>a?c&65535:c&255|(this.b[b+1]&255)<<8},va:function(a,b){var c=a>>2,d=(a&3)<<3;this.b[c]=this.b[c]&~(255<>2,d=(a&3)<<3;24>d?this.b[c]=this.b[c]&~(65535<>8);this.sa=!0},M:function(a,b){if(this.B&&null!=this.u){var c=this.B;ec(c,this.u+a,1,c.R)&&c.U(!0)}return this.eb(a,b)},aa:function(a,b){if(this.B&&null!=this.u){var c=this.B;ec(c,this.u+a,2,c.R)&&c.U(!0)}return this.tb(a,b)},ma:function(a,b,c){if(this.B&&null!=this.u){var d=this.B;ec(d,this.u+a,1,d.F)&&d.U(!0)}this.F?this.w(a,b,c):this.Ua(a,b,c)},Va:function(a,b, -c){if(this.B&&null!=this.u){var d=this.B;ec(d,this.u+a,2,d.F)&&d.U(!0)}this.F?this.w(a,b,c):this.Ob(a,b,c)},L:function(a){return this.G[a]},R:function(a){return this.G[a]},V:function(a){return this.D.getUint16(a,!0)},ca:function(a){return a&1?this.G[a]|this.G[a+1]<<8:this.H[a>>1]},ja:function(a,b){this.G[a]=b;this.sa=!0},ua:function(a,b){this.G[a]=b;this.sa=!0},Ga:function(a,b){this.D.setUint16(a,b,!0);this.sa=!0},Xa:function(a,b){a&1?(this.G[a]=b,this.G[a+1]=b>>8):this.H[a>>1]=b;this.sa=!0}}; -function zb(a,b,c){a.B=b;a.A=a.s=0;c&&((a.A=c.A)&&dc(a,cc,!1),(a.s=c.s)&&bc(a,cc,!1))}function fc(a,b){b?0===--a.s&&(a.mb=a.F?a.w:a.Ua):0===--a.A&&(a.Sa=a.eb,a.Lb=a.tb)}function bc(a,b,c){c&&a.s||(a.mb=!a.F&&b[2]||a.w);if(c||void 0===c)a.Ua=b[2]||a.w,a.Ob=b[3]||a.Wa}function dc(a,b,c){c&&a.A||(a.Sa=b[0]||a.I,a.Lb=b[1]||a.J);if(c||void 0===c)a.eb=b[0]||a.I,a.tb=b[1]||a.J}function Xb(a,b){b||(b=gc);dc(a,b,void 0);bc(a,b,void 0)} -var gc=[],$b=[H.prototype.S,H.prototype.ia,H.prototype.va,H.prototype.ib],cc=[H.prototype.M,H.prototype.aa,H.prototype.ma,H.prototype.Va];if(tb)var Zb=[H.prototype.L,H.prototype.V,H.prototype.ja,H.prototype.Ga],Yb=[H.prototype.R,H.prototype.ca,H.prototype.ua,H.prototype.Xa]; -function hc(a,b){x.call(this,"CPU",a,hc,1);var c=a.cycles||b,d=a.multiplier||1;this.i={};this.i.Ra=c;this.i.Ba=d;this.i.qb=Math.round(this.i.Ra/1E4)/100;this.i.za=this.i.qb*this.i.Ba;this.j.X=!1;this.j.pb=!1;this.j.Db=a.autoStart;this.j.Eb=!1;this.j.Ia=!1;this.i.Ya=this.i.Oa=0;this.i.Za=a.csStart;this.i.Na=a.csInterval;this.i.Pa=a.csStop;this.ca=this.Fa.bind(this);G(this)}z(hc);var ic=["power","reset"];g=hc.prototype; -g.La=function(a,b,c,d){this.s=a;this.A=b;this.B=d;for(b=0;b=a.i.Oa&&(a.i.Oa+=a.i.Na,c=!0);0<=a.i.Pa&&a.i.Pa<=pc(a)&&(a.i.Na=a.i.Pa=-1,lc(a),a.U(),c=!0);c&&a.g(pc(a)+" cycles: checksum="+n(a.i.Ya))}} -g.ea=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.G[b]=c;a=!0;break;case "run":this.G[b]=c;c.onclick=function(){var a;if(a=d.s)if(a=d.s,a.j.W)a=!0;else{var b=null,c,h=C(a.id);for(c=0;cc&&(c=60);2>c&&(c=2);var d=1;b&&1a.i.ya/a.i.za?b=1:d=!0;a.i.Ba=b;b=a.i.qb*a.i.Ba;if(a.i.za!=b){a.i.za=b;b=a.i.za.toFixed(2)+"Mhz";var e=a.G.setSpeed;e&&(e.textContent=b);a.g("target speed: "+b)}c&&a.s&&a.s.fb()}Qc(a,a.F);a.F=0;a.i.Ma=ua();a.i.Aa=0;Rc(a);return d} -g.Fa=function(a){if(pb(this,!0)){if(!this.j.X){qc(this);this.s&&this.s.start(this.i.Ma,pc(this));this.j.X=!0;this.j.pb=!0;this.w&&this.w.Zb();var b=this.G.run;b&&(b.textContent="Halt");this.s&&(this.s.fa(!0),a&&this.s.fb(!0))}this.i.sb>=this.i.Ra&&Rc(this,!0);this.i.bb=0;this.i.lb=ua();this.i.Aa&&(a=this.i.lb-this.i.Aa,a>this.i.Hb&&(this.i.Ma+=a,this.i.Ma>this.i.lb&&(this.i.Ma=this.i.lb)));try{do{var c=this.j.Ia?1:this.i.Yb;this.w&&(this.w.Nb(),c=this.w.ac(0,c),c=this.w.$b(c));try{this.Ta(c)}catch(e){if("number"!= -typeof e)throw e;}var d=this.D-this.b;this.F+=d;this.i.bb+=d;Qc(this,0,!0);oc(this,d);this.i.ab-=d;0>=this.i.ab&&(this.i.ab+=this.i.Jb);this.i.$a-=d;0>=this.i.$a&&(this.i.$a+=this.i.Ib,this.s&&this.s.fa());this.i.Qa-=d;if(0>=this.i.Qa){this.i.Qa+=this.i.rb;break}}while(this.j.X)}catch(e){this.U();I(this);this.s&&this.s.stop(ua(),pc(this));pb(this,!1);sb(this,e.stack||e.message);return}c=setTimeout;d=this.ca;this.i.Aa=ua();a=this.i.Hb;this.i.bb&&(a=Math.round(a*this.i.bb/this.i.rb));a-=this.i.Aa-this.i.lb; -if(b=this.i.Aa-this.i.Ma)this.i.ya=Math.round(this.F/(10*b))/100,864E5<=b&&(this.H=0,this.w&&this.w.Nb(!0),qc(this));if(0>a||this.i.ya>>a.P].Sa(b&a.I,b)}function Yc(a){var b=Xc(a,a.N);a.N=a.N+1&65535;return b}function N(a,b,c,d){d=d||2;a.G[b]&&(void 0===c&&(sb(a,"Value for "+b+" is invalid"),a.U()),c=!a.j.X||a.j.Eb?n(c,d):"--------".substr(0,d),a.G[b].textContent!=c&&(a.G[b].textContent=c))} -g.fa=function(a){this.V&&(a||!this.j.X||this.j.Eb)&&(N(this,"A",this.ha),N(this,"B",this.T),N(this,"C",this.da),N(this,"D",this.ta),N(this,"E",this.Ca),N(this,"H",this.la),N(this,"L",this.qa),N(this,"SP",this.Ea,4),N(this,"PC",this.N,4),a=Wc(this),N(this,"F",a,2),N(this,"S",a&128,1),N(this,"Z",a&64,1),N(this,"A",a&16,1),N(this,"P",a&4,1),N(this,"C",a&1,1));if(a=this.G.speed)a.textContent=this.j.X&&this.i.ya?this.i.ya.toFixed(2)+"Mhz":"Stopped"}; -g.Ta=function(a){this.j.jb=!0;var b=this.j.Tb=this.B&&Zc(this.B),c=a?this.j.pb?0:1:-1;this.j.pb=!1;this.D=this.b=a;this.w&&!a&&this.w.Nb();a||(this.J|=4);do{if(this.M&&this.M&4){this.J=this.b=0;break}if(b){if($c(this.B,this.N,c)){this.U();break}c=1}this.J=0;this.aa[Yc(this)].call(this)}while(0>>this.P;b>8&255;this.da=a&255;this.b-=10},function(){var a=this.T<<8|this.da;this.ga[(a&this.L)>>>this.P].mb(a&this.I,this.ha&255,a);this.b-=7},function(){var a=(this.T<<8|this.da)+1;this.T=a>>8&255;this.da=a&255;this.b-=5},function(){var a=this.T;this.C=a;a=(this.K=a+1)&255;this.O=this.O&-256|a;this.T=a;this.b-= -5},function(){var a=this.T;this.C=a;a=(this.K=a-1)&255;this.O=this.O&-256|a;this.T=a;this.b-=5},function(){this.T=Yc(this);this.b-=7},function(){var a=this.ha<<1;this.ha=a&255|a>>8;this.O=this.O&255|a&256;this.b-=4},ad,function(){var a,b=a=(this.la<<8|this.qa)+(this.T<<8|this.da);this.la=b>>8&255;this.qa=b&255;this.O=this.O&255|a>>8&256;this.b-=10},function(){this.ha=Xc(this,this.T<<8|this.da);this.b-=7},O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O, -O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O]; -function bd(a){x.call(this,"ROM",a,bd);this.s=null;this.F=a.addr;this.w=a.size;this.C=a.alias;this.D=a.file;this.H=ea(this.D);if(this.D){a=this.D;var b=fa(this.H);"json"!=b&&"hex"!=b&&(a=xa()+"/api/v1/dump?file="+this.D+"&format=bytes&decimal=true");var c=this;u(a,null,!0,function(a,b,f){cd(c,a,b,f)})}}z(bd);bd.prototype.La=function(a,b,c,d){this.A=b;this.b=c;this.B=d;dd(this)}; -bd.prototype.pa=function(){if(this.na){if(this.B){var a=this.B,b=this.id,c=this.F,d=this.w,e=this.na,f=[],k;for(k in e){var h=e[k];"number"==typeof h&&(e[k]=h={o:h});var l=h.o,m=h.a;if(void 0!==l){var p=f,l=[l>>>0,k],r=ta(p,l,a.wb);0>r&&p.splice(-(r+1),0,l)}m&&(h.a=m.replace(/''/g,'"'))}a.H.push({bc:b,u:c,Xb:d,na:e,xb:f})}delete this.na}return!0};bd.prototype.oa=function(){return!0}; -function cd(a,b,c,d){if(d)a.ba("Unable to load system ROM (error "+d+": "+b+")");else{kb(a.zb,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var e=eval("("+c+")"),f=e.bytes,k=e.data;if(f)a.s=f;else if(k)for(a.s=Array(4*k.length),d=c=0;c>8&255,a.s[d++]=k[c]>>16&255,a.s[d++]=k[c]>>24&255;else a.s=e;a.na=e.symbols;if(!a.s.length){v("Empty ROM: "+b);return}if(1==a.s.length){v(a.s[0]);return}}catch(h){a.ba("ROM data error: "+h.message);return}else for(b=c.replace(/\n/gm, -" ").replace(/ +$/,"").split(" "),a.s=Array(b.length),e=0;e>>d.P].Ua(e&d.s,a.s[c]&255,e)}b=!0}else b=!1;if(b){b=[];"number"==typeof a.C?b.push(a.C):null!=a.C&&a.C.length&&(b=a.C);for(c=0;c>>e.P;0>>=e.P;0=this.K?12:24>=this.K?14:15;this.Z=1<>2;this.s=this.Z-1;this.J=this.N/this.Z|0;this.L=this.J-1;this.C=[];this.D=[];this.F=this.H=!1;this.T=[];this.V=[];a=new H;zb(a,this.B);this.A=Array(this.J);for(b=0;b>>a.P;0a.Z?a.Z:c;if(f&&f.size){if(f.type==d){if(b+c<=f.u)return f.gb+=f.u-b,f.u=b,!0;if(b>=f.u+f.gb){h=f.size-(b-k);h>c&&(h=c);f.gb=b-f.u+h;c-=h;b=k+a.Z;continue}}return Bb(1,b,c)}f=a.A[e];b=new H(b,h,a.Z,d);zb(b,a.B,f);a.A[e++]=b;b=k+a.Z;c-=h}return 0>=c?!0:Bb(2,b,c)}function Cb(a,b){return a.A[(b&a.w)>>>a.P].eb(b&a.s,b)} +function Db(a,b){if(void 0===b)return a.F=!a.F,a.F;void 0===a.C[b]&&(a.C[b]=[null,!1]);a.C[b][1]=!a.C[b][1];return a.C[b][1]}function Eb(a,b){if(void 0===b)return a.H=!a.H,a.H;void 0===a.D[b]&&(a.D[b]=[null,!1]);a.D[b][1]=!a.D[b][1];return a.D[b][1]}function Bb(a,b,c){v("Memory block error ("+a+": "+n(b)+","+n(c)+")");return!1}var Fb;if(tb){var Gb=new ArrayBuffer(2);(new DataView(Gb)).setUint16(0,256,!0);Fb=256===(new Uint16Array(Gb))[0]}else Fb=!1;var Hb=Fb; +function H(a,b,c,d){this.id=Ib+=2;this.b=null;this.u=a;this.gb=b;this.size=c||0;this.type=d||Jb;this.F=d==Wb;zb(this);this.ua=this.Ub=!1;if(c)if(tb)this.C=new ArrayBuffer(c),this.D=new DataView(this.C,0,c),this.G=new Uint8Array(this.C,0,c),this.H=new Uint16Array(this.C,0,c>>1),this.b=new Int32Array(this.C,0,c>>2),Xb(this,Hb?Yb:Zb);else{this.b=Array(c>>2);for(a=0;a>2),b=0;b>8,c)},T:function(a){return this.b[a>>2]>>>((a&3)<<3)&255},ma:function(a){var b=a>>2;a=(a&3)<<3;var c=this.b[b]>>a;return 24>a?c&65535:c&255|(this.b[b+1]&255)<<8},wa:function(a,b){var c=a>>2,d=(a&3)<<3;this.b[c]=this.b[c]&~(255<>2,d=(a&3)<<3;24>d?this.b[c]=this.b[c]&~(65535<>8);this.ua=!0},N:function(a,b){if(this.B&&null!=this.u){var c=this.B;ec(c,this.u+a,1,c.R)&&c.U(!0)}return this.eb(a,b)},ca:function(a,b){if(this.B&&null!=this.u){var c=this.B;ec(c,this.u+a,2,c.R)&&c.U(!0)}return this.tb(a,b)},pa:function(a,b,c){if(this.B&&null!=this.u){var d=this.B;ec(d,this.u+a,1,d.F)&&d.U(!0)}this.F?this.w(a,b,c):this.Ua(a,b,c)},Va:function(a,b, +c){if(this.B&&null!=this.u){var d=this.B;ec(d,this.u+a,2,d.F)&&d.U(!0)}this.F?this.w(a,b,c):this.Ob(a,b,c)},L:function(a){return this.G[a]},R:function(a){return this.G[a]},V:function(a){return this.D.getUint16(a,!0)},ga:function(a){return a&1?this.G[a]|this.G[a+1]<<8:this.H[a>>1]},na:function(a,b){this.G[a]=b;this.ua=!0},va:function(a,b){this.G[a]=b;this.ua=!0},Ga:function(a,b){this.D.setUint16(a,b,!0);this.ua=!0},Xa:function(a,b){a&1?(this.G[a]=b,this.G[a+1]=b>>8):this.H[a>>1]=b;this.ua=!0}}; +function zb(a,b,c){a.B=b;a.A=a.s=0;c&&((a.A=c.A)&&dc(a,cc,!1),(a.s=c.s)&&bc(a,cc,!1))}function fc(a,b){b?0===--a.s&&(a.hb=a.F?a.w:a.Ua):0===--a.A&&(a.Sa=a.eb,a.Lb=a.tb)}function bc(a,b,c){c&&a.s||(a.hb=!a.F&&b[2]||a.w);if(c||void 0===c)a.Ua=b[2]||a.w,a.Ob=b[3]||a.Wa}function dc(a,b,c){c&&a.A||(a.Sa=b[0]||a.J,a.Lb=b[1]||a.K);if(c||void 0===c)a.eb=b[0]||a.J,a.tb=b[1]||a.K}function Xb(a,b){b||(b=gc);dc(a,b,void 0);bc(a,b,void 0)} +var gc=[],$b=[H.prototype.T,H.prototype.ma,H.prototype.wa,H.prototype.jb],cc=[H.prototype.N,H.prototype.ca,H.prototype.pa,H.prototype.Va];if(tb)var Zb=[H.prototype.L,H.prototype.V,H.prototype.na,H.prototype.Ga],Yb=[H.prototype.R,H.prototype.ga,H.prototype.va,H.prototype.Xa]; +function hc(a,b){x.call(this,"CPU",a,hc,1);var c=a.cycles||b,d=a.multiplier||1;this.i={};this.i.Ra=c;this.i.Ca=d;this.i.qb=Math.round(this.i.Ra/1E4)/100;this.i.Aa=this.i.qb*this.i.Ca;this.j.X=!1;this.j.pb=!1;this.j.Db=a.autoStart;this.j.Eb=!1;this.j.Ia=!1;this.i.Ya=this.i.Oa=0;this.i.Za=a.csStart;this.i.Na=a.csInterval;this.i.Pa=a.csStop;this.ga=this.Fa.bind(this);G(this)}z(hc);var ic=["power","reset"];g=hc.prototype; +g.La=function(a,b,c,d){this.s=a;this.A=b;this.B=d;for(b=0;b=a.i.Oa&&(a.i.Oa+=a.i.Na,c=!0);0<=a.i.Pa&&a.i.Pa<=pc(a)&&(a.i.Na=a.i.Pa=-1,lc(a),a.U(),c=!0);c&&a.g(pc(a)+" cycles: checksum="+n(a.i.Ya))}} +g.ha=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.G[b]=c;a=!0;break;case "run":this.G[b]=c;c.onclick=function(){var a;if(a=d.s)if(a=d.s,a.j.W)a=!0;else{var b=null,c,h=C(a.id);for(c=0;cc&&(c=60);2>c&&(c=2);var d=1;b&&1a.i.za/a.i.Aa?b=1:d=!0;a.i.Ca=b;b=a.i.qb*a.i.Ca;if(a.i.Aa!=b){a.i.Aa=b;b=a.i.Aa.toFixed(2)+"Mhz";var e=a.G.setSpeed;e&&(e.textContent=b);a.g("target speed: "+b)}c&&a.s&&a.s.fb()}rc(a,a.F);a.F=0;a.i.Ma=ua();a.i.Ba=0;sc(a);return d} +g.Fa=function(a){if(pb(this,!0)){if(!this.j.X){qc(this);this.s&&this.s.start(this.i.Ma,pc(this));this.j.X=!0;this.j.pb=!0;this.w&&this.w.Zb();var b=this.G.run;b&&(b.textContent="Halt");this.s&&(this.s.ka(!0),a&&this.s.fb(!0))}this.i.sb>=this.i.Ra&&sc(this,!0);this.i.bb=0;this.i.mb=ua();this.i.Ba&&(a=this.i.mb-this.i.Ba,a>this.i.Hb&&(this.i.Ma+=a,this.i.Ma>this.i.mb&&(this.i.Ma=this.i.mb)));try{do{var c=this.j.Ia?1:this.i.Yb;this.w&&(this.w.Nb(),c=this.w.ac(0,c),c=this.w.$b(c));try{this.Ta(c)}catch(e){if("number"!= +typeof e)throw e;}var d=this.D-this.b;this.F+=d;this.i.bb+=d;rc(this,0,!0);oc(this,d);this.i.ab-=d;0>=this.i.ab&&(this.i.ab+=this.i.Jb);this.i.$a-=d;0>=this.i.$a&&(this.i.$a+=this.i.Ib,this.s&&this.s.ka());this.i.Qa-=d;if(0>=this.i.Qa){this.i.Qa+=this.i.rb;break}}while(this.j.X)}catch(e){this.U();I(this);this.s&&this.s.stop(ua(),pc(this));pb(this,!1);sb(this,e.stack||e.message);return}c=setTimeout;d=this.ga;this.i.Ba=ua();a=this.i.Hb;this.i.bb&&(a=Math.round(a*this.i.bb/this.i.rb));a-=this.i.Ba-this.i.mb; +if(b=this.i.Ba-this.i.Ma)this.i.za=Math.round(this.F/(10*b))/100,864E5<=b&&(this.J=0,this.w&&this.w.Nb(!0),qc(this));if(0>a||this.i.za>8&255;a.ea=b&255}function Zc(a){return a.ba<<8|a.fa}function $c(a,b){a.ba=b>>8&255;a.fa=b&255} +function xc(a){return a.Da&-214|(a.M&128?128:0)|(a.I&255?0:64)|((a.M^a.C)&16?16:0)|(ub[a.M&255]?4:0)|(a.I&256?1:0)}function wc(a,b){a.I=a.M=a.C=0;b&1&&(a.I|=256);b&4||(a.M|=1);b&16&&(a.C|=16);b&64||(a.I|=255);b&128&&(a.M^=192);a.Da=a.Da&-513|b&512|2}function ad(a,b){a.C=b;b=(a.M=b+1)&255;a.I=a.I&-256|b;return b}function bd(a,b){a.C=b;b=(a.M=b-1)&255;a.I=a.I&-256|b;return b}function cd(a,b){return a.ia[(b&a.K)>>>a.P].Sa(b&a.H,b)}function dd(a){var b=cd(a,a.O);a.O=a.O+1&65535;return b} +function ed(a){var b;b=a.O;var c=b&a.H,d=(b&a.K)>>>a.P;c>>this.P].hb(a&this.H,this.S&255,a);this.b-=7},function(){zc(this,yc(this)+1);this.b-=5},function(){this.aa=ad(this,this.aa);this.b-=5},function(){this.aa=bd(this,this.aa);this.b-=5},function(){this.aa=dd(this);this.b-=7},function(){var a=this.S<<1;this.S=a&255|a>>8;this.I=this.I&255|a&256;this.b-=4},hd,function(){var a,b=a=(this.ja<<8|this.la)+yc(this);this.ja=b>>8&255;this.la=b&255;this.I=this.I&255| +a>>8&256;this.b-=10},function(){this.S=cd(this,yc(this));this.b-=7},function(){zc(this,yc(this)-1);this.b-=5},function(){this.ea=ad(this,this.ea);this.b-=5},function(){this.ea=bd(this,this.ea);this.b-=5},function(){this.ea=dd(this);this.b-=7},function(){var a=this.S<<8&256;this.S=(a|this.S)>>1;this.I=this.I&255|a;this.b-=4},hd,function(){$c(this,ed(this));this.b-=10},function(){var a=Zc(this);this.ia[(a&this.K)>>>this.P].hb(a&this.H,this.S&255,a);this.b-=7},function(){$c(this,Zc(this)+1);this.b-= +5},function(){this.ba=ad(this,this.ba);this.b-=5},function(){this.ba=bd(this,this.ba);this.b-=5},function(){this.ba=dd(this);this.b-=7},function(){var a=this.S<<1;this.S=a&255|this.I>>8;this.I=this.I&255|a&256;this.b-=4},hd,function(){var a,b=a=(this.ja<<8|this.la)+Zc(this);this.ja=b>>8&255;this.la=b&255;this.I=this.I&255|a>>8&256;this.b-=10},function(){this.S=cd(this,Zc(this));this.b-=7},function(){$c(this,Zc(this)-1);this.b-=5},function(){this.fa=ad(this,this.fa);this.b-=5},function(){this.fa=bd(this, +this.fa);this.b-=5},function(){this.fa=dd(this);this.b-=7},function(){var a=this.S<<8&256;this.S=(this.I&256|this.S)>>1;this.I=this.I&255|a;this.b-=4},O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O, +O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O];function id(a){x.call(this,"ROM",a,id);this.s=null;this.F=a.addr;this.w=a.size;this.C=a.alias;this.D=a.file;this.H=ea(this.D);if(this.D){a=this.D;var b=fa(this.H);"json"!=b&&"hex"!=b&&(a=xa()+"/api/v1/dump?file="+this.D+"&format=bytes&decimal=true");var c=this;u(a,null,!0,function(a,b,f){jd(c,a,b,f)})}}z(id);id.prototype.La=function(a,b,c,d){this.A=b;this.b=c;this.B=d;kd(this)}; +id.prototype.sa=function(){if(this.qa){if(this.B){var a=this.B,b=this.id,c=this.F,d=this.w,e=this.qa,f=[],k;for(k in e){var h=e[k];"number"==typeof h&&(e[k]=h={o:h});var l=h.o,m=h.a;if(void 0!==l){var p=f,l=[l>>>0,k],r=ta(p,l,a.wb);0>r&&p.splice(-(r+1),0,l)}m&&(h.a=m.replace(/''/g,'"'))}a.H.push({bc:b,u:c,Xb:d,qa:e,xb:f})}delete this.qa}return!0};id.prototype.ra=function(){return!0}; +function jd(a,b,c,d){if(d)a.da("Unable to load system ROM (error "+d+": "+b+")");else{ab(a.zb,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var e=eval("("+c+")"),f=e.bytes,k=e.data;if(f)a.s=f;else if(k)for(a.s=Array(4*k.length),d=c=0;c>8&255,a.s[d++]=k[c]>>16&255,a.s[d++]=k[c]>>24&255;else a.s=e;a.qa=e.symbols;if(!a.s.length){v("Empty ROM: "+b);return}if(1==a.s.length){v(a.s[0]);return}}catch(h){a.da("ROM data error: "+h.message);return}else for(b=c.replace(/\n/gm, +" ").replace(/ +$/,"").split(" "),a.s=Array(b.length),e=0;e>>d.P].Ua(e&d.s,a.s[c]&255,e)}b=!0}else b=!1;if(b){b=[];"number"==typeof a.C?b.push(a.C):null!=a.C&&a.C.length&&(b=a.C);for(c=0;c>>e.P;0>>=e.P;0Missing <canvas> support. Please try a newer web browser.";break}e.setAttribute("class","pcjs-canvas");e.setAttribute("width",d.screenWidth);e.setAttribute("height",d.screenHeight);e.style.backgroundColor=d.screenColor;e.style.height="auto";0<=ya().indexOf("MSIE")&&(c.onresize=function(a,b,c,d){return function(){b.style.height= -(a.clientWidth*d/c|0)+"px"}}(c,e,d.screenWidth,d.screenHeight),c.onresize());var f=+(d.aspect||Va.aspect);f&&.3<=f&&3.33>=f&&(Pa("onresize",function(a,b,c){return function(){b.style.height=(a.clientWidth/c|0)+"px"}}(c,e,f)),window.onresize());c.appendChild(e);f=document.createElement("textarea");Ja("iOS")&&(f.setAttribute("autocapitalize","off"),f.setAttribute("autocorrect","off"));c.appendChild(f);e.getContext("2d");d=new gd(d);mb(d,c)}}); -function hd(a){x.call(this,"Debugger",a,hd);this.V=this.Ga=this.J=0;this.M=P();this.yb=P();this.D=-1;this.C=[];this.ia=!1;this.aa=P();this.H=[];this.ca={};this.w=this.R=this.F=[];id(this);this.ua=0;jd(this);this.Va=[];kd(this,a.messages);this.Xa=a.commands;var b=this;window?void 0===window.$&&(window.$=function(a){return mc(b,a)}):void 0===global.$&&(global.$=function(a){return mc(b,a)})}z(hd); -var ld={"?":"help/print","a [#]":"assemble","b [#]":"breakpoint",c:"clear output","d [#]":"dump memory","e [#]":"edit memory",f:"frequencies","g [#]":"go [to #]",h:"halt","i [#]":"input port #","if":"eval expression",k:"stack trace",ln:"list nearest symbol(s)",m:"messages","o [#]":"output port #",p:"step over",print:"print expression",r:"dump/set registers",reset:"reset machine","t [#]":"trace","u [#]":"unassemble",x:"execution options",v:"print version","var":"assign variable"},md="NONE ACI ADC ADD ADI ANA ANI CALL CC CM CNC CNZ CP CPE CPO CZ CMA CMC CMP CPI DAA DAD DCR DCX DI EI HLT IN INR INX JMP JC JM JNC JNZ JP JPE JPO JZ LDA LDAX LHLD LXI MOV MVI NOP ORA ORI OUT PCHL POP PUSH RAL RAR RET RC RM RNC RNZ RP RPE RPO RZ RLC RRC RST SBB SBI SHLD SPHL STA STAX STC SUB SUI XCHG XRA XRI XTHL".split(" "), -nd="B C D E H L M A F BC DE HL PSW SP PC".split(" "),od=[[45],[42,2323,32],[71,2387],[29,2323],[28,17],[22,17],[44,17,32],[63],[45,32768],[21,6419],[40,2387],[23,2323],[28,273],[22,273],[44,273,32],[64],[45,32768],[42,2579,32],[71,2643],[29,2579],[28,529],[22,529],[44,529,32],[52],[45,32768],[21,6675],[40,2643],[23,2579],[28,785],[22,785],[44,785,32],[53],[45,32768],[42,2835,32],[68,99],[29,2835],[28,1041],[22,1041],[44,1041,32],[20],[45,32768],[21,6931],[41,99],[23,2835],[28,1297],[22,1297],[44, +(a.clientWidth*d/c|0)+"px"}}(c,e,d.screenWidth,d.screenHeight),c.onresize());var f=+(d.aspect||Va.aspect);f&&.3<=f&&3.33>=f&&(Pa("onresize",function(a,b,c){return function(){b.style.height=(a.clientWidth/c|0)+"px"}}(c,e,f)),window.onresize());c.appendChild(e);f=document.createElement("textarea");Ja("iOS")&&(f.setAttribute("autocapitalize","off"),f.setAttribute("autocorrect","off"));c.appendChild(f);e.getContext("2d");d=new nd(d);mb(d,c)}}); +function od(a){x.call(this,"Debugger",a,od);this.V=this.Ga=this.K=0;this.N=P();this.yb=P();this.D=-1;this.C=[];this.ma=!1;this.ca=P();this.H=[];this.ga={};this.w=this.R=this.F=[];pd(this);this.va=0;qd(this);this.Va=[];rd(this,a.messages);this.Xa=a.commands;var b=this;window?void 0===window.$&&(window.$=function(a){return mc(b,a)}):void 0===global.$&&(global.$=function(a){return mc(b,a)})}z(od); +var sd={"?":"help/print","a [#]":"assemble","b [#]":"breakpoint",c:"clear output","d [#]":"dump memory","e [#]":"edit memory",f:"frequencies","g [#]":"go [to #]",h:"halt","i [#]":"input port #","if":"eval expression",k:"stack trace",ln:"list nearest symbol(s)",m:"messages","o [#]":"output port #",p:"step over",print:"print expression",r:"dump/set registers",reset:"reset machine","t [#]":"trace","u [#]":"unassemble",x:"execution options",v:"print version","var":"assign variable"},td="NONE ACI ADC ADD ADI ANA ANI CALL CC CM CNC CNZ CP CPE CPO CZ CMA CMC CMP CPI DAA DAD DCR DCX DI EI HLT IN INR INX JMP JC JM JNC JNZ JP JPE JPO JZ LDA LDAX LHLD LXI MOV MVI NOP ORA ORI OUT PCHL POP PUSH RAL RAR RET RC RM RNC RNZ RP RPE RPO RZ RLC RRC RST SBB SBI SHLD SPHL STA STAX STC SUB SUI XCHG XRA XRI XTHL".split(" "), +ud="B C D E H L M A F BC DE HL PSW SP PC".split(" "),vd=[[45],[42,2323,32],[71,2387],[29,2323],[28,17],[22,17],[44,17,32],[63],[45,32768],[21,6419],[40,2387],[23,2323],[28,273],[22,273],[44,273,32],[64],[45,32768],[42,2579,32],[71,2643],[29,2579],[28,529],[22,529],[44,529,32],[52],[45,32768],[21,6675],[40,2643],[23,2579],[28,785],[22,785],[44,785,32],[53],[45,32768],[42,2835,32],[68,99],[29,2835],[28,1041],[22,1041],[44,1041,32],[20],[45,32768],[21,6931],[41,99],[23,2835],[28,1297],[22,1297],[44, 1297,32],[16],[45,32768],[42,3347,32],[70,97],[29,3347],[28,1553],[22,1553],[44,1553,32],[72],[45,32768],[21,7443],[39,97],[23,3347],[28,1809],[22,1809],[44,1809,32],[17],[43,17,17],[43,17,273],[43,17,529],[43,17,785],[43,17,1041],[43,17,1297],[43,17,1553],[43,17,1809],[43,273,17],[43,273,273],[43,273,529],[43,273,785],[43,273,1041],[43,273,1297],[43,273,1553],[43,273,1809],[43,529,17],[43,529,273],[43,529,529],[43,529,785],[43,529,1041],[43,529,1297],[43,529,1553],[43,529,1809],[43,785,17],[43,785, 273],[43,785,529],[43,785,785],[43,785,1041],[43,785,1297],[43,785,1553],[43,785,1809],[43,1041,17],[43,1041,273],[43,1041,529],[43,1041,785],[43,1041,1041],[43,1041,1297],[43,1041,1553],[43,1041,1809],[43,1297,17],[43,1297,273],[43,1297,529],[43,1297,785],[43,1297,1041],[43,1297,1297],[43,1297,1553],[43,1297,1809],[43,1553,17],[43,1553,273],[43,1553,529],[43,1553,785],[43,1553,1041],[43,1553,1297],[43,1553,1553],[43,1553,1809],[43,1809,17],[43,1809,273],[43,1809,529],[43,1809,785],[43,1809,1041], [43,1809,1297],[43,1809,1553],[43,1809,1809],[3,17],[3,273],[3,529],[3,785],[3,1041],[3,1297],[3,1553],[3,1809],[2,17],[2,273],[2,529],[2,785],[2,1041],[2,1297],[2,1553],[2,1809],[73,17],[73,273],[73,529],[73,785],[73,1041],[73,1297],[73,1553],[73,1809],[66,17],[66,273],[66,529],[66,785],[66,1041],[66,1297],[66,1553],[66,1809],[5,17],[5,273],[5,529],[5,785],[5,1041],[5,1297],[5,1553],[5,1809],[76,17],[76,273],[76,529],[76,785],[76,1041],[76,1297],[76,1553],[76,1809],[46,17],[46,273],[46,529],[46, 785],[46,1041],[46,1297],[46,1553],[46,1809],[18,17],[18,273],[18,529],[18,785],[18,1041],[18,1297],[18,1553],[18,1809],[58],[50,2323],[34,35],[30,35],[11,35],[51,2323],[4,33],[65],[62],[54],[38,35],[30,32803],[15,35],[7,35],[1,33],[65],[57],[50,2579],[33,35],[48,33],[10,35],[51,2579],[74,33],[65],[55],[54,32768],[31,35],[27,33],[8,35],[7,32803],[67,33],[65],[61],[50,2835],[37,35],[78],[14,35],[51,2835],[6,33],[65],[60],[49],[36,35],[75],[13,35],[7,32803],[77,33],[65],[59],[50,3091],[35,35],[24], -[12,35],[51,3091],[47,33],[65],[56],[69],[32,35],[25],[9,35],[7,32803],[19,33],[65]],Q={cpu:1,bus:64,mem:128,port:256,timer:2048,keyboard:65536,key:131072,video:262144,fdc:524288,disk:2097152,serial:8388608,speaker:33554432,computer:67108864,log:536870912,warn:1073741824,halt:-2147483648};g=hd.prototype; -g.La=function(a,b,c,d){this.A=b;this.b=c;this.s=a;(a=jc(a,"messages"))&&kd(this,a);this.ib=od;pd(this,function(a){a:{var b=d.b.ga,c=a[0],h=a=0,l=b.length;if(c){a=T(U(d,c));if(-1===a){d.g("invalid address: "+c);break a}h=a>>>d.b.P;l=1}d.g("blockid physical blockaddr used size type");d.g("-------- --------- ---------- ------ ------ ----");for(var c=-1,m=0;l--;){var p=b[h];p.type==c?m++||d.g("..."):(c=p.type,m=ac[c],p&&d.g(n(p.id)+" %"+n(h<>>c.P,c=e!=c.s?c.A[f].tb(e,d):c.A[f++].eb(e,d)|c.A[f&c.L].eb(0,d+1)<<8;b&&qd(a,b)}return c}; -g.ub=function(a,b,c){var d=T(a);if(-1!==d){var e=this.A;e.A[(d&e.w)>>>e.P].Ua(d&e.s,b&255,d);c&&qd(a,c);I(this.b,!0)}};g.Pb=function(a,b,c){var d=T(a);if(-1!==d){var e=this.A,f=d&e.s,k=(d&e.w)>>>e.P;f!=e.s?e.A[k].Ob(f,b&65535,d):(e.A[k++].Ua(f,b&255,d),e.A[k&e.L].Ua(0,b>>8&255,d+1));c&&qd(a,c);I(this.b,!0)}};function P(a){return{u:a||0,ka:!1}}function rd(a){return[a.u,a.ka]}function sd(a){return{u:a[0],ka:a[1]}} -function U(a,b,c){var d;c=(c?a.M:a.yb).u;if(void 0!==b){d=b=td(a,b);var e;if(d.match(/^[a-z_][a-z0-9_]*$/i))for(d=d.toUpperCase(),c=0;cc&&(c=wa(nd,a.substr(b,2))));return c}function zd(a,b){var c=0,d=Ad(a,b);if(void 0!==d)switch(b){case 7:case 0:case 1:case 2:case 3:case 4:case 5:case 8:c=2;break;case 9:case 10:case 11:case 12:case 13:case 14:c=4}return c?n(d,c):"??"} -function Ad(a,b){var c;if(0<=b){var d=a.b;switch(b){case 7:c=d.ha;break;case 8:c=Wc(d)&255;break;case 0:c=d.T;break;case 1:c=d.da;break;case 9:c=d.T<<8|d.da;break;case 2:c=d.ta;break;case 3:c=d.Ca;break;case 10:c=d.ta<<8|d.Ca;break;case 4:c=d.la;break;case 5:c=d.qa;break;case 11:c=d.la<<8|d.qa;break;case 12:c=d.ha<<8|Wc(d)&255;break;case 13:c=d.Ea;break;case 14:c=d.N}}return c} -function Bd(a,b){b=td(a,b);for(var c=0,d,e;0<=(c=b.indexOf("@",c));)e=yd(b,c+1),0<=e&&(b=b.substr(0,c)+zd(a,e)+b.substr(c+1+nd[e].length)),c++;for(c=0;0<=(c=b.indexOf("#",c));)e=b.substr(c+1,2),d=da(e,16),null!=d&&32<=d&&128>d?(d=e+" '"+String.fromCharCode(d)+"'",b=b.replace("#"+e,d),c+=d.length):c++;for(c=0;0<=(c=b.indexOf("$",c));)e=b.substr(c+1,9),(d=U(a,e))?(d=e+' "'+xd(a,d)+'"',b=b.replace("$"+e,d),c+=d.length):c++;for(c=0;0<=(c=b.indexOf("^",c));)e=b.substr(c+1,9),(d=U(a,e))?(qd(d),d=e+' "'+ -xd(a,d,11)+'"',b=b.replace("^"+e,d),c+=d.length):c++;return b}g.message=function(a,b){b&&(a+=" at "+n(P(this.b.N).u,4));if(!this.va||a!=this.va)if(this.va=a,this.Y&-2147483648&&(this.U(),a+=" (cpu halted)"),this.g(a),this.b){var c=this.b;c.i.Qa=0;c.D-=c.b;c.b=0;I(c)}};function Cd(a,b,c,d){a.message(b.Wa+"."+(null!=d?"outPort":"inPort")+"("+q(c)+",unknown"+(null!=d?",0x"+n(d,2):"")+")")} -function jd(a){var b;if(Zc(a)){if(!a.L||!a.L.length){a.L=Array(1E3);for(b=0;b>>d.P],!1)}a.R=["br"];if(void 0!==a.F)for(b=1;b>>d.P],!0);a.F=["bw"];a.Ab=0}g.wa=function(a,b,c){var d=!0;c||Jd(this,a,b,!1,!0);if(a!=this.w){var e=T(b);if(-1===e)this.g("invalid address: "+n(b.u,4)),d=!1;else{var f=this.b;f.ga[e>>>f.P].wa(e&f.I,a==this.F)}}d&&(a.push(b),c?b.ka=!0:(Kd(this,a,a.length-1,"set"),jd(this)));return d}; -function Jd(a,b,c,d,e){var f=!1;c=T(c);for(var k=1;k>>d.P],b==a.F));h.ka||jd(a);break}}return f}function Ld(a,b){for(var c=1;c>24,4);break;case 3:B=n(r.hb(K,2),4);break;default:B="imm("+q(t)+")"}r=B}else 16==K&&(r=nd[(t&3840)>>8]);if(!r||!r.length){f="INVALID";break}0=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9}; -function Qd(a,b,c){for(c=c||-1;c--&&b.length;){var d=b.pop();if(2>a.length)return!1;var e=a.pop(),f=a.pop();switch(d){case "*":d=f*e;break;case "/":if(!e)return!1;d=f/e;break;case "%":if(!e)return!1;d=f%e;break;case "+":d=f+e;break;case "-":d=f-e;break;case "<<":d=f<>":d=f>>e;break;case ">>>":d=f>>>e;break;case "<":d=f":d=f>e?1:0;break;case ">=":d=f>=e?1:0;break;case "==":d=f==e?1:0;break;case "!=":d=f!=e?1:0;break;case "&":d=f&e;break; +[12,35],[51,3091],[47,33],[65],[56],[69],[32,35],[25],[9,35],[7,32803],[19,33],[65]],Q={cpu:1,bus:64,mem:128,port:256,timer:2048,keyboard:65536,key:131072,video:262144,fdc:524288,disk:2097152,serial:8388608,speaker:33554432,computer:67108864,log:536870912,warn:1073741824,halt:-2147483648};g=od.prototype; +g.La=function(a,b,c,d){this.A=b;this.b=c;this.s=a;(a=jc(a,"messages"))&&rd(this,a);this.jb=vd;wd(this,function(a){a:{var b=d.b.ia,c=a[0],h=a=0,l=b.length;if(c){a=T(U(d,c));if(-1===a){d.g("invalid address: "+c);break a}h=a>>>d.b.P;l=1}d.g("blockid physical blockaddr used size type");d.g("-------- --------- ---------- ------ ------ ----");for(var c=-1,m=0;l--;){var p=b[h];p.type==c?m++||d.g("..."):(c=p.type,m=ac[c],p&&d.g(n(p.id)+" %"+n(h<>>c.P,c=e!=c.s?c.A[f].tb(e,d):c.A[f++].eb(e,d)|c.A[f&c.L].eb(0,d+1)<<8;b&&xd(a,b)}return c}; +g.ub=function(a,b,c){var d=T(a);if(-1!==d){var e=this.A;e.A[(d&e.w)>>>e.P].Ua(d&e.s,b&255,d);c&&xd(a,c);I(this.b,!0)}};g.Pb=function(a,b,c){var d=T(a);if(-1!==d){var e=this.A,f=d&e.s,k=(d&e.w)>>>e.P;f!=e.s?e.A[k].Ob(f,b&65535,d):(e.A[k++].Ua(f,b&255,d),e.A[k&e.L].Ua(0,b>>8&255,d+1));c&&xd(a,c);I(this.b,!0)}};function P(a){return{u:a||0,oa:!1}}function yd(a){return[a.u,a.oa]}function zd(a){return{u:a[0],oa:a[1]}} +function U(a,b,c){var d;c=(c?a.N:a.yb).u;if(void 0!==b){d=b=Ad(a,b);var e;if(d.match(/^[a-z_][a-z0-9_]*$/i))for(d=d.toUpperCase(),c=0;cc&&(c=wa(ud,a.substr(b,2))));return c}function Gd(a,b){var c=0,d=Hd(a,b);if(void 0!==d)switch(b){case 7:case 0:case 1:case 2:case 3:case 4:case 5:case 8:c=2;break;case 9:case 10:case 11:case 12:case 13:case 14:c=4}return c?n(d,c):"??"} +function Hd(a,b){var c;if(0<=b){var d=a.b;switch(b){case 7:c=d.S;break;case 8:c=xc(d)&255;break;case 0:c=d.aa;break;case 1:c=d.ea;break;case 9:c=d.aa<<8|d.ea;break;case 2:c=d.ba;break;case 3:c=d.fa;break;case 10:c=d.ba<<8|d.fa;break;case 4:c=d.ja;break;case 5:c=d.la;break;case 11:c=d.ja<<8|d.la;break;case 12:c=d.S<<8|xc(d)&255;break;case 13:c=d.Ea;break;case 14:c=d.O}}return c} +function Id(a,b){b=Ad(a,b);for(var c=0,d,e;0<=(c=b.indexOf("@",c));)e=Fd(b,c+1),0<=e&&(b=b.substr(0,c)+Gd(a,e)+b.substr(c+1+ud[e].length)),c++;for(c=0;0<=(c=b.indexOf("#",c));)e=b.substr(c+1,2),d=da(e,16),null!=d&&32<=d&&128>d?(d=e+" '"+String.fromCharCode(d)+"'",b=b.replace("#"+e,d),c+=d.length):c++;for(c=0;0<=(c=b.indexOf("$",c));)e=b.substr(c+1,9),(d=U(a,e))?(d=e+' "'+Ed(a,d)+'"',b=b.replace("$"+e,d),c+=d.length):c++;for(c=0;0<=(c=b.indexOf("^",c));)e=b.substr(c+1,9),(d=U(a,e))?(xd(d),d=e+' "'+ +Ed(a,d,11)+'"',b=b.replace("^"+e,d),c+=d.length):c++;return b}g.message=function(a,b){b&&(a+=" at "+n(P(this.b.O).u,4));if(!this.wa||a!=this.wa)if(this.wa=a,this.Y&-2147483648&&(this.U(),a+=" (cpu halted)"),this.g(a),this.b){var c=this.b;c.i.Qa=0;c.D-=c.b;c.b=0;I(c)}};function Jd(a,b,c,d){a.message(b.Wa+"."+(null!=d?"outPort":"inPort")+"("+q(c)+",unknown"+(null!=d?",0x"+n(d,2):"")+")")} +function qd(a){var b;if(fd(a)){if(!a.L||!a.L.length){a.L=Array(1E3);for(b=0;b>>d.P],!1)}a.R=["br"];if(void 0!==a.F)for(b=1;b>>d.P],!0);a.F=["bw"];a.Ab=0}g.xa=function(a,b,c){var d=!0;c||Qd(this,a,b,!1,!0);if(a!=this.w){var e=T(b);if(-1===e)this.g("invalid address: "+n(b.u,4)),d=!1;else{var f=this.b;f.ia[e>>>f.P].xa(e&f.H,a==this.F)}}d&&(a.push(b),c?b.oa=!0:(Rd(this,a,a.length-1,"set"),qd(this)));return d}; +function Qd(a,b,c,d,e){var f=!1;c=T(c);for(var k=1;k>>d.P],b==a.F));h.oa||qd(a);break}}return f}function Sd(a,b){for(var c=1;c>24,4);break;case 3:B=n(r.ib(K,2),4);break;default:B="imm("+q(t)+")"}r=B}else 16==K&&(r=ud[(t&3840)>>8]);if(!r||!r.length){f="INVALID";break}0=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9}; +function Xd(a,b,c){for(c=c||-1;c--&&b.length;){var d=b.pop();if(2>a.length)return!1;var e=a.pop(),f=a.pop();switch(d){case "*":d=f*e;break;case "/":if(!e)return!1;d=f/e;break;case "%":if(!e)return!1;d=f%e;break;case "+":d=f+e;break;case "-":d=f-e;break;case "<<":d=f<>":d=f>>e;break;case ">>>":d=f>>>e;break;case "<":d=f":d=f>e?1:0;break;case ">=":d=f>=e?1:0;break;case "==":d=f==e?1:0;break;case "!=":d=f!=e?1:0;break;case "&":d=f&e;break; case "^":d=f^e;break;case "|":d=f|e;break;case "&&":d=f&&e?1:0;break;case "||":d=f||e?1:0;break;default:return!1}a.push(d|0)}return!0} -function ud(a,b,c){var d;if(b){b=td(a,b);for(var e=0,f=!1,k=b,h=[],l=[],m=b.split(/(\|\||&&|\||^|&|!=|==|>=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*)/);e>=1;k=p+"b"+k;d>>=8}d="0x"+n(c)+" "+c+". ("+k+")"}a.g((null!=b?b+": ":"")+d);return e}function se(a,b){if(b)return re(a,b,a.ca[b]);var c=0;for(b in a.ca)re(a,b,a.ca[b]),c++;return 0b[0]?1:a[0]>>0;for(b=0;b>>0,h=f.Xb;if(e>=k&&eh[0].indexOf("+"))){var m=h[0]+":";h[2]&&(m+=" "+h[2]);a.g(m)}h[3]&&(k=h[3],f=null);f=Nd(a,b,k,f);a.g(f);a.M=b;e-=b.u-l;c++}}} -function wd(a,b,c,d){if(c)if(b){0>a.D&&a.C.length&&(a.D=0);if(0>a.D||b!=a.C[a.D])a.C.splice(0,0,b),a.D=0;a.D--}else b=a.C[a.D+1];a=[];if(b){b=b.toLowerCase().replace(/""/g,"'");c=0;var e=null;d=d||";";for(var f=0;f<=b.length;f++){var k=b.charAt(f);if('"'==k||"'"==k)e?k==e&&(e=null):e=k;else if(k==d&&!e||!k)a.push(sa(b.substring(c,f))),c=f+1}}return a} -function Md(a,b,c){var d=!0;try{b.length&&"end"!=b?c||a.g(">> "+b):(a.ia&&(a.g("ended assemble at "+n(a.aa.u,4)),a.M=a.aa,a.ia=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.va=null;if(rb(a)&&0m||"z"aa.length&&(a.g("note: only "+aa.length+" available"),L=aa.length);D-=L;0>D&&(null==aa[aa.length-1].u?(L=D+L,D=0):D+=aa.length);var tc=[];"call"==Xd&& -(Ga=1E5,tc=["CALL"]);for(void 0!==Wd&&a.g(L+" instructions earlier:");0=aa.length&&(D=0);a.Bb=L;Zd++;Ga--}}Zd||(a.g("no "+Yd+"history available"),a.Bb=void 0)}else{var Eb=U(a,Y);if(Eb){var Fb=0;na&&("l"==na.charAt(0)&&(na=na.substr(1)||Ve),Fb=Rd(a,na)>>>0,65536>4||1,uc="dd"== -Da?4:"dw"==Da?2:1,be=0;bexc;xc++){var Hb=a.ra(Eb,1),Gb=Gb|Hb<<(vc++<<3);vc==uc&&($a+=n(Gb,2*uc),$a+=1==uc?7==xc?"-":" ":" ",Gb=vc=0);wc+=32<=Hb&&128>Hb?String.fromCharCode(Hb):"."}oa&&(oa+="\n");oa+=Y+" "+$a+" "+wc}oa&&a.g(oa);a.yb=Eb}}}}break;case "e":if("else"==f[0])break;var Ib=1,ce=255,de=a.ra,ee=a.ub;"ew"==f[0]&&(Ib=2,ce=65535,de=a.hb,ee=a.Pb);var fe=Ib<<1,ge=f[1];if(null==ge)a.g("edit memory commands:"),a.g("\teb [a] [...] edit bytes at address a"), -a.g("\tew [a] [...] edit words at address a");else{var Jb=U(a,ge);if(Jb)for(var Kb=2;KbHc;){for(var pa=null,af=256;65536>db.u>>>0;){ie.u=a.hb(db,2);if(null==db.u||!af--)break; -for(var bf=a,Mb=ie,je=null,eb=Mb.u,ke=eb,Ic=1;6>=Ic&&eb;Ic++){if(2>>=Nc)&ff;if(void 0!==Ob){if(Ob[0])Ob[0](ja,Pb,void 0);S.B&&S.H!=Ob[1]&&Id(S.B,ja,Pb)}else S.B&& -(Cd(S.B,S,ja,Pb),S.H&&Id(S.B,ja,Pb));Nc+=fb<<3;ja+=fb;Mc-=fb}a.g(q(Kc)+": "+("0x"+n(Lc,2)))}}else a.g("output commands:"),a.g("\to [p] [b]\twrite byte [b] to port [p]"),a.g("warning: port accesses can affect hardware state");break;case "p":if("print"==f[0]){ye(a,b.substr(5));break}var pe="pr"==f[0]?1:0,gf=1+pe;if(a.S)a.g("step in progress");else{var Oc=P(a.b.N);switch(a.ra(Oc)){case 205:a.S=gf,qd(Oc,3)}a.S?(a.wa(a.w,Oc,!0),a.Fa()||(a.s&&a.s.fb(),a.S=0)):ze(a,pe?"tr":"t")}break;case "r":if("reset"== -b){a.s&&a.s.reset();break}Ed(a,f);break;case "t":ze(a,f[0],f[1]);break;case "u":Fd(a,f[1],f[2],8);break;case "v":if("var"==f[0]){we(a,b.substr(3))||(d=!1);break}a.g("PC8080 version 1.21.7 ("+a.b.Gb+",RELEASE"+(tb?",TYPEDARRAYS":",LONGARRAYS")+")");a.g(ya());break;case "x":a:if(f[1]&&"?"!=f[1])switch(f[1]){case "cs":var gb;void 0!==f[3]&&(gb=+f[3]);switch(f[2]){case "int":a.b.i.Na=gb;break;case "start":a.b.i.Za=gb;break;case "stop":a.b.i.Pa=gb;break;default:a.g("unknown cs option");break a}void 0!== -gb&&lc(a.b);a.g("checksums "+(a.b.j.Ia?"enabled":"disabled"));break;case "sp":void 0!==f[2]&&(qc(a.b,+f[2])||a.g("warning: using 1x multiplier, previous target not reached"));a.g("target speed: "+(a.b.i.za.toFixed(2)+"Mhz")+" ("+a.b.i.Ba+"x)");break;default:a.g("unknown option: "+f[1])}else a.g("execution options:"),a.g("\tcs int #\tset checksum cycle interval to #"),a.g("\tcs start #\tset checksum cycle start count to #"),a.g("\tcs stop #\tset checksum cycle stop count to #"),a.g("\tsp #\t\tset speed multiplier to #"); -break;case "?":if(f[1]){ye(a,b.substr(1));break}var hb="commands:",Pc;for(Pc in ld)hb+="\n"+ra(Pc,7)+ld[Pc];Zc(a)||(hb+="\nnote: frequency/history disabled if no exec breakpoints");a.g(hb);break;default:a.g("unknown command: "+b),d=!1}}}catch(qe){a.g("debugger error: "+(qe.stack||qe.message)),d=!1}return d}function mc(a,b,c){b=wd(a,b,c);for(var d in b)if(!Md(a,b[d]))return!1;return!0}Qa(function(){for(var a=F(document,"pc8080","debugger"),b=0;bJe){if(Fe(d,this.L)){this.F=new J(this,W,"failsafe");Fe(this.F)&&(Oe(this,d),a=2,Ce(this.F));M(this.F,"timestamp",va());De(this.F);var e=this.s&&!this.H;if(1==a||za("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=Ee(d)){var f=Ge(d,"code"),k=Ge(d,"data");f&&("ok"==f?Fe(d,k):("error"==f&&"no machine state"!= -k?(this.ba("Error: "+k),"unable to verify user"==k&&(Ia("user",""),this.w=null)):this.g(f+": "+k),Ce(d),Fe(d)?(c=Ee(d),e=!0):c=!1))}e&&Ne(this,c?d:null)}else 2==a&&d.clear()}else Ne(this);delete this.L;delete this.M}e=C(this.id);for(f=0;fa[1];a=a[2];this.j.W=!0;var d=this.G.power;d&&(d.textContent="Shutdown");this.V||(this.g("PC8080 v"+W+"\nCopyright \u00a9 2012-2016 Jeff Parsons \nLicense: GPL version 3 or later "),this.V=!0);this.b&&(Pe(this,this.b,b,c,a),nc(this.b));this.aa&&(Oe(this,b),b.clear());!c&&this.F&&(this.F.clear(),delete this.F);this.C=0}; -function Oe(a,b){if(za("There may be a problem with your PC8080 machine.\n\nTo help us diagnose it, click OK to send this PC8080 machine state to http://www.pcjs.org.")){var c=a.ja,d=a.w||"",e=b.toString(),f={app:"PC8080"};f.ver=W;f.url=c;f.user=d;f.type="bug";f.data=e;u("http://www.pcjs.org/api/v1/report",f,!0)}} -function Ae(a,b,c){var d,e="none";if(a.C)return null;a.C--;var f=new J(a,W),k=new J(a,W,"validate"),h=va();M(k,"timestamp",h);M(f,"timestamp",h);M(f,"version","1.21.7");M(f,"url",window?window.location.href:null);M(f,"browser",ya());a.b&&a.b.oa&&(c&&a.b.U(),d=a.b.oa(b,c),"object"===typeof d&&M(f,a.b.id,d),c&&(a.b.j.W=!1,!1===d&&(e=null)));for(var h=C(a.id),l=0;l=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*)/);e>=1;k=p+"b"+k;d>>=8}d="0x"+n(c)+" "+c+". ("+k+")"}a.g((null!=b?b+": ":"")+d);return e}function ze(a,b){if(b)return ye(a,b,a.ga[b]);var c=0;for(b in a.ga)ye(a,b,a.ga[b]),c++;return 0b[0]?1:a[0]>>0;for(b=0;b>>0,h=f.Xb;if(e>=k&&eh[0].indexOf("+"))){var m=h[0]+":";h[2]&&(m+=" "+h[2]);a.g(m)}h[3]&&(k=h[3],f=null);f=Ud(a,b,k,f);a.g(f);a.N=b;e-=b.u-l;c++}}} +function Dd(a,b,c,d){if(c)if(b){0>a.D&&a.C.length&&(a.D=0);if(0>a.D||b!=a.C[a.D])a.C.splice(0,0,b),a.D=0;a.D--}else b=a.C[a.D+1];a=[];if(b){b=b.toLowerCase().replace(/""/g,"'");c=0;var e=null;d=d||";";for(var f=0;f<=b.length;f++){var k=b.charAt(f);if('"'==k||"'"==k)e?k==e&&(e=null):e=k;else if(k==d&&!e||!k)a.push(sa(b.substring(c,f))),c=f+1}}return a} +function Td(a,b,c){var d=!0;try{b.length&&"end"!=b?c||a.g(">> "+b):(a.ma&&(a.g("ended assemble at "+n(a.ca.u,4)),a.N=a.ca,a.ma=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.wa=null;if(rb(a)&&0m||"z"aa.length&&(a.g("note: only "+aa.length+" available"),L=aa.length);D-=L;0>D&&(null==aa[aa.length-1].u?(L=D+L,D=0):D+=aa.length);var Cc=[];"call"==de&& +(Ga=1E5,Cc=["CALL"]);for(void 0!==ce&&a.g(L+" instructions earlier:");0=aa.length&&(D=0);a.Bb=L;fe++;Ga--}}fe||(a.g("no "+ee+"history available"),a.Bb=void 0)}else{var Kb=U(a,Y);if(Kb){var Lb=0;na&&("l"==na.charAt(0)&&(na=na.substr(1)||bf),Lb=Yd(a,na)>>>0,65536>4||1,Dc="dd"== +Da?4:"dw"==Da?2:1,ie=0;ieGc;Gc++){var Nb=a.ta(Kb,1),Mb=Mb|Nb<<(Ec++<<3);Ec==Dc&&(cb+=n(Mb,2*Dc),cb+=1==Dc?7==Gc?"-":" ":" ",Mb=Ec=0);Fc+=32<=Nb&&128>Nb?String.fromCharCode(Nb):"."}oa&&(oa+="\n");oa+=Y+" "+cb+" "+Fc}oa&&a.g(oa);a.yb=Kb}}}}break;case "e":if("else"==f[0])break;var Ob=1,je=255,ke=a.ta,le=a.ub;"ew"==f[0]&&(Ob=2,je=65535,ke=a.ib,le=a.Pb);var me=Ob<<1,ne=f[1];if(null==ne)a.g("edit memory commands:"),a.g("\teb [a] [...] edit bytes at address a"), +a.g("\tew [a] [...] edit words at address a");else{var Pb=U(a,ne);if(Pb)for(var Qb=2;QbQc;){for(var pa=null,hf=256;65536>gb.u>>>0;){pe.u=a.ib(gb,2);if(null==gb.u||!hf--)break; +for(var jf=a,Sb=pe,qe=null,hb=Sb.u,re=hb,Rc=1;6>=Rc&&hb;Rc++){if(2>>=Wc)&nf;if(void 0!==Ub){if(Ub[0])Ub[0](ja,Vb,void 0);S.B&&S.H!=Ub[1]&&Pd(S.B,ja,Vb)}else S.B&& +(Jd(S.B,S,ja,Vb),S.H&&Pd(S.B,ja,Vb));Wc+=ib<<3;ja+=ib;Vc-=ib}a.g(q(Tc)+": "+("0x"+n(Uc,2)))}}else a.g("output commands:"),a.g("\to [p] [b]\twrite byte [b] to port [p]"),a.g("warning: port accesses can affect hardware state");break;case "p":if("print"==f[0]){Fe(a,b.substr(5));break}var we="pr"==f[0]?1:0,of=1+we;if(a.T)a.g("step in progress");else{var Xc=P(a.b.O);switch(a.ta(Xc)){case 205:a.T=of,xd(Xc,3)}a.T?(a.xa(a.w,Xc,!0),a.Fa()||(a.s&&a.s.fb(),a.T=0)):Ge(a,we?"tr":"t")}break;case "r":if("reset"== +b){a.s&&a.s.reset();break}Ld(a,f);break;case "t":Ge(a,f[0],f[1]);break;case "u":Md(a,f[1],f[2],8);break;case "v":if("var"==f[0]){De(a,b.substr(3))||(d=!1);break}a.g("PC8080 version 1.21.7 ("+a.b.Gb+",RELEASE"+(tb?",TYPEDARRAYS":",LONGARRAYS")+")");a.g(ya());break;case "x":a:if(f[1]&&"?"!=f[1])switch(f[1]){case "cs":var jb;void 0!==f[3]&&(jb=+f[3]);switch(f[2]){case "int":a.b.i.Na=jb;break;case "start":a.b.i.Za=jb;break;case "stop":a.b.i.Pa=jb;break;default:a.g("unknown cs option");break a}void 0!== +jb&&lc(a.b);a.g("checksums "+(a.b.j.Ia?"enabled":"disabled"));break;case "sp":void 0!==f[2]&&(qc(a.b,+f[2])||a.g("warning: using 1x multiplier, previous target not reached"));a.g("target speed: "+(a.b.i.Aa.toFixed(2)+"Mhz")+" ("+a.b.i.Ca+"x)");break;default:a.g("unknown option: "+f[1])}else a.g("execution options:"),a.g("\tcs int #\tset checksum cycle interval to #"),a.g("\tcs start #\tset checksum cycle start count to #"),a.g("\tcs stop #\tset checksum cycle stop count to #"),a.g("\tsp #\t\tset speed multiplier to #"); +break;case "?":if(f[1]){Fe(a,b.substr(1));break}var kb="commands:",Yc;for(Yc in sd)kb+="\n"+ra(Yc,7)+sd[Yc];fd(a)||(kb+="\nnote: frequency/history disabled if no exec breakpoints");a.g(kb);break;default:a.g("unknown command: "+b),d=!1}}}catch(xe){a.g("debugger error: "+(xe.stack||xe.message)),d=!1}return d}function mc(a,b,c){b=Dd(a,b,c);for(var d in b)if(!Td(a,b[d]))return!1;return!0}Qa(function(){for(var a=F(document,"pc8080","debugger"),b=0;bQe){if(Me(d,this.L)){this.F=new J(this,W,"failsafe");Me(this.F)&&(Ve(this,d),a=2,Je(this.F));M(this.F,"timestamp",va());Ke(this.F);var e=this.s&&!this.H;if(1==a||za("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=Le(d)){var f=Ne(d,"code"),k=Ne(d,"data");f&&("ok"==f?Me(d,k):("error"==f&&"no machine state"!= +k?(this.da("Error: "+k),"unable to verify user"==k&&(Ia("user",""),this.w=null)):this.g(f+": "+k),Je(d),Me(d)?(c=Le(d),e=!0):c=!1))}e&&Ue(this,c?d:null)}else 2==a&&d.clear()}else Ue(this);delete this.L;delete this.N}e=C(this.id);for(f=0;fa[1];a=a[2];this.j.W=!0;var d=this.G.power;d&&(d.textContent="Shutdown");this.V||(this.g("PC8080 v"+W+"\nCopyright \u00a9 2012-2016 Jeff Parsons \nLicense: GPL version 3 or later "),this.V=!0);this.b&&(We(this,this.b,b,c,a),nc(this.b));this.ca&&(Ve(this,b),b.clear());!c&&this.F&&(this.F.clear(),delete this.F);this.C=0}; +function Ve(a,b){if(za("There may be a problem with your PC8080 machine.\n\nTo help us diagnose it, click OK to send this PC8080 machine state to http://www.pcjs.org.")){var c=a.na,d=a.w||"",e=b.toString(),f={app:"PC8080"};f.ver=W;f.url=c;f.user=d;f.type="bug";f.data=e;u("http://www.pcjs.org/api/v1/report",f,!0)}} +function He(a,b,c){var d,e="none";if(a.C)return null;a.C--;var f=new J(a,W),k=new J(a,W,"validate"),h=va();M(k,"timestamp",h);M(f,"timestamp",h);M(f,"version","1.21.7");M(f,"url",window?window.location.href:null);M(f,"browser",ya());a.b&&a.b.ra&&(c&&a.b.U(),d=a.b.ra(b,c),"object"===typeof d&&M(f,a.b.id,d),c&&(a.b.j.W=!1,!1===d&&(e=null)));for(var h=C(a.id),l=0;lh.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(h=window.location.pathname+h);d?"}"==d.slice(-1)?(d=d.slice(0,-1),1]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(h?' url="'+h+'"':""))}e||(a=a.replace(/().*?(<\/xsl:variable>)/,"$1pc8080$2")); -h=null;if("<"==a.charAt(0))try{e||(a=a.replace(/\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(h=new window.ActiveXObject("Microsoft.XMLDOM"),h.async=!1,h.loadXML(a)):h=(new window.DOMParser).parseFromString(a,"text/xml")}catch(r){h=null,a=r.message}else a="unrecognized XML: "+(255/g.exec(a)){var e=d[2];b("Loading "+e+"...");u(e,null,!0,function(f,k,h){if(h||!k)c(a,"unable to resolve XML reference: "+d[0]+" ("+h+")");else{if(f=d[3])if(h=k.match(new RegExp("<"+d[1]+"[^>]*>"))){for(var l=h[0],m,p=/( [a-z]+=)(['"])(.*?)\2/g;m=p.exec(f);)l=0>l.indexOf(m[1])?l.replace(">",m[0]+">"):l.replace(new RegExp(m[1]+"(['\"])(.*?)\\1"),m[0]);h[0]!=l&&(k=k.replace(h[0],l))}else{c(a,"missing <"+d[1]+"> in "+e);return}k=k.replace(/<\?xml[^>]*>[\r\n]*/, -"");a=a.replace(d[0],k);jf(a,b,c)}})}else c(a,null)} -function kf(a,b,c,d){function e(a){if(void 0===h){var b=k&&F(k,"machine-warning");h=b&&b[0]||k}h&&(h.innerHTML=ma(a))}function f(a){e("Error: "+a);l&&(--Se||Sa(!0));l=!1}var k,h,l=!0;Se++;jb[a]={};try{if(k=document.getElementById(a)){var m;if("object"==typeof resources&&(m=resources.css)){var p=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css";r.styleSheet?r.styleSheet.cssText=m:r.appendChild(document.createTextNode(m));p.appendChild(r)}c|| -(c="/versions/pc8080/1.21.7/components.xsl");m=function(d,h){h?Te(c,null,null,!1,e,function(d,m){if(m)if(kb(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window){var l=h.transformNode(m);l?(k.outerHTML=l,--Se||Sa(!0)):f("transformNodeToObject failed")}else document.implementation&&document.implementation.createDocument?(l=new XSLTProcessor,l.importStylesheet(m),(l=l.transformToFragment(h,document))?k.parentNode?(k.parentNode.replaceChild(l,k),--Se||Sa(!0)):f("invalid machine element: "+ -a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser");else f(d)}):f(d)};"<"!=b.charAt(0)?Te(b,a,d,!0,e,m):hf(b,null,a,d,!1,e,m)}else f("missing machine element: "+a)}catch(t){f(t.message)}return l}window.embedPC8080=function(a,b,c,d){Sa(!1);return kf(a,b,c,d)};window.enableEvents=Sa;window.sendEvent=Ta; -function lf(a,b,c,d){if(!c&&b){d.push(b);a=jb[d[0]];b=null;for(var e in a)if(ka(e,"components.xsl")){b=e.replace(".xsl",".css");break}b?u(b,null,!0,function(a,b){mf(b,d)}):mf(null,d)}else v("Error ("+c+") requesting "+a)} -function mf(a,b){var c,d,e,f=b[0],k=b[1];c=b[4];c=c.match(/^(\s*\(function\(\)\{)([\s\S]*)(}\)\(\);\s*)$/);var h=jb[f],l={},m;for(m in h){var p=h[m],r=fa(m);if("xml"==r){for(r=/[ \t]*]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;d=r.exec(h[m]);){var t=d[2];t&&(h[t]||(p=p.replace(d[0],"")))}d=m=ea(m)}else"xsl"==r&&(e=m=ea(m));l[m]=p}a&&(l[m="css"]=a);b[2]&&(l[m="parms"]=b[2]);b[3]&&(l[m="state"]=b[3]);d&&e?(m=JSON.stringify(l),k+=".js",c=c[1]+"var resources="+m+";"+c[2]+c[3],c=c.replace(/\u00A9/g, +g.ha=function(a,b,c){var d=this;switch(b){case "power":return this.G[b]=c,c.onclick=function(){d.C||(d.j.W?He(d,!1,!0):Te(d,d.cb))},!0;case "reset":return this.G[b]=c,c.onclick=function(){if(d.j.W&&!d.C)if(d.s&&!d.K){var a=za("Click OK to save changes to this PC8080 machine.\n\nWARNING: If you CANCEL, all disk changes will be discarded.");He(d,a,!0);!a&&d.T?window&&window.location.reload():d.cb(Qe)}else d.reset(),d.b&&nc(d.b)},!0;case "save":if(ka(xa(),"pcjs.org")){c.parentNode.removeChild(c);break}this.G[b]= +c;c.onclick=function(){var a=Re(d,!0);if(a){var b=!!(d.s&&!d.K||d.T),c=He(d,b);b?Xe(d,a,c):d.da("Resume disabled, machine state not saved")}};return!0}return!1}; +function Re(a,b){var c=a.w;c||(c=Ha("user"),void 0!==c?!c&&b&&(c=null,window&&(c=window.prompt("Saving machine states on the pcjs.org server is currently unsupported.\n\nIf you're running your own server, enter your user ID below.","")),c&&((c=Ye(a,c))||a.da("The user ID is invalid."))):b&&a.da("Browser local storage is not available"));return c} +function Ye(a,b){a.w=null;var c=u(xa()+"/api/v1/user?req=verify&user="+b),d=c[1];if(!c[0]&&d)try{c=eval("("+d+")"),c.code&&"ok"==c.code&&(Ia("user",c.data),a.w=c.data)}catch(e){v(e.message+" ("+d+")")}return a.w}function Se(a){var b=null;a.w&&(b=xa()+"/api/v1/user?req=load&user="+a.w+"&state="+Ie(a,W));return b} +function Xe(a,b,c){if(c){var d={req:"store"};d.user=b;d.state=Ie(a,W);d.data=c;b=u(xa()+"/api/v1/user",d);d=b[0];if(b[1]){if(d){var e=d.indexOf("\n");0h.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(h=window.location.pathname+h);d?"}"==d.slice(-1)?(d=d.slice(0,-1),1]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(h?' url="'+h+'"':""))}e||(a=a.replace(/().*?(<\/xsl:variable>)/,"$1pc8080$2")); +h=null;if("<"==a.charAt(0))try{e||(a=a.replace(/\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(h=new window.ActiveXObject("Microsoft.XMLDOM"),h.async=!1,h.loadXML(a)):h=(new window.DOMParser).parseFromString(a,"text/xml")}catch(r){h=null,a=r.message}else a="unrecognized XML: "+(255/g.exec(a)){var e=d[2];b("Loading "+e+"...");u(e,null,!0,function(f,k,h){if(h||!k)c(a,"unable to resolve XML reference: "+d[0]+" ("+h+")");else{if(f=d[3])if(h=k.match(new RegExp("<"+d[1]+"[^>]*>"))){for(var l=h[0],m,p=/( [a-z]+=)(['"])(.*?)\2/g;m=p.exec(f);)l=0>l.indexOf(m[1])?l.replace(">",m[0]+">"):l.replace(new RegExp(m[1]+"(['\"])(.*?)\\1"),m[0]);h[0]!=l&&(k=k.replace(h[0],l))}else{c(a,"missing <"+d[1]+"> in "+e);return}k=k.replace(/<\?xml[^>]*>[\r\n]*/, +"");a=a.replace(d[0],k);qf(a,b,c)}})}else c(a,null)} +function rf(a,b,c,d){function e(a){if(void 0===h){var b=k&&F(k,"machine-warning");h=b&&b[0]||k}h&&(h.innerHTML=ma(a))}function f(a){e("Error: "+a);l&&(--Ze||Sa(!0));l=!1}var k,h,l=!0;Ze++;$a[a]={};try{if(k=document.getElementById(a)){var m;if("object"==typeof resources&&(m=resources.css)){var p=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css";r.styleSheet?r.styleSheet.cssText=m:r.appendChild(document.createTextNode(m));p.appendChild(r)}c|| +(c="/versions/pc8080/1.21.7/components.xsl");m=function(d,h){h?$e(c,null,null,!1,e,function(d,m){if(m)if(ab(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window){var l=h.transformNode(m);l?(k.outerHTML=l,--Ze||Sa(!0)):f("transformNodeToObject failed")}else document.implementation&&document.implementation.createDocument?(l=new XSLTProcessor,l.importStylesheet(m),(l=l.transformToFragment(h,document))?k.parentNode?(k.parentNode.replaceChild(l,k),--Ze||Sa(!0)):f("invalid machine element: "+ +a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser");else f(d)}):f(d)};"<"!=b.charAt(0)?$e(b,a,d,!0,e,m):pf(b,null,a,d,!1,e,m)}else f("missing machine element: "+a)}catch(t){f(t.message)}return l}window.embedPC8080=function(a,b,c,d){Sa(!1);return rf(a,b,c,d)};window.enableEvents=Sa;window.sendEvent=Ta; +function sf(a,b,c,d){if(!c&&b){d.push(b);a=$a[d[0]];b=null;for(var e in a)if(ka(e,"components.xsl")){b=e.replace(".xsl",".css");break}b?u(b,null,!0,function(a,b){tf(b,d)}):tf(null,d)}else v("Error ("+c+") requesting "+a)} +function tf(a,b){var c,d,e,f=b[0],k=b[1];c=b[4];c=c.match(/^(\s*\(function\(\)\{)([\s\S]*)(}\)\(\);\s*)$/);var h=$a[f],l={},m;for(m in h){var p=h[m],r=fa(m);if("xml"==r){for(r=/[ \t]*]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;d=r.exec(h[m]);){var t=d[2];t&&(h[t]||(p=p.replace(d[0],"")))}d=m=ea(m)}else"xsl"==r&&(e=m=ea(m));l[m]=p}a&&(l[m="css"]=a);b[2]&&(l[m="parms"]=b[2]);b[3]&&(l[m="state"]=b[3]);d&&e?(m=JSON.stringify(l),k+=".js",c=c[1]+"var resources="+m+";"+c[2]+c[3],c=c.replace(/\u00A9/g, "©"),m=k,h=null,l="data:application/javascript,",l=Ja("Firefox")?l+encodeURIComponent(c):l+encodeURI(c),m&&(h=document.createElement("a"),"string"!=typeof h.download&&(h=null)),h?(h.href=l,h.download=m,document.body.appendChild(h),h.click(),document.body.removeChild(h),c="Check your Downloads folder for "+m+"."):(window.open(l),c="Check your browser for a new window/tab containing the requested data"+(m?" ("+m+")":"")+"."),c+=', copy it to your web server as "'+k+'", and then add the following to your web page:\n\n', c+='
\n',c+="...\n",c+='