pcjs/versions/pdpjs/1.30.2/pdp11-dbg.js
2016-11-01 19:02:06 -07:00

317 lines
117 KiB
JavaScript

(function(){/*
http://pcjs.org/modules/shared/lib/diskapi.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/shared/lib/dumpapi.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/shared/lib/reportapi.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/shared/lib/userapi.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/shared/lib/keys.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/shared/lib/strlib.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/shared/lib/usrlib.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/shared/lib/weblib.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/pdp11/lib/messages.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/shared/lib/debugger.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/pdp11/lib/debugger.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/shared/lib/embed.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/shared/lib/defines.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/shared/lib/component.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/pdp11/lib/defines.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/pdp11/lib/panel.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/pdp11/lib/bus.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/pdp11/lib/device.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/pdp11/lib/memory.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/pdp11/lib/cpu.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/pdp11/lib/cpustate.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/pdp11/lib/cpuops.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/pdp11/lib/rom.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/pdp11/lib/ram.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/pdp11/lib/keyboard.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/pdp11/lib/serialport.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/pdp11/lib/pc11.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/pdp11/lib/disk.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/pdp11/lib/rl11.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/pdp11/lib/computer.js (C) Jeff Parsons 2012-2016
http://pcjs.org/modules/shared/lib/state.js (C) Jeff Parsons 2012-2016
*/
for(var k,aa="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)},ca="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global?global:this,da=["Math","log2"],ea=0;ea<da.length-1;ea++){var fa=da[ea];fa in ca||(ca[fa]={});ca=ca[fa]}var ha=da[da.length-1],ia=ca[ha],ja=ia?ia:function(a){return Math.log(a)/Math.LN2};
ja!=ia&&null!=ja&&aa(ca,ha,{configurable:!0,writable:!0,value:ja});var la={163840:[40,1,8,,254],184320:[40,1,9,,252],327680:[40,2,8,,255],368640:[40,2,9,,253],737280:[80,2,9,,249],1228800:[80,2,15,,249],1474560:[80,2,18,,240],2949120:[80,2,36,,240],21368320:[615,4,17],5242880:[256,2,40,256],10485760:[512,2,40,256]};
function ma(a,b){var c;if(a){b||(b=10);var d=a.charAt(0),e=0<a.indexOf(",");e&&(a=a.replace(/,/g,""));"#"==d?(b=8,d=null):"$"==d&&(b=16,d=null);null==d?a=a.substr(1):("0"==d&&(d=a.charAt(1),"b"==d&&e&&(b=2,d=null),"o"==d?(b=8,d=null):"x"==d&&(b=16,d=null)),null==d?a=a.substr(2):(d=a.charAt(a.length-1).toLowerCase(),"y"==d?(b=2,d=null):"."==d?(b=10,d=null):"h"==d&&(b=16,d=null),null==d&&(a=a.substr(0,a.length-1))));var f,d=a;((e=b)&&10!=e?16==e?d.match(/^[0-9a-f]+$/i):8==e?d.match(/^[0-7]+$/):2==e&&
d.match(/^[01]+$/):d.match(/^[0-9]+$/))&&!isNaN(f=parseInt(a,b))&&(c=f|0)}return c}function ra(a,b,c){var d="";b?11<b&&(b=11):b=a&-65536?11:6;if(null==a||isNaN(a))for(;0<b--;)d="?"+d;else for(;0<b--;)d=String.fromCharCode((a&7)+48)+d,a>>=3;return(c?"0o":"")+d}function p(a,b,c){var d="";b?8<b&&(b=8):b=a&-65536?8:4;if(null==a||isNaN(a))for(;0<b--;)d="?"+d;else for(;0<b--;){var e=a&15,e=e+(0<=e&&9>=e?48:55),d=String.fromCharCode(e)+d;a>>=4}return(c?"0x":"")+d}
function sa(a,b){var c=a,d=a.lastIndexOf("/");0<=d&&(c=a.substr(d+1));d=c.indexOf("&");0<d&&(c=c.substr(0,d));b&&(d=c.lastIndexOf("."),0<d&&(c=c.substring(0,d)));return c}function ta(a){var b="",c=a.lastIndexOf(".");0<=c&&(b=a.substr(c+1).toLowerCase());return b}function ua(a,b){return-1!==a.indexOf(b,a.length-b.length)}var va={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};function wa(a){return a.replace(/[&<>"']/g,function(a){return va[a]})}
function xa(a,b){return(a+" ").slice(0,b)}function ya(a){return String.prototype.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}var za={0:"NUL",1:"SOH",2:"STX",3:"ETX",4:"EOT",5:"ENQ",6:"ACK",7:"BEL",8:"BS",9:"TAB",11:"VT",12:"FF",13:"CR",14:"SO",15:"SI",16:"DLE",17:"XON",18:"DC2",19:"XOFF",20:"DC4",21:"NAK",22:"SYN",23:"ETB",24:"CAN",25:"EM",26:"SUB",27:"ESC",28:"FS",29:"GS",30:"RS",31:"US"};
function Aa(a,b,c){var d=0,e=a.length,f=0;for(c||(c=function(a,b){return a>b?1:a<b?-1:0});d<e;){var g=d+e>>1,h;h=c(b,a[g]);0<h?d=g+1:(e=g,f=!h)}return f?d:~d}var Ba=Date.now||function(){return+new Date};function Ca(){function a(a){return(10>a?"0":"")+a}var b=new Date;return b.getFullYear()+"-"+a(b.getMonth()+1)+"-"+a(b.getDate())+" "+a(b.getHours())+":"+a(b.getMinutes())+":"+a(b.getSeconds())}
function Ea(a,b,c,d){var e=0,f=null,g=null;if("object"==typeof resources&&(f=resources[a]))return d&&d(a,f,e),[f,e];if(c&&"function"==typeof resources)return resources(a,function(b,c){d&&d(a,b,c)}),g;var h=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");c&&(h.onreadystatechange=function(){4===h.readyState&&(f=h.responseText,200==h.status||!h.status&&f.length&&"file:"==(window?window.location.protocol:"file:")||(e=h.status||-1),d&&d(a,f,e))});if(b&&"object"==
typeof b){var l="",m;for(m in b)b.hasOwnProperty(m)&&(l&&(l+="&"),l+=m+"="+encodeURIComponent(b[m]));l=l.replace(/%20/g,"+");h.open("POST",a,!!c);h.setRequestHeader("Content-type","application/x-www-form-urlencoded");h.send(l)}else h.open("GET",a,!!c),"bytes"==b&&h.overrideMimeType("text/plain; charset=x-user-defined"),h.send();c||(f=h.responseText,200!=h.status&&(e=h.status||-1),d&&d(a,f,e),g=[f,e]);return g}
function Fa(a,b){var c,d={ea:null,ia:null,Ja:null,Ia:null};if("["==b.charAt(0)||"{"==b.charAt(0))try{var e,f,g;if("<"==b.substr(0,1))throw Error(b);g=0>b.indexOf("0x")&&'["'!=b.substr(0,2)?JSON.parse(b.replace(/([a-z]+):/gm,'"$1":').replace(/\/\/[^\n]*/gm,"")):eval("("+b+")");d.Ja=g.load;d.Ia=g.exec;if(e=g.bytes)d.ea=e;else if(e=g.words)for(d.ea=Array(2*e.length),f=c=0;c<e.length;c++)d.ea[f++]=e[c]&255,d.ea[f++]=e[c]>>8&255;else if(e=g.data)for(d.ea=Array(4*e.length),f=c=0;c<e.length;c++)d.ea[f++]=
e[c]&255,d.ea[f++]=e[c]>>8&255,d.ea[f++]=e[c]>>16&255,d.ea[f++]=e[c]>>24&255;else d.ea=g;d.ia=g.symbols;d.ea.length?1==d.ea.length&&(q(d.ea[0]),d=null):(q("Empty resource: "+a),d=null)}catch(h){q("Resource data error ("+a+"): "+h.message),d=null}else{e=[];b=b.replace(/\n/gm," ").replace(/ +$/,"").split(" ");for(c=0;c<b.length;c++){f=parseInt(b[c],16);if(isNaN(f)){q("Resource data error ("+a+"): invalid hex byte ("+b[c]+")");break}e.push(f&255)}c==b.length&&(d.ea=e)}return d}
function Ga(){return"http://"+(window?window.location.host:"www.pcjs.org")}function q(a){window&&window.alert(a)}function Ha(a){var b=!1;window&&(b=window.confirm(a));return b}var Ia=null;function Ka(){if(null==Ia){var a=!1;if(window)try{window.localStorage.setItem("PCjs.localStorage","PCjs.localStorage"),a="PCjs.localStorage"==window.localStorage.getItem("PCjs.localStorage"),window.localStorage.removeItem("PCjs.localStorage")}catch(b){a=!1}Ia=a}return Ia}
function Na(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(c){}return b}function Oa(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function Pa(a){if(window){var b=window?window.navigator.userAgent:"";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 Qa(a,b,c){function d(){--a;0<=a&&(b()||(a=0));0<a?setTimeout(d,0):c()}d()}
function Ra(a,b){function c(){b(100===d)&&(e=setTimeout(c,d),d=100)}var d=0,e=null,f=!1;a.onmousedown=function(){f||e||(d=500,c())};a.ontouchstart=function(){e||(d=500,c())};a.onmouseup=a.onmouseout=function(){e&&(clearTimeout(e),e=null)};a.ontouchend=a.ontouchcancel=function(){e&&(clearTimeout(e),e=null);f=!0}}var Sa={init:[],show:[],exit:[]},Ta=!1,Ua=!1,Va=!0;function Wa(a,b){if(window){var c=window[a];window[a]="function"!==typeof c?b:function(){c&&c();b()}}}function Xa(a){Sa.init.push(a)}
function Ya(a){if(Va)try{for(var b=0;b<a.length;b++)a[b]()}catch(c){q(""+("An unexpected exception occurred:\n\n"+c.message+"\n\nPlease send this information to support@pcjs.org. Thanks."))}}function Za(a){!Va&&a?(Va=!0,Ta&&$a("init"),Ua&&$a("show")):Va=a}function $a(a){Sa[a]&&Ya(Sa[a])}Wa("onload",function(){Ta=!0;Ya(Sa.init)});Wa("onpageshow",function(){Ua=!0;Ya(Sa.show)});Wa(Pa("Opera")||Pa("iOS")?"onunload":"onbeforeunload",function(){Ya(Sa.exit)});
function u(a,b,c,d){this.type=a;b||(b={id:"",name:""});this.id=b.id||"";this.name=b.name;this.mc=b.comment;this.Rc=b;b=this.id.indexOf(".");0>b?this.fb=this.id:(this.Na=this.id.substr(0,b),this.fb=this.id.substr(b+1));this[a]=c;this.A={ready:!1,Va:!1,Wb:!1,ja:!1,error:!1};this.Pb=null;this.A.error=!1;this.G={};this.i=null;this.na=d||0;v.push(this)}var ab=void 0,bb={};
if(window){ab||(ab=window.location.search.substr(1));for(var cb,db=/\+/g,kb=/([^&=]+)=?([^&]*)/g;cb=kb.exec(ab);)bb[decodeURIComponent(cb[1].replace(db," "))]=decodeURIComponent(cb[2].replace(db," "))}function lb(a){function b(){}if(window){if(!a)throw new TypeError;if(Object.create)return Object.create(a);var c=typeof a;if("object"!==c&&"function"!==c)throw new TypeError;}b.prototype=a;return new b}
function z(a,b){b||(b=u);a.prototype=lb(b.prototype);a.prototype.constructor=a;a.prototype.parent=b.prototype}if(window){window.PCjs||(window.PCjs={});var mb=window.PCjs.Machines||(window.PCjs.Machines={}),v=window.PCjs.Components||(window.PCjs.Components=[])}else mb={},v=[];function nb(a,b,c){mb[a]&&b&&(mb[a][b]=c)}function ob(a){var b,c=[];a&&(a=0<(b=a.indexOf("."))?a.substr(0,b+1):"");for(b=0;b<v.length;b++){var d=v[b];a&&d.id.indexOf(a)||c.push(d)}return c}
function pb(a){if(void 0!==a){var b;for(b=0;b<v.length;b++)if(v[b].id===a)return v[b]}return null}function qb(a,b){var c;if(void 0!==a){var d;b&&(b=0<(d=b.indexOf("."))?b.substr(0,d+1):"");for(d=0;d<v.length;d++)if(c)c==v[d]&&(c=null);else if(!(a!=v[d].type||b&&v[d].id.indexOf(b)))return v[d]}return null}function B(a){var b=null;if(a=a.getAttribute("data-value"))try{b=eval("("+a+")")}catch(c){q(c.message+" ("+a+")")}return b}
function C(a,b){b=D(b.parentNode,"pdp11-control");for(var c=0;c<b.length;c++)for(var d=b[c].childNodes,e=0;e<d.length;e++){var f=d[e];if(1===f.nodeType){var g=f.getAttribute("class");if(g)for(var h=g.split(" "),l=0;l<h.length;l++)switch(g=h[l],g){case "pdp11-binding":(g=B(f))&&g.binding&&a.sa(g.type,g.binding,f,g.value),l=h.length}}}}
function D(a,b,c){c&&(b+="-"+c+"-object");if(a.getElementsByClassName)return a.getElementsByClassName(b);var d;c=[];a=a.getElementsByTagName("*");var e=new RegExp("(^| )"+b+"( |$)");b=0;for(d=a.length;b<d;b++)e.test(a[b].className)&&c.push(a[b]);return c}
u.prototype={constructor:u,parent:null,toString:function(){return this.name?this.name:this.id||this.type},sa:function(a,b,c){switch(b){case "clear":return this.G[b]||(this.G[b]=c,c.onclick=function(a){return function(){a.G.print&&(a.G.print.value="")}}(this)),!0;case "print":return this.G[b]||(this.Oa=this.G[b]=c,c.value="",this.j=function(a){return function(b,c){8192<a.value.length&&(a.value=a.value.substr(a.value.length-4096));a.value+=(void 0!==c?c+": ":"")+(b||"")+"\n";a.scrollTop=a.scrollHeight}}(c),
this.P=function(a){this.j(a,this.fb)}),!0;default:return!1}},log:function(){},j:function(){},status:function(a){this.j(this.fb+": "+a)},P:function(a,b,c){c=c||this.type;b||q((c?c+": ":"")+a)},Fa:function(){return this.A.ja=!0},Ea:function(a,b){b&&(this.A.ja=!1);return!0}};function E(a,b,c,d){a.i&&(!0===c||F(a,c|0))&&a.i.message(b,d)}function F(a,b){if(a.i){a===a.i?b|=0:b=b||a.na;var c=a.i.na&b;return!!b&&c===b||!!(c&a.i.Jc)}return!1}
function rb(a,b){if(a.A.Wb)return a.A.Va=!1,a.A.Wb=!1;if(a.A.error)return a.j(a.toString()+" error"),!1;a.A.Va=b;return a.A.Va}function sb(a,b){a.A.Va&&(b?a.A.Wb=!0:void 0===b&&a.j(a.toString()+" busy"));return a.A.Va}function H(a,b){a.A.error||(a.A.ready=!1!==b,a.A.ready&&(b=a.Pb,a.Pb=null,b&&b()))}function tb(a,b){b&&(a.A.ready?b():a.Pb=b);return a.A.ready}function ub(a){return a.A.error?(a.j(a.toString()+" error"),!0):!1}function vb(a,b){a.A.error=!0;a.P(b)}
Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){b=b||0;for(var c=this.length;b<c;b++)if(this[b]===a)return b;return-1});Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)});
Function.prototype.bind||(Function.prototype.bind=function(a){function b(){return e.apply(this instanceof c&&a?this:a,d.concat(Array.prototype.slice.call(arguments)))}function c(){}if("function"!=typeof this)throw new TypeError("Function.prototype.bind: non-callable object");var d=Array.prototype.slice.call(arguments,1),e=this;c.prototype=this.prototype;b.prototype=new c;return b});
var wb="undefined"!==typeof ArrayBuffer,xb={cpu:1,trap:16,bus:64,memory:128,device:256,keyboard:65536,key:131072,disk:2097152,serial:8388608,speaker:33554432,computer:67108864,log:268435456,warn:536870912,buffer:1073741824,halt:-2147483648};
function yb(a){u.call(this,"Panel",a,yb);this.D=0;this.K=this.J=!1;this.g=this.B=this.v=0;this.L=20;this.I={};this.f={START:[1,!0,!1,this.$c],STEP:[1,!1,!1,this.ad],ENABLE:[1,!1,!1,this.Wc],CONT:[1,!0,!1,this.Uc],DEP:[0,!0,!1,this.Vc],EXAM:[1,!0,!1,this.Xc],LOAD:[1,!0,!1,this.Zc],TEST:[0,!0,!1,this.Yc]};for(a=0;22>a;a++)this.f["S"+a]=[0,!1,!1,this.bd,a]}z(yb);k=yb.prototype;k.reset=function(){this.L=this.L&-120|20};
k.sa=function(a,b,c,d){if(this.C&&this.C.sa(a,b,c,d)||this.b&&this.b.sa(a,b,c,d)||this.i&&this.i.sa(a,b,c,d))return!0;switch(b){case "R0":case "R1":case "R2":case "R3":case "R4":case "R5":case "R6":case "R7":case "NF":case "ZF":case "VF":case "CF":case "PS":return this.G[b]=c,this.D++,!0;default:return"led"==a||"rled"==a?(this.G[b]=c,this.I[b]=d?1:0,this.D++,!0):"switch"==a?(void 0===this.f[b]&&(this.f[b]=[d?1:0]),this.G[b]=c,a=c.parentElement||c,a=a.parentElement||a,a.onmousedown=function(a,b){return function(){var c=
a.f[b];zb(a,b,c[0]=1-c[0]);c[2]=!0;c[3]&&c[3].call(a,c[0],c[4]);a.J="DEP"==b;a.K="EXAM"==b}}(this,b),a.onmouseup=a.onmouseout=function(a,b){return function(){var c=a.f[b];c[1]&&c[2]&&(zb(a,b,c[0]=1-c[0]),c[3]&&c[3].call(a,c[0],c[4]));c[2]=!1}}(this,b),!0):this.parent.sa.call(this,a,b,c,d)}};k.Da=function(a,b,c,d){this.C=a;this.w=b;this.b=c;this.i=d;Ab(b,this,Bb);Cb(b,this.reset.bind(this));Db(this);for(var e in this.f)zb(this,e,this.f[e][0])};k.Fa=function(a,b){b||Eb();return!0};k.Ea=function(){return!0};
function Fb(a,b,c,d){a.G[b]&&(void 0===c&&(vb(a,"Value for "+b+" is invalid"),a.b.ha()),c=8==(a.i&&a.i.$||8)?ra(c,d):p(c,d),a.G[b].textContent!=c&&(a.G[b].textContent=c))}function Gb(a,b,c){if(a=a.G[b])a.style.backgroundColor=c?"#ff0000":"#000000"}function Db(a,b){for(var c in a.I)Gb(a,c,null!=b?b:a.I[c])}function zb(a,b,c){if(a=a.G[b])a.style.marginTop=c?"0px":"20px",a.style.backgroundColor=c?"#00ff00":"#228B22"}
k.$c=function(a){a||this.b.A.ca||(this.w.reset(),Ub(this.b),this.f.ENABLE&&this.f.ENABLE[0]&&this.b.bb())};k.ad=function(){};k.Wc=function(a){a||this.b.ha()};k.Uc=function(a){a||this.b.A.ca||(this.f.ENABLE&&this.f.ENABLE[0]?this.b.bb():(a=this.i)&&!sb(a,!0)?(rb(a,!0),a.cb(0),rb(a,!1)):(this.b.cb(1),this.Z()))};k.Vc=function(a){a&&!this.b.A.ca&&(this.J&&Vb(this,this.g+2),this.w.Ib(this.g,Wb(this,this.v)))};k.Xc=function(a){a||this.b.A.ca||(this.K&&Vb(this,this.g+2),Wb(this,this.w.lb(this.g)))};
k.Zc=function(a){a||this.b.A.ca||Vb(this,this.v)};k.Yc=function(a){Db(this,a||null)};k.bd=function(a,b){this.v=a?this.v|1<<b:this.v&~(1<<b)};function Vb(a,b){a.g=b&a.w.Ra;b=a.g;for(var c=0;22>c;c++)Gb(a,"A"+c,b&1<<c)}function Wb(a,b){a.B=b&65535;b=a.B;for(var c=0;16>c;c++)Gb(a,"D"+c,b&1<<c);return a.B}
k.Z=function(){if(this.D){for(var a=0;a<this.b.u.length;a++)Fb(this,"R"+a,this.b.u[a]);a=Xb(this.b);Fb(this,"PS",a);Fb(this,"NF",a&8?1:0,1);Fb(this,"ZF",a&4?1:0,1);Fb(this,"VF",a&2?1:0,1);Fb(this,"CF",a&1?1:0,1);Wb(this,this.b.u[0]);Vb(this,this.b.u[7])}};k.cd=function(a){return(a?this.v:this.B)&65535};k.Xd=function(a){this.B=a};var Yb={},Bb=(Yb[65400]=[null,null,yb.prototype.cd,yb.prototype.Xd,"CNSW"],Yb);
function Eb(){for(var a=!1,b=D(document,"pdp11","panel"),c=0;c<b.length;c++){var d=b[c],e=B(d),f=pb(e.id);f||(a=!0,f=new yb(e));C(f,d);a&&H(f)}}Xa(Eb);
function Zb(a,b,c){u.call(this,"Bus",a,Zb,64);this.b=b;this.i=c;this.L=a.busWidth||16;this.C=0;this.K=[];this.D=null;this.I=Math.pow(2,this.L);this.Ra=this.I-1|0;this.ya=$b;this.ka=Math.log2(this.ya);this.J=this.ya>>2;this.w=this.ya-1;this.B=this.I/this.ya|0;this.Ua=[];this.f=0;this.g=!1;this.v=[];this.Gc=[ac,bc,cc,dc];a=new I(this);ec(a,this.i);this.X=Array(this.B);for(b=0;b<this.B;b++)this.X[b]=a;H(this)}z(Zb);var $b=8192,fc=$b-1;
function ac(a,b){var c=-1,d=this.controller,e=d.Ua[a];e?e[0]?c=e[0](b):e[2]&&(c=b&1?e[2](b&-2)>>8:e[2](b)&255):b&1&&(e=d.Ua[a&-2])&&e[2]&&(c=e[2](b&-2)>>8);if(0<=c)return this.i&&F(this.i,64)&&E(this.i,e[4]+".readByte("+J(this.i,b)+"): "+J(this.i,c),!0,!0),c;K(d,b,16,3);c=255;this.i&&F(this.i,64)&&E(this.i,"warning: unconverted read access to byte @"+J(this.i,b)+": "+J(this.i,c),!0,!0);return c}
function bc(a,b,c){var d=!1,e=this.controller,f=e.Ua[a];if(f)if(f[1])f[1](b,c),d=!0;else{if(f[3]){a=f[2]?f[2](0):0;if(c&1)f[3](a&255|b<<8,c&-2);else f[3](a&-256|b,c);d=!0}}else c&1&&(f=e.Ua[a&-2])&&f[3]&&(c&=-2,a=f[2]?f[2](0):0,f[3](a&255|b<<8,c),d=!0);d?this.i&&F(this.i,64)&&E(this.i,f[4]+".writeByte("+J(this.i,c)+","+J(this.i,b)+")",!0,!0):(K(e,c,16,5),this.i&&F(this.i,64)&&E(this.i,"warning: unconverted write access to byte @"+J(this.i,c)+": "+J(this.i,b),!0,!0))}
function cc(a,b){var c=-1,d=this.controller;(a=d.Ua[a])&&(a[2]?c=a[2](b):a[0]&&(c=a[0](b)|a[0](b+1)<<8));if(0<=c)return this.i&&F(this.i,64)&&E(this.i,a[4]+".readWord("+J(this.i,b)+"): "+J(this.i,c),!0,!0),c;K(d,b,16,2);c=65535;this.i&&F(this.i,64)&&E(this.i,"warning: unconverted read access to word @"+J(this.i,b)+": "+J(this.i,c),!0,!0);return c}
function dc(a,b,c){var d=!1,e=this.controller;if(a=e.Ua[a])a[3]?(a[3](b,c),d=!0):a[1]&&(a[1](b&255,c),a[1](b>>8,c+1),d=!0);d?this.i&&F(this.i,64)&&E(this.i,a[4]+".writeWord("+J(this.i,c)+","+J(this.i,b)+")",!0,!0):(K(e,c,16,4),this.i&&F(this.i,64)&&E(this.i,"warning: unconverted write access to word @"+J(this.i,c)+": "+J(this.i,b),!0,!0))}
function gc(a,b){if(b!=a.C){var c;a.C&&(c=(1<<a.C)-$b,hc(a,c,$b,a.K),a.C=0);b&&(a.C=b,c=(1<<b)-$b,a.K=ic(a,c,$b),a.D?hc(a,c,$b,a.D):(jc(a,c,$b,kc,a),a.D=ic(a,c,$b)))}}k=Zb.prototype;k.reset=function(){for(var a=0;a<this.v.length;a++)this.v[a]();gc(this,16)};k.Fa=function(a,b){b||this.reset();return!0};
function jc(a,b,c,d,e){for(var f=b,g=c,h=f>>>a.ka;0<g&&h<a.X.length;){var l=a.X[h],m=h*a.ya,n=a.ya-(f-m);n>g&&(n=g);if(!e&&l&&l.size){if(l.type==d){if(f+g<=l.F)return l.Kb+=l.F-f,l.F=f,!0;if(f>=l.F+l.Kb){n=l.size-(f-m);n>g&&(n=g);l.Kb=f-l.F+n;f=m+a.ya;g-=n;h++;continue}}return lc(1,f,g)}f=new I(a,f,n,a.ya,d,e);ec(f,a.i,l);a.X[h++]=f;f=m+a.ya;g-=n}if(0>=g){c/=1024;var r;e="";r?10<r&&(r=10):r=c&-65536?10:5;if(null==c||isNaN(c))for(;0<r--;)e="?"+e;else for(;0<r--;)e=String.fromCharCode(c%10+48)+e,c/=
10;a.status(e+"Kb "+mc[d]+" at "+ra(b));return!0}return lc(2,b,c)}function ic(a,b,c){var d=[];for(b>>>=a.ka;0<c&&b<a.X.length;)d.push(a.X[b++]),c-=a.ya;return d}function hc(a,b,c,d){var e=0;for(b>>>=a.ka;0<c&&b<a.X.length;){var f=d[e++];if(!f)break;a.X[b++]=f;c-=a.ya}}k.Db=function(a){3932160<=a&&(a=nc(this.b,a));return this.X[(a&this.Ra)>>>this.ka].Rb(a&this.w,a)};k.Qb=function(a){this.g=!1;this.f++;a=this.X[(a&this.Ra)>>>this.ka].bc(a&this.w,a);this.f--;return a};
k.oa=function(a){3932160<=a&&(a=nc(this.b,a));return this.X[(a&this.Ra)>>>this.ka].ra(a&this.w,a)};k.lb=function(a){var b=a&this.w,c=(a&this.Ra)>>>this.ka;this.g=!1;this.f++;a=this.X[c].cc(b,a);this.f--;return a};k.Sb=function(a,b){3932160<=a&&(a=nc(this.b,a));this.X[(a&this.Ra)>>>this.ka].Ub(a&this.w,b&255,a)};k.nb=function(a,b){this.g=!1;this.f++;this.X[(a&this.Ra)>>>this.ka].Vb(a&this.w,b&255,a);this.f--};
k.ab=function(a,b){3932160<=a&&(a=nc(this.b,a));this.X[(a&this.Ra)>>>this.ka].Lb(a&this.w,b&65535,a)};k.Ib=function(a,b){var c=a&this.w,d=(a&this.Ra)>>>this.ka;this.g=!1;this.f++;this.X[d].gc(c,b&65535,a);this.f--};function oc(a){for(var b=0,c=[],d=0;d<a.B;d++){var e=a.X[d];if(e.Pa||e.Mc){c[b++]=d;var f=b++;if(e=e.save()){for(var g=0,h=0,l=[];g<e.length;){for(var m=e[g],n=g+1;n<e.length&&e[n]===m;)n++;l[h++]=n-g;l[h++]=m;g=n}l.length<e.length&&(e=l)}c[f]=e}}return c}
function pc(a,b,c,d,e,f,g,h){for(;b<=c;b+=2){var l=b&fc;void 0!==a.Ua[l]?q("I/O address already registered: "+p(b,8,!0)):a.Ua[l]=[d,e,f,g,h||"unknown",!1]}}
function Ab(a,b,c){for(var d in c){var e=+d,f=c[d];if(!(f[6]&&f[6]>a.b.rb)){var g=f[0]?f[0].bind(b):null,h=f[1]?f[1].bind(b):null,l=f[2]?f[2].bind(b):null,m=f[3]?f[3].bind(b):null,n=f[5]||1;65472<=e&&65487>=e&&(!g&&l&&(g=function(a){return function(b){return a(b)&255}.bind(b)}(l)),!h&&m&&(h=function(a){return function(b,c){return a(b,c)}.bind(b)}(m)));for(var r=f[4],t=0;t<n;t++,e+=2)r&&1<n&&(r=f[4]+t),pc(a,e,e,g,h,l,m,r)}}}function Cb(a,b){a.v.push(b)}
function K(a,b,c,d){a.g=!0;a.f||(a.i&&F(a.i,64)&&(E(a.i,"memory fault ("+d+") on address "+J(a.i,b),!0,!0),qc(a.i)),c&&(a.b.ga|=c),a.b.pa(4,b))}function rc(a){var b=a.g;a.g=!1;return b}function lc(a,b,c){q("Memory block error ("+a+": "+p(b)+","+p(c)+")");return!1}function L(a){u.call(this,"Device",a,L,256);this.f={fa:0,fc:-1}}z(L);k=L.prototype;
k.Da=function(a,b,c,d){this.w=b;this.b=c;this.i=d;var e=this;this.f.fc=sc(c,function(){e.f.Wa|=128;e.f.Wa&64&&(tc(e.b,e.f.Vd),uc(e.b,e.f.fc,1E3/60))});this.f.Vd=vc(64,6);Ab(b,this,M);Cb(b,this.reset.bind(this));H(this)};k.reset=function(){this.f.Wa=0};k.ld=function(){var a=this.f.Wa;this.f.Wa&=-129;return a};k.ee=function(a){this.f.Wa=a;a&64&&uc(this.b,this.f.fc,1E3/60);this.f.Wa=a&-129};k.nd=function(){var a=this.b;return a.B&62337|a.gb<<5|a.hb<<1};
k.ge=function(a){var b=this.b;a&=62337;if(b.B!=a){b.B=a;b.gb=a>>5&3;b.hb=a>>1&15;var c=0;a&257&&(c=4,a&1&&(c|=2));b.da!=c&&(b.da=c,wc(b));b.I&&b.I.Z()}};k.od=function(){var a=this.b.Ya;a&65280&&(a=(a<<8|a>>8)&65535);return a};k.pd=function(){return this.b.Hb};k.qd=function(){return this.b.xb};k.he=function(a){var b=this.b;1170>b.rb&&(a&=-49);b.xb!=a&&(b.xb=a,b.qc=a&16?4194303:262143,wc(b),b.I&&b.I.Z())};k.Qd=function(a){a=a>>1&63;var b=this.b.Jb[a>>1];return a&1?b>>16:b&65535};
k.He=function(a,b){b=b>>1&63;var c=b>>1;this.b.Jb[c]=b&1?this.b.Jb[c]&65535|(a&63)<<16:this.b.Jb[c]&-65536|a&65534};k.Jd=function(a){return this.b.V[1][a>>1&7]};k.Ae=function(a,b){this.b.V[1][b>>1&7]=a&65295};k.Hd=function(a){return this.b.V[1][(a>>1&7)+8]};k.ye=function(a,b){this.b.V[1][(b>>1&7)+8]=a&65295};k.Id=function(a){return this.b.xa[1][a>>1&7]};k.ze=function(a,b){b=b>>1&7;this.b.xa[1][b]=a;this.b.V[1][b]&=65295};k.Gd=function(a){return this.b.xa[1][(a>>1&7)+8]};
k.xe=function(a,b){b=(b>>1&7)+8;this.b.xa[1][b]=a;this.b.V[1][b]&=65295};k.kd=function(a){return this.b.V[0][a>>1&7]};k.de=function(a,b){this.b.V[0][b>>1&7]=a&65295};k.hd=function(a){return this.b.V[0][(a>>1&7)+8]};k.be=function(a,b){this.b.V[0][(b>>1&7)+8]=a&65295};k.jd=function(a){return this.b.xa[0][a>>1&7]};k.ce=function(a,b){b=b>>1&7;this.b.xa[0][b]=a;this.b.V[0][b]&=65295};k.gd=function(a){return this.b.xa[0][(a>>1&7)+8]};k.ae=function(a,b){b=(b>>1&7)+8;this.b.xa[0][b]=a;this.b.V[0][b]&=65295};
k.Pd=function(a){return this.b.V[3][a>>1&7]};k.Ge=function(a,b){this.b.V[3][b>>1&7]=a&65295};k.Nd=function(a){return this.b.V[3][(a>>1&7)+8]};k.Ee=function(a,b){this.b.V[3][(b>>1&7)+8]=a&65295};k.Od=function(a){return this.b.xa[3][a>>1&7]};k.Fe=function(a,b){b=b>>1&7;this.b.xa[3][b]=a;this.b.V[3][b]&=65295};k.Md=function(a){return this.b.xa[3][(a>>1&7)+8]};k.De=function(a,b){b=(b>>1&7)+8;this.b.xa[3][b]=a;this.b.V[3][b]&=65295};k.vb=function(a){a&=7;return this.b.M&2048?this.b.Sa[a]:this.b.u[a]};
k.yb=function(a,b){b&=7;this.b.M&2048?this.b.Sa[b]=a:this.b.u[b]=a};k.vd=function(){return this.b.M&49152?this.b.Ga[0]:this.b.u[6]};k.me=function(a){this.b.M&49152?this.b.Ga[0]=a:this.b.u[6]=a};k.yd=function(){return this.b.u[7]};k.pe=function(a){this.b.u[7]=a};k.wb=function(a){a&=7;return this.b.M&2048?this.b.u[a]:this.b.Sa[a]};k.zb=function(a,b){b&=7;this.b.M&2048?this.b.u[b]=a:this.b.Sa[b]=a};k.wd=function(){return 1==(this.b.M&49152)>>14?this.b.u[6]:this.b.Ga[1]};
k.ne=function(a){1==(this.b.M&49152)>>14?this.b.u[6]=a:this.b.Ga[1]=a};k.xd=function(){return 3==(this.b.M&49152)>>14?this.b.u[6]:this.b.Ga[3]};k.oe=function(a){3==(this.b.M&49152)>>14?this.b.u[6]=a:this.b.Ga[3]=a};k.ed=function(a){return this.b.zc[a-65504>>1]};k.Zd=function(a,b){this.b.zc[b-65504>>1]=a};k.wc=function(a){return 65520==a?61183:0};k.Dc=function(){};k.Ld=function(){return 1};k.Ce=function(){};k.dd=function(){return this.b.ga};k.Yd=function(){this.b.ga=0};k.md=function(){return this.b.yc};
k.fe=function(a,b){b&1||(a&=255);this.b.yc=a};k.rd=function(a){return a?this.b.ec:0};k.ie=function(a){var b=this.b;if(a&=65024){var c=a>>9;do a+=34;while(c>>=1)}b.ec=a;b.H|=2};k.Kd=function(a){return a?this.b.Za&65280:0};k.Be=function(a){this.b.Za=a|255};k.ud=function(){return Xb(this.b)};k.le=function(a){xc(this.b,a&-1809|Xb(this.b)&1808);this.b.H|=128};k.Cc=function(a,b){F(this)&&E(this,"writeIgnored("+ra(b)+"): "+ra(a),!0,!0)};
var N={},M=(N[61568]=[null,null,L.prototype.Qd,L.prototype.He,"UNIMAP",64,1170],N[62592]=[null,null,L.prototype.Jd,L.prototype.Ae,"SISDR",8,1145],N[62608]=[null,null,L.prototype.Hd,L.prototype.ye,"SDSDR",8,1145],N[62624]=[null,null,L.prototype.Id,L.prototype.ze,"SISAR",8,1145],N[62640]=[null,null,L.prototype.Gd,L.prototype.xe,"SDSAR",8,1145],N[62656]=[null,null,L.prototype.kd,L.prototype.de,"KISDR",8,1145],N[62672]=[null,null,L.prototype.hd,L.prototype.be,"KDSDR",8,1145],N[62688]=[null,null,L.prototype.jd,
L.prototype.ce,"KISAR",8,1145],N[62704]=[null,null,L.prototype.gd,L.prototype.ae,"KDSAR",8,1145],N[62798]=[null,null,L.prototype.qd,L.prototype.he,"MMR3",1,1145],N[65382]=[null,null,L.prototype.ld,L.prototype.ee,"LKS"],N[65402]=[null,null,L.prototype.nd,L.prototype.ge,"MMR0",1,1145],N[65404]=[null,null,L.prototype.od,L.prototype.Cc,"MMR1",1,1145],N[65406]=[null,null,L.prototype.pd,L.prototype.Cc,"MMR2",1,1145],N[65408]=[null,null,L.prototype.Pd,L.prototype.Ge,"UISDR",8,1145],N[65424]=[null,null,L.prototype.Nd,
L.prototype.Ee,"UDSDR",8,1145],N[65440]=[null,null,L.prototype.Od,L.prototype.Fe,"UISAR",8,1145],N[65456]=[null,null,L.prototype.Md,L.prototype.De,"UDSAR",8,1145],N[65472]=[null,null,L.prototype.vb,L.prototype.yb,"R0SET0"],N[65473]=[null,null,L.prototype.vb,L.prototype.yb,"R1SET0"],N[65474]=[null,null,L.prototype.vb,L.prototype.yb,"R2SET0"],N[65475]=[null,null,L.prototype.vb,L.prototype.yb,"R3SET0"],N[65476]=[null,null,L.prototype.vb,L.prototype.yb,"R4SET0"],N[65477]=[null,null,L.prototype.vb,L.prototype.yb,
"R5SET0"],N[65478]=[null,null,L.prototype.vd,L.prototype.me,"R6KERNEL"],N[65479]=[null,null,L.prototype.yd,L.prototype.pe,"R7KERNEL"],N[65480]=[null,null,L.prototype.wb,L.prototype.zb,"R0SET1",1,1145],N[65481]=[null,null,L.prototype.wb,L.prototype.zb,"R1SET1",1,1145],N[65482]=[null,null,L.prototype.wb,L.prototype.zb,"R2SET1",1,1145],N[65483]=[null,null,L.prototype.wb,L.prototype.zb,"R3SET1",1,1145],N[65484]=[null,null,L.prototype.wb,L.prototype.zb,"R4SET1",1,1145],N[65485]=[null,null,L.prototype.wb,
L.prototype.zb,"R5SET1",1,1145],N[65486]=[null,null,L.prototype.wd,L.prototype.ne,"R6SUPER",1,1145],N[65487]=[null,null,L.prototype.xd,L.prototype.oe,"R6USER",1,1145],N[65504]=[null,null,L.prototype.ed,L.prototype.Zd,"CTRL",1,1170],N[65520]=[null,null,L.prototype.wc,L.prototype.Dc,"LSIZE",1,1170],N[65522]=[null,null,L.prototype.wc,L.prototype.Dc,"HSIZE",1,1170],N[65524]=[null,null,L.prototype.Ld,L.prototype.Ce,"SYSID",1,1170],N[65526]=[null,null,L.prototype.dd,L.prototype.Yd,"CPUERR",1,1170],N[65528]=
[null,null,L.prototype.md,L.prototype.fe,"MB",1,1170],N[65530]=[null,null,L.prototype.rd,L.prototype.ie,"PIR"],N[65532]=[null,null,L.prototype.Kd,L.prototype.Be,"SL"],N[65534]=[null,null,L.prototype.ud,L.prototype.le,"PSW"],N);M[65506]=M[65504];M[65508]=M[65504];M[65510]=M[65504];M[65512]=M[65504];M[65514]=M[65504];M[65516]=M[65504];M[65518]=M[65504];
Xa(function(){for(var a=D(document,"pdp11","device"),b=0;b<a.length;b++){var c,d=a[b];c=B(d);switch(c.type){case "default":c=new L(c);C(c,d);break;case "pc11":c=new Hc(c);C(c,d);break;case "rl11":c=new O(c),C(c,d)}}});var Ic;if(wb){var Jc=new ArrayBuffer(2);(new DataView(Jc)).setUint16(0,256,!0);Ic=256===(new Uint16Array(Jc))[0]}else Ic=!1;var Kc=Ic;
function I(a,b,c,d,e,f){this.w=a;this.id=Lc+=2;this.b=null;this.F=b;this.Kb=c;this.size=d||0;this.type=e||Mc;this.f=e==Nc;this.controller=null;ec(this);this.Pa=this.Mc=!1;if(this.size)if(f)this.controller=f,a=[null,0],this.b=a[0],Oc(this,f.Gc);else if(wb)this.B=new ArrayBuffer(this.size),this.D=new DataView(this.B,0,this.size),this.G=new Uint8Array(this.B,0,this.size),this.J=new Uint16Array(this.B,0,this.size>>1),this.b=new Int32Array(this.B,0,this.size>>2),Oc(this,Kc?Pc:Qc);else{a=this.b=Array(this.size>>
2);for(f=0;f<a.length;f++)a[f]=0;Oc(this,Rc)}else Oc(this)}var Mc=0,Nc=2,kc=4,mc=["NONE","RAM","ROM","VID","H/W"],Lc=0;
I.prototype={constructor:I,parent:null,save:function(){var a,b;if(this.controller)a=null;else if(wb)for(a=Array(this.size>>2),b=0;b<a.length;b++)a[b]=this.D.getInt32(b<<2,!0);else a=this.b;return a},restore:function(a){if(this.controller)return!a;if(a&&this.size==a.length<<2){var b;if(wb)for(b=0;b<a.length;b++)this.D.setInt32(b<<2,a[b],!0);else this.b=a;return this.Pa=!0}return!1},jb:function(a,b){b?this.C++||Sc(this,Tc,!1):this.g++||Uc(this,Tc,!1)},K:function(a,b){this.i&&F(this.i,128)&&(E(this.i,
"attempt to read invalid address "+J(this.i,b),!0),qc(this.i));K(this.w,b,32,2);return 255},v:function(a,b,c){this.i&&F(this.i,128)&&(E(this.i,"attempt to write "+J(this.i,b)+" to invalid addresses "+J(this.i,c),!0),qc(this.i));K(this.w,c,32,4)},L:function(a,b){return this.Rb(a++,b++)|this.Rb(a,b)<<8},I:function(a,b,c){this.Ub(a++,b&255,c++);this.Ub(a,b>>8,c)},S:function(a){return this.b[a>>2]>>>((a&3)<<3)&255},da:function(a,b){a&1&&K(this.w,b,64,2);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;a=(a&3)<<3;this.b[c]=this.b[c]&~(255<<a)|b<<a;this.Pa=!0},Ha:function(a,b,c){a&1&&K(this.w,c,64,4);c=a>>2;a=(a&3)<<3;24>a?this.b[c]=this.b[c]&~(65535<<a)|b<<a:(this.b[c]=this.b[c]&16777215|b<<24,c++,this.b[c]=this.b[c]&-256|b>>8);this.Pa=!0},O:function(a,b){if(this.i&&null!=this.F){var c=this.i;Vc(c,this.F+a,1,c.L)&&c.ha(!0)}return this.bc(a,b)},Na:function(a,b){if(this.i&&null!=this.F){var c=this.i;Vc(c,this.F+a,2,c.L)&&c.ha(!0)}return this.cc(a,
b)},ma:function(a,b,c){if(this.i&&null!=this.F){var d=this.i;Vc(d,this.F+a,1,d.B)&&d.ha(!0)}this.f?this.v(a,b,c):this.Vb(a,b,c)},Aa:function(a,b,c){if(this.i&&null!=this.F){var d=this.i;Vc(d,this.F+a,2,d.B)&&d.ha(!0)}this.f?this.v(a,b,c):this.gc(a,b,c)},N:function(a){return this.G[a]},R:function(a,b){a=this.G[a];this.i&&F(this.i,128)&&E(this.i,"Memory.readByte("+J(this.i,b)+"): "+J(this.i,a),!0);return a},W:function(a,b){a&1&&K(this.w,b,64,2);return this.D.getUint16(a,!0)},$:function(a,b){a&1&&K(this.w,
b,64,2);a=this.J[a>>1];this.i&&F(this.i,128)&&E(this.i,"Memory.readWord("+J(this.i,b)+"): "+J(this.i,a),!0);return a},la:function(a,b){this.G[a]=b;this.Pa=!0},ta:function(a,b,c){this.G[a]=b;this.Pa=!0;this.i&&F(this.i,128)&&E(this.i,"Memory.writeByte("+J(this.i,c)+","+J(this.i,b)+")",!0)},wa:function(a,b,c){a&1&&K(this.w,c,64,4);this.D.setUint16(a,b,!0);this.Pa=!0},fb:function(a,b,c){a&1&&K(this.w,c,64,4);this.J[a>>1]=b;this.Pa=!0;this.i&&F(this.i,128)&&E(this.i,"Memory.writeWord("+J(this.i,c)+","+
J(this.i,b)+")",!0)}};function ec(a,b,c){a.i=b;a.g=a.C=0;c&&((a.g=c.g)&&Uc(a,Tc,!1),(a.C=c.C)&&Sc(a,Tc,!1))}function Wc(a,b){b?--a.C||(a.Ub=a.f?a.v:a.Vb,a.Lb=a.f?a.I:a.gc):--a.g||(a.Rb=a.bc,a.ra=a.cc)}function Sc(a,b,c){c&&a.C||(a.Ub=!a.f&&b[1]||a.v,a.Lb=!a.f&&b[3]||a.I);if(c||void 0===c)a.Vb=b[1]||a.v,a.gc=b[3]||a.I}function Uc(a,b,c){c&&a.g||(a.Rb=b[0]||a.K,a.ra=b[2]||a.L);if(c||void 0===c)a.bc=b[0]||a.K,a.cc=b[2]||a.L}function Oc(a,b){b||(b=Xc);Uc(a,b,void 0);Sc(a,b,void 0)}
var Xc=[],Rc=[I.prototype.S,I.prototype.va,I.prototype.da,I.prototype.Ha],Tc=[I.prototype.O,I.prototype.ma,I.prototype.Na,I.prototype.Aa];if(wb)var Qc=[I.prototype.N,I.prototype.la,I.prototype.W,I.prototype.wa],Pc=[I.prototype.R,I.prototype.ta,I.prototype.$,I.prototype.fb];
function Yc(a,b){u.call(this,"CPU",a,Yc,1);var c=a.multiplier||1;this.ib=a.cycles||b;this.Xa=c;this.Bb=Math.round(this.ib/1E4)/100;this.mb=this.Bb*this.Xa;this.A.ca=!1;this.A.Tb=!1;this.A.pb=a.autoStart;this.A.qb=!1;this.Eb=this.va=0;this.Fb=a.csStart;this.sb=a.csInterval;this.tb=a.csStop;this.L=[];this.uc=this.Ud.bind(this);H(this)}z(Yc);var Zc=["power","reset"];k=Yc.prototype;
k.Da=function(a,b,c,d){this.C=a;this.w=b;this.i=d;this.I=a.I;for(b=0;b<Zc.length;b++)(c=this.G[Zc[b]])&&this.C.sa(null,Zc[b],c);a=$c(a,"autoStart");null!=a&&(this.A.pb="true"==a?!0:"false"==a?!1:!!a);H(this)};k.reset=function(){};k.save=function(){return null};k.restore=function(){return!1};
k.Fa=function(a,b){if(!b){if(a&&this.restore){ad(this);if(!this.restore(a))return!1;bd(this)}else this.reset();this.i?(a=this.i,b=this.A.pb,a.hb=!0,a.j("Type ? for help with PDPjs Debugger commands"),a.Z(),b||a.ob(),a.Ha&&(b=a.Ha,a.Ha=null,cd(a,b))):this.j("No debugger detected")}this.C.Z();return!0};k.Ea=function(a){return a?this.save():!0};k.pb=function(){return this.A.pb||!this.i&&void 0===this.G.run?(this.bb(),!0):!1};k.nc=function(){return 0};
function bd(a){void 0===a.Fb&&(a.Fb=0);void 0===a.sb&&(a.sb=-1);void 0===a.tb&&(a.tb=-1);a.A.qb=0<=a.Fb&&0<a.sb;a.A.qb&&(a.Eb=0,a.va=a.Fb-a.ta)}function dd(a,b){if(a.A.qb){var c=!1;a.Eb=a.Eb+a.nc()|0;a.va-=b;0>=a.va&&(a.va+=a.sb,c=!0);0<=a.tb&&a.tb<=ed(a)&&(a.sb=a.tb=-1,bd(a),a.ha(),c=!0);c&&a.j(ed(a)+" cycles: checksum="+p(a.Eb))}}
k.sa=function(a,b,c){var d=this;switch(b){case "power":case "reset":return this.G[b]=c,!0;case "run":return this.G[b]=c,c.onclick=function(){var a;if(a=d.C)if(a=d.C,a.A.ja)a=!0;else{var b=null,c,h=ob(a.id);for(c=0;c<h.length&&(b=h[c],b===a||b.A.ready);c++);if(c==h.length)for(c=0;c<h.length&&(b=h[c],b===a||b.A.ja);c++);c==h.length&&(b=a);q("The "+b.type+" component ("+b.id+") is not "+(b.A.ready?"powered yet":"ready yet"+(b.Pb?" (waiting for notification)":""))+".");a=!1}a&&(d.A.ca?d.ha():d.bb())},
!0;case "speed":return this.G[b]=c,!0;case "setSpeed":return this.G[b]=c,c.onclick=function(){fd(d,d.Xa<<1,!0)},c.textContent=this.mb.toFixed(2)+"Mhz",!0}return!1};k.Z=function(){var a=this.G.speed;a&&(a.textContent=this.A.ca&&this.$?this.$.toFixed(2)+"Mhz":"Stopped")};function gd(a,b,c){a.ta+=b;c&&(a.ma=a.b=a.K=0)}function hd(a,b){var c=1;b&&1<a.Xa&&a.$&&(c=a.$/a.Bb);a.rc=Math.round(1E3/30);a.kb=Math.floor(a.ib/30*c);b||(a.wa=a.kb);a.Cb=0}function ed(a){return a.ta+a.W+a.ma-a.b}
function ad(a){a.$=0;a.tc=0;a.ta=a.W=a.ma=a.b=a.K=0;bd(a);fd(a,1)}function fd(a,b,c){var d=!1;if(void 0!==b){.8>a.$/a.mb?b=1:d=!0;a.Xa=b;b=a.Bb*a.Xa;if(a.mb!=b){a.mb=b;b=a.mb.toFixed(2)+"Mhz";var e=a.G.setSpeed;e&&(e.textContent=b);a.j("target speed: "+b)}c&&a.C&&a.C.ob()}gd(a,a.W);a.W=0;a.S=Ba();a.la=0;hd(a);return d}function sc(a,b){var c=a.L.length;a.L.push([-1,b]);return c}function uc(a,b,c){0<=b&&b<a.L.length&&0>a.L[b][0]&&(c=a.ib*a.Xa/1E3*c|0,a.L[b][0]=c+id(a))}
function jd(a,b){for(var c=a.L.length-1;0<=c;c--){var d=a.L[c];0>d[0]||b>d[0]&&(b=d[0])}return b}function kd(a,b){for(var c=a.L.length-1;0<=c;c--){var d=a.L[c];0>d[0]||(d[0]-=b,0>=d[0]&&(d[0]=-1,d[1]()))}}function id(a,b){var c=a.ma-=a.b;a.b=a.K=0;b&&(a.ma=0);return c}
k.Ud=function(){if(this.A.ca){this.Cb>=this.ib&&hd(this,!0);this.Ha=0;this.eb=Ba();if(this.la){var a=this.eb-this.la;a>this.rc&&(this.S+=a,this.S>this.eb&&(this.S=this.eb))}try{do{var b=jd(this,this.A.qb?1:this.kb);try{this.cb(b)}catch(e){if("number"!=typeof e)throw e;}b=id(this,!0);this.Ha+=b;this.W+=b;dd(this,b);kd(this,b);this.wa-=b;if(0>=this.wa){this.wa+=this.kb;15<=++this.tc&&(this.C&&this.C.Z(),this.tc=0);break}}while(this.A.ca)}catch(e){this.ha();this.C&&this.C.stop(Ba(),ed(this));vb(this,
e.stack||e.message);return}if(this.A.ca){a=setTimeout;b=this.uc;this.la=Ba();var c=this.rc;this.Ha&&(c=Math.round(c*this.Ha/this.kb));var c=c-(this.la-this.eb),d=this.la-this.S;d&&(this.$=Math.round(this.W/(10*d))/100,864E5<=d&&(this.ta=0,fd(this)));if(0>c||this.$<this.mb)-1E3>c&&(this.S-=c),c=0;this.Cb+=this.Ha;this.la+=c;a(b,c)}}};
k.bb=function(a){if(ub(this))return!1;if(this.A.ca)return this.j(this.toString()+" busy"),!1;fd(this);this.A.ca=!0;this.A.Tb=!0;var b=this.G.run;b&&(b.textContent="Halt");this.C&&(a&&this.C.ob(!0),this.C.start(this.S,ed(this)));setTimeout(this.uc,0);return!0};k.cb=function(){return 0};k.ha=function(a){var b=!1;if(this.A.ca){id(this);gd(this,this.W);this.W=0;this.A.ca=!1;if(b=this.G.run)b.textContent="Run";this.C&&this.C.stop(Ba(),ed(this));b=!0}this.A.complete=a;return b};
function ld(a){this.rb=+a.model||1170;this.Ob=a.addrReset||0;Yc.call(this,a,6666667);this.decode=1120==this.rb?md.bind(this):nd.bind(this);od(this);this.N=0;this.O=null;this.A.complete=!1}z(ld,Yc);k=ld.prototype;k.reset=function(){this.status("model "+this.rb);this.A.ca&&this.ha();od(this);ad(this);this.A.error=!1;this.parent.reset.call(this)};
function od(a){a.T=65536;a.U=32768;a.aa=65535;a.Y=32768;a.M=15;a.u=[0,0,0,0,0,0,0,a.Ob];a.Sa=[0,0,0,0,0,0];a.Ga=[0,0,0,0];a.v=0;a.hb=0;a.Pc=[4,2,0,1];a.V=[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[65535,65535,65535,65535,65535,65535,65535,65535],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];a.xa=[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];a.Jb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0];a.zc=[0,0,0,0,0,0,0,0];a.yc=0;a.H=0;a.D=a.J=0;a.g=a.f=a.Ab=0;a.Aa=-1;Ub(a)}function Ub(a){a.Za=255;a.ga=0;a.ec=0;a.B=0;a.Ya=0;a.Hb=0;a.xb=0;a.da=0;a.gb=0;a.qc=262143;a.O=null;a.w&&wc(a)}function wc(a){a.da?(a.R=65536,a.ba=a.Oc,a.ra=a.Rd,a.Lb=a.Ie,gc(a.w,a.xb&16?22:18)):(a.R=0,a.ba=a.Nc,a.ra=a.xc,a.Lb=a.Ec,gc(a.w,16))}function pd(a,b,c){a.Ob=b;P(a,b);!c&&a.i&&(a.ha()||a.i.Z())}k.nc=function(){return 0};
k.save=function(){var a=new R(this);a.set(0,[]);a.set(1,[this.ta,this.Xa]);a.set(2,oc(this.w));return a.data()};k.restore=function(a){var b=a[1];this.ta=b[1];fd(this,b[3]);a:{b=this.w;a=a[2];var c;for(c=0;c<a.length-1;c+=2){var d=a[c],e=a[c+1];if(e&&e.length<b.J){for(var f=0,g=Array(b.J),h=0;h<e.length-1;)for(var l=e[h++],m=e[h++];l--;)g[f++]=m;e=g}f=b.X[d];if(!f||!f.restore(e)){q("Unable to restore memory block "+d);b=!1;break a}}b=!0}return b};function qd(a){return a.T&65536?1:0}
function rd(a){return a.U&32768?2:0}function sd(a){return a.aa&65535?0:4}k.Qa=function(){return this.Y&32768?8:0};function td(a){var b=a.u[7];a.B&57344||(a.Ya=0,a.Hb=b);a.u[7]=b+2&65535;return a.ra(b)}function ud(a,b){var c=a.u[7];a.u[7]=c+b&65535;return c}function P(a,b){a.u[7]=b&65535}function vc(a,b){return{Wd:a,ub:b,next:null}}function tc(a,b){if(b!=a.O){var c=a.O;if(!c||c.ub<=b.ub)b.next=c,a.O=b;else{do{var d=c.next;if(!d||d.ub<=b.ub){b.next=d;c.next=b;break}c=d}while(c)}}a.H|=2}
function Xb(a){return a.M=a.M&63728|a.Qa()|sd(a)|rd(a)|qd(a)}function xc(a,b){a.Y=b<<12;a.aa=~b&4;a.U=b<<14;a.T=b<<16;if((b^a.M)&2048)for(var c=a.Sa.length;0<=--c;){var d=a.u[c];a.u[c]=a.Sa[c];a.Sa[c]=d}a.v=b>>14&3;c=a.M>>14&3;a.v!=c&&(a.Ga[c]=a.u[6],a.u[6]=a.Ga[a.v]);a.M=b;a.H|=2}function S(a,b){a.H&128||(a.Y=a.aa=b,a.U=0)}function vd(a,b,c){a.H&128||(a.Y=a.aa=a.T=b,a.U=c||0)}function wd(a,b,c,d){a.H&128||(a.Y=a.aa=a.T=b,a.U=(c^b)&(d^b))}
function xd(a,b){a.H&128||(a.Y=a.aa=a.T=b,a.U=a.Y^a.T>>1)}function yd(a,b,c,d){a.H&128||(a.Y=a.aa=a.T=b,a.U=(c^d)&(d^b))}k.pa=function(a,b){if(!this.N){var c=!1;0>this.Aa?this.Aa=Xb(this):this.v||(a=4,c=!0);this.B&57344||(this.Ya=63222,this.Hb=a);this.v=0;var d=this.ra(a|this.R),e=this.ra(a+2&65535|this.R);xc(this,e&-12289|this.Aa>>2&12288);c&&(this.ga|=4,this.u[6]=4);zd(this,this.Aa);zd(this,this.u[7]);P(this,d);this.H&=-113;this.Aa=-1;this.H|=8;this.Tc=a;this.Sc=b;if(26!=b)throw a;}};
function Ad(a){var b=Bd(a),c=Bd(a)&-1793;a.M&49152&&(c=c&-225|a.M&63712);P(a,b);xc(a,c);a.H&=-17}function nc(a,b){var c=b>>13&31;31>c&&a.xb&32&&(b=a.Jb[c]+(b&8190)&4194302,3932160<=b&&4186112>b&&console.log("panic(898)"));return b}
function Td(a,b,c){var d,e,f,g=0;d=b>>13;a.xb&a.Pc[a.v]||(d&=7);e=a.V[a.v][d];f=(a.xa[a.v][d]<<6)+(b&8191)&a.qc;switch(e&7){case 1:g=4096;case 2:e|=128;c&4&&(g=8192);break;case 4:g=4096;case 5:c&4&&(g=4096);case 6:e|=c&4?192:128;break;default:g=32768}32512!==(e&32520)&&(e&8?e&32512&&(b&8128)<(e>>2&8128)&&(g|=16384):(b&8128)>(e>>2&8128)&&(g|=16384));a.V[a.v][d]=e;if(4194170!==f||a.v)a.gb=a.v,a.hb=d;b=!1;g&&(g&57344&&(0<=a.Aa&&(g|=128),a.B&57344||(a.B=a.B|g|a.gb<<5|a.hb<<1),b=!0),a.B&61440||!(4191360>
f||4194239<f)||(a.B|=4096,a.B&512&&(a.H|=32)),b&&a.pa(168,16));return f}function Ud(a,b){return a.w.Db(b)}function Vd(a,b,c){b&1&&a.b--;a.w.Sb(b,c&255)}function Bd(a){var b=a.ra(a.u[6]|a.R);a.u[6]=a.u[6]+2&65535;return b}function zd(a,b){var c=a.u[6]-2&65535;a.u[6]=c;a.B&57344||(a.Ya=a.Ya<<8|246);!a.v&&c<=a.Za&&4<c&&(c<=a.Za-32?(a.ga|=4,a.u[6]=4,a.pa(4,18)):(a.ga|=8,a.H|=4));a.Lb(c,b)}
function Wd(a,b,c,d){var e,f,g=d&8?0:a.R;switch(b){case 0:return a.pa(4,20),0;case 1:return 6===c&&!a.v&&d&4&&(a.u[6]<=a.Za||65534<=a.u[6])&&(a.u[6]<=a.Za-32||65534<=a.u[6]?(a.ga|=4,a.u[6]=4,a.pa(4,22)):(a.ga|=8,a.H|=64)),a.b-=3,7===c?a.u[c]:a.u[c]|g;case 2:f=2;e=a.u[c];7!==c&&(e|=g,6>c&&d&1&&(f=1));a.b-=3;break;case 3:f=2;e=a.u[c];7!==c&&(e|=g);e=a.ra(e);e|=g;a.b-=7;break;case 4:f=-2;6>c&&d&1&&(f=-1);e=a.u[c]+f&65535;7!==c&&(e|=g);a.b-=4;break;case 5:f=-2;e=a.u[c]-2&65535;7!==c&&(e|=g);e=a.ra(e)|
g;a.b-=8;break;case 6:return e=a.ra(ud(a,2)),e=e+a.u[c]&65535|g,a.b-=6,e;case 7:return e=a.ra(ud(a,2)),e=e+a.u[c]&65535,e=a.ra(e|a.R)|g,a.b-=10,e}a.u[c]=a.u[c]+f&65535;!g||a.B&57344||(a.Ya=a.Ya<<8|f<<3&248|c);6==c&&!a.v&&d&4&&0>=f&&(a.u[6]<=a.Za||65534<=a.u[6])&&(a.u[6]<=a.Za-32?(a.ga|=4,a.u[6]=4,a.pa(4,24)):(a.ga|=8,a.H|=64));return e}k.Qb=function(a){if(!this.da)return this.w.Qb(a);this.N++;a=Ud(this,Td(this,a,3));this.N--;return a};
k.lb=function(a){if(!this.da)return this.w.lb(a);this.N++;a=this.xc(Td(this,a,2));this.N--;return a};k.nb=function(a,b){this.da?(this.N++,Vd(this,Td(this,a,5),b),this.N--):this.w.nb(a,b)};k.Ib=function(a,b){this.da?(this.N++,this.Ec(Td(this,a,4),b),this.N--):this.w.Ib(a,b)};k.Nc=function(a,b,c){return Wd(this,a,b,c)};k.Oc=function(a,b,c){return Td(this,Wd(this,a,b,c),c)};k.xc=function(a){return this.w.oa(a)};k.Rd=function(a){return this.w.oa(Td(this,a,2))};k.Ec=function(a,b){this.w.ab(a,b&65535)};
k.Ie=function(a,b){this.w.ab(Td(this,a,4),b)};function Xd(a,b,c){var d=a.f=b&7;(b=a.g=(b&56)>>3)?(d=Wd(a,b,d,2),c&65536||61440!==(a.M&61440)&&(d&=65535),a.v=a.M>>12&3,c=a.ra(d|c&a.R),a.v=a.M>>14&3):c=6!=d||(a.M>>2&12288)===(a.M&12288)?a.u[d]:a.Ga[a.M>>12&3];return c}function Yd(a,b,c,d){a.B&57344||(a.Ya=22);var e=a.f=b&7;(b=a.g=(b&56)>>3)?(e=Wd(a,b,e,4),c&65536||(e&=65535),a.v=a.M>>12&3,e=Td(a,e|c&65536,4),a.v=a.M>>14&3,a.w.ab(e,d)):6!=e||(a.M>>2&12288)===(a.M&12288)?a.u[e]=d:a.Ga[a.M>>12&3]=d}
function Zd(a,b){b>>=6;var c=a.J=b&7;return(b=a.D=(b&56)>>3)?Ud(a,a.ba(b,c,3)):a.u[c]&255}function $d(a,b){b>>=6;var c=a.J=b&7;return(b=a.D=(b&56)>>3)?a.w.oa(a.ba(b,c,2)):a.u[c]}function ae(a,b){var c=a.f=b&7;b=a.g=(b&56)>>3;return Wd(a,b,c,8)}function be(a,b){var c=a.f=b&7;return(b=a.g=(b&56)>>3)?Ud(a,a.ba(b,c,3)):a.u[c]&255}function ce(a,b){var c=a.f=b&7;return(b=a.g=(b&56)>>3)?a.w.oa(a.ba(b,c,2)):a.u[c]}
function T(a,b,c,d){var e=a.f=b&7;(b=a.g=(b&56)>>3)?(e=a.Ab=a.ba(b,e,7),Vd(a,e,d.call(a,c,Ud(a,e)))):a.u[e]=a.u[e]&65280|d.call(a,c,a.u[e])}function U(a,b,c,d){var e=a.f=b&7;(b=a.g=(b&56)>>3)?(e=a.ba(b,e,6),a.w.ab(e,d.call(a,c,a.w.oa(e)))):a.u[e]=d.call(a,c,a.u[e])}function de(a,b,c,d){var e=a.f=b&7;(b=a.g=(b&56)>>3)?Vd(a,a.ba(b,e,5),c):a.u[e]=c?d&1?c<<24>>24&65535:a.u[e]&-256|c&255:a.u[e]&-256;return c}
function ee(a,b,c){var d=a.f=b&7;(b=a.g=(b&56)>>3)?a.w.ab(a.ba(b,d,4),c):a.u[d]=c&65535;return c}function V(a,b,c){c&&(P(a,a.u[7]+(b<<24>>23)),a.b-=2);a.b-=3}
k.cb=function(a){this.A.complete=!0;var b=this.i&&fe(this.i)?1:this.A.Tb?-1:0,c=a?this.A.Tb?0:1:-1;this.A.Tb=!1;this.ma=this.b=a;do{if(b){if(this.i&&ge(this.i,this.u[7],c)){this.ha();break}c||c++;b++}if(this.H){this.H&112&&(this.H&32?this.pa(168,28):this.H&64?this.pa(4,30):this.H&16&&this.pa(12,32),this.H&=-113);if(a=this.H&7){a=!1;if(this.H&2){this.H&=-3;var d=160,e=(this.ec&224)>>5,f=this.O&&this.O.ub>e?this.O:null;f&&(d=f.Wd,e=f.ub);e>(this.M&224)>>5?(this.H&4&&(ud(this,2),this.H&=-5),this.pa(d,
26),e=!0):e=!1;if(e){if(f)if(a=f,f=this.O,f==a)this.O=a.next;else for(;f;){e=f.next;if(e==a){f.next=e.next;break}f=e}a=!0}}else this.H&1&&this.H++;a=a&&0>c}if(a)break}this.H=this.H&7|this.M&16;this.decode(td(this))}while(0<this.b);return this.A.complete?this.ma-this.b:void 0===this.A.complete?0:-1};Xa(function(){for(var a=D(document,"pdp11","cpu"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new ld(d);C(d,c)}});function he(a,b){var c=b+a;wd(this,c,a,b);return c&65535}
function ie(a,b){var c=b+a;wd(this,c<<8,a<<8,b<<8);return c&255}function je(a,b){a=b<<1;xd(this,a);return a&65535}function ke(a,b){a=b<<1;xd(this,a<<8);return a&255}function le(a,b){a=b&32768|b>>1|b<<16;xd(this,a);return a&65535}function me(a,b){a=b&2048|b>>1|b<<8;xd(this,a<<8);return a&255}function ne(a,b){a=b&~a;S(this,a);return a}function oe(a,b){a=b&~a;S(this,a<<8);return a}function pe(a,b){a|=b;S(this,a);return a}function qe(a,b){a|=b;S(this,a<<8);return a}
function re(a,b){a=~b|65536;vd(this,a);return a&65535}function se(a,b){a=~b|256;vd(this,a<<8);return a&255}function te(a,b){a=b-a;this.H&128||(this.Y=this.aa=a,this.U=b&(b^a));return a&65535}function ue(a,b){a=b-a;var c=a<<8;b<<=8;this.H&128||(this.Y=this.aa=c,this.U=b&(b^c));return a&255}function ve(a,b){a=b+a;this.H&128||(this.Y=this.aa=a,this.U=a&(b^a));return a&65535}function we(a,b){a=b+a;var c=a<<8;this.H&128||(this.Y=this.aa=c,this.U=c&(b<<8^c));return a&255}
function xe(a,b){a=-b;vd(this,a,a&b&32768);return a&65535}function ye(a,b){a=-b;vd(this,a<<8,(a&b&128)<<8);return a&255}function ze(a,b){a=b<<1|this.T>>16&1;xd(this,a);return a&65535}function Ae(a,b){a=b<<1|this.T>>16&1;xd(this,a<<8);return a&255}function Be(a,b){a=(this.T&65536|b)>>1|b<<16;xd(this,a);return a&65535}function Ce(a,b){a=((this.T&65536)>>8|b)>>1|b<<8;xd(this,a<<8);return a&255}function De(a,b){var c=b-a;yd(this,c,a,b);return c&65535}
function Ee(a,b){var c=b-a;yd(this,c<<8,a<<8,b<<8);return c&255}function Fe(a,b){this.H&128||(this.Y=this.aa=b&65280,this.U=this.T=0);return(b<<8|b>>8)&65535}function Ge(a,b){a^=b;S(this,a);return a&65535}function He(a){U(this,a,$d(this,a),he);this.b-=this.g?9+(this.J&&6<=this.f?1:0):(this.D?5:3)+(7==this.f?2:0)}
function Ie(a){var b=ce(this,a);a=a>>6&7;var c=this.u[a];c&32768&&(c|=4294901760);this.T=this.U=0;b&=63;if(b&32)b=64-b,16<b&&(b=16),this.T=c<<17-b,c>>=b;else if(b)if(16<b)this.U=c,c=0;else{this.T=c<<=b;var d=c>>15&65535;d&&65535!==d&&(this.U=32768)}this.u[a]=c&65535;this.Y=this.aa=c;this.b-=(this.g?6:7)+b}
function Je(a){var b=ce(this,a);a=a>>6&7;var c=this.u[a]<<16|this.u[a|1];this.T=this.U=0;b&=63;if(b&32){b=64-b;32<b&&(b=32);var d=c>>b-1;this.T=d<<16;d>>=1;c&2147483648&&(d|=4294967295<<32-b)}else b?(d=c<<b-1,this.T=d>>15,d<<=1,32<b&&(b=32),(c>>=32-b)&&4294967295!==(c|4294967295<<b&4294967295)&&(this.U=32768)):d=c;this.u[a]=d>>16&65535;this.u[a|1]=d&65535;this.Y=d>>16;this.aa=d>>16|d;this.b-=(this.g?6:7)+b}function Ke(a){V(this,a,!qd(this))}function Le(a){V(this,a,qd(this))}
function Me(a){U(this,a,$d(this,a),ne);this.b-=this.g?9+(this.J&&6<=this.f?1:0):(this.D?5:3)+(7==this.f?2:0)}function Ne(a){T(this,a,Zd(this,a),oe);this.b-=this.g?9+(this.J&&6<=this.f?1:0):(this.D?5:3)+(7==this.f?2:0)}function Oe(a){U(this,a,$d(this,a),pe);this.b-=this.g?9+(this.J&&6<=this.f?1:0):(this.D?5:3)+(7==this.f?2:0)}function Pe(a){T(this,a,Zd(this,a),qe);this.b-=this.g?9+(this.J&&6<=this.f?1:0):(this.D?5:3)+(7==this.f?2:0)}
function Qe(a){S(this,$d(this,a)&ce(this,a));this.b-=this.g?4+(this.J&&6<=this.f?1:0):(this.D?4:3)+(7==this.f?2:0)}function Re(a){S(this,(Zd(this,a)&be(this,a))<<8);this.b-=this.g?4+(this.J&&6<=this.f?1:0):(this.D?4:3)+(7==this.f?2:0)}function Se(a){V(this,a,sd(this))}function Te(a){V(this,a,!this.Qa()==!rd(this))}function Ue(a){V(this,a,!sd(this)&&!this.Qa()==!rd(this))}function Ve(a){V(this,a,!qd(this)&&!sd(this))}function We(a){V(this,a,sd(this)||!this.Qa()!=!rd(this))}
function Xe(a){V(this,a,qd(this)||sd(this))}function Ye(a){V(this,a,!this.Qa()!=!rd(this))}function Ze(a){V(this,a,this.Qa())}function $e(a){V(this,a,!sd(this))}function af(a){V(this,a,!this.Qa())}function bf(){this.pa(12,1);this.b-=5}function cf(a){V(this,a,!0)}function df(a){V(this,a,!rd(this))}function ef(a){V(this,a,rd(this))}function W(a){a&1&&(this.T=0);a&2&&(this.U=0);a&4&&(this.aa=1);a&8&&(this.Y=0);this.b-=5}
function ff(a){var b=$d(this,a);a=ce(this,a);yd(this,b-a,a,b);this.b-=this.g?4+(this.J&&6<=this.f?1:0):(this.D?4:3)+(7==this.f?2:0)}function gf(a){var b=Zd(this,a)<<8;a=be(this,a)<<8;yd(this,b-a,a,b);this.b-=this.g?4+(this.J&&6<=this.f?1:0):(this.D?4:3)+(7==this.f?2:0)}
function hf(a){var b=ce(this,a);if(b){a=a>>6&7;var c=this.u[a]<<16|this.u[a|1];this.T=this.U=0;b&32768&&(b|=-65536);var d=~~(c/b);-32768<=d&&32767>=d?(this.u[a]=d&65535,this.u[a|1]=c-d*b&65535,this.aa=d>>16|d,this.Y=d>>16):(this.U=32768,this.aa=d>>15|d,this.Y=c>>16,-1===b&&65534===this.u[a]&&(this.u[a]=this.u[a|1]=1));this.b-=53}else this.aa=this.Y=0,this.U=32768,this.T=65536,this.b-=7}function jf(){this.pa(24,2);this.b-=25}
function kf(){this.M&49152?(this.ga|=128,this.pa(4,3)):this.i?qc(this.i):this.ha();this.b-=7}function lf(){this.pa(16,4);this.b-=25}var mf=[0,7,7,10,7,11,9,13];function nf(a){this.K=this.b;P(this,ae(this,a));this.b=this.K-mf[this.g]}var of=[0,14,14,17,14,18,16,20];function pf(a){this.K=this.b;var b=ae(this,a);a=a>>6&7;zd(this,this.u[a]);this.u[a]=this.u[7];P(this,b);this.b=this.K-of[this.g]}var qf=[3,9,9,13,10,14,12,16,4,9,9,13,10,14,13,17];
function rf(a){var b=$d(this,a);this.K=this.b;S(this,ee(this,a,b));this.b=this.K-qf[(this.D?8:0)+this.g]+(7!=this.f||this.g?0:2)}function sf(a){var b=Zd(this,a);S(this,de(this,a,b,1)<<8);this.b-=this.g?9+(this.J&&6<=this.f?1:0):(this.D?5:3)+(7==this.f?2:0)}var tf=[7,13,13,17,14,18,17,21];
function uf(a){var b=ce(this,a);a=a>>6&7;b&32768&&(b|=-65536);var c=this.u[a];c&32768&&(c|=-65536);b=~~(b*c);this.u[a]=b>>16&65535;this.u[a|1]=b&65535;this.H&128||(this.Y=b>>16,this.aa=this.Y|b,this.U=0,this.T=-32768>b||32767<b?65536:0);this.b-=23}function vf(){this.b-=5}function wf(){this.M&49152||(this.w.reset(),Ub(this));this.b-=667}function xf(){Ad(this);this.H|=this.M&16;this.b-=13}
function yf(a){if(a&8)X.call(this,a);else{var b=Bd(this);a&=7;7==a?P(this,b):(P(this,this.u[a]),this.u[a]=b);this.b-=9}}function zf(a){a&1&&(this.T=65536);a&2&&(this.U=32768);a&4&&(this.aa=0);a&8&&(this.Y=32768);this.b-=5}function Af(a){var b=(a&448)>>6;if(this.u[b]=this.u[b]-1&65535)P(this,this.u[7]-((a&63)<<1)),this.b+=1;this.b-=6}function Bf(a){U(this,a,$d(this,a),De);this.b-=this.g?9+(this.J&&6<=this.f?1:0):(this.D?5:3)+(7==this.f?2:0)}
function Cf(a){U(this,a,0,Fe);this.b-=this.g?9:3+(7==this.f?2:0)}function Df(){this.pa(28,5);this.b-=5}function Ef(){this.H&4||this.C.Z();this.H|=4;ud(this,-2);this.b-=3}function Ff(a){U(this,a,$d(this,a),Ge);this.b-=this.g?9:3+(7==this.f?2:0)}function X(a){var b;if(b=this.i)b=this.i,E(b,"undefined opcode "+J(b,a),!0,!0),b=qc(b);b||this.pa(8,6)}function md(a){Gf[a>>12].call(this,a)}function Hf(a){If[a>>6&3].call(this,a)}function Jf(a){Kf[a>>6&3].call(this,a)}
function Lf(a){Mf[a>>6&3].call(this,a)}function Nf(a){Of[a&15].call(this,a)}function Pf(a){Qf[a&15].call(this,a)}function Rf(a){Sf[a>>6&3].call(this,a)}function Tf(a){Uf[a>>6&3].call(this,a)}function Vf(a){Wf[a>>6&3].call(this,a)}
var Gf=[function(a){Xf[a>>8&15].call(this,a)},rf,ff,Qe,Me,Oe,He,X,function(a){Yf[a>>8&15].call(this,a)},sf,gf,Re,Ne,Pe,Bf,X],Xf=[function(a){Zf[a>>4&15].call(this,a)},cf,$e,Se,Te,Ye,Ue,We,pf,pf,Hf,Jf,Lf,X,X,X],If=[function(a){vd(this,ee(this,a,0));this.b-=this.g?9:3+(7==this.f?2:0)},function(a){U(this,a,0,re);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){U(this,a,1,ve);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){U(this,a,1,te);this.b-=this.g?9:3+(7==this.f?2:0)}],Kf=[function(a){U(this,a,0,
xe);this.b-=this.g?11:6},function(a){U(this,a,qd(this)?1:0,he);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){U(this,a,qd(this)?1:0,De);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){a=ce(this,a);vd(this,a);this.b-=this.g?4:3+(7==this.f?2:0)}],Mf=[function(a){U(this,a,0,Be);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){U(this,a,0,ze);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){U(this,a,0,le);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){U(this,a,0,je);this.b-=this.g?9:3+(7==this.f?2:0)}],
Zf=[function(a){$f[a&15].call(this,a)},X,X,X,nf,nf,nf,nf,yf,X,Nf,Pf,Cf,Cf,Cf,Cf],$f=[kf,Ef,xf,bf,lf,wf,X,X,X,X,X,X,X,X,X,X],Of=[vf,function(){this.T=0;this.b-=5},function(){this.U=0;this.b-=5},W,function(){this.aa=1;this.b-=5},W,W,W,function(){this.Y=0;this.b-=5},W,W,W,W,W,W,W],Qf=[vf,function(){this.T=65536;this.b-=5},function(){this.U=32768;this.b-=5},zf,function(){this.aa=0;this.b-=5},zf,zf,zf,function(){this.Y=32768;this.b-=5},zf,zf,zf,zf,zf,zf,zf],Yf=[af,Ze,Ve,Xe,df,ef,Ke,Le,jf,Df,Rf,Tf,Vf,X,
X,X],Sf=[function(a){vd(this,de(this,a,0));this.b-=this.g?9:3+(7==this.f?2:0)},function(a){T(this,a,0,se);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){T(this,a,1,we);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){T(this,a,1,ue);this.b-=this.g?9:3+(7==this.f?2:0)}],Uf=[function(a){T(this,a,0,ye);this.b-=this.g?11:6},function(a){T(this,a,qd(this)?1:0,ie);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){T(this,a,qd(this)?1:0,Ee);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){a=be(this,a);vd(this,
a<<8);this.b-=this.g?4:3+(7==this.f?2:0)}],Wf=[function(a){T(this,a,0,Ce);this.b-=this.g?9+(this.Ab&1):3+(7==this.f?2:0)},function(a){T(this,a,0,Ae);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){T(this,a,0,me);this.b-=this.g?9+(this.Ab&1):3+(7==this.f?2:0)},function(a){T(this,a,0,ke);this.b-=this.g?9:3+(7==this.f?2:0)}];function nd(a){ag[a>>12].call(this,a)}
var ag=[function(a){bg[a>>8&15].call(this,a)},rf,ff,Qe,Me,Oe,He,function(a){cg[a>>8&15].call(this,a)},function(a){dg[a>>8&15].call(this,a)},sf,gf,Re,Ne,Pe,Bf,X],bg=[function(a){eg[a>>4&15].call(this,a)},cf,$e,Se,Te,Ye,Ue,We,pf,pf,Hf,Jf,Lf,function(a){fg[a>>6&3].call(this,a)},X,X],fg=[function(a){a=this.u[7]+((a&63)<<1)&65535;var b=this.ra(a|this.R);P(this,this.u[5]);this.u[6]=a+2&65535;this.u[5]=b;this.b-=8},function(a){a=Xd(this,a,0);zd(this,a);S(this,a);this.b-=11},function(a){var b=Bd(this);this.K=
this.b;Yd(this,a,0,b);S(this,b);this.b=this.K-tf[this.g]},function(a){S(this,ee(this,a,this.Qa?65535:0));this.b-=this.g?9:3+(7==this.f?2:0)}],eg=[function(a){gg[a&15].call(this,a)},X,X,X,nf,nf,nf,nf,yf,function(a){a&8?(this.M&49152||(this.M=this.M&-2017|(a&7)<<5,this.H|=1),this.b-=5):X.call(this,a)},Nf,Pf,Cf,Cf,Cf,Cf],gg=[kf,Ef,xf,bf,lf,wf,function(){Ad(this);this.b-=13},X,X,X,X,X,X,X,X,X],cg=[uf,uf,hf,hf,Ie,Ie,Je,Je,Ff,Ff,X,X,X,X,Af,Af],dg=[af,Ze,Ve,Xe,df,ef,Ke,Le,jf,Df,Rf,Tf,Vf,function(a){hg[a>>
6&3].call(this,a)},X,X],hg=[X,function(a){a=Xd(this,a,65536);zd(this,a);S(this,a);this.b-=11},function(a){var b=Bd(this);this.K=this.b;Yd(this,a,65536,b);S(this,b);this.b=this.K-tf[this.g]},X];
function ig(a){u.call(this,"ROM",a,ig);this.ia=this.f=null;this.B=a.addr;this.g=a.size;this.v=a.alias;this.C=a.file;this.D=sa(this.C);if(this.C){a=this.C;var b=ta(this.D);"json"!=b&&"hex"!=b&&(a=Ga()+"/api/v1/dump?file="+this.C+"&format=bytes&decimal=true");var c=this;Ea(a,null,!0,function(a,b,f){f?(c.P("Unable to load ROM resource (error "+f+": "+a+")"),c.C=null):(nb(c.Na,a,b),(a=Fa(a,b))?(c.f=a.ea,c.ia=a.ia):c.C=null);jg(c)})}}z(ig);ig.prototype.Da=function(a,b,c,d){this.w=b;this.b=c;this.i=d;jg(this)};
ig.prototype.Fa=function(){this.ia&&(this.i&&kg(this.i,this.id,this.B,this.g,this.ia),delete this.ia);return!0};ig.prototype.Ea=function(){return!0};
function jg(a){if(!tb(a)){if(a.C){if(!a.f||!a.w)return;a.g||(a.g=a.f.length);if(a.f.length!=a.g)vb(a,"ROM size ("+p(a.f.length,8,!0)+") does not match specified size ("+p(a.g,8,!0)+")");else{var b;b=a.B;if(jc(a.w,b,a.g,Nc)){var c;for(c=0;c<a.f.length;c++)a.w.nb(b+c,a.f[c]);b=!0}else b=!1;if(b){b=[];"number"==typeof a.v?b.push(a.v):null!=a.v&&a.v.length&&(b=a.v);for(c=0;c<b.length;c++){var d=a,e=b[c],f=ic(d.w,d.B,d.g);hc(d.w,e,d.g,f)}delete a.f}}}H(a)}}
Xa(function(){for(var a=D(document,"pdp11","rom"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new ig(d);C(d,c)}});
function lg(a){u.call(this,"RAM",a,lg);this.ia=this.g=null;this.C=a.addr;this.B=a.size;this.Ja=a.load;this.Ia=a.exec;this.v=!1;this.f=a.file;this.D=sa(this.f);if(this.f){a=this.f;var b=ta(this.D);"json"!=b&&"hex"!=b&&(a=Ga()+"/api/v1/dump?file="+this.f+"&format=bytes&decimal=true");var c=this;Ea(a,null,!0,function(a,b,f){f?(c.P("Unable to load RAM resource (error "+f+": "+a+")"),c.f=null):(nb(c.Na,a,b),(a=Fa(a,b))?(c.g=a.ea,c.ia=a.ia,null==c.Ja&&(c.Ja=a.Ja),null==c.Ia&&(c.Ia=a.Ia)):c.f=null);mg(c)})}}
z(lg);lg.prototype.Da=function(a,b,c,d){this.w=b;this.b=c;this.i=d;mg(this)};lg.prototype.Fa=function(){this.ia&&(this.i&&kg(this.i,this.id,this.C,this.B,this.ia),delete this.ia);return!0};lg.prototype.Ea=function(){return!0};function mg(a){if(a.w&&(!a.v&&a.B&&jc(a.w,a.C,a.B,1)&&(a.v=!0),!tb(a))){if(!a.v)q("No RAM allocated");else if(a.f){if(!a.g||!a.w)return;Gg(a,a.g,a.Ja,a.Ia,a.C)}H(a)}}
lg.prototype.reset=function(){if(this.v){for(var a=this.w,b=this.C,c=this.B,d=b&a.w,b=b>>>a.ka;0<c&&b<a.X.length;){var e=a.X[b],f=c,g,d=d||0;void 0===f&&(f=e.size);if(wb)for(g=d;f--&&g<e.G.length;g++)e.G[g]=0;else for(g=d;f--&&g<e.size;g++)e.Vb(d,0,e.F+d);c-=a.ya;b++;d=0}this.g&&Gg(this,this.g,this.Ja,this.Ia,this.C,!0)}};
function Gg(a,b,c,d,e,f){var g=!1;if(null==c)for(var h=0;h<b.length-1;){var l=b[h]&255|(b[h+1]&255)<<8;if(l)if(l&255){if(1!=l)break;if(h+6>=b.length)break;for(var h=h+2,m=b[h++]&255|(b[h++]&255)<<8,n=b[h++]&255|(b[h++]&255)<<8,l=l+((m&255)+(m>>8)+(n&255)+(n>>8)),r=h,t=m-=6;0<m&&h<b.length;)l+=b[h++]&255,m--;if(m||h>=b.length)break;l+=b[h++]&255;if(l&255)break;if(t)for(;t--;)a.b.nb(n++,b[r++]&255);else n&1?a.b.ha():pd(a.b,n,f);g=!0}else h++;else h+=2}if(!g&&(null==c&&(c=e),null!=c)){for(e=0;e<b.length;e++)a.b.nb(c+
e,b[e]);null!=d&&pd(a.b,d,f);g=!0}return g}Xa(function(){for(var a=D(document,"pdp11","ram"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new lg(d);C(d,c)}});function Hg(a){u.call(this,"Keyboard",a,Hg,65536);H(this)}z(Hg);Hg.prototype.sa=function(){return!1};Hg.prototype.Da=function(a,b,c,d){this.C=a;this.b=c;this.i=d};Xa(function(){for(var a=D(document,"pdp11","keyboard"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new Hg(d);C(d,c)}});
function Y(a){this.N=a.baudReceive||9600;this.R=a.baudTransmit||9600;this.da=a.upperCase;this.v=this.D=null;this.S=a.tabSize;this.O=a.charBOL;this.I=0;u.call(this,"SerialPort",a,Y,8388608);var b=a.binding;if("console"==b)this.D="";else{var c;a=Ig;b&&(void 0===c&&(c="Panel"),(c=qb(c,this.id))&&(b=c.G[b])&&this.sa(null,a,b))}this.J=this.L=null;this.exports={connect:this.sc,receiveData:this.dc}}z(Y);var Ig="buffer";k=Y.prototype;
k.sa=function(a,b,c){var d=this;switch(b){case Ig:return this.G[b]=this.v=c,c.onkeydown=function(a){a=a||window.event;var b=a.keyCode;if(8===b||a.ctrlKey&&65<=b&&90>=b)a.preventDefault&&a.preventDefault(),64<b&&(b-=64),d.dc(b);return!0},c.onkeypress=function(a){a=a||window.event;d.dc(a.which||a.keyCode);a.preventDefault&&a.preventDefault();return!0},c.removeAttribute("readonly"),!0}return!1};
k.Da=function(a,b,c,d){this.C=a;this.w=b;this.b=c;this.i=d;var e=this;this.la=vc(48,4);this.W=sc(this.b,function(){e.f&128||!e.B.length||(e.K=e.B.shift()&255,e.da&&97<=e.K&&122>e.K&&(e.K-=32),e.f|=128,e.f&64&&tc(e.b,e.la))});this.ma=vc(52,4);this.$=sc(this.b,function(){e.g|=128;e.g&64&&tc(e.b,e.ma)});Ab(b,this,Jg);H(this)};
k.sc=function(){if(!this.J){var a=$c(this.C,"connection");if(a){var b=a.split("->");if(2==b.length){var c=ya(b[0]);if(c!=this.fb)return;b=ya(b[1]);if(this.J=pb(b)){var d=this.J.exports;if(d){var e=d.connect;e&&e.call(this.J);if(this.L=d.receiveData){this.status(this.Na+"."+c+" connected to "+b);return}}}}this.status("Unable to establish connection: "+a)}}};k.Fa=function(a,b){if(!b)if(this.sc(),!a||!this.restore)this.reset();else if(!this.restore(a))return!1;return!0};
k.Ea=function(a){return a?this.save():!0};k.reset=function(){Kg(this)};k.save=function(){var a=new R(this);a.set(0,[]);return a.data()};k.restore=function(){return Kg(this)};function Kg(a){a.K=0;a.f=0;a.g=128;a.B=[];return!0}k.dc=function(a){if("number"==typeof a)this.B.push(a);else if("string"==typeof a)for(var b=0;b<a.length;b++)this.B.push(a.charCodeAt(b));else this.B=this.B.concat(a);uc(this.b,this.W,1E3/Math.round(this.N/10));return!0};k.Ad=function(){return this.f&65534};
k.re=function(a){this.f=this.f&-112|a&111};k.zd=function(){this.f&=-129;0<this.B.length&&uc(this.b,this.W,1E3/Math.round(this.N/10));return this.K};k.qe=function(){};k.Td=function(){return this.g};k.Ke=function(a){128==(this.g&192)&&a&64&&uc(this.b,this.$,1E3/Math.round(this.R/10));this.g=this.g&-70|a&69};k.Sd=function(){return 0};
k.Je=function(a){if(a&=255){E(this,"transmitByte("+p(a,2,!0)+")");this.L&&this.L.call(this.J,a);if(this.v)if(13==a)this.I=0;else if(8==a)this.v.value=this.v.value.slice(0,-1),0<this.I&&this.I--;else{var b;b=(b=za[a])?"<"+b+">":String.fromCharCode(a);var c=b.length;32>a&&1==c&&(c=0);9==a&&(a=this.S||8,c=a-this.I%a,this.S&&(b=xa("",c)));this.O&&!this.I&&c&&(b=String.fromCharCode(this.O)+b);this.v.value+=b;this.v.scrollTop=this.v.scrollHeight;this.I+=c}else if(null!=this.D){if(10==a||1024<=this.D.length)this.j(this.D),
this.D="";10!=a&&(this.D+=String.fromCharCode(a))}this.g&=-129;uc(this.b,this.$,1E3/Math.round(this.R/10))}};var Lg={},Jg=(Lg[65392]=[null,null,Y.prototype.Ad,Y.prototype.re,"RCSR"],Lg[65394]=[null,null,Y.prototype.zd,Y.prototype.qe,"RBUF"],Lg[65396]=[null,null,Y.prototype.Td,Y.prototype.Ke,"XCSR"],Lg[65398]=[null,null,Y.prototype.Sd,Y.prototype.Je,"XBUF"],Lg);Xa(function(){for(var a=D(document,"pdp11","serial"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new Y(d);C(d,c)}});
function Hc(a){u.call(this,"PC11",a,Hc);this.g=a.autoMount||null;this.D=0;this.$=a.baudReceive||3600;this.K=this.L=this.f=0;this.J=[];this.I=Mg;this.v=Ng;this.N=this.B="";this.ea=this.Ja=this.Ia=null;this.R=-1;this.O=!Pa("Mobi")&&window&&"FileReader"in window}z(Hc);var Mg="",Ng=0;k=Hc.prototype;
k.sa=function(a,b,c){var d=this,e=Ng;switch(b){case "listTapes":return this.G[b]=c,c.onchange=function(){var a=d.G.descTape,b=c.options[c.selectedIndex];if(a&&b){var e={};if(b=b.getAttribute("data-value"))try{e=eval("("+b+")")}catch(l){q("PC11 option error: "+l.message)}b=e.desc;void 0===b&&(b="");e=e.href;void 0!==e&&(b='<a href="'+e+'" target="_blank">'+b+"</a>");a.innerHTML=b}},!0;case "descTape":return this.G[b]=c,!0;case "loadTape":e=2;case "attachTape":return e||(e=1),this.G[b]=c,c.onclick=
function(){var a=d.G.listTapes;a&&Og(d,a.options[a.selectedIndex].text,a.value,e)},!0;case "mountTape":if(!this.O){c.parentNode.removeChild(c);break}this.G[b]=c;c.addEventListener("change",function(){var a=c.children[0];a.children[1].disabled=!a.children[0].files.length});c.onsubmit=function(a){if(a=a.currentTarget[1].files[0]){var b=a.name;Og(d,sa(b,!0),b,1,a)}return!1};return!0;case "readProgress":return this.G[b]=c,!0}return!1};
k.Da=function(a,b,c,d){this.C=a;this.w=b;this.b=c;this.i=d;this.S=Pg(a);var e=this;if((this.g=$c(this.C,"autoMount")||this.g)&&"string"==typeof this.g)try{this.g=eval("("+this.g+")")}catch(f){q("PC11 auto-mount error: "+f.message+" ("+this.g+")"),this.g=null}this.W=vc(56,4);this.da=sc(this.b,function(){1==(e.f&32769)&&!(e.f&128)&&e.K<e.J.length&&(e.L=e.J[e.K++]&255,Qg(e,e.K/e.J.length*100),e.f|=128,e.f&=-2049,e.f&64&&tc(e.b,e.W))});Ab(b,this,Rg);Sg(this,"None",Mg,!0);this.O&&Sg(this,"Local Tape",
"?");Sg(this,"Remote Tape","??");Tg(this)||H(this)};k.Fa=function(a,b){if(!b)if(!a||!this.restore)this.reset();else if(!this.restore(a))return!1;return!0};k.Ea=function(a){return a?this.save():!0};k.reset=function(){this.f&=-2241;this.L=0};function Tg(a){a.D=0;if(a.g){var b=a.g.path||"",c;if(!(c=a.g.name))a:{if((c=a.G.listTapes)&&c.options)for(var d=0;d<c.options.length;d++){var e=c.options[d];if(e.value==b){c=e.text;break a}}c=sa(b,!0)}b&&c?Ug(a,c,b,1,!0):Vg(a)}return!!a.D}
function Og(a,b,c,d,e){if(c)if("?"==c)a.P('Use "Choose File" and "Mount" to select and load a local tape.');else{if("??"==c){c=window.prompt("Enter the URL of a remote tape image.","")||"";if(!c)return;b=sa(c);a.status("Attempting to load "+c+' as "'+b+'"');a.I="??"}else a.I=c;Ug(a,b,c,d,!1,e)}else Wg(a,!1)}
function Ug(a,b,c,d,e,f){var g=-1;if(a.B.toLowerCase()!=c.toLowerCase()||a.v!=d)g++,Wg(a,!0),a.A.Va?a.P("PC11 busy"):(e&&(a.D++,F(a)&&E(a,"auto-loading tape: "+b)),Xg(a,b,c,d,f)?g++:a.A.Va=!0);g&&Yg(a,a.N,a.B,a.v,a.ea,a.Ja,a.Ia)}
function Xg(a,b,c,d,e){var f=c;if(e){var g=new FileReader;g.onload=function(){var e=g.result;e&&(e=new Uint8Array(e,0,e.byteLength),Yg(a,b,c,d,e),a.I="?");Vg(a)};g.readAsArrayBuffer(e);return!0}0>c.indexOf("/api/v1/dump")&&(e=ta(c),f="json"==e||"gz"==e?encodeURI(c):Ga()+"/api/v1/dump?path="+encodeURIComponent(c)+"&format=json");return!!Ea(f,null,!0,function(e,f,g){var h=0>g&&a.C&&!a.C.A.ja;g?a.P('Unable to load tape "'+b+'" (error '+g+": "+e+")",h):(nb(a.Na,e,f),(e=Fa(e,f))&&Yg(a,b,c,d,e.ea,e.Ja,
e.Ia));a.A.Va=!1;a.D&&(a.D--,a.D||H(a));Vg(a)})}function Sg(a,b,c,d){if((a=a.G.listTapes)&&a.options){for(var e=0;e<a.options.length;e++)if(a.options[e].value==c)return;e=document.createElement("option");e.text=b;e.value=c;d&&a.childNodes[0]?a.insertBefore(e,a.childNodes[0]):a.appendChild(e)}}
function Vg(a){var b=a.G.listTapes;if(b&&b.options){a=a.I||a.B;for(var c=0;c<b.options.length;c++)if(b.options[c].value==a){b.selectedIndex!=c&&(b.selectedIndex=c);break}c==b.options.length&&(b.selectedIndex=0)}}function Qg(a,b){b|=0;if(b!==a.R){var c=a.G.readProgress;c&&(c=(c=D(c,"pcjs-progress-bar"))&&c[0])&&c.style&&(c.style.width=b+"%");a.R=b}}
function Yg(a,b,c,d,e,f,g){a.N=b;a.B=c;a.v=d;a.ea=e;a.Ja=f;a.Ia=g;2==d?a.S&&Gg(a.S,e,f,g)?a.status("tape loaded: "+b):(a.N="",a.B="",a.I=Mg,a.v=Ng,a.P("No load address available for tape: "+b)):(a.K=0,a.J=e,a.status("tape attached: "+b),Qg(a,0))}function Wg(a,b){if(a.B||!1===b)a.N="",a.B="",b||(a.v&&a.status(1==a.v?"tape detached":"tape unloaded"),a.I=Mg,a.v=Ng,Vg(a))}k.save=function(){return(new R(this)).data()};k.restore=function(){return!0};k.td=function(){return this.f&65534};
k.ke=function(a){a&1&&(this.f&32768?(a&=-2,this.f&64&&tc(this.b,this.W)):(this.f&=-129,this.f|=2048,this.L=0,uc(this.b,this.da,1E3/Math.round(this.$/10))));this.f=this.f&-66|a&65};k.sd=function(){this.f&=-129;this.f|=2048;return this.L};k.je=function(){};var Zg={},Rg=(Zg[65384]=[null,null,Hc.prototype.td,Hc.prototype.ke,"PRS"],Zg[65386]=[null,null,Hc.prototype.sd,Hc.prototype.je,"PRB"],Zg);
function $g(a,b,c){u.call(this,"Disk",{id:a.Na+".disk"+p(++ah,4)},$g,2097152);this.controller=a;this.C=a.C;this.i=a.i;this.v=b;this.Ta=b.name;this.$b=b.$b;bh(this,c,b.ua,b.za,b.qa,b.Ka);H(this)}var ah=0;z($g);k=$g.prototype;k.Da=function(a,b,c,d){this.i=d};
function bh(a,b,c,d,e,f){a.mode=b;a.ua=c;a.za=d;a.qa=e;a.Ka=f;a.b=[];if("preload"!=a.mode){b=Array(a.ua);for(c=0;c<b.length;c++){d=Array(a.za);for(e=0;e<d.length;e++){f=Array(a.qa);for(var g=1;g<=f.length;g++)f[g-1]=ch(null,c,e,g,a.Ka,0);d[e]=f}b[c]=d}a.b=b}a.f=null}
function dh(a,b,c,d,e){var f=c;if(a.w)return!0;a.Ta=b;a.$a=c;a.Bc=sa(c);a.w=e;a.B=a.controller;if(d){var g=new FileReader;g.onload=function(){var b=g.result,c,d=b?b.byteLength:0,e=la[d];if(e){a.ua=e[0];a.za=e[1];a.qa=e[2];a.Ka=e[3]||512;c=a.Ka>>2;var f=e=0,b=new DataView(b,0,d);a.b=Array(a.ua);for(d=0;d<a.b.length;d++)for(var t=a.b[d]=Array(a.za),w=0;w<t.length;w++)for(var y=t[w]=Array(a.qa),x=0;x<y.length;x++){for(var A=ch(null,d,w,x+1,a.Ka,0),ka=A.data,Ja=0;Ja<c;Ja++,f+=4)var Q=ka[Ja]=b.getInt32(f,
!0),e=e+Q&-1;A.Ba=c;y[x]=A}a.f=e;c=a}else a.P("Unrecognized disk format ("+d+" bytes)");a.w&&(a.w.call(a.controller,a.v,c,a.Ta,a.$a),a.w=null)};g.readAsArrayBuffer(d);return!0}0>c.indexOf("/api/v1/dump")&&(b=ta(c),"json"==b||"gz"==b?f=encodeURI(c):(d="path",e="&mbhd=10",!c.indexOf("http:")||!c.indexOf("ftp:")||0<="dsk ima img 360 720 12 144".split(" ").indexOf(b)?(d="disk",e="&mbhd=0"):ua(c,"/")&&(d="dir"),f=Ga()+"/api/v1/dump?"+d+"="+encodeURIComponent(c)+(a.$b?"":e)+"&format=json"));return!!Ea(f,
null,!0,function(b,c,d){eh(a,b,c,d)})}
function eh(a,b,c,d){var e=null;a.g=!1;var f=0>d&&a.C&&!a.C.A.ja;if(d)a.controller.P('Unable to load disk "'+a.Ta+'" (error '+d+": "+b+")",f);else{nb(a.controller.Na,b,c);try{if(0<sa(a.Bc,!0).toLowerCase().indexOf("-readonly"))a.g=!0;else{var g=c.indexOf("\n");0<g&&1024>g&&0<c.substring(0,g).indexOf("write-protected")&&(a.g=!0)}var h;"<"==c.substr(0,1)?h=["Missing disk image: "+a.Ta]:h=0>c.indexOf("0x")&&'["'!=c.substr(0,2)?JSON.parse(c.replace(/([a-z]+):/gm,'"$1":').replace(/\/\/[^\n]*/gm,"")):eval("("+
c+")");if(h.length)if(1==h.length)q(h[0]);else{a.ua=h.length;a.za=h[0].length;a.qa=h[0][0].length;var l=h[0][0][0];a.Ka=l&&l.length||512;for(d=c=0;d<a.ua;d++)for(f=0;f<a.za;f++)for(g=0;g<a.qa;g++)if(l=h[d][f][g]){var m=l.length;void 0===m&&(m=l.length=512);var m=m>>2,n=l.pattern;void 0===n&&(n=l.pattern=0);var r=l.data;if(void 0===r){var t=l.bytes;if(void 0!==t&&t.length){for(var w=m<<2,y=t.length;y<w;y++)t[y]=n;fh(l,t)}else r=[],n=l.pattern=n|n<<8|n<<16|n<<24,l.data=r;delete l.bytes}ch(l,d,f);for(w=
0;w<r.length;w++)c=c+r[w]&-1}a.b=h;a.f=c;e=a}else q("Empty disk image: "+a.Ta)}catch(x){q("Disk image error ("+b+"): "+x.message)}}a.w&&(a.w.call(a.B,a.v,e,a.Ta,a.$a),a.w=null)}function ch(a,b,c,d,e,f){a||(a={sector:d,length:e,data:[],pattern:f});a.Ne=b;a.Oe=c;a.Ma=a.Ba=0;a.Pa=!1;return a}
k.seek=function(a,b,c,d,e){d=null;var f=this.v,g=this.b[a];if(g){var h=g[b];if(!h&&f.Hc&&b<f.za)for(h=g[b]=Array(f.Ic),g=0;g<h.length;g++)h[g]=ch(null,a,b,g+1,f.vc,0);if(h){for(g=0;g<h.length;g++)if(h[g]&&h[g].sector==c){d=h[g];break}!d&&f.Hc&&9==f.ic&&(d=h[g]=ch(null,a,b,f.ic,f.vc,0))}}e&&e(d,!1);return d};function fh(a,b){for(var c=0,d=a.length>>2,e=Array(d),f=0;f<d;f++)e[f]=b[c]|b[c+1]<<8|b[c+2]<<16|b[c+3]<<24,c+=4;a.data=e}
k.read=function(a,b){var c=-1;if(a&&b<a.length)var c=a.data,d=b>>2,c=(d<c.length?c[d]:a.pattern)>>((b&3)<<3)&255;return c};k.write=function(a,b,c){if(this.g)return!1;if(b<a.length){if(c!=this.read(a,b,!0)){var d=a.data,e=a.pattern,f=b>>2;b=(b&3)<<3;for(var g=d.length;g<=f;g++)d[g]=e;a.Ba?f<a.Ma?(a.Ba+=a.Ma-f,a.Ma=f):f>=a.Ma+a.Ba&&(a.Ba+=f-(a.Ma+a.Ba)+1):(a.Ma=f,a.Ba=1);d[f]=d[f]&~(255<<b)|c<<b}return!0}return null};
function gh(a,b){var c=a.za*a.qa,d=b/c|0;return d<a.ua?(b%=c,a.seek(d,b/a.qa|0,b%a.qa+1)):null}function hh(a,b,c){for(var d=1,e=0,f=0;d--;){var g=a.read(b,c++);if(0>g)break;e|=g<<f;f+=8}return e}
k.save=function(){var a=0,b=[];b[a++]=[this.$a,this.f,this.ua,this.za,this.qa,this.Ka];if(!this.g)for(var c=this.b,d=0;d<c.length;d++)for(var e=0;e<c[d].length;e++)for(var f=0;f<c[d][e].length;f++){var g=c[d][e][f];if(g&&g.Ba){for(var h=[],l=0,m=g.Ma,n=g.Ma+g.Ba;m<n;)h[l++]=g.data[m++];b[a++]=[d,e,f,g.Ma,h]}}return b};
k.restore=function(a){var b=0,c="unsupported restore format";if(a&&0<a.length){var d=0,e=a[d++];e&&2<=e.length&&(!this.b.length&&6<=e.length?bh(this,"local",e[2],e[3],e[4],e[5]):null!=e[1]&&null!=this.f&&e[1]!=this.f&&(c="original checksum ("+e[1]+") differs from current checksum ("+this.f+")",b=-2));for(this.b.length||(b=-1);d<a.length&&0<=b;){var f=0,g=a[d++],h=g[f++],l=g[f++],m=g[f++];if(h>=this.b.length||l>=this.b[h].length||m>=this.b[h][l].length){c="sector (CHS="+h+":"+l+":"+m+") out of range ("+
b+" changes applied)";b=-1;break}if(this.g){c="unable to modify write-protected disk";b=-1;break}e=g[f++];f=g[f++];g=e+f.length;if(h=this.b[h][l][m]){for(l=h.data.length;l<e;)h.data[l++]=h.pattern;l=0;h.Ma=e;for(h.Ba=f.length;e<g;)h.data[e++]=f[l++];b++}}}0>b&&-2!=b&&this.controller.P("Unable to restore disk '"+this.Ta+": "+c);return b};
k.toJSON=function(){var a;a=0;for(var b;b=gh(this,a++);)ih(b);a=JSON.stringify(this.b,function(a,b){if("file"!=a)return b});a=a.replace(/,"length":512/gm,"").replace(/,"pattern":0/gm,"");a=a.replace(/"(sector|length|data|pattern)":/gm,"$1:");a=a.replace(/,"[^"]*":([0-9]+|true|false)/gm,"");a=a.replace(/(sector|length|data|pattern):/gm,'"$1":');return a=a.replace(/([\]}]),/gm,"$1,\n")};
function ih(a){var b=a.data,c=b.length;if(c<<2==a.length){for(var d=c-1,e=b[d],f=0;d--&&b[d]===e;)f++;f++&&(b.length=c-f,a.pattern=e)}}function O(a){u.call(this,"RL11",a,O,2097152);this.v=a.autoMount||null;this.I=0;this.f=Array(1);this.L=!Pa("Mobi")&&window&&"FileReader"in window}z(O);k=O.prototype;
k.sa=function(a,b,c){var d=this;switch(b){case "listDisks":return this.G[b]=c,c.onchange=function(){var a=d.G.descDisk,b=c.options[c.selectedIndex];if(a&&b){var g={};if(b=b.getAttribute("data-value"))try{g=eval("("+b+")")}catch(h){q("RL11 option error: "+h.message)}b=g.desc;void 0===b&&(b="");g=g.href;void 0!==g&&(b='<a href="'+g+'" target="_blank">'+b+"</a>");a.innerHTML=b}},!0;case "descDisk":case "listDrives":return this.G[b]=c,c.onchange=function(){var a=ma(c.value,10);null!=a&&jh(d,a)},!0;case "loadDrive":return this.G[b]=
c,c.onclick=function(){var a=d.G.listDisks;a&&kh(d,a.options[a.selectedIndex].text,a.value)},!0;case "saveDrive":if(!this.L){c.parentNode.removeChild(c);break}this.G[b]=c;c.onclick=function(){var a=d.G.listDrives;if(a&&a.options&&d.f)if(a=d.f[ma(a.value,10)||0])if(a=a.Ca){var b;b="";for(var c=0,h;h=gh(a,c++);)for(var l=0,m=h.length;l<m;l++)b+=String.fromCharCode(hh(a,h,l));b=btoa(b);a=a.Bc.replace(".json",".img");c=null;b="data:application/octet-stream;base64,"+b;a&&(c=document.createElement("a"),
"string"!=typeof c.download&&(c=null));c?(c.href=b,c.download=a,document.body.appendChild(c),c.click(),document.body.removeChild(c),a="Check your Downloads folder for "+a+"."):(window.open(b),a="Check your browser for a new window/tab containing the requested data"+(a?" ("+a+")":"")+".");q(a)}else d.P("No disk loaded in drive.");else d.P("No disk drive selected.")};return!0;case "mountDrive":if(this.L)return this.G[b]=c,c.addEventListener("change",function(){var a=c.children[0];a.children[1].disabled=
!a.children[0].files.length}),c.onsubmit=function(a){if(a=a.currentTarget[1].files[0]){var b=a.name;kh(d,sa(b,!0),b,a)}return!1},!0;c.parentNode.removeChild(c)}return!1};
k.Da=function(a,b,c,d){this.C=a;this.w=b;this.b=c;this.i=d;if((this.v=$c(this.C,"autoMount")||this.v)&&"string"==typeof this.v)try{this.v=eval("("+this.v+")")}catch(e){q("RL11 auto-mount error: "+e.message+" ("+this.v+")"),this.v=null}lh(this);this.O=vc(112,5);Ab(b,this,mh);nh(this,"None","",!0);this.L&&nh(this,"Local Disk","?");nh(this,"Remote Disk","??");oh(this)||H(this)};
k.Fa=function(a,b){if(!b){if(!a||!this.restore){if(this.reset(),this.C.lc){for(a=0;a<this.f.length;a++)ph(this,a,!0);oh(this,!0)}}else if(!this.restore(a))return!1;if(a=this.G.listDrives){for(;a.firstChild;)a.removeChild(a.firstChild);a.value="";for(b=0;1>b;b++){var c=document.createElement("option");c.value=b;c.text="RL"+b;a.appendChild(c)}a.value="0";jh(this,0)}}return!0};k.Ea=function(a){return a?this.save():!0};k.reset=function(){lh(this)};k.save=function(){return(new R(this)).data()};
k.restore=function(a){return lh(this,a[0])};function oh(a,b){b||(a.I=0);if(a.v)for(var c in a.v){var d=a.v[c],e=d.path||"",f;if(!(f=d.name))a:{if((f=a.G.listDisks)&&f.options)for(var g=0;g<f.options.length;g++){var h=f.options[g];if(h.value==e){f=h.text;break a}}f=sa(e,!0)}if(e&&f&&(g=-1,c&&(g=c.charCodeAt(c.length-1)-48,0>g||9<g)&&(g=-1),0<=g&&g<a.f.length)){!qh(a,g,f,e,!0)&&b&&H(a,!1);continue}a.P("Incorrect auto-mount settings for drive "+c+" ("+JSON.stringify(d)+")")}return!!a.I}
function kh(a,b,c,d){var e=a.G.listDrives,e=e&&ma(e.value,10);if(void 0===e||0>e||e>=a.f.length)a.P("Unable to load the selected drive");else if(c)if("?"==c)a.P('Use "Choose File" and "Mount" to select and load a local disk.');else{if("??"==c){c=window.prompt("Enter the URL of a remote disk image.","")||"";if(!c)return;b=sa(c);a.status("Attempting to load "+c+' as "'+b+'"')}qh(a,e,b,c,!1,d)}else ph(a,e)}
function qh(a,b,c,d,e,f){var g=-1,h=a.f[b];h.$a.toLowerCase()!=d.toLowerCase()&&(g++,ph(a,b,!0),h.Zb?a.P("RL11 busy"):(h.Zb=!0,e&&(h.Yb=!0,a.I++,F(a)&&E(a,"auto-loading disk: "+c)),h.Mb=!!f,dh(new $g(a,h,"preload"),c,d,f,a.Kc)&&g++));return g}
k.Kc=function(a,b,c,d,e){var f;a.Zb=!1;b&&(f=b.b.length?[b.b.length,b.b[0].length,b.b[0][0].length,b.b[0][0][0].length]:[0,0,0,0],b&&f[0]>a.ua||f[1]>a.za)&&(this.P('Disk "'+c+'" too large for drive '+("RL"+a.ac)),b=null);b?(a.Ca=b,a.Ta=c,a.$a=d,this.P('Mounted disk "'+c+'" in drive '+("RL"+a.ac),a.Yb||e),this.C&&this.C.ob()):a.Mb=!1;a.Yb&&(a.Yb=!1,--this.I||H(this));jh(this,a.ac)};
function nh(a,b,c,d){if((a=a.G.listDisks)&&a.options){for(var e=0;e<a.options.length;e++)if(a.options[e].value==c)return;e=document.createElement("option");e.text=b;e.value=c;d&&a.childNodes[0]?a.insertBefore(e,a.childNodes[0]):a.appendChild(e)}}
function jh(a,b){if(0<=b&&b<a.f.length){var c=a.f[b],d=a.G.listDisks;a=a.G.listDrives;if(d&&a&&d.options&&a.options&&(a=ma(a.value,10),c=c.Mb?"?":c.$a,!isNaN(a)&&a==b)){for(b=0;b<d.options.length;b++)if(d.options[b].value==c){d.selectedIndex!=b&&(d.selectedIndex=b);break}b==d.options.length&&(d.selectedIndex=0)}}}function ph(a,b,c){var d=a.f[b];if(d.Ca||!1===c)d.Ta="",d.$a="",d.Ca=null,d.Mb=!1,c||(a.P("Drive RL"+b+" unloaded",c),jh(a,b))}
function lh(a,b){var c=0;b||(b=[]);a.fa=b[c++]||0;a.J=b[c++]||0;a.g=b[c++]||0;a.B=b[c++]||0;a.D=b[c++]||0;a.K=b[c]||0;for(b=0;b<a.f.length;b++){var d=a.f[b];void 0===d&&(d=a.f[b]={});c=a;d.ac=b;d.Zb=d.Mb=!1;d.name=c.fb;d.ua=512;d.za=2;d.qa=40;d.Ka=256;d.$b=!0;d.Me=0;d.Le=0;d.ic=1;d.Ic=d.qa;d.vc=d.Ka;d.Pe=0;d.Re=null;d.Ca||(d.$a="");d.status=29|(512==d.ua?128:0)}return!0}
k.Lc=function(a,b,c,d,e,f){this.J=f&65535;this.fa=this.fa&-49|f>>12&48;this.K=f>>16&63;this.B=this.g=b<<7|(c?64:0)|d&63;this.D=65536-e&65535;a&&(this.fa=this.fa|a|32768);return!0};
k.fd=function(a,b,c,d,e,f,g){for(var h=0,l=a.Ca,m=null,n;e--;){if(!m){m=a.Ca.seek(b,c,d+1);if(!m){h=5120;break}n=0}var r,t;if(0>(r=a.Ca.read(m,n++))||0>(t=a.Ca.read(m,n++))){h=5120;break}this.w.ab(f,r|t<<8);if(rc(this.w)){h=8192;break}f+=2;if(n>=l.Ka&&(m=null,++d>=l.qa&&(d=0,++c>=l.za&&(c=0,++b>=l.ua)))){h=5120;break}}return g(h,b,c,d,e,f)};
k.$d=function(a,b,c,d,e,f,g){for(var h=0,l=a.Ca,m=null,n;e--;){var r=this.w.oa(f);if(rc(this.w)){h=8192;break}f+=2;if(!m){m=a.Ca.seek(b,c,d+1,!0);if(!m){h=5120;break}n=0}if(!a.Ca.write(m,n++,r&255)||!a.Ca.write(m,n++,r>>8)){h=5120;break}if(n>=l.Ka&&(m=null,++d>=l.qa&&(d=0,++c>=l.za&&(c=0,++b>=l.ua)))){h=5120;break}}return g(h,b,c,d,e,f)};k.Dd=function(){return this.fa&65535};
k.ue=function(a){this.fa=this.fa&-1023|a&1022;this.N=this.N&-4|(a&48)>>4;if(!(this.fa&128)){var b;a=!0;var c=this.f[(this.fa&768)>>8],d,e,f,g;this.fa&=-2;switch(this.fa&14){case 4:this.g&8&&(this.fa&=63);this.D=c.status|this.B&64;break;case 6:1==(this.g&3)&&(b=this.g&65408,c=(this.g&16)<<2,this.B=this.g&4?this.B+b:this.B-b,this.g=this.B=this.B&65408|c);break;case 8:this.D=this.B;break;case 12:b=this.fd;case 10:b||(b=this.$d),d=this.g>>7,e=this.g&64?0:1,f=this.g&63,d>=c.ua||f>=c.qa?this.fa|=37888:
(g=(this.K&63)<<16|this.J,a=65536-this.D&65535,a=b.call(this,c,d,e,f,a,g,this.Lc.bind(this)))}a&&(this.fa|=129,this.fa&64&&tc(this.b,this.O))}};k.Bd=function(){return this.J};k.se=function(a){this.J=a&65534};k.Ed=function(){return this.g};k.ve=function(a){this.g=a};k.Fd=function(){return this.D};k.we=function(a){this.D=a};k.Cd=function(){return this.K};k.te=function(a){this.K=a&63};
var rh={},mh=(rh[63744]=[null,null,O.prototype.Dd,O.prototype.ue,"RLCS"],rh[63746]=[null,null,O.prototype.Bd,O.prototype.se,"RLBA"],rh[65284]=[null,null,O.prototype.Ed,O.prototype.ve,"RLDA"],rh[65286]=[null,null,O.prototype.Fd,O.prototype.we,"RLMP"],rh[65288]=[null,null,O.prototype.Cd,O.prototype.te,"RLBE"],rh);function sh(a){u.call(this,"Debugger",a,sh);this.$=a.base||16;this.wa=!1;this.J=0;this.O=!1;this.v=-1;this.g=[];this.S={}}z(sh);
var th={"||":0,"&&":1,"|":2,"^":3,"&":4,"!=":5,"==":5,">=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9};sh.prototype.oc=function(){return-1};sh.prototype.pc=function(){};
function uh(a,b,c,d){if(c)if(b){0>a.v&&a.g.length&&(a.v=0);if(0>a.v||b!=a.g[a.v])a.g.splice(0,0,b),a.v=0;a.v--}else a.O?b="end":b=a.g[a.v+1];a=[];if(b){b=b.replace(/""/g,"'");c=0;var e=null;d=d||";";for(var f=0;f<=b.length;f++){var g=b.charAt(f);if('"'==g||"'"==g)e?g==e&&(e=null):e=g;else if(g==d&&!e||!g)a.push(ya(b.substring(c,f))),c=f+1}}return a}
function vh(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<<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;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?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 wh(a,b,c){var d;if(b){b=xh(a,b);for(var e=0,f=!1,g=b,h=[],l=[],m=b.split(/(\|\||&&|\||^|&|!=|==|>=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*)/);e<m.length;){var n=m[e++],r=n.length,n=ya(n);if(!n){f=!0;break}n=yh(a,n,null,!1===c);if(void 0===n){f=!0;c=!1;break}h.push(n);if(e==m.length)break;var n=m[e++],t=n.length;l.length&&th[n]<th[l[l.length-1]]&&vh(h,l,1);l.push(n);b=b.substr(r+t)}vh(h,l)&&1==h.length||(f=!0);f?c&&a.j("error parsing '"+g+"' at character "+(g.length-b.length)):(d=h.pop(),c&&zh(a,null,
d))}return d}function xh(a,b){for(var c,d=a.wa?"(":"{",e=a.wa?")":"}",f=new RegExp(a.wa?"\\((.*?)\\)":"\\{(.*?)\\}");(c=b.match(f))&&!(0<=c[1].indexOf(d));){var g=wh(a,c[1]);b=b.replace(d+c[1]+e,null!=g?J(a,g):"undefined")}for(;(c=b.match(/\[(.*?)]/))&&!(0<=c[1].indexOf("["));)b=b.replace("["+c[1]+"]","unimplemented");for(a=b;b=a.match(/\$([a-z]+)/i);){c=null;switch(b[1].toLowerCase()){case "ops":c=0}if(null==c)break;a=a.replace(b[0],c.toString())}return a}
function yh(a,b,c,d){var e;null!=b?(e=a.oc(b),0<=e?e=a.pc(e):(e=a.S[b],null==e&&(e=ma(b,a.$))),null!=e||d||a.j("invalid "+(c?c:"value")+": "+b)):d||a.j("missing "+(c||"value"));return e}
function zh(a,b,c){var d,e=!1;if(void 0!==c){e=!0;d=c;var f=0,g="";if(!f||4<f)f=4;for(var h=0;h<f;h++){g&&(g=","+g);var l=d&255,m=8,n="";m?32<m&&(m=32):m=32;if(null==l||isNaN(l))for(;0<m--;)n="?"+n;else for(;0<m--;)n=(l&1?"1":"0")+n,l>>=1;g=n+g;d>>=8}d=p(c,0,!0)+" "+c+". "+ra(c,0,!0)+" "+("0b"+g);32<=c&&127>c&&(d+=" '"+String.fromCharCode(c)+"'")}a.j((null!=b?b+": ":"")+d);return e}function Ah(a,b){if(b)return zh(a,b,a.S[b]);var c=0;for(b in a.S)zh(a,b,a.S[b]),c++;return 0<c}
function J(a,b,c,d){switch(a.$){case 8:a=ra(b,3*c);break;case 10:a=b.toString();break;default:a=p(b,2*c)}d?d=a.replace(/^0+([0-9A-F]+)$/i,"$1"):d=a;return d}
function Bh(a){sh.call(this,a);this.hb=!1;this.wa=!0;this.K=Z(0);this.gb=Z(0);this.N=Z(0);this.I=[];this.f=this.L=this.B=[];Ch(this);this.ma=0;Dh(this);this.Aa={};Eh(this,a.messages);this.Ha=a.commands;var b=this;window?void 0===window.pdp11&&(window.pdp11=function(a){return cd(b,a)}):void 0===global.pdp11&&(global.pdp11=function(a){return cd(b,a)})}z(Bh,sh);
var Fh={"?":"help/print","a [#]":"assemble","b [#]":"breakpoint",c:"clear output","d [#]":"dump memory","e [#]":"edit memory","g [#]":"go [to #]",h:"halt","if":"eval expression","int [#]":"request interrupt",k:"stack trace",ln:"list nearest symbol(s)",m:"messages",p:"step over",print:"print expression",r:"dump/set registers",reset:"reset machine",s:"set options","t [#]":"trace","u [#]":"unassemble","var":"assign variable",ver:"print version"},Gh=".WORD ADC ADCB ADD ASL ASLB ASR ASRB BCC BCS BEQ BGE BGT BHI BIC BICB BIS BISB BIT BITB BLE BLOS BLT BMI BNE BPL BPT BR BVC BVS CCC CLC CLCN CLCV CLCVN CLCVZ CLCZ CLCZN CLN CLR CLRB CLV CLVN CLVZ CLVZN CLZ CLZN CMP CMPB COM COMB DEC DECB INC INCB HALT JMP JSR MARK MFPD MFPI MFPS MOV MOVB MTPD MTPI MTPS NEG NEGB NOP RESET ROL ROLB ROR RORB RTI RTS SBC SBCB SCC SEC SECN SECV SECVN SECVZ SECZ SECZN SEN SEV SEVN SEVZ SEVZN SEZ SEZN SUB SWAB SXT TST TSTB WAIT MUL DIV ASH ASHC XOR SOB EMT TRAP SPL IOT RTT MFPT".split(" "),
Hh={61440:{4096:[62,4032,63],8192:[47,4032,63],12288:[18,4032,63],16384:[14,4032,63],20480:[16,4032,63],24576:[3,4032,63],36864:[63,4032,63],40960:[48,4032,63],45056:[19,4032,63],49152:[15,4032,63],53248:[17,4032,63],57344:[94,4032,63]},65024:{2048:[57,448,63],28672:[100,63,448],29184:[101,63,448],29696:[102,63,448],30208:[103,63,448],30720:[104,448,63],32256:[105,448,8192]},65280:{256:[27,4096],512:[24,4096],768:[10,4096],1024:[11,4096],1280:[22,4096],1536:[12,4096],1792:[20,4096],32768:[25,4096],
33024:[23,4096],33280:[13,4096],33536:[21,4096],33792:[28,4096],34048:[29,4096],34304:[8,4096],34560:[9,4096],34816:[106,32768],35072:[107,32768]},65472:{64:[56,63],192:[95,63],2560:[39,63],2624:[49,63],2688:[53,63],2752:[51,63],2816:[67,63],2880:[1,63],2944:[77,63],3008:[97,63],3072:[73,63],3136:[71,63],3200:[6,63],3264:[4,63],3328:[58,24576],3392:[60,63],3456:[65,63],3520:[96,63],35328:[40,63],35392:[50,63],35456:[54,63],35520:[52,63],35584:[68,63],35648:[2,63],35712:[78,63],35776:[98,63],35840:[74,
63],35904:[72,63],35968:[7,63],36032:[5,63],36096:[66,63],36160:[59,63],36224:[64,63],36288:[61,63]},65528:{128:[76,7],152:[108,12288]},65535:{0:[55],1:[99],2:[75],3:[26],4:[109],5:[70],6:[110],7:[111],160:[69],161:[31],162:[41],163:[33],164:[45],165:[36],166:[43],167:[35],168:[38],169:[32],170:[42],171:[34],172:[46],173:[37],174:[44],175:[30],176:[69],177:[80],178:[88],179:[82],180:[92],181:[85],182:[90],183:[84],184:[87],185:[81],186:[89],187:[83],188:[93],189:[86],190:[91],191:[79]}},Ih=[0],Jh=
[58,60,65,96,108,110,100,101,102,103,104,105,59,64];k=Bh.prototype;
k.Da=function(a,b,c,d){this.w=b;this.b=c;this.C=a;(a=$c(a,"messages"))&&Eh(this,a);this.kb=Hh;this.Ab=1145>this.b.rb?Jh:[];Kh(this,function(a){a:{var b=d.w.X,c=a[0],e=a=0,l=b.length;if(c){a=d.ba(Lh(d,c));if(-1===a){d.j("invalid address: "+c);break a}e=a>>>d.w.ka;l=1}d.j("blockid physical blockaddr used size type");d.j("-------- --------- ---------- ------ ------ ----");for(var c=-1,m=0;l--;){var n=b[e];n.type==c?m++||d.j("..."):(c=n.type,m=mc[c],n&&d.j(p(n.id,8)+" %"+p(e<<d.w.ka,
8)+" %%"+p(n.F,8)+" "+p(n.Kb,4,!0)+" "+p(n.size,4,!0)+" "+m),c!=Mc&&(c=-1),m=0);a+=d.w.ya;e++}}});H(this)};
k.sa=function(a,b,c){var d=this;switch(b){case "debugInput":return this.la=this.G[b]=c,c.onkeydown=function(a){var b;if(13==a.keyCode)b=c.value,c.value="",cd(d,b,!0);else if(27==a.keyCode)c.value=b="";else if(38==a.keyCode?(b=null,d.v<d.g.length-1&&(b=d.g[++d.v])):40==a.keyCode&&(0<d.v?b=d.g[--d.v]:(b="",d.v=-1)),null!=b){var e=b.length;c.value=b;c.setSelectionRange(e,e)}null!=b&&a.preventDefault&&a.preventDefault()},!0;case "debugEnter":return this.G[b]=c,Ra(c,function(){if(d.la){var a=d.la.value;
d.la.value="";cd(d,a,!0);return!0}return!1}),!0;case "step":return this.G[b]=c,Ra(c,function(a){var b=!1;sb(d,!0)||(rb(d,!0),b=d.cb(a?1:0),rb(d,!1));return b}),!0}return!1};k.ob=function(a){if(this.la){var b=0,c=0;!a&&window&&(b=window.scrollX,c=window.scrollY);this.la.focus();!a&&window&&window.scrollTo(b,c)}};k.ba=function(a){a=a&&a.F;null==a&&(a=-1);return a};k.Db=function(a,b){var c=255,d=this.ba(a,!1,1);-1!==d&&(c=a.Nb?this.w.Qb(d):this.b.Qb(d),b&&Mh(a,b));return c};
k.oa=function(a,b){var c=65535,d=this.ba(a,!1,2);-1!==d&&(c=a.Nb?this.w.lb(d):this.b.lb(d),b&&Mh(a,b));return c};k.Sb=function(a,b,c){var d=this.ba(a,!0,1);-1!==d&&(a.Nb?this.w.nb(d,b):this.b.nb(d,b),c&&Mh(a,c),this.C.Z(!0))};k.ab=function(a,b,c){var d=this.ba(a,!0,2);-1!==d&&(a.Nb?this.w.Ib(d,b):this.b.Ib(d,b),c&&Mh(a,c),this.C.Z(!0))};function Z(a,b){return{F:a,Nb:b,La:!1}}function Nh(a){return[a.F,a.La]}function Oh(a){return{F:a[0],La:a[1]}}
function Lh(a,b,c){var d,e=(c?a.K:a.gb).F;c=!1;if(void 0!==b){b=xh(a,b);"%"==b.charAt(0)&&(c=!0,b=b.substr(1));d=b;var f;if(d.match(/^[a-z_][a-z0-9_]*$/i))for(d=d.toUpperCase(),e=0;e<a.I.length;e++){var g=a.I[e].ia[d];if(void 0!==g){d=g.o;void 0!==d&&(f=Z(d));break}}if(d=f)return d;e=wh(a,b,void 0)}null!=e&&(d=Z(e,c));return d}function Ph(a,b,c){c&&(c=c.match(/(['"])(.*?)\1/))&&(b.Fc=uh(a,b.Ac=c[2]))}function Mh(a,b){null!=a.F&&(a.F+=b||1)}
function Eh(a,b){a.i=a;a.na=a.Jc=536870912;a.da=null;a.ta=[];b=uh(a,b.replace("keys","key").replace("kbd","keyboard"),!1,"|");if(b.length)for(var c in xb){var d;a:if(d=void 0,Array.prototype.indexOf)d=b.indexOf(c,d);else{d=d||0;0>d&&(d+=b.length);0>d&&(d=0);for(var e=b.length;d<e;d++)if(d in b&&b[d]===c)break a;d=-1}0<=d&&(a.na|=xb[c],a.j(c+" messages enabled"))}}function Kh(a,b){for(var c in xb)if(64==xb[c]){a.Aa[c]=b;break}}
k.oc=function(a){var b=-1;a=a.toUpperCase();switch(a){case "SP":b=6;break;case "PC":b=7;break;default:"R"==a.charAt(0)&&(b=+a.charAt(1),0>b||7<b)&&(b=-1)}return b};function Qh(a){return 6>a?"R"+a:6==a?"SP":"PC"}k.pc=function(a){var b;0<=a&&(8>a?b=this.b.u[a]:16>a?b=this.b.Sa[a-8]:20>a?b=this.b.Ga[a-16]:20==a&&(b=Xb(this.b)));return b};
k.message=function(a,b){b&&(a+=" @"+J(this,Z(this.b.Hb).F));this.na&1073741824?this.ta.push(a):this.da&&a==this.da||(this.da=a,this.na&-2147483648&&(this.ha(),a+=" (cpu halted)"),this.j(a),this.b&&(a=this.b,id(a),a.wa=0,a.C.Z()))};function Dh(a){var b;if(!fe(a))a.D&&a.D.length&&a.j("instruction history buffer freed"),a.W=0,a.D=[];else if(!a.D||!a.D.length){a.D=Array(1E3);for(b=0;b<a.D.length;b++)a.D[b]=Z();a.W=0;a.j("instruction history buffer allocated")}}
k.bb=function(a,b){if(!Rh(this,b))return!1;this.b.bb(a);return!0};k.cb=function(a,b,c){if(!Rh(this))return!1;this.J=0;a||fe(this)&&ge(this,this.b.u[7],0);try{a=jd(this.b,a);var d=this.b.cb(a);0<d&&(kd(this.b,a),this.J+=d,gd(this.b,d,!0),dd(this.b,d),this.va++)}catch(e){"number"!=typeof e&&(this.J=0,vb(this.b,e.stack||e.message))}!1!==c&&this.C.Z();this.Z(b||!1);return 0<this.J};k.ha=function(a){this.b&&this.b.ha(a)};
k.Z=function(a){if(this.hb){void 0===a&&(a=!0);var b;b=this.b;if(b=b.H&8?b.Tc|b.Sc<<8:0){var c=b>>8;this.j("trapped to "+J(this,b&255,1)+(c?" ("+J(this,c)+")":""))}this.K=Z(this.b.u[7]);a&&1!=this.R?Sh(this):Th(this)}};function Rh(a,b){var c;(c=!a.b||!tb(a.b))||(c=a.b,c.A.ja?c=!0:(c.j(c.toString()+" not powered"),c=!1),c=!c);return c||a.b.A.ca?(b||a.j("cpu busy or unavailable, command ignored"),!1):!ub(a.b)}k.Fa=function(a,b){return!b&&(this.reset(!0),a&&this.restore&&!this.restore(a))?!1:!0};
k.Ea=function(a,b){b&&this.j(a?"suspending":"shutting down");return a?this.save():!0};k.reset=function(a){Dh(this);this.va=0;this.da=null;this.J=0;this.K=Z(this.b.u[7]);this.A.ca=!1;Uh(this);a||this.Z()};k.save=function(){var a=new R(this);a.set(0,Nh(this.K));a.set(1,Nh(this.N));a.set(2,[this.g,this.O,this.na]);a.set(3,this.I);return a.data()};
k.restore=function(a){var b=0;void 0!==a[2]&&(this.K=Oh(a[b++]),this.N=Oh(a[b++]),this.g=a[b][0],"string"==typeof this.g&&(this.g=[this.g]),this.O=a[b][1],this.na|=a[b][2]);a[3]&&(this.I=a[3]);return!0};k.start=function(a,b){this.R||this.j("running");this.A.ca=!0;this.Bb=a;this.Cb=b};
k.stop=function(a,b){if(this.A.ca){this.A.ca=!1;this.J=b-this.Cb;if(!this.R){b="stopped";if(this.J){a-=this.Bb;var c=0<a?Math.round(1E3*this.J/a):0;b+=" (";fe(this)&&(b+=this.va+" instructions, ",this.va=0);b+=this.J+" cycles, "+a+" ms, "+c+" hz)"}else F(this,-2147483648)&&(b+=" (use the 't' command to execute blocked faults)");this.j(b)}this.Z(!0);this.ob();Uh(this,this.b.u[7]);this.da=null}};function fe(a){return 1<a.f.length||!!a.ma}
function ge(a,b,c){var d=-1;c||(d=a.b.lb(b),0==d&&(b=ud(a.b,2)));if(0<c&&(a.ma&&!--a.ma||Vc(a,b,1,a.f)))return!0;0<=c&&a.D.length&&(a.va++,0>d&&(d=a.b.lb(b)),65535!=(d&65535)&&(c=a.D[a.W],c.F=b,c.La=!1,++a.W==a.D.length&&(a.W=0)));return!1}function qc(a){var b=a.b;if(b.A.ca)throw P(b,a.b.Hb),a.ha(),-1;return!1}
function Ch(a){var b,c;a.f=["bp"];if(a.L)for(b=1;b<a.L.length;b++){c=a.L[b];var d=a.w;c=a.ba(c);Wc(d.X[c>>>d.ka],!1)}a.L=["br"];if(a.B)for(b=1;b<a.B.length;b++)c=a.B[b],d=a.w,c=a.ba(c),Wc(d.X[c>>>d.ka],!0);a.B=["bw"];a.eb=0}k.jb=function(a,b,c){var d=!0;c||Vh(this,a,b,!1,!0);if(a!=this.f){var e=this.ba(b);if(-1===e)this.j("invalid address: "+J(this,b.F)),d=!1;else{var f=this.w;f.X[e>>>f.ka].jb(e&f.w,a==this.B)}}d&&(a.push(b),c?b.La=!0:(Wh(this,a,a.length-1,"set"),Dh(this)));return d};
function Vh(a,b,c,d,e){var f=!1;c=a.ba(c);for(var g=1;g<b.length;g++){var h=b[g];if(c==a.ba(h)&&(!d||h.La)){f=!0;h.La||e||Wh(a,b,g,"cleared");b.splice(g,1);b!=a.f&&(d=a.w,Wc(d.X[c>>>d.ka],b==a.B));h.La||Dh(a);break}}return f}function Xh(a,b){for(var c=1;c<b.length;c++)Wh(a,b,c);return b.length-1}function Wh(a,b,c,d){c=b[c];a.j(b[0]+" "+J(a,c.F)+(d?" "+d:c.Ac?' "'+c.Ac+'"':""))}
function Uh(a,b){if(void 0!==b)Vc(a,b,1,a.f,!0),a.R=0;else for(b=1;b<a.f.length;b++){var c=a.f[b];if(c.La){if(!Vh(a,a.f,c,!0))break;b=0}}}
function Vc(a,b,c,d,e){var f=!1;if(!a.eb++)for(var g=1;!f&&g<d.length;g++){var h=d[g];if(!e||h.La)for(var l=a.ba(h),m=0;m<c;m++)if(b+m==l){var n,f=!0;h.La&&(Vh(a,d,h,!0),e=!0);if(n=h.Fc){for(var f=!1,r=0;r<n.length;r++)if(!Yh(a,n[r],!0)){if(n[r].indexOf("if")){f=!0;break}for(var t=r+1;t<n.length&&n[t].indexOf("else");t++)r++;if(t==n.length){f=!0;break}}a.b.A.ca||(f=!0)}if(f){e||Wh(a,d,g,"hit");break}}}a.eb--;return f}
function Zh(a,b,c,d){var e=Z(b.F),f=a.oa(b,2),g,h;for(h in a.kb)if(g=a.kb[h][f&h])break;g||(g=Ih);var l=g[0];0<=a.Ab.indexOf(l)&&(g=Ih,l=g[0]);var m=h="",n=Gh[l],r=g.length-1;l||r||(h=J(a,f));for(l=1;l<=r;l++){var t=g[l];if(void 0!==t){var w;w=a;var y=t,t=b,x="",A=y&61440;if(4096==A)t=t.F+((f&255)<<24>>23)&65535,x=J(w,t);else if(8192==A)t=t.F-((f&63)<<1)&65535,x=J(w,t);else if(12288==A)x=J(w,f&7,1);else if(24576==A)x=J(w,f&63,1);else if(32768==A)x=J(w,f&255,1);else if(A=f&y,y&4032&&(A>>=6,y>>=6),
y&63)switch(y=A&7,A&56){case 0:x=Qh(y);break;case 8:x="@"+Qh(y);break;case 16:7>y?x="("+Qh(y)+")+":(A=w.oa(t,2),x="#"+J(w,A,0,!0));break;case 24:7>y?x="@("+Qh(y)+")+":(A=w.oa(t,2),x="@#"+J(w,A,0,!0));break;case 32:x="-("+Qh(y)+")";break;case 40:x="@-("+Qh(y)+")";break;case 48:A=w.oa(t,2);x=J(w,A,0,!0)+"("+Qh(y)+")";7==y&&(x=J(w,A+t.F&65535));break;case 56:A=w.oa(t,2),x="@"+J(w,A)+"("+Qh(y)+")",7==y&&(x="@"+J(w,A+t.F&65535))}w=x;if(!w||!w.length){h="INVALID";break}"string"!=typeof w&&(m=w[1],w=w[0]);
0<h.length&&(h+=",");h+=w||"???"}}f="";g=J(a,e.F)+":";if(-1!==e.F&&-1!==b.F){do if(f+=" "+J(a,a.oa(e,2)),null==e.F)break;while(e.F!=b.F)}g+=xa(f,24);g+=xa(n,5);h&&(g+=" "+h);if(c||m)g=xa(g,60)+";"+(c||""),g=a.b.A.qb?g+("cycles="+ed(a.b).toString()+" cs="+p(a.b.Eb)):g+(null!=d?"="+d.toString():""),m&&(g+=" @"+m);return g}function $h(a,b){switch(b){case "N":a=a.b.Qa();break;case "Z":a=sd(a.b);break;case "V":a=rd(a.b);break;case "C":a=qd(a.b);break;default:a=0}return b.charAt(0)+(a?"1":"0")+" "}
function ai(a,b){var c="",d=a.b;8>b?(c=Qh(b),c+="="+J(a,d.u[b])):13>b?c="A"+(b-8)+"="+J(a,d.Sa[b-8]):16<=b&&20>b?c="S"+(b-16)+"="+J(a,d.Ga[b-16]):20==b&&(c="PS="+J(a,Xb(d)));c&&(c+=" ");return c}function bi(a){var b,c="";for(b=0;6>b;b++)c+=ai(a,b);c=c+"\n"+(ai(a,6)+ai(a,7)+ai(a,20));return c+=$h(a,"T")+$h(a,"N")+$h(a,"Z")+$h(a,"V")+$h(a,"C")}k.jc=function(a,b){return a[0]>b[0]?1:a[0]<b[0]?-1:0};
function kg(a,b,c,d,e){var f=[],g;for(g in e){var h=e[g];"number"==typeof h&&(e[g]=h={o:h});var l=h.o,m=h.a;if(void 0!==l){var n=f,l=[l>>>0,g],r=Aa(n,l,a.jc);0>r&&n.splice(-(r+1),0,l)}m&&(h.a=m.replace(/''/g,'"'))}a.I.push({Qe:b,F:c,Qc:d,ia:e,hc:f})}function ci(a,b,c){var d=[],e=a.ba(b)>>>0;for(b=0;b<a.I.length;b++){var f=a.I[b],g=f.F>>>0,h=f.Qc;if(e>=g&&e<g+h){e=Aa(f.hc,[e-g],a.jc);0<=e?di(a,b,e,d):c&&(e=~e,di(a,b,e-1,d),di(a,b,e,d));break}}return d}
function di(a,b,c,d){var e={},f=a.I[b].hc,g=0,h=null;0<=c&&c<f.length&&(g=f[c][0],h=f[c][1]);h&&(e=a.I[b].ia[h],h="."==h.charAt(0)?null:e.l||h);d.push(h);d.push(g);d.push(e.a);d.push(e.c)}function ei(a,b){var c=b.match(/^\s*([A-Z_]?[A-Z0-9_]*)\s*(=?)\s*(.*)$/i);if(c){if(!c[1])return Ah(a)||a.j("no variables"),!0;if(!c[2])return Ah(a,c[1]);if(!c[3])return delete a.S[c[1]],!0;b=wh(a,c[3]);return void 0!==b?(a.S[c[1]]=b,!0):!1}a.j("invalid assignment:"+b);return!1}
function fi(a,b,c){var d=null;if(b=Lh(a,b,!0)){a.ba(b);var e=ci(a,b,!0);if(e.length){var f,g;e[0]&&(g="",(f=b.F-e[1])&&(g=" + "+p(f,4,!0)),f=e[0]+" ("+J(a,e[1])+")"+g,c&&a.j(f),d=f);4<e.length&&e[4]&&(g="",(f=e[5]-b.F)&&(g=" - "+p(f,4,!0)),f=e[4]+" ("+J(a,e[5])+")"+g,c&&a.j(f),d||(d=f))}else c&&a.j("no symbols")}return d}
function Sh(a,b){var c;if(b&&"?"==b[1])a.j("register commands:"),a.j("\tr\tdump registers"),a.j("\trx [#]\tset flag or register x to [#]");else{var d=a.b;null==c&&(c=!0);if(b&&1<b.length){var e=b[1],f=e.indexOf("=");if(0<f)b=e.substr(f+1),e=e.substr(0,f);else if(2<b.length)b=b[2];else{a.j("missing value for "+b[1]);return}f=wh(a,b);if(void 0===f)return;b=e.toUpperCase();switch(b){case "SP":case "R6":d.u[6]=f&65535;break;case "PC":case "R7":P(d,f);a.K=Z(d.u[7]);break;case "N":d.Y=f?32768:0;break;case "Z":d.aa=
f?0:1;break;case "V":d.U=f?32768:0;break;case "C":d.T=f?65536:0;break;default:if("R"==b.charAt(0)&&(b=+b.charAt(1),0<=b&&6>b)){d.u[b]=f&65535;break}a.j("unknown register: "+e);return}a.C.Z();a.j("updated registers:")}a.j(bi(a));c&&(a.K=Z(d.u[7]),Th(a,J(a,a.K.F)))}}function gi(a,b){b=ya(b);var c=b.match(/^(['"])(.*?)\1$/);c?1<c[2].length?a.j(c[2]):zh(a,null,c[2].charCodeAt(0)):wh(a,b,!0)}
function hi(a,b,c){var d="t"!=b;c=yh(a,c,null,!0)||1;var e=1==c?0:1;"tc"==b&&(e=c,c=1);Qa(c,function(){return rb(a,!0)&&a.cb(e,d,!1)},function(){a.C.Z();rb(a,!1)})}
function Th(a,b,c,d){if(b=Lh(a,b,!0)){void 0===d&&(d=1);var e=256;if(void 0!==c)if("l"==c.charAt(0))c=yh(a,c.substr(1)),null!=c&&(d=c);else{d=Lh(a,c,!0);if(!d||d.F<b.F)return;e=d.F-b.F;if(256<e){a.j("range too large");return}d=-1}c=0;for(var f;0<e&&d--;){f=sb(a,!1)||a.R?a.J:null;var g=null!=f?"cycles":null,h=ci(a,b),l=b.F;if(h[0]&&d&&(!c&&d||0>h[0].indexOf("+"))){var m=h[0]+":";h[2]&&(m+=" "+h[2]);a.j(m)}h[3]&&(g=h[3],f=null);f=Zh(a,b,g,f);a.j(f);a.K=b;e-=b.F-l;c++}}}
function Yh(a,b,c){var d=!0;try{b.length&&"end"!=b?c||a.j(">> "+b):(a.O&&(a.j("ended assemble at "+J(a,a.N.F)),a.K=a.N,a.O=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.da=null;if(tb(a)&&0<b.length){a.O&&(b="a "+J(a,a.N.F)+" "+b);var f=!1,g=b.replace(/ +/g," ").split(" ");g[0]=g[0].toLowerCase();if(g&&g.length)for(var h=g[0],l=h.charAt(0),m=1;m<h.length;m++){var n=h.charAt(m);if("?"==l||"r"==l||"a">n||"z"<n){g[0]=h.substr(m);g.unshift(h.substr(0,m));break}}switch(g[0].charAt(0)){case "a":var r=
Lh(a,g[1],!0);if(r)if(a.N=r,void 0===g[2])a.j("begin assemble at "+J(a,r.F)),a.O=!0,a.C.Z();else{var t;a.j("not supported yet");t=[];if(t.length){for(var w=0;w<t.length;w++)a.Sb(r,t[w],1);a.j(Zh(a,a.N))}}break;case "b":a:{var y=g[0],x=g[1],A=b;if("?"==x)a.j("breakpoint commands:"),a.j("\tbp [a]\tset exec breakpoint at addr [a]"),a.j("\tbr [a]\tset read breakpoint at addr [a]"),a.j("\tbw [a]\tset write breakpoint at addr [a]"),a.j("\tbc [a]\tclear breakpoint at addr [a]"),a.j("\tbl\tlist all breakpoints"),
a.j("\tbn [n]\tbreak after [n] instruction(s)");else{var ka=y.charAt(1);if("l"==ka){var Ja;Ja=0+Xh(a,a.f);Ja+=Xh(a,a.L);(Ja+=Xh(a,a.B))||a.j("no breakpoints")}else if("n"==ka)a.ma=yh(a,x),a.j("break after "+a.ma+" instruction(s)");else if(void 0===x)a.j("missing breakpoint address");else{var Q=Z();if("*"!=x&&(Q=Lh(a,x,!0),!Q))break a;"c"==ka?null==Q.F?(Ch(a),a.j("all breakpoints cleared")):Vh(a,a.f,Q)||Vh(a,a.L,Q)||Vh(a,a.B,Q)||a.j("breakpoint missing: "+J(a,Q.F)):null!=Q.F&&(Ph(a,Q,A),"p"==ka?a.jb(a.f,
Q):"r"==ka?a.jb(a.L,Q):"w"==ka?a.jb(a.B,Q):a.j("unknown breakpoint command: "+ka))}}}break;case "c":a.Oa&&(a.Oa.value="");break;case "d":a:{var eb,fb=g[0],na=g[1],La=g[2],Ai=g[3];if("?"==na){var gb="";for(eb in xb)a.Aa[eb]&&(gb&&(gb+=","),gb+=eb);gb+=",state,symbols";a.j("dump memory commands:");a.j("\tdb [a] [#] dump # bytes at address a");a.j("\tdw [a] [#] dump # words at address a");a.j("\tdd [a] [#] dump # dwords at address a");a.j("\tdh [#] [#] dump # instructions from history");
gb.length&&a.j("dump extension commands:\n\t"+gb)}else if("state"==na){var ng=ii(a.C,!0);"console"==La?console.log(ng):(a.Oa&&(a.Oa.value=""),a.j(ng))}else if("symbols"==na)for(var Cd=0;Cd<a.I.length;Cd++){var Dd=a.I[Cd],hb;for(hb in Dd.ia)if("."!=hb.charAt(0)){var og=Dd.ia[hb].o;if(void 0!==og){var pg=Dd.ia[hb].l;pg&&(hb=pg);a.j(J(a,og)+" "+hb)}}}else{if("d"==fb){for(eb in xb)if(g[1]==eb){var qg=a.Aa[eb];qg?(g.shift(),g.shift(),qg(g)):a.j("no dump registered for "+na);break a}na||(fb=a.Ob||"db")}else a.Ob=
fb;if("dh"==fb){var rg=na,sg=La,tg="",ug=0,ga=a.W,oa=a.D;if(oa.length){var ba=+rg||a.ib,Hb=+sg||10;isNaN(ba)?ba=Hb:tg="more ";ba>oa.length&&(a.j("note: only "+oa.length+" available"),ba=oa.length);ga-=ba;0>ga&&(null==oa[oa.length-1].F?(ba=ga+ba,ga=0):ga+=oa.length);var Ed=[];"call"==sg&&(Hb=1E5,Ed=["CALL"]);for(void 0!==rg&&a.j(ba+" instructions earlier:");0<Hb&&ga!=a.W;){var vg=oa[ga++];if(null==vg.F)break;var Ib=Z(vg.F),Bi=ba--,wg=Zh(a,Ib,"history",Bi);(!Ed.length||0<=wg.indexOf(Ed[0]))&&a.j(wg);
Ib.Xb&&(ga+=Ib.Xb,Hb-=Ib.Xb,ba-=Ib.Xb);ga>=oa.length&&(ga=0);a.ib=ba;ug++;Hb--}}ug||(a.j("no "+tg+"history available"),a.ib=void 0)}else{var Jb=Lh(a,na);if(Jb){var yc=0;La&&("l"==La.charAt(0)&&(La=La.substr(1)||Ai),yc=yh(a,La)>>>0,65536<yc&&(yc=65536));for(var Kb="",ib="dd"==fb?4:"dw"==fb?2:1,zc=ib*yc||128,Ci=zc+15>>4||1;Ci--&&0<zc;){var Ac=0,Lb=0,Mb,Fd="",xg="",na=J(a,Jb.F);for(Mb=4==ib?16:a.$;0<Mb&&0<zc;Mb--){var Bc=1,Cc=1==ib?a.Db(Jb,Bc):a.oa(Jb,Bc=2),Ac=Ac|Cc<<(Lb<<3),Lb=Lb+Bc;Lb==ib&&(Fd+=J(a,
Ac,ib),Fd+=1==ib?9==Mb?"-":" ":" ",Ac=Lb=0);xg+=32<=Cc&&128>Cc?String.fromCharCode(Cc):".";zc-=Bc}Kb&&(Kb+="\n");Kb+=na+" "+Fd+(0==Mb?" "+xg:"")}Kb&&a.j(Kb);a.gb=Jb}}}}break;case "e":if("else"==g[0])break;var jb,Gd,Hd,Id,Jd=g[0],Kd=g[1];"eb"==Jd?(jb=1,Gd=255,Hd=a.Db,Id=a.Sb):"e"==Jd||"ew"==Jd?(jb=2,Gd=65535,Hd=a.oa,Id=a.ab):Kd=null;if(null==Kd)a.j("edit memory commands:"),a.j("\teb [a] [...] edit bytes at address a"),a.j("\tew [a] [...] edit words at address a");else{var Dc=Lh(a,Kd);if(Dc)for(var Ec=
2;Ec<g.length;Ec++){var Nb=wh(a,g[Ec]);if(void 0===Nb){a.j("unrecognized value: "+g[Ec]);break}Nb&~Gd&&a.j("warning: "+p(Nb)+" exceeds "+jb+"-byte value");var Di=Hd.call(a,Dc);a.j("changing "+J(a,Dc.F)+" from "+J(a,Di,jb)+" to "+J(a,Nb,jb));Id.call(a,Dc,Nb,jb)}}break;case "g":a:{var yg=g[1],Ei=b;if(void 0!==yg){var Ld=Lh(a,yg,!0);if(!Ld)break a;Ph(a,Ld,Ei);a.jb(a.f,Ld,!0)}a.bb(!0,c)}break;case "h":a.A.ca?(c||a.j("halting"),a.ha()):sb(a,!0)||c||a.j("already halted");break;case "i":if("if"==g[0]){var Md;
var Ob=b.substr(2),Ob=ya(Ob);wh(a,Ob)?(c||a.j("true: "+Ob),Md=!0):(c||a.j("false: "+Ob),Md=!1);Md||(d=!1);break}f=!0;break;case "k":var Fi=g[0];if("?"==g[1])a.j("stack trace commands:"),a.j("\tk\tshow frame addresses"),a.j("\tks\tshow symbol information");else{var Nd=0,Od=Z(),Pb=Z(a.b.u[6]);for(a.j("stack trace for "+J(a,Pb.F));10>Nd;){for(var Ma=null,Gi=256;65536>Pb.F>>>0;){Od.F=a.oa(Pb,2);if(null==Pb.F||!Gi--)break;if(!(Od.F&1)){for(var Hi=a,Fc=Od,zg=null,Qb=Fc.F,Ag=Qb,Pd=1;6>=Pd&&Qb;Pd++){if(2<
Pd){Fc.F=Qb;var Gc=Zh(Hi,Fc);if(0<=Gc.indexOf("JSR")){var Bg=Gc.indexOf(" ");if(Qb+(Gc.indexOf(" ",Bg+1)-Bg-1)/2==Ag){zg=Gc;break}}}Qb-=2}Fc.F=Ag;if(Ma=zg)break}}if(!Ma||null==Ma)break;var Cg=null;if("ks"==Fi){var Dg=Ma.match(/[0-9A-F]+$/);Dg&&(Cg=fi(a,Dg[0]))}Ma=xa(Ma,50)+" ;"+(Cg||"stack="+J(a,Pb.F));a.j(Ma);Nd++}Nd||a.j("no return addresses found")}break;case "l":if("ln"==g[0]){fi(a,g[1],!0);break}f=!0;break;case "m":a:{var pa,qa=null,G=g[1];"?"==G&&(G=void 0);if(void 0!==G){var Da=0;if("all"==
G)Da=1878917119,G=null;else if("on"==G)qa=!0,G=null;else if("off"==G)qa=!1,G=null;else{"keys"==G&&(G="key");"kbd"==G&&(G="keyboard");for(pa in xb)if(G==pa){Da=xb[pa];qa=!!(a.na&Da);break}if(!Da){a.j("unknown message category: "+G);break a}}if(Da)if("on"==g[2])a.na|=Da,qa=!0;else if("off"==g[2]&&(a.na&=~Da,qa=!1,1073741824==Da)){for(var Qd=0;Qd<a.ta.length;Qd++)a.j(a.ta[Qd]);a.ta=[]}}var Ii=0,Rb="";for(pa in xb)if(!G||G==pa){var Ji=!!(a.na&xb[pa]);if(null===qa||qa==Ji)Rb&&(Rb+=","),++Ii%10||(Rb+="\n\t"),
"key"==pa&&(pa="keys"),Rb+=pa}void 0===G&&a.j("message commands:\n\tm [category] [on|off]\tturn categories on/off");a.j((null!==qa?qa?"messages on: ":"messages off: ":"message categories:\n\t")+(Rb||"none"));Dh(a)}break;case "p":if("print"==g[0]){gi(a,b.substr(5));break}var Ki="pr"==g[0]?1:0;if(a.R)a.j("step in progress");else{var Eg=Z(a.b.u[7]);a.Db(Eg);a.R?(a.jb(a.f,Eg,!0),a.bb()||(a.C&&a.C.ob(),a.R=0)):hi(a,Ki?"tr":"t")}break;case "r":if("reset"==b){a.C&&a.C.reset();break}Sh(a,g);break;case "s":a:switch(g[1]){case "base":if(g[2]){var Sb=
+g[2];if(8==Sb||10==Sb||16==Sb)a.$=Sb;else{a.j("invalid base: "+Sb);break}}a.j("default base: "+a.$);break;case "cs":var Tb;void 0!==g[3]&&(Tb=+g[3]);switch(g[2]){case "int":a.b.sb=Tb;break;case "start":a.b.Fb=Tb;break;case "stop":a.b.tb=Tb;break;default:a.j("unknown cs option");break a}void 0!==Tb&&bd(a.b);a.j("checksums "+(a.b.A.qb?"enabled":"disabled"));break;case "sp":void 0!==g[2]&&(fd(a.b,+g[2])||a.j("warning: using 1x multiplier, previous target not reached"));a.j("target speed: "+(a.b.mb.toFixed(2)+
"Mhz")+" ("+a.b.Xa+"x)");break;default:if(g[1]){a.j("unknown option: "+g[1]);break}case "?":a.j("debugger options:"),a.j("\tbase #\t\tset default base to #"),a.j("\tcs int #\tset checksum cycle interval to #"),a.j("\tcs start #\tset checksum cycle start count to #"),a.j("\tcs stop #\tset checksum cycle stop count to #"),a.j("\tsp #\t\tset speed multiplier to #")}break;case "t":hi(a,g[0],g[1]);break;case "u":Th(a,g[1],g[2],8);break;case "v":if("var"==g[0]){ei(a,b.substr(3))||(d=!1);break}if("ver"==
g[0]){a.j("PDPjs version 1.30.2 ("+a.b.rb+",RELEASE"+(wb?",TYPEDARRAYS":",LONGARRAYS")+")");a.j(window?window.navigator.userAgent:"");break}f=!0;break;case "?":if(g[1]){gi(a,b.substr(1));break}var Rd="commands:",Sd;for(Sd in Fh)Rd+="\n"+xa(Sd,9)+Fh[Sd];fe(a)||(Rd+="\nnote: history disabled if no exec breakpoints");a.j(Rd);break;default:f=!0}f&&(a.j("unknown command: "+b),d=!1)}}catch(Fg){a.j("debugger error: "+(Fg.stack||Fg.message)),d=!1}return d}
function cd(a,b,c){b=uh(a,b,c);for(var d in b)if(!Yh(a,b[+d]))return!1;return!0}Xa(function(){for(var a=D(document,"pdp11","debugger"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new Bh(d);C(d,c)}});
function ji(a,b,c){u.call(this,"Computer",a,ji,67108864);this.A.ja=!1;ki(this,b);this.L=$c(this,"autoPower",a);this.C=0;this.W=a.busWidth||a.buswidth;this.f=li;this.J=null;this.B=this.R=!1;this.$=$c(this,"url")||"";(Math.random()+.1).toString(36);this.g=mi(this);if(this.b=qb("CPU",this.id)){this.i=qb("Debugger",this.id);this.w=new Zb({id:this.Na+".bus",busWidth:this.W},this.b,this.i);var d,e=ob(this.id);if((this.I=qb("Panel",this.id))&&this.I.Oa)for(b=0;b<e.length;b++)d=e[b],d.P=this.I.P,d.j=this.I.j,
d.Oa=this.I.Oa;this.j("PDPjs v1.30.2\nCopyright \u00a9 2012-2016 Jeff Parsons <Jeff@pcjs.org>\nLicense: GPL version 3 or later <http://gnu.org/licenses/gpl.html>");this.j("Portions adapted from the PDP-11/70 Emulator v1.4 by Paul Nankervis <paulnank@hotmail.com>");for(b=0;b<e.length;b++)d=e[b],d.Da&&d.Da(this,this.w,this.b,this.i);b=null;d=a.resume;void 0!==d&&(1<d.length?b=this.D=d:this.f=parseInt(d,10));var f;if(a=$c(this,"state")||(f=!0,a.state))b=this.N=a,f||(this.B=!0,this.f=li),this.f&&(this.K=
new R(this,"1.30.2"),ni(this.K)?b=null:delete this.K);!b&&this.f&&(b=oi(this))&&(this.B=!0);if(b){var g=this;Ea(b,null,!0,function(a,b,c){c?(g.D=null,g.B=!1,g.P("Unable to load machine state from server (error "+c+(b?": "+ya(b):"")+")")):(g.J=b,g.R=!0);H(g)})}else H(this);this.G.power||(this.L=!0);!c&&this.L&&pi(this,this.Gb)}else q("Unable to find CPU component")}z(ji);var li=0;
function ki(a,b){if(!b){var c;if("object"==typeof resources&&(c=resources.parms))try{b=eval("("+c+")")}catch(d){q(d.message+" ("+c+")")}}a.S=b}function $c(a,b,c){var d=b.toLowerCase(),d=bb[b]||bb[d];void 0===d&&a.S&&(d=a.S[b]);void 0===d&&c&&(d=c[b]);void 0===d&&"object"==typeof resources&&resources[b]&&(d=b);return d}function pi(a,b,c){for(var d=ob(a.id),e=0;e<=d.length;e++){var f=e<d.length?d[e]:a;if(!tb(f)){tb(f,function(){pi(a,b,c)});return}}b.call(a,c)}
function qi(a,b){var c=new R(a,"1.30.2","validate");if(ni(c)&&ri(c)){var d=c.get("timestamp"),e=b?b.get("timestamp"):"unknown";d!=e&&(a.P("Machine state may be out-of-date\n("+d+" vs. "+e+")\nCheck your browser's local storage limits"),b||c.clear())}}k=ji.prototype;
k.Gb=function(a){void 0===a&&(a=this.f||(this.J?1:li));if(!this.C){this.C++;var b=!1,c=!1;this.O=!1;var d=this.K||new R(this,"1.30.2");if(-1==a)b=!0;else if(a>li){if(ni(d,this.J)){this.v=new R(this,"1.30.2","failsafe");ni(this.v)&&(si(this,d),a=2,ti(this.v));this.v.set("timestamp",Ca());ui(this.v);var e=this.f&&!this.B;if(1==a||Ha("Click OK to restore the previous PDPjs machine state, or CANCEL to reset the machine.")){if(c=ri(d)){var f=d.get("code"),g=d.get("data");f&&("ok"==f?ni(d,g):("error"==
f&&"no machine state"!=g?(this.P("Error: "+g),"unable to verify user"==g&&(Oa("user",""),this.g=null)):this.j(f+": "+g),ti(d),ni(d)?(c=ri(d),e=!0):c=!1))}e&&qi(this,c?d:null)}else 2==a&&d.clear()}else qi(this);delete this.J;delete this.K}e=ob(this.id);for(f=0;f<e.length;f++)g=e[f],g!==this&&g!=this.b&&(c=vi(this,g,d,b,c));b=[d,a,c];-1!=a?pi(this,this.kc,b):this.kc(b)}};
function vi(a,b,c,d,e){if(!b.A.ja){b.A.ja=!0;if(b.Fa){var f=null;e&&((f=c.get(b.id))||(f=c.get(b.id.replace(/[a-z0-9]\./i,"."))));"string"===typeof f&&(f=null);!b.Fa(f,d)&&f&&(q("Unable to restore state for "+b.type),a.N&&!a.R?(c.clear(),a.f=li,window&&window.location.reload()):a.O=!0,b.Fa(null),e=!1)}if(!d&&b.mc)for(a=b.mc.split("|"),c=0;c<a.length;c++)b.status(a[c])}return e}
k.kc=function(a){var b=a[0],c=0>a[1];a=a[2];this.da=!0;this.A.ja=!0;var d=this.G.power;d&&(d.textContent="Shutdown");this.b&&(vi(this,this.b,b,c,a),this.b.pb());this.O&&(si(this,b),b.clear());!c&&this.v&&(this.v.clear(),delete this.v);this.C=0};
function si(a,b){if(Ha("There may be a problem with your PDPjs machine.\n\nTo help us diagnose it, click OK to send this PDPjs machine state to http://www.pcjs.org.")){var c=a.g||"";b=b.toString();var d={app:"PDPjs",ver:"1.30.2"};d.url=a.$;d.user=c;d.type="bug";d.data=b;Ea("http://www.pcjs.org/api/v1/report",d,!0)}}
function ii(a,b,c){var d,e="none";if(a.C)return null;a.C--;var f=new R(a,"1.30.2"),g=new R(a,"1.30.2","validate"),h=Ca();g.set("timestamp",h);f.set("timestamp",h);f.set("version","1.30.2");f.set("url",window?window.location.href:null);f.set("browser",window?window.navigator.userAgent:"");a.b&&a.b.Ea&&(c&&a.b.ha(),d=a.b.Ea(b,c),"object"===typeof d&&f.set(a.b.id,d),c&&(a.b.A.ja=!1,!1===d&&(e=null)));for(var h=ob(a.id),l=0;l<h.length;l++){var m=h[l];m.A.ja&&(m.Ea&&(d=m.Ea(b,c),"object"===typeof d&&f.set(m.id,
d)),c&&(m.A.ja=!1,!1===d&&(e=null)))}e&&(c?(h=d=!1,b?(a.g&&wi(a,a.g,f.toString()),ui(g)&&ui(f)||(e=null,d=h=!0)):a.f&&(d=!0,h=3==a.f),d&&f.clear(h)):e=f.toString());c&&(a.A.ja=!1,b=a.G.power)&&(b.textContent="Power");a.C=0;return e}k.reset=function(){this.w&&this.w.reset&&(E(this,"Resetting "+this.w.type),this.w.reset());for(var a=ob(this.id),b=0;b<a.length;b++){var c=a[b];c!==this&&c!==this.w&&c.reset&&(E(this,"Resetting "+c.type),c.reset())}};
k.start=function(a,b){for(var c=ob(this.id),d=0;d<c.length;d++){var e=c[d];"CPU"!=e.type&&e!==this&&e.start&&e.start(a,b)}this.Z(!0)};k.stop=function(a,b){for(var c=ob(this.id),d=0;d<c.length;d++){var e=c[d];"CPU"!=e.type&&e!==this&&e.stop&&e.stop(a,b)}this.Z(!0)};
k.sa=function(a,b,c){var d=this;switch(b){case "power":return this.G[b]=c,c.onclick=function(){d.C||(d.A.ja?ii(d,!1,!0):pi(d,d.Gb))},!0;case "reset":return this.G[b]=c,c.onclick=function(){if(d.A.ja&&!d.C)if(d.f&&!d.D){var a=Ha("Click OK to save changes to this PDPjs machine.\n\nWARNING: If you CANCEL, all disk changes will be discarded.");ii(d,a,!0);!a&&d.N?window&&window.location.reload():(a||(d.lc=!0),d.Gb(li),d.lc=!1)}else d.reset(),d.b&&d.b.pb()},!0;case "save":if(ua(Ga(),"pcjs.org"))c.parentNode.removeChild(c);
else return this.G[b]=c,c.onclick=function(){var a=mi(d,!0);if(a){var b=!!(d.f&&!d.D||d.N),c=ii(d,b);b?wi(d,a,c):d.P("Resume disabled, machine state not saved")}},!0}return!1};
function mi(a,b){var c=a.g;c||((c=Na("user"),void 0!==c)?!c&&b&&(b=null,window&&(b=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=b)&&((c=xi(a,c))||a.P("The user ID is invalid.")):b&&a.P("Browser local storage is not available"));return c}
function xi(a,b){a.g=null;b=Ea(Ga()+"/api/v1/user?req=verify&user="+b);var c=b[1];if(!b[0]&&c)try{b=eval("("+c+")"),b.code&&"ok"==b.code&&(Oa("user",b.data),a.g=b.data)}catch(d){q(d.message+" ("+c+")")}return a.g}function oi(a){var b=null;a.g&&(b=Ga()+"/api/v1/user?req=load&user="+a.g+"&state="+yi(a,"1.30.2"));return b}
function wi(a,b,c){if(c){var d={req:"store"};d.user=b;d.state=yi(a,"1.30.2");d.data=c;b=Ea(Ga()+"/api/v1/user",d);d=b[0];if(b[1]){if(d){var e=d.indexOf("\n");0<e&&(d=d.substr(0,e));d.indexOf("Error: ")||(d=d.substr(7))}d='{"code":'+b[1]+',"data":"'+d+'"}'}b=JSON.parse(d);b&&"ok"==b.code?a.P("Machine state saved to server"):c&&(c=b&&b.data||"unable to save machine state",c="error"==b.code?"Error: "+c:"Error "+b.code+": "+c,a.P(c),Oa("user",""),a.g=null)}}
function Pg(a){var b;a=ob(a.id);for(var c=0;c<a.length;c++){var d=a[c];if(b)b==d&&(b=null);else if("RAM"==d.type)return d}return null}k.ob=function(a){if(this.Oa){var b=0,c=0;!a&&window&&(b=window.scrollX,c=window.scrollY);this.Oa.focus();!a&&window&&window.scrollTo(b,c)}};k.Z=function(a){this.b&&this.b.Z(a);this.I&&this.I.Z(a)};
Xa(function(){for(var a=D(document,"pdp11-machine"),b=0;b<a.length;b++)for(var c=a[b],d=B(c),c=D(c,"pdp11","computer"),e=0;e<c.length;e++){var f=c[e],g=B(f),g=new ji(g,d,!0);C(g,f);g.L&&pi(g,g.Gb)}});Sa.show.push(function(){for(var a=D(document,"pdp11","computer"),b=0;b<a.length;b++){var c=B(a[b]);(c=qb("Computer",c.id))&&c.da&&!c.A.ja&&c.Gb(-1)}});
Sa.exit.push(function(){for(var a=D(document,"pdp11","computer"),b=0;b<a.length;b++){var c=B(a[b]);(c=qb("Computer",c.id))&&c.A.ja&&ii(c,!(!c.f||c.D),!0)}});function R(a,b,c){this.id=a.id;this.key=yi(a,b,c);this.i=a.i;ti(this,a.Rc)}function yi(a,b,c){a=a.id;if(b){var d=b.indexOf(".");0<d&&(a+=".v"+b.substr(0,d))}c&&(a+="."+c);return a}
R.prototype={constructor:R,set:function(a,b){try{this[this.id][a]=b}catch(c){}},get:function(a){return this[this.id][a]||null},value:function(){return this[this.id]},data:function(){return this[this.id]},toString:function(){var a=this[this.id];return"string"==typeof a?a:JSON.stringify(a)},clear:function(a){ti(this);var b=[];try{for(var c=0,d=window.localStorage.length;c<d;c++)b.push(window.localStorage.key(c))}catch(e){}for(c=0;c<b.length;c++)if((d=b[c])&&(a||d.substr(0,this.key.length)==this.key)){try{window.localStorage.removeItem(d)}catch(e){}b.splice(c,
1);c=0}}};function ti(a,b){a[a.id]={};b&&a.set("parms",b);a.b=!1}function ui(a){var b=!0;if(Ka()){var c=JSON.stringify(a[a.id]);Oa(a.key,c)||(q("Unable to store "+c.length+" bytes in browser local storage"),b=!1)}return b}function ri(a){var b=!0;try{a[a.id]=JSON.parse(a[a.id])}catch(c){q(c.message||c),b=!1}return b}function ni(a,b){return b?(a[a.id]=b,a.b=!0):a.b?!0:Ka()&&(b=Na(a.key))?(a[a.id]=b,a.b=!0):!1}var zi=0;
function Li(a,b,c,d,e,f){e("Loading "+a+"...");Ea(a,null,!0,function(g,h,l){l?(h||(h="unable to load "+a+" ("+l+")"),f(h,null)):Mi(h,a,b,c,d,e,f)})}
function Mi(a,b,c,d,e,f,g){function h(a,f){if(f)g(f,null);else{c&&(nb(c,b,a),(f=b)&&0>f.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(f=window.location.pathname+f),d?"}"==d.slice(-1)?(d=d.slice(0,-1),1<d.length&&(d+=",")):d='{state:"'+d+'",':d="{",d+='url:"'+f+'"}',"object"==typeof resources&&(f=null),a=a.replace(/(<machine[^>]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(f?' url="'+f+'"':"")));e||(a=a.replace(/(<xsl:variable name="APPNAME">).*?(<\/xsl:variable>)/,"$1PDPjs$2"),
a=a.replace(/(<xsl:variable name="APPCLASS">).*?(<\/xsl:variable>)/,"$1pdp11$2"));f=null;if("<"==a.charAt(0))try{e||(a=a.replace(/<!DOCTYPE(.|[\r\n])*]>\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(f=new window.ActiveXObject("Microsoft.XMLDOM"),f.async=!1,f.loadXML(a)):f=(new window.DOMParser).parseFromString(a,"text/xml")}catch(n){f=null,a=n.message}else a="unrecognized XML: "+(255<a.length?a.substr(0,255)+"...":a);g(a,f)}}a?e?Ni(a,f,h):h(a,null):g("no data"+(b?" for file: "+b:""),null)}
function Ni(a,b,c){var d;if(d=/<([a-z]+)\s+ref="(.*?)"(.*?)\/>/g.exec(a)){var e=d[2];b("Loading "+e+"...");Ea(e,null,!0,function(f,g,h){if(h||!g)c(a,"unable to resolve XML reference: "+d[0]+" ("+h+")");else{if(f=d[3])if(h=g.match(new RegExp("<"+d[1]+"[^>]*>"))){for(var l=h[0],m,n=/( [a-z]+=)(['"])(.*?)\2/g;m=n.exec(f);)l=0>l.indexOf(m[1])?l.replace(">",m[0]+">"):l.replace(new RegExp(m[1]+"(['\"])(.*?)\\1"),m[0]);h[0]!=l&&(g=g.replace(h[0],l))}else{c(a,"missing <"+d[1]+"> in "+e);return}g=g.replace(/<\?xml[^>]*>[\r\n]*/,
"");a=a.replace(d[0],g);Ni(a,b,c)}})}else c(a,null)}
function Oi(a,b,c,d){function e(a){if(void 0===h){var b=g&&D(g,"machine-warning");h=b&&b[0]||g}h&&(h.innerHTML=wa(a))}function f(a){e("Error: "+a);l&&(--zi||Za(!0));l=!1}var g,h,l=!0;zi++;mb[a]={};try{if(g=document.getElementById(a)){var m;if("object"==typeof resources&&(m=resources.css)){var n=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));n.appendChild(r)}c||
(c="/versions/pdpjs/1.30.2/components.xsl");m=function(d,h){h?Li(c,null,null,!1,e,function(d,l){l?(nb(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window?(l=h.transformNode(l))?(g.outerHTML=l,--zi||Za(!0)):f("transformNodeToObject failed"):document.implementation&&document.implementation.createDocument?(d=new XSLTProcessor,d.importStylesheet(l),(l=d.transformToFragment(h,document))?g.parentNode?(g.parentNode.replaceChild(l,g),--zi||Za(!0)):f("invalid machine element: "+
a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser")):f(d)}):f(d)};"<"!=b.charAt(0)?Li(b,a,d,!0,e,m):Mi(b,null,a,d,!1,e,m)}else f("missing machine element: "+a)}catch(t){f(t.message)}return l}window.embedPDP11=function(a,b,c,d){Za(!1);return Oi(a,b,c,d)};window.enableEvents=Za;window.sendEvent=$a;})();//# sourceMappingURL=/tmp/pdpjs/1.30.2/pdp11-dbg.map