pcjs/versions/pdpjs/1.30.2/pdp11-dbg.js

318 lines
118 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,ba="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 ga=da[ea];ga in ca||(ca[ga]={});ca=ca[ga]}var ha=da[da.length-1],ia=ca[ha],ka=ia?ia:function(a){return Math.log(a)/Math.LN2};
ka!=ia&&null!=ka&&ba(ca,ha,{configurable:!0,writable:!0,value:ka});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 qa(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,La:null,Ka: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.La=g.load;d.Ka=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.qc=b.comment;this.Sc=b;b=this.id.indexOf(".");0>b?this.lb=this.id:(this.Qa=this.id.substr(0,b),this.lb=this.id.substr(b+1));this[a]=c;this.B={ready:!1,$a:!1,ac:!1,ja:!1,error:!1};this.Sb=null;this.B.error=!1;this.G={};this.i=null;this.oa=d||0;v.push(this)}var ab=void 0,bb={};
if(window){ab||(ab=window.location.search.substr(1));for(var cb,db=/\+/g,eb=/([^&=]+)=?([^&]*)/g;cb=eb.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.ta(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},ta: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.Ra=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.O=function(a){this.j(a,this.lb)}),!0;default:return!1}},log:function(){},j:function(){},status:function(a){this.j(this.lb+": "+a)},O:function(a,b,c){c=c||this.type;b||q((c?c+": ":"")+a)},Ha:function(){return this.B.ja=!0},Ga:function(a,b){b&&(this.B.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.oa;var c=a.i.oa&b;return!!b&&c===b||!!(c&a.i.Lc)}return!1}
function rb(a,b){if(a.B.ac)return a.B.$a=!1,a.B.ac=!1;if(a.B.error)return a.j(a.toString()+" error"),!1;a.B.$a=b;return a.B.$a}function sb(a,b){a.B.$a&&(b?a.B.ac=!0:void 0===b&&a.j(a.toString()+" busy"));return a.B.$a}function H(a,b){a.B.error||(a.B.ready=!1!==b,a.B.ready&&(b=a.Sb,a.Sb=null,b&&b()))}function tb(a,b){b&&(a.B.ready?b():a.Sb=b);return a.B.ready}function ub(a){return a.B.error?(a.j(a.toString()+" error"),!0):!1}function vb(a,b){a.B.error=!0;a.O(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,fault:32,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.f=this.v=this.Va=this.D=0;this.J=this.K=this.H=!1;this.L=zb;this.C={};this.g={START:[1,!0,!1,this.bd],STEP:[1,!1,!1,this.cd],ENABLE:[1,!1,!1,this.Yc],CONT:[1,!0,!1,this.Wc],DEP:[0,!0,!1,this.Xc],EXAM:[1,!0,!1,this.Zc],LOAD:[1,!0,!1,this.ad],TEST:[0,!0,!1,this.$c]};for(a=0;22>a;a++)this.g["S"+a]=[0,!1,!1,this.dd,a]}z(yb);var zb=7;function Ab(a,b){return a.g[b]&&a.g[b][0]}k=yb.prototype;k.reset=function(){this.stop()};
k.ta=function(a,b,c,d){if(this.A&&this.A.ta(a,b,c,d)||this.b&&this.b.ta(a,b,c,d)||this.i&&this.i.ta(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.C[b]=d?1:0,this.D++,!0):"switch"==a?(void 0===this.g[b]&&(this.g[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.g[b];Bb(a,b,c[0]=1-c[0]);c[2]=!0;c[3]&&c[3].call(a,c[0],c[4]);"STEP"!=b&&(a.J="DEP"==b,a.K="EXAM"==b)}}(this,b),a.onmouseup=a.onmouseout=function(a,b){return function(){var c=a.g[b];c[1]&&c[2]&&(Bb(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.ta.call(this,a,b,c,d)}};k.Ea=function(a,b,c,d){this.A=a;this.w=b;this.b=c;this.i=d;Cb(b,this,Db);Eb(b,this.reset.bind(this));Fb(this);Gb(this)};k.Ha=function(a,b){b||(Hb(),this.reset());return!0};k.Ga=function(){return!0};
function Ib(a,b,c){if(a=a.G[b])a.style.backgroundColor=c?"#ff0000":"#000000"}function Fb(a,b){for(var c in a.C)Ib(a,c,null!=b?b:a.C[c])}function Bb(a,b,c){if(a=a.G[b])a.style.marginTop=c?"0px":"20px",a.style.backgroundColor=c?"#00ff00":"#228B22"}function Gb(a){for(var b in a.g)Bb(a,b,a.g[b][0])}function Xb(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.da||8)?ra(c,d):p(c,d),a.G[b].textContent!=c&&(a.G[b].textContent=c))}
k.bd=function(a){a||this.b.B.Z||(this.w.reset(),Yb(this.b),Ab(this,"ENABLE")&&this.b.ib())};k.cd=function(){};k.Yc=function(a){a||this.b.ha()};k.Wc=function(a){if(!a&&!this.b.B.Z)if(Ab(this,"ENABLE"))this.b.ib();else{if((a=this.i)&&!sb(a,!0))rb(a,!0),a.jb(0),rb(a,!1);else try{var b=this.b.jb(1);0<b&&(Zb(this.b,b),$b(this.b,b,!0),ac(this.b,b))}catch(c){"number"!=typeof c&&vb(this.b,c.stack||c.message)}this.stop();this.A&&this.A.$()}};
k.Xc=function(a){a&&!this.b.B.Z&&(this.J&&bc(this),a=cc(this,this.Va),this.L==zb?this.w.Db(this.f,a):this.b.Db(this.f,a))};k.Zc=function(a){a||this.b.B.Z||(this.K&&bc(this),a=this.L==zb?this.w.ab(this.f):this.b.ab(this.f),cc(this,a))};k.ad=function(a){a||this.b.B.Z||(this.f=this.Va&this.w.Fa,dc(this,"A",this.f,22))};k.$c=function(a){a?(this.H=!0,Fb(this,!0)):(this.H=!1,Fb(this))};k.dd=function(a,b){this.Va=a?this.Va|1<<b:this.Va&~(1<<b)};
function bc(a){a.f=a.f+(Ab(a,"STEP")?2:-2)&a.w.Fa;dc(a,"A",a.f,22)}function cc(a,b){a.v=b&65535;dc(a,"D",a.v,16);return a.v}function ec(a,b,c){a.C[b]=c;a.H||Ib(a,b,c)}function dc(a,b,c,d){for(var e=0;e<d;e++)ec(a,b+e,c&1<<e)}function fc(a){return void 0!==a.G.S0}k.stop=function(){this.f=this.b.u[7]&this.w.Fa;dc(this,"A",this.f,22)};
k.$=function(){if(this.D){for(var a=0;a<this.b.u.length;a++)Xb(this,"R"+a,this.b.u[a]);a=gc(this.b);Xb(this,"PS",a);Xb(this,"NF",a&8?1:0,1);Xb(this,"ZF",a&4?1:0,1);Xb(this,"VF",a&2?1:0,1);Xb(this,"CF",a&1?1:0,1);dc(this,"D",this.v,16);dc(this,"A",this.f,22);a=this.b.Ua?this.b.pb&16?1:2:4;ec(this,"B22",a&1);ec(this,"B18",a&2);ec(this,"B16",a&4)}};k.ed=function(a){return(a?this.Va:this.v)&65535};k.Zd=function(a){this.v=a};var hc={},Db=(hc[65400]=[null,null,yb.prototype.ed,yb.prototype.Zd,"CNSW"],hc);
function Hb(){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(Hb);
function ic(a,b,c){u.call(this,"Bus",a,ic,64);this.b=b;this.i=c;this.K=a.busWidth||16;this.A=0;this.v=[];this.g=null;this.H=1<<this.K;this.Fa=this.H-1;this.ya=jc;this.la=Math.log2(this.ya);this.J=this.ya>>2;this.w=this.ya-1;this.D=this.H/this.ya|0;this.Za=[];this.ma=0;this.f=!1;this.C=[];this.Ic=[kc,lc,mc,nc];a=new I(this);oc(a,this.i);this.W=Array(this.D);for(b=0;b<this.D;b++)this.W[b]=a;H(this)}z(ic);var jc=8192,pc=jc-1;
function kc(a,b){var c=-1,d=this.controller,e=d.Za[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.Za[a&-2])&&e[2]&&(c=e[2](b&-2)>>8);if(0<=c)return this.i&&F(this.i,e[5])&&E(this.i,e[4]+".readByte("+J(this.i,b)+"): "+J(this.i,c),!0,!d.ma),c;d.Da(b,16,3);c=255;this.i&&F(this.i,e[5])&&E(this.i,"warning: unconverted read access to byte @"+J(this.i,b)+": "+J(this.i,c),!0,!d.ma);return c}
function lc(a,b,c){var d=!1,e=this.controller,f=e.Za[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.Za[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,f[5])&&E(this.i,f[4]+".writeByte("+J(this.i,c)+","+J(this.i,b)+")",!0,!e.ma):(e.Da(c,16,5),this.i&&F(this.i,f[5])&&E(this.i,"warning: unconverted write access to byte @"+J(this.i,c)+": "+J(this.i,b),!0,!e.ma))}
function mc(a,b){var c=-1,d=this.controller;(a=d.Za[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,a[5])&&E(this.i,a[4]+".readWord("+J(this.i,b)+"): "+J(this.i,c),!0,!d.ma),c;d.Da(b,16,2);c=65535;this.i&&F(this.i,a[5])&&E(this.i,"warning: unconverted read access to word @"+J(this.i,b)+": "+J(this.i,c),!0,!d.ma);return c}
function nc(a,b,c){var d=!1,e=this.controller;if(a=e.Za[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,a[5])&&E(this.i,a[4]+".writeWord("+J(this.i,c)+","+J(this.i,b)+")",!0,!e.ma):(e.Da(c,16,4),this.i&&F(this.i,a[5])&&E(this.i,"warning: unconverted write access to word @"+J(this.i,c)+": "+J(this.i,b),!0,!e.ma))}
function qc(a,b){if(b!=a.A){var c;a.A&&(c=(1<<a.A)-jc,rc(a,c,jc,a.v),a.A=0);b&&(a.A=b,c=1<<b,a.Fa=c-1,c-=jc,a.v=sc(a,c,jc),a.g?rc(a,c,jc,a.g):(tc(a,c,jc,uc,a),a.g=sc(a,c,jc)))}}k=ic.prototype;k.reset=function(){for(var a=0;a<this.C.length;a++)this.C[a]();qc(this,16)};k.Ha=function(a,b){b||this.reset();return!0};
function tc(a,b,c,d,e){for(var f=b,g=c,h=f>>>a.la;0<g&&h<a.W.length;){var l=a.W[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.Mb+=l.F-f,l.F=f,!0;if(f>=l.F+l.Mb){n=l.size-(f-m);n>g&&(n=g);l.Mb=f-l.F+n;f=m+a.ya;g-=n;h++;continue}}return vc(1,f,g)}f=new I(a,f,n,a.ya,d,e);oc(f,a.i,l);a.W[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 "+wc[d]+" at "+ra(b));return!0}return vc(2,b,c)}function sc(a,b,c){var d=[];for(b>>>=a.la;0<c&&b<a.W.length;)d.push(a.W[b++]),c-=a.ya;return d}function rc(a,b,c,d){var e=0;for(b>>>=a.la;0<c&&b<a.W.length;){var f=d[e++];if(!f)break;a.W[b++]=f;c-=a.ya}}k.Gb=function(a){3932160<=a&&(a=xc(this.b,a));return this.W[(a&this.Fa)>>>this.la].Wb(a&this.w,a)};k.Ub=function(a){3932160<=a&&(a=xc(this.b,a));this.f=!1;this.ma++;a=this.W[(a&this.Fa)>>>this.la].gc(a&this.w,a);this.ma--;return a};
k.pa=function(a){3932160<=a&&(a=xc(this.b,a));return this.W[(a&this.Fa)>>>this.la].sa(a&this.w,a)};k.ab=function(a){3932160<=a&&(a=xc(this.b,a));var b=a&this.w,c=(a&this.Fa)>>>this.la;this.f=!1;this.ma++;a=this.W[c].hc(b,a);this.ma--;return a};k.Xb=function(a,b){3932160<=a&&(a=xc(this.b,a));this.W[(a&this.Fa)>>>this.la].Zb(a&this.w,b&255,a)};k.qb=function(a,b){3932160<=a&&(a=xc(this.b,a));this.f=!1;this.ma++;this.W[(a&this.Fa)>>>this.la].$b(a&this.w,b&255,a);this.ma--};
k.hb=function(a,b){3932160<=a&&(a=xc(this.b,a));this.W[(a&this.Fa)>>>this.la].Nb(a&this.w,b&65535,a)};k.Db=function(a,b){3932160<=a&&(a=xc(this.b,a));var c=a&this.w,d=(a&this.Fa)>>>this.la;this.f=!1;this.ma++;this.W[d].lc(c,b&65535,a);this.ma--};
function yc(a){for(var b=0,c=[],d=0;d<a.D;d++){var e=a.W[d];if(e.Sa||e.Oc){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 zc(a,b,c,d,e,f,g,h,l){for(;b<=c;b+=2){var m=b&pc;void 0!==a.Za[m]?q("I/O address already registered: "+p(b,8,!0)):a.Za[m]=[d,e,f,g,h||"unknown",l,!1]}}
function Cb(a,b,c,d){for(var e in c){var f=+e,g=c[e];if(!(g[6]&&g[6]>a.b.xb)){var h=g[0]?g[0].bind(b):null,l=g[1]?g[1].bind(b):null,m=g[2]?g[2].bind(b):null,n=g[3]?g[3].bind(b):null,r=g[5]||1;65472<=f&&65487>=f&&(!h&&m&&(h=function(a){return function(b){return a(b)&255}.bind(b)}(m)),!l&&n&&(l=function(a){return function(b,c){return a(b,c)}.bind(b)}(n)));for(var t=g[4],w=0;w<r;w++,f+=2)t&&1<r&&(t=g[4]+w),zc(a,f,f,h,l,m,n,t,d||64)}}}function Eb(a,b){a.C.push(b)}
k.Da=function(a,b,c){this.f=!0;this.ma||(this.i&&F(this.i,32)&&E(this.i,"memory fault ("+c+") on address "+J(this.i,a),!0,!0),b&&(this.b.ga|=b),this.b.qa(4,a))};function Ic(a){var b=a.f;a.f=!1;return b}function vc(a,b,c){q("Memory block error ("+a+": "+p(b)+","+p(c)+")");return!1}function K(a){u.call(this,"Device",a,K,256);this.f={fa:0,kc:-1}}z(K);k=K.prototype;
k.Ea=function(a,b,c,d){this.w=b;this.b=c;this.i=d;var e=this;this.f.kc=Jc(c,function(){e.f.bb|=128;e.f.bb&64&&(Kc(e.b,e.f.Xd),Lc(e.b,e.f.kc,1E3/60))});this.f.Xd=Mc(64,6);Cb(b,this,L);Eb(b,this.reset.bind(this));H(this)};k.reset=function(){this.f.bb=0};k.nd=function(){var a=this.f.bb;this.f.bb&=-129;return a};k.ge=function(a){this.f.bb=a;a&64&&Lc(this.b,this.f.kc,1E3/60);this.f.bb=a&-129};k.pd=function(){var a=this.b;return a.C&62337|a.Ja<<5|a.Na<<1};
k.ie=function(a){var b=this.b;a&=62337;if(b.C!=a){b.C=a;b.Ja=a>>5&3;b.Na=a>>1&15;var c=0;a&257&&(c=4,a&1&&(c|=2));b.Ua!=c&&(b.Ua=c,Nc(b))}};k.qd=function(){var a=this.b.eb;a&65280&&(a=(a<<8|a>>8)&65535);return a};k.rd=function(){return this.b.Kb};k.sd=function(){return this.b.pb};k.je=function(a){var b=this.b;1170>b.xb&&(a&=-49);b.pb!=a&&(b.pb=a,b.Rb=a&16?4194303:262143,Nc(b))};k.Sd=function(a){a=a>>1&63;var b=this.b.Lb[a>>1];return a&1?b>>16:b&65535};
k.Je=function(a,b){b=b>>1&63;var c=b>>1;this.b.Lb[c]=b&1?this.b.Lb[c]&65535|(a&63)<<16:this.b.Lb[c]&-65536|a&65534};k.Ld=function(a){return this.b.V[1][a>>1&7]};k.Ce=function(a,b){this.b.V[1][b>>1&7]=a&65295};k.Jd=function(a){return this.b.V[1][(a>>1&7)+8]};k.Ae=function(a,b){this.b.V[1][(b>>1&7)+8]=a&65295};k.Kd=function(a){return this.b.xa[1][a>>1&7]};k.Be=function(a,b){b=b>>1&7;this.b.xa[1][b]=a;this.b.V[1][b]&=65295};k.Id=function(a){return this.b.xa[1][(a>>1&7)+8]};
k.ze=function(a,b){b=(b>>1&7)+8;this.b.xa[1][b]=a;this.b.V[1][b]&=65295};k.md=function(a){return this.b.V[0][a>>1&7]};k.fe=function(a,b){this.b.V[0][b>>1&7]=a&65295};k.kd=function(a){return this.b.V[0][(a>>1&7)+8]};k.de=function(a,b){this.b.V[0][(b>>1&7)+8]=a&65295};k.ld=function(a){return this.b.xa[0][a>>1&7]};k.ee=function(a,b){b=b>>1&7;this.b.xa[0][b]=a;this.b.V[0][b]&=65295};k.jd=function(a){return this.b.xa[0][(a>>1&7)+8]};k.ce=function(a,b){b=(b>>1&7)+8;this.b.xa[0][b]=a;this.b.V[0][b]&=65295};
k.Rd=function(a){return this.b.V[3][a>>1&7]};k.Ie=function(a,b){this.b.V[3][b>>1&7]=a&65295};k.Pd=function(a){return this.b.V[3][(a>>1&7)+8]};k.Ge=function(a,b){this.b.V[3][(b>>1&7)+8]=a&65295};k.Qd=function(a){return this.b.xa[3][a>>1&7]};k.He=function(a,b){b=b>>1&7;this.b.xa[3][b]=a;this.b.V[3][b]&=65295};k.Od=function(a){return this.b.xa[3][(a>>1&7)+8]};k.Fe=function(a,b){b=(b>>1&7)+8;this.b.xa[3][b]=a;this.b.V[3][b]&=65295};k.Bb=function(a){a&=7;return this.b.M&2048?this.b.Wa[a]:this.b.u[a]};
k.Eb=function(a,b){b&=7;this.b.M&2048?this.b.Wa[b]=a:this.b.u[b]=a};k.xd=function(){return this.b.M&49152?this.b.Ia[0]:this.b.u[6]};k.oe=function(a){this.b.M&49152?this.b.Ia[0]=a:this.b.u[6]=a};k.Ad=function(){return this.b.u[7]};k.re=function(a){this.b.u[7]=a};k.Cb=function(a){a&=7;return this.b.M&2048?this.b.u[a]:this.b.Wa[a]};k.Fb=function(a,b){b&=7;this.b.M&2048?this.b.u[b]=a:this.b.Wa[b]=a};k.yd=function(){return 1==(this.b.M&49152)>>14?this.b.u[6]:this.b.Ia[1]};
k.pe=function(a){1==(this.b.M&49152)>>14?this.b.u[6]=a:this.b.Ia[1]=a};k.zd=function(){return 3==(this.b.M&49152)>>14?this.b.u[6]:this.b.Ia[3]};k.qe=function(a){3==(this.b.M&49152)>>14?this.b.u[6]=a:this.b.Ia[3]=a};k.gd=function(a){return this.b.Bc[a-65504>>1]};k.ae=function(a,b){this.b.Bc[b-65504>>1]=a};k.yc=function(a){return 65520==a?61183:0};k.Fc=function(){};k.Nd=function(){return 1};k.Ee=function(){};k.fd=function(){return this.b.ga};k.$d=function(){this.b.ga=0};k.od=function(){return this.b.Ac};
k.he=function(a,b){b&1||(a&=255);this.b.Ac=a};k.td=function(a){return a?this.b.jc:0};k.ke=function(a){var b=this.b;if(a&=65024){var c=a>>9;do a+=34;while(c>>=1)}b.jc=a;b.I|=2};k.Md=function(a){return a?this.b.fb&65280:0};k.De=function(a){this.b.fb=a|255};k.wd=function(){return gc(this.b)};k.ne=function(a){Oc(this.b,a&-1809|gc(this.b)&1808);this.b.I|=128};k.Ec=function(a,b){F(this)&&E(this,"writeIgnored("+ra(b)+"): "+ra(a),!0,!0)};
var M={},L=(M[61568]=[null,null,K.prototype.Sd,K.prototype.Je,"UNIMAP",64,1170],M[62592]=[null,null,K.prototype.Ld,K.prototype.Ce,"SISDR",8,1145],M[62608]=[null,null,K.prototype.Jd,K.prototype.Ae,"SDSDR",8,1145],M[62624]=[null,null,K.prototype.Kd,K.prototype.Be,"SISAR",8,1145],M[62640]=[null,null,K.prototype.Id,K.prototype.ze,"SDSAR",8,1145],M[62656]=[null,null,K.prototype.md,K.prototype.fe,"KISDR",8,1145],M[62672]=[null,null,K.prototype.kd,K.prototype.de,"KDSDR",8,1145],M[62688]=[null,null,K.prototype.ld,
K.prototype.ee,"KISAR",8,1145],M[62704]=[null,null,K.prototype.jd,K.prototype.ce,"KDSAR",8,1145],M[62798]=[null,null,K.prototype.sd,K.prototype.je,"MMR3",1,1145],M[65382]=[null,null,K.prototype.nd,K.prototype.ge,"LKS"],M[65402]=[null,null,K.prototype.pd,K.prototype.ie,"MMR0",1,1145],M[65404]=[null,null,K.prototype.qd,K.prototype.Ec,"MMR1",1,1145],M[65406]=[null,null,K.prototype.rd,K.prototype.Ec,"MMR2",1,1145],M[65408]=[null,null,K.prototype.Rd,K.prototype.Ie,"UISDR",8,1145],M[65424]=[null,null,K.prototype.Pd,
K.prototype.Ge,"UDSDR",8,1145],M[65440]=[null,null,K.prototype.Qd,K.prototype.He,"UISAR",8,1145],M[65456]=[null,null,K.prototype.Od,K.prototype.Fe,"UDSAR",8,1145],M[65472]=[null,null,K.prototype.Bb,K.prototype.Eb,"R0SET0"],M[65473]=[null,null,K.prototype.Bb,K.prototype.Eb,"R1SET0"],M[65474]=[null,null,K.prototype.Bb,K.prototype.Eb,"R2SET0"],M[65475]=[null,null,K.prototype.Bb,K.prototype.Eb,"R3SET0"],M[65476]=[null,null,K.prototype.Bb,K.prototype.Eb,"R4SET0"],M[65477]=[null,null,K.prototype.Bb,K.prototype.Eb,
"R5SET0"],M[65478]=[null,null,K.prototype.xd,K.prototype.oe,"R6KERNEL"],M[65479]=[null,null,K.prototype.Ad,K.prototype.re,"R7KERNEL"],M[65480]=[null,null,K.prototype.Cb,K.prototype.Fb,"R0SET1",1,1145],M[65481]=[null,null,K.prototype.Cb,K.prototype.Fb,"R1SET1",1,1145],M[65482]=[null,null,K.prototype.Cb,K.prototype.Fb,"R2SET1",1,1145],M[65483]=[null,null,K.prototype.Cb,K.prototype.Fb,"R3SET1",1,1145],M[65484]=[null,null,K.prototype.Cb,K.prototype.Fb,"R4SET1",1,1145],M[65485]=[null,null,K.prototype.Cb,
K.prototype.Fb,"R5SET1",1,1145],M[65486]=[null,null,K.prototype.yd,K.prototype.pe,"R6SUPER",1,1145],M[65487]=[null,null,K.prototype.zd,K.prototype.qe,"R6USER",1,1145],M[65504]=[null,null,K.prototype.gd,K.prototype.ae,"CTRL",1,1170],M[65520]=[null,null,K.prototype.yc,K.prototype.Fc,"LSIZE",1,1170],M[65522]=[null,null,K.prototype.yc,K.prototype.Fc,"HSIZE",1,1170],M[65524]=[null,null,K.prototype.Nd,K.prototype.Ee,"SYSID",1,1170],M[65526]=[null,null,K.prototype.fd,K.prototype.$d,"CPUERR",1,1170],M[65528]=
[null,null,K.prototype.od,K.prototype.he,"MB",1,1170],M[65530]=[null,null,K.prototype.td,K.prototype.ke,"PIR"],M[65532]=[null,null,K.prototype.Md,K.prototype.De,"SL"],M[65534]=[null,null,K.prototype.wd,K.prototype.ne,"PSW"],M);L[65506]=L[65504];L[65508]=L[65504];L[65510]=L[65504];L[65512]=L[65504];L[65514]=L[65504];L[65516]=L[65504];L[65518]=L[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 K(c);C(c,d);break;case "pc11":c=new Pc(c);C(c,d);break;case "rl11":c=new N(c),C(c,d)}}});var Qc;if(wb){var Rc=new ArrayBuffer(2);(new DataView(Rc)).setUint16(0,256,!0);Qc=256===(new Uint16Array(Rc))[0]}else Qc=!1;var Sc=Qc;
function I(a,b,c,d,e,f){this.w=a;this.id=Tc+=2;this.b=null;this.F=b;this.Mb=c;this.size=d||0;this.type=e||Uc;this.f=e==Vc;this.controller=null;oc(this);this.Sa=this.Oc=!1;if(this.size)if(f)this.controller=f,a=[null,0],this.b=a[0],Wc(this,f.Ic);else if(wb)this.C=new ArrayBuffer(this.size),this.D=new DataView(this.C,0,this.size),this.G=new Uint8Array(this.C,0,this.size),this.J=new Uint16Array(this.C,0,this.size>>1),this.b=new Int32Array(this.C,0,this.size>>2),Wc(this,Sc?Xc:Yc);else{a=this.b=Array(this.size>>
2);for(f=0;f<a.length;f++)a[f]=0;Wc(this,Zc)}else Wc(this)}var Uc=0,Vc=2,uc=4,wc=["NONE","RAM","ROM","VID","H/W"],Tc=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.Sa=!0}return!1},nb:function(a,b){b?this.A++||$c(this,ad,!1):this.g++||bd(this,ad,!1)},K:function(a,b){this.i&&F(this.i,128)&&E(this.i,
"attempt to read invalid address "+J(this.i,b),!0);this.w.Da(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);this.w.Da(c,32,4)},L:function(a,b){return this.Wb(a++,b++)|this.Wb(a,b)<<8},H:function(a,b,c){this.Zb(a++,b&255,c++);this.Zb(a,b>>8,c)},S:function(a){return this.b[a>>2]>>>((a&3)<<3)&255},da:function(a,b){a&1&&this.w.Da(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},wa:function(a,b){var c=a>>2;a=(a&3)<<3;this.b[c]=this.b[c]&~(255<<a)|b<<a;this.Sa=!0},Na:function(a,b,c){a&1&&this.w.Da(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.Sa=!0},P:function(a,b){if(this.i&&null!=this.F){var c=this.i;cd(c,this.F+a,1,c.N)&&c.ha(!0)}return this.gc(a,b)},Y:function(a,b){if(this.i&&null!=this.F){var c=this.i;cd(c,this.F+a,2,c.N)&&c.ha(!0)}return this.hc(a,b)},na:function(a,
b,c){if(this.i&&null!=this.F){var d=this.i;cd(d,this.F+a,1,d.D)&&d.ha(!0)}this.f?this.v(a,b,c):this.$b(a,b,c)},Aa:function(a,b,c){if(this.i&&null!=this.F){var d=this.i;cd(d,this.F+a,2,d.D)&&d.ha(!0)}this.f?this.v(a,b,c):this.lc(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},Qa:function(a,b){a&1&&this.w.Da(b,64,2);return this.D.getUint16(a,!0)},aa:function(a,b){a&1&&this.w.Da(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},ka:function(a,b){this.G[a]=b;this.Sa=!0},ua:function(a,b,c){this.G[a]=b;this.Sa=!0;this.i&&F(this.i,128)&&E(this.i,"Memory.writeByte("+J(this.i,c)+","+J(this.i,b)+")",!0)},lb:function(a,b,c){a&1&&this.w.Da(c,64,4);this.D.setUint16(a,b,!0);this.Sa=!0},Ja:function(a,b,c){a&1&&this.w.Da(c,64,4);this.J[a>>1]=b;this.Sa=!0;this.i&&F(this.i,128)&&E(this.i,"Memory.writeWord("+J(this.i,c)+","+J(this.i,
b)+")",!0)}};function oc(a,b,c){a.i=b;a.g=a.A=0;c&&((a.g=c.g)&&bd(a,ad,!1),(a.A=c.A)&&$c(a,ad,!1))}function dd(a,b){b?--a.A||(a.Zb=a.f?a.v:a.$b,a.Nb=a.f?a.H:a.lc):--a.g||(a.Wb=a.gc,a.sa=a.hc)}function $c(a,b,c){c&&a.A||(a.Zb=!a.f&&b[1]||a.v,a.Nb=!a.f&&b[3]||a.H);if(c||void 0===c)a.$b=b[1]||a.v,a.lc=b[3]||a.H}function bd(a,b,c){c&&a.g||(a.Wb=b[0]||a.K,a.sa=b[2]||a.L);if(c||void 0===c)a.gc=b[0]||a.K,a.hc=b[2]||a.L}function Wc(a,b){b||(b=ed);bd(a,b,void 0);$c(a,b,void 0)}
var ed=[],Zc=[I.prototype.S,I.prototype.wa,I.prototype.da,I.prototype.Na],ad=[I.prototype.P,I.prototype.na,I.prototype.Y,I.prototype.Aa];if(wb)var Yc=[I.prototype.N,I.prototype.ka,I.prototype.Qa,I.prototype.lb],Xc=[I.prototype.R,I.prototype.ua,I.prototype.aa,I.prototype.Ja];
function fd(a,b){u.call(this,"CPU",a,fd,1);var c=a.multiplier||1;this.mb=a.cycles||b;this.cb=c;this.ub=Math.round(this.mb/1E4)/100;this.ob=this.ub*this.cb;this.B.Z=!1;this.B.Yb=!1;this.B.tb=a.autoStart;this.B.wb=!1;this.Hb=this.na=0;this.Ib=a.csStart;this.yb=a.csInterval;this.zb=a.csStop;this.K=[];this.vc=this.Wd.bind(this);H(this)}z(fd);var gd=["power","reset"];k=fd.prototype;
k.Ea=function(a,b,c,d){this.A=a;this.w=b;this.i=d;for(b=0;b<gd.length;b++)(c=this.G[gd[b]])&&this.A.ta(null,gd[b],c);a=hd(a,"autoStart");null!=a&&(this.B.tb="true"==a?!0:"false"==a?!1:!!a);H(this)};k.reset=function(){};k.save=function(){return null};k.restore=function(){return!1};
k.Ha=function(a,b){if(!b){if(a&&this.restore){id(this);if(!this.restore(a))return!1;jd(this)}else this.reset();this.i?(a=this.i,b=this.B.tb,a.kb=!0,a.j("Type ? for help with PDPjs Debugger commands"),a.$(),b||a.rb(),a.Ya&&(b=a.Ya,a.Ya=null,kd(a,b))):this.j("No debugger detected")}return!0};k.Ga=function(a){return a?this.save():!0};k.tb=function(){return this.B.tb||!this.i&&void 0===this.G.run?(this.ib(),!0):!1};k.sc=function(){return 0};
function jd(a){void 0===a.Ib&&(a.Ib=0);void 0===a.yb&&(a.yb=-1);void 0===a.zb&&(a.zb=-1);a.B.wb=0<=a.Ib&&0<a.yb;a.B.wb&&(a.Hb=0,a.na=a.Ib-a.ka)}function ac(a,b){if(a.B.wb){var c=!1;a.Hb=a.Hb+a.sc()|0;a.na-=b;0>=a.na&&(a.na+=a.yb,c=!0);0<=a.zb&&a.zb<=ld(a)&&(a.yb=a.zb=-1,jd(a),a.ha(),c=!0);c&&a.j(ld(a)+" cycles: checksum="+p(a.Hb))}}
k.ta=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.A)if(a=d.A,a.B.ja)a=!0;else{var b=null,c,h=ob(a.id);for(c=0;c<h.length&&(b=h[c],b===a||b.B.ready);c++);if(c==h.length)for(c=0;c<h.length&&(b=h[c],b===a||b.B.ja);c++);c==h.length&&(b=a);q("The "+b.type+" component ("+b.id+") is not "+(b.B.ready?"powered yet":"ready yet"+(b.Sb?" (waiting for notification)":""))+".");a=!1}a&&(d.B.Z?d.ha():d.ib())},
!0;case "speed":return this.G[b]=c,!0;case "setSpeed":return this.G[b]=c,c.onclick=function(){md(d,d.cb<<1,!0)},c.textContent=this.ob.toFixed(2)+"Mhz",!0}return!1};k.$=function(){var a=this.G.speed;a&&(a.textContent=this.B.Z&&this.Y?this.Y.toFixed(2)+"Mhz":"Stopped")};function $b(a,b,c){a.ka+=b;c&&(a.da=a.b=a.J=0)}function nd(a,b){var c=1;b&&1<a.cb&&a.Y&&(c=a.Y/a.ub);a.Tb=Math.round(1E3/30);a.kb=Math.floor(a.mb/30*c);b||(a.ua=a.kb);a.vb=0}function ld(a){return a.ka+a.S+a.da-a.b}
function id(a){a.Y=0;a.Vb=0;a.ka=a.S=a.da=a.b=a.J=0;jd(a);md(a,1)}function md(a,b,c){var d=!1;if(void 0!==b){.8>a.Y/a.ob?b=1:d=!0;a.cb=b;b=a.ub*a.cb;if(a.ob!=b){a.ob=b;b=a.ob.toFixed(2)+"Mhz";var e=a.G.setSpeed;e&&(e.textContent=b);a.j("target speed: "+b)}c&&a.A&&a.A.rb()}$b(a,a.S);a.S=0;a.R=Ba();a.aa=0;nd(a);return d}function Jc(a,b){var c=a.K.length;a.K.push([-1,b]);return c}function Lc(a,b,c){0<=b&&b<a.K.length&&0>a.K[b][0]&&(c=a.mb*a.cb/1E3*c|0,a.K[b][0]=c+od(a))}
function pd(a,b){for(var c=a.K.length-1;0<=c;c--){var d=a.K[c];0>d[0]||b>d[0]&&(b=d[0])}return b}function Zb(a,b){for(var c=a.K.length-1;0<=c;c--){var d=a.K[c];0>d[0]||(d[0]-=b,0>=d[0]&&(d[0]=-1,d[1]()))}}function od(a,b){var c=a.da-=a.b;a.b=a.J=0;b&&(a.da=0);return c}
k.Wd=function(){if(this.B.Z){this.vb>=this.mb&&nd(this,!0);this.Aa=0;this.Ya=Ba();if(this.aa){var a=this.Ya-this.aa;a>this.Tb&&(this.R+=a,this.R>this.Ya&&(this.R=this.Ya))}try{do{var b=pd(this,this.B.wb?1:this.kb);try{this.jb(b)}catch(e){if("number"!=typeof e)throw e;}b=od(this,!0);this.Aa+=b;this.S+=b;ac(this,b);Zb(this,b);this.ua-=b;if(0>=this.ua){this.ua+=this.kb;15<=++this.Vb&&(this.A&&this.A.$(void 0),this.Vb=0);break}}while(this.B.Z)}catch(e){this.ha();this.A&&this.A.stop(Ba(),ld(this));vb(this,
e.stack||e.message);return}if(this.B.Z){a=setTimeout;b=this.vc;this.aa=Ba();var c=this.Tb;this.Aa&&(c=Math.round(c*this.Aa/this.kb));var c=c-(this.aa-this.Ya),d=this.aa-this.R;d&&(this.Y=Math.round(this.S/(10*d))/100,864E5<=d&&(this.ka=0,md(this)));if(0>c||this.Y<this.ob)-1E3>c&&(this.R-=c),c=0;this.vb+=this.Aa;this.aa+=c;a(b,c)}}};
k.ib=function(a){if(ub(this))return!1;if(this.B.Z)return this.j(this.toString()+" busy"),!1;md(this);this.B.Z=!0;this.B.Yb=!0;var b=this.G.run;b&&(b.textContent="Halt");this.A&&(a&&this.A.rb(!0),this.A.start(this.R,ld(this)));setTimeout(this.vc,0);return!0};k.jb=function(){return 0};k.ha=function(a){var b=!1;if(this.B.Z){od(this);$b(this,this.S);this.S=0;this.B.Z=!1;if(b=this.G.run)b.textContent="Run";this.A&&this.A.stop(Ba(),ld(this));b=!0}this.B.complete=a;return b};
function qd(a){this.xb=+a.model||1170;this.Ob=a.addrReset||0;fd.call(this,a,6666667);this.decode=1120==this.xb?rd.bind(this):sd.bind(this);td(this);this.L=0;this.N=null;this.B.complete=!1}z(qd,fd);k=qd.prototype;k.reset=function(){this.status("model "+this.xb);this.B.Z&&this.ha();td(this);id(this);this.B.error=!1;this.parent.reset.call(this)};
function td(a){a.T=65536;a.U=32768;a.ba=65535;a.X=32768;a.M=15;a.u=[0,0,0,0,0,0,0,a.Ob];a.Wa=[0,0,0,0,0,0];a.Ia=[0,0,0,0];a.v=0;a.Na=0;a.Rc=[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.Lb=[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.Bc=[0,0,0,0,0,0,0,0];a.Ac=0;a.I=0;a.D=a.H=0;a.g=a.f=a.sb=0;a.wa=-1;Yb(a)}function Yb(a){a.fb=255;a.ga=0;a.jc=0;a.C=0;a.eb=0;a.Kb=0;a.pb=0;a.Ua=0;a.Ja=0;a.Rb=262143;a.N=null;a.w&&Nc(a)}function Nc(a){a.Ua?(a.P=65536,a.ca=a.Qc,a.sa=a.Td,a.Nb=a.Ke,qc(a.w,a.pb&16?22:18)):(a.P=0,a.ca=a.Pc,a.sa=a.zc,a.Nb=a.Gc,qc(a.w,16))}function ud(a,b,c){a.Ob=b;O(a,b);!c&&a.i&&(a.ha()||a.i.$())}k.sc=function(){return 0};
k.save=function(){var a=new P(this);a.set(0,[]);a.set(1,[this.ka,this.cb]);a.set(2,yc(this.w));return a.data()};k.restore=function(a){var b=a[1];this.ka=b[1];md(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.W[d];if(!f||!f.restore(e)){q("Unable to restore memory block "+d);b=!1;break a}}b=!0}return b};function vd(a){return a.T&65536?1:0}
function wd(a){return a.U&32768?2:0}function xd(a){return a.ba&65535?0:4}k.Ta=function(){return this.X&32768?8:0};function yd(a){var b=a.u[7];a.C&57344||(a.eb=0,a.Kb=b);a.u[7]=b+2&65535;return a.sa(b)}function zd(a,b){var c=a.u[7];a.u[7]=c+b&65535;return c}function O(a,b){a.u[7]=b&65535}function Mc(a,b){return{Yd:a,Ab:b,next:null}}function Kc(a,b){if(b!=a.N){var c=a.N;if(!c||c.Ab<=b.Ab)b.next=c,a.N=b;else{do{var d=c.next;if(!d||d.Ab<=b.Ab){b.next=d;c.next=b;break}c=d}while(c)}}a.I|=2}
function gc(a){return a.M=a.M&63728|a.Ta()|xd(a)|wd(a)|vd(a)}function Oc(a,b){a.X=b<<12;a.ba=~b&4;a.U=b<<14;a.T=b<<16;if((b^a.M)&2048)for(var c=a.Wa.length;0<=--c;){var d=a.u[c];a.u[c]=a.Wa[c];a.Wa[c]=d}a.v=b>>14&3;c=a.M>>14&3;a.v!=c&&(a.Ia[c]=a.u[6],a.u[6]=a.Ia[a.v]);a.M=b;a.I|=2}function R(a,b){a.I&128||(a.X=a.ba=b,a.U=0)}function Ad(a,b,c){a.I&128||(a.X=a.ba=a.T=b,a.U=c||0)}function Bd(a,b,c,d){a.I&128||(a.X=a.ba=a.T=b,a.U=(c^b)&(d^b))}
function Cd(a,b){a.I&128||(a.X=a.ba=a.T=b,a.U=a.X^a.T>>1)}function Dd(a,b,c,d){a.I&128||(a.X=a.ba=a.T=b,a.U=(c^d)&(d^b))}k.qa=function(a,b){if(!this.L){var c=!1;0>this.wa?this.wa=gc(this):this.v||(a=4,c=!0);this.C&57344||(this.eb=63222,this.Kb=a);this.v=0;var d=this.sa(a|this.P),e=this.sa(a+2&65535|this.P);Oc(this,e&-12289|this.wa>>2&12288);c&&(this.ga|=4,this.u[6]=4);Ed(this,this.wa);Ed(this,this.u[7]);O(this,d);this.I&=-113;this.wa=-1;this.I|=8;this.Vc=a;this.Tc=b;if(26!=b)throw a;}};
function Wd(a){var b=Xd(a),c=Xd(a)&-1793;a.M&49152&&(c=c&-225|a.M&63712);O(a,b);Oc(a,c);a.I&=-17}function xc(a,b){var c=b>>13&31;31>c&&a.pb&32&&(b=a.Lb[c]+(b&8190)&4194302,3932160<=b&&4186112>b&&console.log("panic(898)"));return b}
function Yd(a,b,c){var d,e,f;if(!(c&a.Ua))return b;d=b>>13;a.pb&a.Rc[a.v]||(d&=7);e=a.V[a.v][d];f=(a.xa[a.v][d]<<6)+(b&8191)&a.Rb;var g=0;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.Ja=a.v,a.Na=d;b=!1;g&&(g&57344&&(0<=a.wa&&(g|=128),a.C&57344||(a.C=a.C|g|a.Ja<<5|a.Na<<1),
b=!0),a.C&61440||!(4191360>f||4194239<f)||(a.C|=4096,a.C&512&&(a.I|=32)),b&&a.qa(168,16));return f}function Zd(a,b){return a.w.Gb(b)}function $d(a,b,c){b&1&&a.b--;a.w.Xb(b,c&255)}function Xd(a){var b=a.sa(a.u[6]|a.P);a.u[6]=a.u[6]+2&65535;return b}function Ed(a,b){var c=a.u[6]-2&65535;a.u[6]=c;a.C&57344||(a.eb=a.eb<<8|246);!a.v&&c<=a.fb&&4<c&&(c<=a.fb-32?(a.ga|=4,a.u[6]=4,a.qa(4,18)):(a.ga|=8,a.I|=4));a.Nb(c,b)}
function ae(a,b,c,d){var e,f,g=d&8?0:a.P;switch(b){case 0:return a.qa(4,20),0;case 1:return 6===c&&!a.v&&d&4&&(a.u[6]<=a.fb||65534<=a.u[6])&&(a.u[6]<=a.fb-32||65534<=a.u[6]?(a.ga|=4,a.u[6]=4,a.qa(4,22)):(a.ga|=8,a.I|=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.sa(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.sa(e)|
g;a.b-=8;break;case 6:return e=a.sa(zd(a,2)),e=e+a.u[c]&65535|g,a.b-=6,e;case 7:return e=a.sa(zd(a,2)),e=e+a.u[c]&65535,e=a.sa(e|a.P)|g,a.b-=10,e}a.u[c]=a.u[c]+f&65535;!g||a.C&57344||(a.eb=a.eb<<8|f<<3&248|c);6==c&&!a.v&&d&4&&0>=f&&(a.u[6]<=a.fb||65534<=a.u[6])&&(a.u[6]<=a.fb-32?(a.ga|=4,a.u[6]=4,a.qa(4,24)):(a.ga|=8,a.I|=64));return e}k.Ub=function(a){if(!this.Ua)return this.w.Ub(a);this.L++;a=Zd(this,Yd(this,a,3));this.L--;return a};
k.ab=function(a){if(!this.Ua)return this.w.ab(a);this.L++;a=this.zc(Yd(this,a,2));this.L--;return a};k.qb=function(a,b){this.Ua?(this.L++,$d(this,Yd(this,a,5),b),this.L--):this.w.qb(a,b)};k.Db=function(a,b){this.Ua?(this.L++,this.Gc(Yd(this,a,4),b),this.L--):this.w.Db(a,b)};k.Pc=function(a,b,c){return ae(this,a,b,c)};k.Qc=function(a,b,c){return Yd(this,ae(this,a,b,c),c)};k.zc=function(a){return this.w.pa(a)};k.Td=function(a){return this.w.pa(Yd(this,a,2))};k.Gc=function(a,b){this.w.hb(a,b&65535)};
k.Ke=function(a,b){this.w.hb(Yd(this,a,4),b)};function be(a,b,c){var d=a.f=b&7;(b=a.g=(b&56)>>3)?(d=ae(a,b,d,2),c&65536||61440!==(a.M&61440)&&(d&=65535),a.v=a.M>>12&3,c=a.sa(d|c&a.P),a.v=a.M>>14&3):c=6!=d||(a.M>>2&12288)===(a.M&12288)?a.u[d]:a.Ia[a.M>>12&3];return c}function ce(a,b,c,d){a.C&57344||(a.eb=22);var e=a.f=b&7;(b=a.g=(b&56)>>3)?(e=ae(a,b,e,4),c&65536||(e&=65535),a.v=a.M>>12&3,e=Yd(a,e|c&65536,4),a.v=a.M>>14&3,a.w.hb(e,d)):6!=e||(a.M>>2&12288)===(a.M&12288)?a.u[e]=d:a.Ia[a.M>>12&3]=d}
function de(a,b){b>>=6;var c=a.H=b&7;return(b=a.D=(b&56)>>3)?Zd(a,a.ca(b,c,3)):a.u[c]&255}function ee(a,b){b>>=6;var c=a.H=b&7;return(b=a.D=(b&56)>>3)?a.w.pa(a.ca(b,c,2)):a.u[c]}function fe(a,b){var c=a.f=b&7;b=a.g=(b&56)>>3;return ae(a,b,c,8)}function ge(a,b){var c=a.f=b&7;return(b=a.g=(b&56)>>3)?Zd(a,a.ca(b,c,3)):a.u[c]&255}function he(a,b){var c=a.f=b&7;return(b=a.g=(b&56)>>3)?a.w.pa(a.ca(b,c,2)):a.u[c]}
function S(a,b,c,d){var e=a.f=b&7;(b=a.g=(b&56)>>3)?(e=a.sb=a.ca(b,e,7),$d(a,e,d.call(a,c,Zd(a,e)))):a.u[e]=a.u[e]&65280|d.call(a,c,a.u[e])}function T(a,b,c,d){var e=a.f=b&7;(b=a.g=(b&56)>>3)?(e=a.ca(b,e,6),a.w.hb(e,d.call(a,c,a.w.pa(e)))):a.u[e]=d.call(a,c,a.u[e])}function ie(a,b,c,d){var e=a.f=b&7;(b=a.g=(b&56)>>3)?$d(a,a.ca(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 je(a,b,c){var d=a.f=b&7;(b=a.g=(b&56)>>3)?a.w.hb(a.ca(b,d,4),c):a.u[d]=c&65535;return c}function U(a,b,c){c&&(O(a,a.u[7]+(b<<24>>23)),a.b-=2);a.b-=3}
k.jb=function(a){this.B.complete=!0;var b=this.i&&ke(this.i)?1:this.B.Yb?-1:0,c=a?this.B.Yb?0:1:-1;this.B.Yb=!1;this.da=this.b=a;do{if(b){if(this.i&&le(this.i,this.u[7],c)){this.ha();break}c||c++;b++}if(this.I){this.I&112&&(this.I&32?this.qa(168,28):this.I&64?this.qa(4,30):this.I&16&&this.qa(12,32),this.I&=-113);if(a=this.I&7){a=!1;if(this.I&2){this.I&=-3;var d=160,e=(this.jc&224)>>5,f=this.N&&this.N.Ab>e?this.N:null;f&&(d=f.Yd,e=f.Ab);e>(this.M&224)>>5?(this.I&4&&(zd(this,2),this.I&=-5),this.qa(d,
26),e=!0):e=!1;if(e){if(f)if(a=f,f=this.N,f==a)this.N=a.next;else for(;f;){e=f.next;if(e==a){f.next=e.next;break}f=e}a=!0}}else this.I&1&&this.I++;a=a&&0>c}if(a)break}this.I=this.I&7|this.M&16;this.decode(yd(this))}while(0<this.b);return this.B.complete?this.da-this.b:void 0===this.B.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 qd(d);C(d,c)}});function me(a,b){var c=b+a;Bd(this,c,a,b);return c&65535}
function ne(a,b){var c=b+a;Bd(this,c<<8,a<<8,b<<8);return c&255}function oe(a,b){a=b<<1;Cd(this,a);return a&65535}function pe(a,b){a=b<<1;Cd(this,a<<8);return a&255}function qe(a,b){a=b&32768|b>>1|b<<16;Cd(this,a);return a&65535}function re(a,b){a=b&2048|b>>1|b<<8;Cd(this,a<<8);return a&255}function se(a,b){a=b&~a;R(this,a);return a}function te(a,b){a=b&~a;R(this,a<<8);return a}function ue(a,b){a|=b;R(this,a);return a}function ve(a,b){a|=b;R(this,a<<8);return a}
function we(a,b){a=~b|65536;Ad(this,a);return a&65535}function xe(a,b){a=~b|256;Ad(this,a<<8);return a&255}function ye(a,b){a=b-a;this.I&128||(this.X=this.ba=a,this.U=b&(b^a));return a&65535}function ze(a,b){a=b-a;var c=a<<8;b<<=8;this.I&128||(this.X=this.ba=c,this.U=b&(b^c));return a&255}function Ae(a,b){a=b+a;this.I&128||(this.X=this.ba=a,this.U=a&(b^a));return a&65535}function Be(a,b){a=b+a;var c=a<<8;this.I&128||(this.X=this.ba=c,this.U=c&(b<<8^c));return a&255}
function Ce(a,b){a=-b;Ad(this,a,a&b&32768);return a&65535}function De(a,b){a=-b;Ad(this,a<<8,(a&b&128)<<8);return a&255}function Ee(a,b){a=b<<1|this.T>>16&1;Cd(this,a);return a&65535}function Fe(a,b){a=b<<1|this.T>>16&1;Cd(this,a<<8);return a&255}function Ge(a,b){a=(this.T&65536|b)>>1|b<<16;Cd(this,a);return a&65535}function He(a,b){a=((this.T&65536)>>8|b)>>1|b<<8;Cd(this,a<<8);return a&255}function Ie(a,b){var c=b-a;Dd(this,c,a,b);return c&65535}
function Je(a,b){var c=b-a;Dd(this,c<<8,a<<8,b<<8);return c&255}function Ke(a,b){this.I&128||(this.X=this.ba=b&65280,this.U=this.T=0);return(b<<8|b>>8)&65535}function Le(a,b){a^=b;R(this,a);return a&65535}function Me(a){T(this,a,ee(this,a),me);this.b-=this.g?9+(this.H&&6<=this.f?1:0):(this.D?5:3)+(7==this.f?2:0)}
function Ne(a){var b=he(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.X=this.ba=c;this.b-=(this.g?6:7)+b}
function Oe(a){var b=he(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.X=d>>16;this.ba=d>>16|d;this.b-=(this.g?6:7)+b}function Pe(a){U(this,a,!vd(this))}function Qe(a){U(this,a,vd(this))}
function Re(a){T(this,a,ee(this,a),se);this.b-=this.g?9+(this.H&&6<=this.f?1:0):(this.D?5:3)+(7==this.f?2:0)}function Se(a){S(this,a,de(this,a),te);this.b-=this.g?9+(this.H&&6<=this.f?1:0):(this.D?5:3)+(7==this.f?2:0)}function Te(a){T(this,a,ee(this,a),ue);this.b-=this.g?9+(this.H&&6<=this.f?1:0):(this.D?5:3)+(7==this.f?2:0)}function Ue(a){S(this,a,de(this,a),ve);this.b-=this.g?9+(this.H&&6<=this.f?1:0):(this.D?5:3)+(7==this.f?2:0)}
function Ve(a){R(this,ee(this,a)&he(this,a));this.b-=this.g?4+(this.H&&6<=this.f?1:0):(this.D?4:3)+(7==this.f?2:0)}function We(a){R(this,(de(this,a)&ge(this,a))<<8);this.b-=this.g?4+(this.H&&6<=this.f?1:0):(this.D?4:3)+(7==this.f?2:0)}function Xe(a){U(this,a,xd(this))}function Ye(a){U(this,a,!this.Ta()==!wd(this))}function Ze(a){U(this,a,!xd(this)&&!this.Ta()==!wd(this))}function $e(a){U(this,a,!vd(this)&&!xd(this))}function af(a){U(this,a,xd(this)||!this.Ta()!=!wd(this))}
function bf(a){U(this,a,vd(this)||xd(this))}function cf(a){U(this,a,!this.Ta()!=!wd(this))}function df(a){U(this,a,this.Ta())}function ef(a){U(this,a,!xd(this))}function ff(a){U(this,a,!this.Ta())}function gf(){this.qa(12,1);this.b-=5}function hf(a){U(this,a,!0)}function jf(a){U(this,a,!wd(this))}function kf(a){U(this,a,wd(this))}function V(a){a&1&&(this.T=0);a&2&&(this.U=0);a&4&&(this.ba=1);a&8&&(this.X=0);this.b-=5}
function lf(a){var b=ee(this,a);a=he(this,a);Dd(this,b-a,a,b);this.b-=this.g?4+(this.H&&6<=this.f?1:0):(this.D?4:3)+(7==this.f?2:0)}function mf(a){var b=de(this,a)<<8;a=ge(this,a)<<8;Dd(this,b-a,a,b);this.b-=this.g?4+(this.H&&6<=this.f?1:0):(this.D?4:3)+(7==this.f?2:0)}
function nf(a){var b=he(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.ba=d>>16|d,this.X=d>>16):(this.U=32768,this.ba=d>>15|d,this.X=c>>16,-1===b&&65534===this.u[a]&&(this.u[a]=this.u[a|1]=1));this.b-=53}else this.ba=this.X=0,this.U=32768,this.T=65536,this.b-=7}function of(){this.qa(24,2);this.b-=25}
function pf(){this.M&49152?(this.ga|=128,this.qa(4,3)):this.i?qf(this.i):this.ha();this.b-=7}function rf(){this.qa(16,4);this.b-=25}var sf=[0,7,7,10,7,11,9,13];function tf(a){this.J=this.b;O(this,fe(this,a));this.b=this.J-sf[this.g]}var uf=[0,14,14,17,14,18,16,20];function vf(a){this.J=this.b;var b=fe(this,a);a=a>>6&7;Ed(this,this.u[a]);this.u[a]=this.u[7];O(this,b);this.b=this.J-uf[this.g]}var wf=[3,9,9,13,10,14,12,16,4,9,9,13,10,14,13,17];
function xf(a){var b=ee(this,a);this.J=this.b;R(this,je(this,a,b));this.b=this.J-wf[(this.D?8:0)+this.g]+(7!=this.f||this.g?0:2)}function yf(a){var b=de(this,a);R(this,ie(this,a,b,1)<<8);this.b-=this.g?9+(this.H&&6<=this.f?1:0):(this.D?5:3)+(7==this.f?2:0)}var zf=[7,13,13,17,14,18,17,21];
function Af(a){var b=he(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.I&128||(this.X=b>>16,this.ba=this.X|b,this.U=0,this.T=-32768>b||32767<b?65536:0);this.b-=23}function Bf(){this.b-=5}function Cf(){this.M&49152||(this.w.reset(),Yb(this));this.b-=667}function Df(){Wd(this);this.I|=this.M&16;this.b-=13}
function Ef(a){if(a&8)W.call(this,a);else{var b=Xd(this);a&=7;7==a?O(this,b):(O(this,this.u[a]),this.u[a]=b);this.b-=9}}function X(a){a&1&&(this.T=65536);a&2&&(this.U=32768);a&4&&(this.ba=0);a&8&&(this.X=32768);this.b-=5}function Ff(a){var b=(a&448)>>6;if(this.u[b]=this.u[b]-1&65535)O(this,this.u[7]-((a&63)<<1)),this.b+=1;this.b-=6}function Gf(a){T(this,a,ee(this,a),Ie);this.b-=this.g?9+(this.H&&6<=this.f?1:0):(this.D?5:3)+(7==this.f?2:0)}
function Hf(a){T(this,a,0,Ke);this.b-=this.g?9:3+(7==this.f?2:0)}function If(){this.qa(28,5);this.b-=5}function Jf(){this.I&4||this.A&&this.A.$();this.I|=4;zd(this,-2);this.b-=3}function Kf(a){T(this,a,ee(this,a),Le);this.b-=this.g?9:3+(7==this.f?2:0)}function W(a){var b;if(b=this.i)b=this.i,E(b,"undefined opcode "+J(b,a),!0,!0),b=qf(b);b||this.qa(8,6)}function rd(a){Lf[a>>12].call(this,a)}function Mf(a){Nf[a>>6&3].call(this,a)}function Of(a){Pf[a>>6&3].call(this,a)}
function Qf(a){Rf[a>>6&3].call(this,a)}function Sf(a){Tf[a&15].call(this,a)}function Uf(a){Vf[a&15].call(this,a)}function Wf(a){Xf[a>>6&3].call(this,a)}function Yf(a){Zf[a>>6&3].call(this,a)}function $f(a){ag[a>>6&3].call(this,a)}
var Lf=[function(a){bg[a>>8&15].call(this,a)},xf,lf,Ve,Re,Te,Me,W,function(a){cg[a>>8&15].call(this,a)},yf,mf,We,Se,Ue,Gf,W],bg=[function(a){dg[a>>4&15].call(this,a)},hf,ef,Xe,Ye,cf,Ze,af,vf,vf,Mf,Of,Qf,W,W,W],Nf=[function(a){Ad(this,je(this,a,0));this.b-=this.g?9:3+(7==this.f?2:0)},function(a){T(this,a,0,we);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){T(this,a,1,Ae);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){T(this,a,1,ye);this.b-=this.g?9:3+(7==this.f?2:0)}],Pf=[function(a){T(this,a,0,
Ce);this.b-=this.g?11:6},function(a){T(this,a,vd(this)?1:0,me);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){T(this,a,vd(this)?1:0,Ie);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){a=he(this,a);Ad(this,a);this.b-=this.g?4:3+(7==this.f?2:0)}],Rf=[function(a){T(this,a,0,Ge);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){T(this,a,0,Ee);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){T(this,a,0,qe);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){T(this,a,0,oe);this.b-=this.g?9:3+(7==this.f?2:0)}],
dg=[function(a){eg[a&15].call(this,a)},W,W,W,tf,tf,tf,tf,Ef,W,Sf,Uf,Hf,Hf,Hf,Hf],eg=[pf,Jf,Df,gf,rf,Cf,W,W,W,W,W,W,W,W,W,W],Tf=[Bf,function(){this.T=0;this.b-=5},function(){this.U=0;this.b-=5},V,function(){this.ba=1;this.b-=5},V,V,V,function(){this.X=0;this.b-=5},V,V,V,V,V,V,V],Vf=[Bf,function(){this.T=65536;this.b-=5},function(){this.U=32768;this.b-=5},X,function(){this.ba=0;this.b-=5},X,X,X,function(){this.X=32768;this.b-=5},X,X,X,X,X,X,X],cg=[ff,df,$e,bf,jf,kf,Pe,Qe,of,If,Wf,Yf,$f,W,W,W],Xf=[function(a){Ad(this,
ie(this,a,0));this.b-=this.g?9:3+(7==this.f?2:0)},function(a){S(this,a,0,xe);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){S(this,a,1,Be);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){S(this,a,1,ze);this.b-=this.g?9:3+(7==this.f?2:0)}],Zf=[function(a){S(this,a,0,De);this.b-=this.g?11:6},function(a){S(this,a,vd(this)?1:0,ne);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){S(this,a,vd(this)?1:0,Je);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){a=ge(this,a);Ad(this,a<<8);this.b-=this.g?4:3+(7==
this.f?2:0)}],ag=[function(a){S(this,a,0,He);this.b-=this.g?9+(this.sb&1):3+(7==this.f?2:0)},function(a){S(this,a,0,Fe);this.b-=this.g?9:3+(7==this.f?2:0)},function(a){S(this,a,0,re);this.b-=this.g?9+(this.sb&1):3+(7==this.f?2:0)},function(a){S(this,a,0,pe);this.b-=this.g?9:3+(7==this.f?2:0)}];function sd(a){fg[a>>12].call(this,a)}
var fg=[function(a){gg[a>>8&15].call(this,a)},xf,lf,Ve,Re,Te,Me,function(a){hg[a>>8&15].call(this,a)},function(a){ig[a>>8&15].call(this,a)},yf,mf,We,Se,Ue,Gf,W],gg=[function(a){jg[a>>4&15].call(this,a)},hf,ef,Xe,Ye,cf,Ze,af,vf,vf,Mf,Of,Qf,function(a){kg[a>>6&3].call(this,a)},W,W],kg=[function(a){a=this.u[7]+((a&63)<<1)&65535;var b=this.sa(a|this.P);O(this,this.u[5]);this.u[6]=a+2&65535;this.u[5]=b;this.b-=8},function(a){a=be(this,a,0);Ed(this,a);R(this,a);this.b-=11},function(a){var b=Xd(this);this.J=
this.b;ce(this,a,0,b);R(this,b);this.b=this.J-zf[this.g]},function(a){R(this,je(this,a,this.Ta?65535:0));this.b-=this.g?9:3+(7==this.f?2:0)}],jg=[function(a){lg[a&15].call(this,a)},W,W,W,tf,tf,tf,tf,Ef,function(a){a&8?(this.M&49152||(this.M=this.M&-2017|(a&7)<<5,this.I|=1),this.b-=5):W.call(this,a)},Sf,Uf,Hf,Hf,Hf,Hf],lg=[pf,Jf,Df,gf,rf,Cf,function(){Wd(this);this.b-=13},W,W,W,W,W,W,W,W,W],hg=[Af,Af,nf,nf,Ne,Ne,Oe,Oe,Kf,Kf,W,W,W,W,Ff,Ff],ig=[ff,df,$e,bf,jf,kf,Pe,Qe,of,If,Wf,Yf,$f,function(a){mg[a>>
6&3].call(this,a)},W,W],mg=[W,function(a){a=be(this,a,65536);Ed(this,a);R(this,a);this.b-=11},function(a){var b=Xd(this);this.J=this.b;ce(this,a,65536,b);R(this,b);this.b=this.J-zf[this.g]},W];
function ng(a){u.call(this,"ROM",a,ng);this.ia=this.f=null;this.C=a.addr;this.g=a.size;this.v=a.alias;this.A=a.file;this.D=sa(this.A);if(this.A){a=this.A;var b=ta(this.D);"json"!=b&&"hex"!=b&&(a=Ga()+"/api/v1/dump?file="+this.A+"&format=bytes&decimal=true");var c=this;Ea(a,null,!0,function(a,b,f){f?(c.O("Unable to load ROM resource (error "+f+": "+a+")"),c.A=null):(nb(c.Qa,a,b),(a=Fa(a,b))?(c.f=a.ea,c.ia=a.ia):c.A=null);og(c)})}}z(ng);ng.prototype.Ea=function(a,b,c,d){this.w=b;this.b=c;this.i=d;og(this)};
ng.prototype.Ha=function(){this.ia&&(this.i&&pg(this.i,this.id,this.C,this.g,this.ia),delete this.ia);return!0};ng.prototype.Ga=function(){return!0};
function og(a){if(!tb(a)){if(a.A){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.C;if(tc(a.w,b,a.g,Vc)){var c;for(c=0;c<a.f.length;c++)a.w.qb(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=sc(d.w,d.C,d.g);rc(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 ng(d);C(d,c)}});
function qg(a){u.call(this,"RAM",a,qg);this.ia=this.g=null;this.A=a.addr;this.C=a.size;this.La=a.load;this.Ka=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.O("Unable to load RAM resource (error "+f+": "+a+")"),c.f=null):(nb(c.Qa,a,b),(a=Fa(a,b))?(c.g=a.ea,c.ia=a.ia,null==c.La&&(c.La=a.La),null==c.Ka&&(c.Ka=a.Ka)):c.f=null);rg(c)})}}
z(qg);qg.prototype.Ea=function(a,b,c,d){this.w=b;this.b=c;this.i=d;rg(this)};qg.prototype.Ha=function(){this.ia&&(this.i&&pg(this.i,this.id,this.A,this.C,this.ia),delete this.ia);return!0};qg.prototype.Ga=function(){return!0};function rg(a){if(a.w&&(!a.v&&a.C&&tc(a.w,a.A,a.C,1)&&(a.v=!0),!tb(a))){if(!a.v)q("No RAM allocated");else if(a.f){if(!a.g||!a.w)return;Lg(a,a.g,a.La,a.Ka,a.A)}H(a)}}
qg.prototype.reset=function(){if(this.v){for(var a=this.w,b=this.A,c=this.C,d=b&a.w,b=b>>>a.la;0<c&&b<a.W.length;){var e=a.W[b];if(e.controller&&a.g&&a.g.length==a.v.length){var f=a.g.indexOf(e);0<=f&&(e=a.v[f])}if(e){var f=c,g=0,h,d=d||0,g=g&255;void 0===f&&(f=e.size);if(wb&&e.G)for(h=d;f--&&h<e.G.length;h++)e.G[h]=g;else for(h=d;f--&&h<e.size;h++)e.$b(d,g,e.F+d)}c-=a.ya;b++;d=0}this.g&&Lg(this,this.g,this.La,this.Ka,this.A,!0)}};
function Lg(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.qb(n++,b[r++]&255);else n&1?a.b.ha():ud(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.qb(c+
e,b[e]);null!=d&&ud(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 qg(d);C(d,c)}});function Mg(a){u.call(this,"Keyboard",a,Mg,65536);H(this)}z(Mg);Mg.prototype.ta=function(){return!1};Mg.prototype.Ea=function(a,b,c,d){this.A=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 Mg(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.P=a.charBOL;this.H=0;u.call(this,"SerialPort",a,Y,8388608);var b=a.binding;if("console"==b)this.D="";else{var c;a=Ng;b&&(void 0===c&&(c="Panel"),(c=qb(c,this.id))&&(b=c.G[b])&&this.ta(null,a,b))}this.J=this.L=null;this.exports={connect:this.wc,receiveData:this.ic}}z(Y);var Ng="buffer";k=Y.prototype;
k.ta=function(a,b,c){var d=this;switch(b){case Ng: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.ic(b);return!0},c.onkeypress=function(a){a=a||window.event;d.ic(a.which||a.keyCode);a.preventDefault&&a.preventDefault();return!0},c.removeAttribute("readonly"),!0}return!1};
k.Ea=function(a,b,c,d){this.A=a;this.w=b;this.b=c;this.i=d;var e=this;this.ka=Mc(48,4);this.Y=Jc(this.b,function(){e.f&128||!e.C.length||(e.K=e.C.shift()&255,e.da&&97<=e.K&&122>e.K&&(e.K-=32),e.f|=128,e.f&64&&Kc(e.b,e.ka))});this.na=Mc(52,4);this.aa=Jc(this.b,function(){e.g|=128;e.g&64&&Kc(e.b,e.na)});Cb(b,this,Og);H(this)};
k.wc=function(){if(!this.J){var a=hd(this.A,"connection");if(a){var b=a.split("->");if(2==b.length){var c=ya(b[0]);if(c!=this.lb)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.Qa+"."+c+" connected to "+b);return}}}}this.status("Unable to establish connection: "+a)}}};k.Ha=function(a,b){if(!b)if(this.wc(),!a||!this.restore)this.reset();else if(!this.restore(a))return!1;return!0};
k.Ga=function(a){return a?this.save():!0};k.reset=function(){Pg(this)};k.save=function(){var a=new P(this);a.set(0,[]);return a.data()};k.restore=function(){return Pg(this)};function Pg(a){a.K=0;a.f=0;a.g=128;a.C=[];return!0}k.ic=function(a){if("number"==typeof a)this.C.push(a);else if("string"==typeof a)for(var b=0;b<a.length;b++)this.C.push(a.charCodeAt(b));else this.C=this.C.concat(a);Lc(this.b,this.Y,1E3/Math.round(this.N/10));return!0};k.Cd=function(){return this.f&65534};
k.te=function(a){this.f=this.f&-112|a&111};k.Bd=function(){this.f&=-129;0<this.C.length&&Lc(this.b,this.Y,1E3/Math.round(this.N/10));return this.K};k.se=function(){};k.Vd=function(){return this.g};k.Me=function(a){128==(this.g&192)&&a&64&&Lc(this.b,this.aa,1E3/Math.round(this.R/10));this.g=this.g&-70|a&69};k.Ud=function(){return 0};
k.Le=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.H=0;else if(8==a)this.v.value=this.v.value.slice(0,-1),0<this.H&&this.H--;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.H%a,this.S&&(b=xa("",c)));this.P&&!this.H&&c&&(b=String.fromCharCode(this.P)+b);this.v.value+=b;this.v.scrollTop=this.v.scrollHeight;this.H+=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;Lc(this.b,this.aa,1E3/Math.round(this.R/10))}};var Qg={},Og=(Qg[65392]=[null,null,Y.prototype.Cd,Y.prototype.te,"RCSR"],Qg[65394]=[null,null,Y.prototype.Bd,Y.prototype.se,"RBUF"],Qg[65396]=[null,null,Y.prototype.Vd,Y.prototype.Me,"XCSR"],Qg[65398]=[null,null,Y.prototype.Ud,Y.prototype.Le,"XBUF"],Qg);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 Pc(a){u.call(this,"PC11",a,Pc);this.g=a.autoMount||null;this.D=0;this.aa=a.baudReceive||3600;this.K=this.L=this.f=0;this.J=[];this.H=Rg;this.v=Sg;this.N=this.C="";this.ea=this.La=this.Ka=null;this.R=-1;this.P=!Pa("Mobi")&&window&&"FileReader"in window}z(Pc);var Rg="",Sg=0;k=Pc.prototype;
k.ta=function(a,b,c){var d=this,e=Sg;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&&Tg(d,a.options[a.selectedIndex].text,a.value,e)},!0;case "mountTape":if(!this.P){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;Tg(d,sa(b,!0),b,1,a)}return!1};return!0;case "readProgress":return this.G[b]=c,!0}return!1};
k.Ea=function(a,b,c,d){this.A=a;this.w=b;this.b=c;this.i=d;this.S=Ug(a);var e=this;if((this.g=hd(this.A,"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.Y=Mc(56,4);this.da=Jc(this.b,function(){1==(e.f&32769)&&!(e.f&128)&&e.K<e.J.length&&(e.L=e.J[e.K++]&255,Vg(e,e.K/e.J.length*100),e.f|=128,e.f&=-2049,e.f&64&&Kc(e.b,e.Y))});Cb(b,this,Wg);Xg(this,"None",Rg,!0);this.P&&Xg(this,"Local Tape",
"?");Xg(this,"Remote Tape","??");Yg(this)||H(this)};k.Ha=function(a,b){if(!b)if(!a||!this.restore)this.reset();else if(!this.restore(a))return!1;return!0};k.Ga=function(a){return a?this.save():!0};k.reset=function(){this.f&=-2241;this.L=0};function Yg(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?Zg(a,c,b,1,!0):$g(a)}return!!a.D}
function Tg(a,b,c,d,e){if(c)if("?"==c)a.O('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.H="??"}else a.H=c;Zg(a,b,c,d,!1,e)}else ah(a,!1)}
function Zg(a,b,c,d,e,f){var g=-1;if(a.C.toLowerCase()!=c.toLowerCase()||a.v!=d)g++,ah(a,!0),a.B.$a?a.O("PC11 busy"):(e&&(a.D++,F(a)&&E(a,"auto-loading tape: "+b)),bh(a,b,c,d,f)?g++:a.B.$a=!0);g&&ch(a,a.N,a.C,a.v,a.ea,a.La,a.Ka)}
function bh(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),ch(a,b,c,d,e),a.H="?");$g(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.A&&!a.A.B.ja;g?a.O('Unable to load tape "'+b+'" (error '+g+": "+e+")",h):(nb(a.Qa,e,f),(e=Fa(e,f))&&ch(a,b,c,d,e.ea,e.La,
e.Ka));a.B.$a=!1;a.D&&(a.D--,a.D||H(a));$g(a)})}function Xg(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 $g(a){var b=a.G.listTapes;if(b&&b.options){a=a.H||a.C;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 Vg(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 ch(a,b,c,d,e,f,g){a.N=b;a.C=c;a.v=d;a.ea=e;a.La=f;a.Ka=g;2==d?a.S&&Lg(a.S,e,f,g)?a.status("tape loaded: "+b):(a.N="",a.C="",a.H=Rg,a.v=Sg,a.O("No load address available for tape: "+b)):(a.K=0,a.J=e,a.status("tape attached: "+b),Vg(a,0))}function ah(a,b){if(a.C||!1===b)a.N="",a.C="",b||(a.v&&a.status(1==a.v?"tape detached":"tape unloaded"),a.H=Rg,a.v=Sg,$g(a))}k.save=function(){return(new P(this)).data()};k.restore=function(){return!0};k.vd=function(){return this.f&65534};
k.me=function(a){a&1&&(this.f&32768?(a&=-2,this.f&64&&Kc(this.b,this.Y)):(this.f&=-129,this.f|=2048,this.L=0,Lc(this.b,this.da,1E3/Math.round(this.aa/10))));this.f=this.f&-66|a&65};k.ud=function(){this.f&=-129;this.f|=2048;return this.L};k.le=function(){};var dh={},Wg=(dh[65384]=[null,null,Pc.prototype.vd,Pc.prototype.me,"PRS"],dh[65386]=[null,null,Pc.prototype.ud,Pc.prototype.le,"PRB"],dh);
function eh(a,b,c){u.call(this,"Disk",{id:a.Qa+".disk"+p(++fh,4)},eh,2097152);this.controller=a;this.A=a.A;this.i=a.i;this.v=b;this.Xa=b.name;this.ec=b.ec;gh(this,c,b.va,b.za,b.ra,b.Ma);H(this)}var fh=0;z(eh);k=eh.prototype;k.Ea=function(a,b,c,d){this.i=d};
function gh(a,b,c,d,e,f){a.mode=b;a.va=c;a.za=d;a.ra=e;a.Ma=f;a.b=[];if("preload"!=a.mode){b=Array(a.va);for(c=0;c<b.length;c++){d=Array(a.za);for(e=0;e<d.length;e++){f=Array(a.ra);for(var g=1;g<=f.length;g++)f[g-1]=hh(null,c,e,g,a.Ma,0);d[e]=f}b[c]=d}a.b=b}a.f=null}
function ih(a,b,c,d,e){var f=c;if(a.w)return!0;a.Xa=b;a.gb=c;a.Dc=sa(c);a.w=e;a.C=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.va=e[0];a.za=e[1];a.ra=e[2];a.Ma=e[3]||512;c=a.Ma>>2;var f=e=0,b=new DataView(b,0,d);a.b=Array(a.va);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.ra),x=0;x<y.length;x++){for(var A=hh(null,d,w,x+1,a.Ma,0),ja=A.data,Ja=0;Ja<c;Ja++,f+=4)var Q=ja[Ja]=b.getInt32(f,
!0),e=e+Q&-1;A.Ba=c;y[x]=A}a.f=e;c=a}else a.O("Unrecognized disk format ("+d+" bytes)");a.w&&(a.w.call(a.controller,a.v,c,a.Xa,a.gb),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.ec?"":e)+"&format=json"));return!!Ea(f,
null,!0,function(b,c,d){jh(a,b,c,d)})}
function jh(a,b,c,d){var e=null;a.g=!1;var f=0>d&&a.A&&!a.A.B.ja;if(d)a.controller.O('Unable to load disk "'+a.Xa+'" (error '+d+": "+b+")",f);else{nb(a.controller.Qa,b,c);try{if(0<sa(a.Dc,!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.Xa]: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.va=h.length;a.za=h[0].length;a.ra=h[0][0].length;var l=h[0][0][0];a.Ma=l&&l.length||512;for(d=c=0;d<a.va;d++)for(f=0;f<a.za;f++)for(g=0;g<a.ra;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;kh(l,t)}else r=[],n=l.pattern=n|n<<8|n<<16|n<<24,l.data=r;delete l.bytes}hh(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.Xa)}catch(x){q("Disk image error ("+b+"): "+x.message)}}a.w&&(a.w.call(a.C,a.v,e,a.Xa,a.gb),a.w=null)}function hh(a,b,c,d,e,f){a||(a={sector:d,length:e,data:[],pattern:f});a.Pe=b;a.Qe=c;a.Pa=a.Ba=0;a.Sa=!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.Jc&&b<f.za)for(h=g[b]=Array(f.Kc),g=0;g<h.length;g++)h[g]=hh(null,a,b,g+1,f.xc,0);if(h){for(g=0;g<h.length;g++)if(h[g]&&h[g].sector==c){d=h[g];break}!d&&f.Jc&&9==f.nc&&(d=h[g]=hh(null,a,b,f.nc,f.xc,0))}}e&&e(d,!1);return d};function kh(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.Pa?(a.Ba+=a.Pa-f,a.Pa=f):f>=a.Pa+a.Ba&&(a.Ba+=f-(a.Pa+a.Ba)+1):(a.Pa=f,a.Ba=1);d[f]=d[f]&~(255<<b)|c<<b}return!0}return null};
function lh(a,b){var c=a.za*a.ra,d=b/c|0;return d<a.va?(b%=c,a.seek(d,b/a.ra|0,b%a.ra+1)):null}function mh(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.gb,this.f,this.va,this.za,this.ra,this.Ma];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.Pa,n=g.Pa+g.Ba;m<n;)h[l++]=g.data[m++];b[a++]=[d,e,f,g.Pa,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?gh(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.Pa=e;for(h.Ba=f.length;e<g;)h.data[e++]=f[l++];b++}}}0>b&&-2!=b&&this.controller.O("Unable to restore disk '"+this.Xa+": "+c);return b};
k.toJSON=function(){var a;a=0;for(var b;b=lh(this,a++);)nh(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 nh(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 N(a){u.call(this,"RL11",a,N,2097152);this.v=a.autoMount||null;this.H=0;this.f=Array(4);this.L=!Pa("Mobi")&&window&&"FileReader"in window}z(N);k=N.prototype;
k.ta=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=qa(c.value,10);null!=a&&oh(d,a)},!0;case "loadDrive":return this.G[b]=
c,c.onclick=function(){var a=d.G.listDisks;a&&ph(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[qa(a.value,10)||0])if(a=a.Ca){var b;b="";for(var c=0,h;h=lh(a,c++);)for(var l=0,m=h.length;l<m;l++)b+=String.fromCharCode(mh(a,h,l));b=btoa(b);a=a.Dc.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.O("No disk loaded in drive.");else d.O("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;ph(d,sa(b,!0),b,a)}return!1},!0;c.parentNode.removeChild(c)}return!1};
k.Ea=function(a,b,c,d){this.A=a;this.w=b;this.b=c;this.i=d;if((this.v=hd(this.A,"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}qh(this);this.P=Mc(112,5);Cb(b,this,rh,2097152);sh(this,"None","",!0);this.L&&sh(this,"Local Disk","?");sh(this,"Remote Disk","??");th(this)||H(this)};
k.Ha=function(a,b){if(!b){if(!a||!this.restore){if(this.reset(),this.A.rc){for(a=0;a<this.f.length;a++)uh(this,a,!0);th(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;4>b;b++){var c=document.createElement("option");c.value=b;c.text="RL"+b;a.appendChild(c)}a.value="0";oh(this,0)}}return!0};k.Ga=function(a){return a?this.save():!0};k.reset=function(){qh(this)};k.save=function(){return(new P(this)).data()};
k.restore=function(a){return qh(this,a[0])};function th(a,b){b||(a.H=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)){!vh(a,g,f,e,!0)&&b&&H(a,!1);continue}a.O("Incorrect auto-mount settings for drive "+c+" ("+JSON.stringify(d)+")")}return!!a.H}
function ph(a,b,c,d){var e=a.G.listDrives,e=e&&qa(e.value,10);if(void 0===e||0>e||e>=a.f.length)a.O("Unable to load the selected drive");else if(c)if("?"==c)a.O('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+'"')}vh(a,e,b,c,!1,d)}else uh(a,e)}
function vh(a,b,c,d,e,f){var g=-1,h=a.f[b];h.gb.toLowerCase()!=d.toLowerCase()&&(g++,uh(a,b,!0),h.dc?a.O("RL11 busy"):(h.dc=!0,e&&(h.cc=!0,a.H++,F(a)&&E(a,"auto-loading disk: "+c)),h.Pb=!!f,ih(new eh(a,h,"preload"),c,d,f,a.Mc)&&g++));return g}
k.Mc=function(a,b,c,d,e){var f;a.dc=!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.va||f[1]>a.za)&&(this.O('Disk "'+c+'" too large for drive '+("RL"+a.fc)),b=null);b?(a.Ca=b,a.Xa=c,a.gb=d,this.O('Mounted disk "'+c+'" in drive '+("RL"+a.fc),a.cc||e),this.A&&this.A.rb()):a.Pb=!1;a.cc&&(a.cc=!1,--this.H||H(this));oh(this,a.fc)};
function sh(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 oh(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=qa(a.value,10),c=c.Pb?"?":c.gb,!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 uh(a,b,c){var d=a.f[b];if(d.Ca||!1===c)d.Xa="",d.gb="",d.Ca=null,d.Pb=!1,c||(a.O("Drive RL"+b+" unloaded",c),oh(a,b))}
function qh(a,b){var c=0;b||(b=[]);a.fa=b[c++]||0;a.J=b[c++]||0;a.g=b[c++]||0;a.C=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.fc=b;d.dc=d.Pb=!1;d.name=c.lb;d.va=512;d.za=2;d.ra=40;d.Ma=256;d.ec=!0;d.Oe=0;d.Ne=0;d.nc=1;d.Kc=d.ra;d.xc=d.Ma;d.Re=0;d.Te=null;d.Ca||(d.gb="");d.status=29|(512==d.va?128:0)}return!0}
k.Nc=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.C=this.g=b<<7|(c?64:0)|d&63;this.D=65536-e&65535;a&&(this.fa=this.fa|a|32768);return!0};
k.hd=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.hb(f,r|t<<8);if(Ic(this.w)){h=8192;break}f+=2;if(n>=l.Ma&&(m=null,++d>=l.ra&&(d=0,++c>=l.za&&(c=0,++b>=l.va)))){h=5120;break}}return g(h,b,c,d,e,f)};
k.be=function(a,b,c,d,e,f,g){for(var h=0,l=a.Ca,m=null,n;e--;){var r=this.w.pa(f);if(Ic(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.Ma&&(m=null,++d>=l.ra&&(d=0,++c>=l.za&&(c=0,++b>=l.va)))){h=5120;break}}return g(h,b,c,d,e,f)};k.Fd=function(){return this.fa&65535};
k.we=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.C&64;break;case 6:1==(this.g&3)&&(b=this.g&65408,c=(this.g&16)<<2,this.C=this.g&4?this.C+b:this.C-b,this.g=this.C=this.C&65408|c);break;case 8:this.D=this.C;break;case 12:b=this.hd;case 10:b||(b=this.be),d=this.g>>7,e=this.g&64?0:1,f=this.g&63,d>=c.va||f>=c.ra?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.Nc.bind(this)))}a&&(this.fa|=129,this.fa&64&&Kc(this.b,this.P))}};k.Dd=function(){return this.J};k.ue=function(a){this.J=a&65534};k.Gd=function(){return this.g};k.xe=function(a){this.g=a};k.Hd=function(){return this.D};k.ye=function(a){this.D=a};k.Ed=function(){return this.K};k.ve=function(a){this.K=a&63};
var wh={},rh=(wh[63744]=[null,null,N.prototype.Fd,N.prototype.we,"RLCS"],wh[63746]=[null,null,N.prototype.Dd,N.prototype.ue,"RLBA"],wh[65284]=[null,null,N.prototype.Gd,N.prototype.xe,"RLDA"],wh[65286]=[null,null,N.prototype.Hd,N.prototype.ye,"RLMP"],wh[65288]=[null,null,N.prototype.Ed,N.prototype.ve,"RLBE"],wh);function xh(a){u.call(this,"Debugger",a,xh);this.da=a.base||16;this.Ja=!1;this.K=0;this.R=!1;this.C=-1;this.v=[];this.Y={}}z(xh);
var yh={"||":0,"&&":1,"|":2,"^":3,"&":4,"!=":5,"==":5,">=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9};xh.prototype.tc=function(){return-1};xh.prototype.uc=function(){};
function zh(a,b,c,d){if(c)if(b){0>a.C&&a.v.length&&(a.C=0);if(0>a.C||b!=a.v[a.C])a.v.splice(0,0,b),a.C=0;a.C--}else a.R?b="end":b=a.v[a.C+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 Ah(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 Bh(a,b,c){var d;if(b){b=Ch(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=Dh(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&&yh[n]<yh[l[l.length-1]]&&Ah(h,l,1);l.push(n);b=b.substr(r+t)}Ah(h,l)&&1==h.length||(f=!0);f?c&&a.j("error parsing '"+g+"' at character "+(g.length-b.length)):(d=h.pop(),c&&Eh(a,null,
d))}return d}function Ch(a,b){for(var c,d=a.Ja?"(":"{",e=a.Ja?")":"}",f=new RegExp(a.Ja?"\\((.*?)\\)":"\\{(.*?)\\}");(c=b.match(f))&&!(0<=c[1].indexOf(d));){var g=Bh(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 Dh(a,b,c,d){var e;null!=b?(e=a.tc(b),0<=e?e=a.uc(e):(e=a.Y[b],null==e&&(e=qa(b,a.da))),null!=e||d||a.j("invalid "+(c?c:"value")+": "+b)):d||a.j("missing "+(c||"value"));return e}
function Eh(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 Fh(a,b){if(b)return Eh(a,b,a.Y[b]);var c=0;for(b in a.Y)Eh(a,b,a.Y[b]),c++;return 0<c}
function J(a,b,c,d){switch(a.da){case 8:a=ra(b,3*c-(2<c?1:0));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 Gh(a){xh.call(this,a);this.kb=!1;this.Ja=!0;this.L=Z(0);this.mb=Z(0);this.P=Z(0);this.J=[];this.g=this.N=this.D=[];Hh(this);this.ua=0;Ih(this);this.Na={};Jh(this,a.messages);this.Ya=a.commands;var b=this;window?void 0===window.pdp11&&(window.pdp11=function(a){return kd(b,a)}):void 0===global.pdp11&&(global.pdp11=function(a){return kd(b,a)})}z(Gh,xh);
var Kh={"?":"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"},Lh=".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(" "),
Mh={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]}},Nh=[0],Oh=
[58,60,65,96,108,110,100,101,102,103,104,105,59,64];k=Gh.prototype;
k.Ea=function(a,b,c,d){this.w=b;this.b=c;this.A=a;this.f=a.f;(a=hd(a,"messages"))&&Jh(this,a);this.vb=Mh;this.Ob=1145>this.b.xb?Oh:[];Ph(this,function(a){a:{var b=d.w.W,c=a[0],e=a=0,l=b.length;if(c){a=d.ca(Qh(d,c));if(-1===a){d.j("invalid address: "+c);break a}e=a>>>d.w.la;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=wc[c],n&&d.j(p(n.id,8)+" %"+
p(e<<d.w.la,8)+" %%"+p(n.F,8)+" "+p(n.Mb,4,!0)+" "+p(n.size,4,!0)+" "+m),c!=Uc&&(c=-1),m=0);a+=d.w.ya;e++}}});H(this)};
k.ta=function(a,b,c){var d=this;switch(b){case "debugInput":return this.na=this.G[b]=c,c.onkeydown=function(a){var b;if(13==a.keyCode)b=c.value,c.value="",kd(d,b,!0);else if(27==a.keyCode)c.value=b="";else if(38==a.keyCode?(b=null,d.C<d.v.length-1&&(b=d.v[++d.C])):40==a.keyCode&&(0<d.C?b=d.v[--d.C]:(b="",d.C=-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.na){var a=d.na.value;
d.na.value="";kd(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.jb(a?1:0),rb(d,!1));return b}),!0}return!1};k.rb=function(a){if(this.na){var b=0,c=0;!a&&window&&(b=window.scrollX,c=window.scrollY);this.na.focus();!a&&window&&window.scrollTo(b,c)}};k.ca=function(a){a=a&&a.F;null==a&&(a=-1);return a};k.Gb=function(a,b){var c=255,d=this.ca(a,!1,1);-1!==d&&(c=a.Qb?this.w.Ub(d):this.b.Ub(d),b&&Rh(a,b));return c};
k.pa=function(a,b){var c=65535,d=this.ca(a,!1,2);-1!==d&&(c=a.Qb?this.w.ab(d):this.b.ab(d),b&&Rh(a,b));return c};k.Xb=function(a,b,c){var d=this.ca(a,!0,1);-1!==d&&(a.Qb?this.w.qb(d,b):this.b.qb(d,b),c&&Rh(a,c),this.A.$(!0))};k.hb=function(a,b,c){var d=this.ca(a,!0,2);-1!==d&&(a.Qb?this.w.Db(d,b):this.b.Db(d,b),c&&Rh(a,c),this.A.$(!0))};function Z(a,b){return{F:a,Qb:b,Oa:!1}}function Sh(a){return[a.F,a.Oa]}function Th(a){return{F:a[0],Oa:a[1]}}
function Qh(a,b,c){var d,e=(c?a.L:a.mb).F;c=!1;if(void 0!==b){b=Ch(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.J.length;e++){var g=a.J[e].ia[d];if(void 0!==g){d=g.o;void 0!==d&&(f=Z(d));break}}if(d=f)return d;e=Bh(a,b,void 0)}null!=e&&(d=Z(e,c));return d}function Uh(a,b,c){c&&(c=c.match(/(['"])(.*?)\1/))&&(b.Hc=zh(a,b.Cc=c[2]))}function Rh(a,b){null!=a.F&&(a.F+=b||1)}
function Jh(a,b){a.i=a;a.oa=a.Lc=536870912;a.ka=null;a.wa=[];b=zh(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.oa|=xb[c],a.j(c+" messages enabled"))}}function Ph(a,b){for(var c in xb)if(64==xb[c]){a.Na[c]=b;break}}
k.tc=function(a){var b=-1;a=a.toUpperCase();switch(a){case "SP":b=6;break;case "PC":b=7;break;case "SW":b=21;break;default:"R"==a.charAt(0)&&(b=+a.charAt(1),0>b||7<b)&&(b=-1)}return b};function Vh(a){return 6>a?"R"+a:6==a?"SP":"PC"}k.uc=function(a){var b;0<=a&&(8>a?b=this.b.u[a]:16>a?b=this.b.Wa[a-8]:20>a?b=this.b.Ia[a-16]:20==a?b=gc(this.b):21==a&&this.f&&fc(this.f)&&(b=this.f.Va));return b};
k.message=function(a,b){b&&(a+=" @"+J(this,Z(this.b.Kb).F));this.oa&1073741824?this.wa.push(a):this.ka&&a==this.ka||(this.ka=a,this.oa&-2147483648&&this.b&&this.b.B.Z&&(this.ha(),a+=" (cpu halted)"),this.j(a),this.b&&(a=this.b,od(a),a.ua=0,a.A&&a.A.$(void 0)))};function Ih(a){var b;if(!ke(a))a.H&&a.H.length&&a.j("instruction history buffer freed"),a.aa=0,a.H=[];else if(!a.H||!a.H.length){a.H=Array(1E3);for(b=0;b<a.H.length;b++)a.H[b]=Z();a.aa=0;a.j("instruction history buffer allocated")}}
k.ib=function(a,b){if(!Wh(this,b))return!1;this.b.ib(a);return!0};k.jb=function(a,b,c){if(!Wh(this))return!1;this.K=0;a||ke(this)&&le(this,this.b.u[7],0);try{a=pd(this.b,a);var d=this.b.jb(a);0<d&&(Zb(this.b,d),this.K+=d,$b(this.b,d,!0),ac(this.b,d),this.Aa++)}catch(e){"number"!=typeof e&&(this.K=0,vb(this.b,e.stack||e.message))}!1!==c&&(this.f&&this.f.stop&&this.f.stop(),this.A.$());this.$(b||!1);return 0<this.K};k.ha=function(a){this.b&&this.b.ha(a)};
k.$=function(a){if(this.kb){void 0===a&&(a=!0);var b;b=this.b;if(b=b.I&8?b.Vc|b.Tc<<8:0){var c=b>>8;this.j("trapped to "+J(this,b&255,1)+(c?" ("+J(this,c)+")":""))}this.L=Z(this.b.u[7]);a&&1!=this.S?Xh(this):Yh(this)}};function Wh(a,b){var c;(c=!a.b||!tb(a.b))||(c=a.b,c.B.ja?c=!0:(c.j(c.toString()+" not powered"),c=!1),c=!c);return c||a.b.B.Z?(b||a.j("cpu busy or unavailable, command ignored"),!1):!ub(a.b)}k.Ha=function(a,b){return!b&&(this.reset(!0),a&&this.restore&&!this.restore(a))?!1:!0};
k.Ga=function(a,b){b&&this.j(a?"suspending":"shutting down");return a?this.save():!0};k.reset=function(a){Ih(this);this.Aa=0;this.ka=null;this.K=0;this.L=Z(this.b.u[7]);this.B.Z=!1;Zh(this);a||this.$()};k.save=function(){var a=new P(this);a.set(0,Sh(this.L));a.set(1,Sh(this.P));a.set(2,[this.v,this.R,this.oa]);a.set(3,this.J);return a.data()};
k.restore=function(a){var b=0;void 0!==a[2]&&(this.L=Th(a[b++]),this.P=Th(a[b++]),this.v=a[b][0],"string"==typeof this.v&&(this.v=[this.v]),this.R=a[b][1],this.oa|=a[b][2]);a[3]&&(this.J=a[3]);return!0};k.start=function(a,b){this.S||this.j("running");this.B.Z=!0;this.Rb=a;this.Tb=b};
k.stop=function(a,b){if(this.B.Z){this.B.Z=!1;this.K=b-this.Tb;if(!this.S){b="stopped";if(this.K){a-=this.Rb;var c=0<a?Math.round(1E3*this.K/a):0;b+=" (";ke(this)&&(b+=this.Aa+" instructions, ",this.Aa=0);b+=this.K+" cycles, "+a+" ms, "+c+" hz)"}else F(this,-2147483648)&&(b+=" (use the 't' command to execute blocked faults)");this.j(b)}this.$(!0);this.rb();Zh(this,this.b.u[7]);this.ka=null}};function ke(a){return 1<a.g.length||!!a.ua}
function le(a,b,c){var d=-1;c||(d=a.b.ab(b),0==d&&(b=zd(a.b,2)));if(0<c&&(a.ua&&!--a.ua||cd(a,b,1,a.g)))return!0;0<=c&&a.H.length&&(a.Aa++,0>d&&(d=a.b.ab(b)),65535!=(d&65535)&&(c=a.H[a.aa],c.F=b,c.Oa=!1,++a.aa==a.H.length&&(a.aa=0)));return!1}function qf(a){var b=a.b;if(b.B.Z)throw O(b,a.b.Kb),a.ha(),-1;return!1}
function Hh(a){var b,c;a.g=["bp"];if(a.N)for(b=1;b<a.N.length;b++){c=a.N[b];var d=a.w;c=a.ca(c);dd(d.W[c>>>d.la],!1)}a.N=["br"];if(a.D)for(b=1;b<a.D.length;b++)c=a.D[b],d=a.w,c=a.ca(c),dd(d.W[c>>>d.la],!0);a.D=["bw"];a.sb=0}k.nb=function(a,b,c){var d=!0;c||$h(this,a,b,!1,!0);if(a!=this.g){var e=this.ca(b);if(-1===e)this.j("invalid address: "+J(this,b.F)),d=!1;else{var f=this.w;f.W[e>>>f.la].nb(e&f.w,a==this.D)}}d&&(a.push(b),c?b.Oa=!0:(ai(this,a,a.length-1,"set"),Ih(this)));return d};
function $h(a,b,c,d,e){var f=!1;c=a.ca(c);for(var g=1;g<b.length;g++){var h=b[g];if(c==a.ca(h)&&(!d||h.Oa)){f=!0;h.Oa||e||ai(a,b,g,"cleared");b.splice(g,1);b!=a.g&&(d=a.w,dd(d.W[c>>>d.la],b==a.D));h.Oa||Ih(a);break}}return f}function bi(a,b){for(var c=1;c<b.length;c++)ai(a,b,c);return b.length-1}function ai(a,b,c,d){c=b[c];a.j(b[0]+" "+J(a,c.F)+(d?" "+d:c.Cc?' "'+c.Cc+'"':""))}
function Zh(a,b){if(void 0!==b)cd(a,b,1,a.g,!0),a.S=0;else for(b=1;b<a.g.length;b++){var c=a.g[b];if(c.Oa){if(!$h(a,a.g,c,!0))break;b=0}}}
function cd(a,b,c,d,e){var f=!1;if(!a.sb++)for(var g=1;!f&&g<d.length;g++){var h=d[g];if(!e||h.Oa)for(var l=a.ca(h),m=0;m<c;m++)if(b+m==l){var n,f=!0;h.Oa&&($h(a,d,h,!0),e=!0);if(n=h.Hc){for(var f=!1,r=0;r<n.length;r++)if(!ci(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.B.Z||(f=!0)}if(f){e||ai(a,d,g,"hit");break}}}a.sb--;return f}
function di(a,b,c,d){var e=Z(b.F),f=a.pa(b,2),g,h;for(h in a.vb)if(g=a.vb[h][f&h])break;g||(g=Nh);var l=g[0];0<=a.Ob.indexOf(l)&&(g=Nh,l=g[0]);var m=h="",n=Lh[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=Vh(y);break;case 8:x="@"+Vh(y);break;case 16:7>y?x="("+Vh(y)+")+":(A=w.pa(t,2),x="#"+J(w,A,0,!0));break;case 24:7>y?x="@("+Vh(y)+")+":(A=w.pa(t,2),x="@#"+J(w,A,0,!0));break;case 32:x="-("+Vh(y)+")";break;case 40:x="@-("+Vh(y)+")";break;case 48:A=w.pa(t,2);x=J(w,A,0,!0)+"("+Vh(y)+")";7==y&&(x=J(w,A+t.F&65535));break;case 56:A=w.pa(t,2),x="@"+J(w,A)+"("+Vh(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.pa(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.B.wb?g+("cycles="+ld(a.b).toString()+" cs="+p(a.b.Hb)):g+(null!=d?"="+d.toString():""),m&&(g+=" @"+m);return g}function ei(a,b){switch(b){case "N":a=a.b.Ta();break;case "Z":a=xd(a.b);break;case "V":a=wd(a.b);break;case "C":a=vd(a.b);break;default:a=0}return b.charAt(0)+(a?"1":"0")+" "}
function fi(a,b){var c="",d=a.b;8>b?(c=Vh(b),c+="="+J(a,d.u[b])):13>b?c="A"+(b-8)+"="+J(a,d.Wa[b-8]):16<=b&&20>b?c="S"+(b-16)+"="+J(a,d.Ia[b-16]):20==b?c="PS="+J(a,gc(d)):21==b&&a.f&&fc(a.f)&&(c="SW="+J(a,a.f.Va,3));c&&(c+=" ");return c}function gi(a){var b,c="";for(b=0;6>b;b++)c+=fi(a,b);c=c+"\n"+(fi(a,6)+fi(a,7));c+=fi(a,20)+fi(a,21);return c+=ei(a,"T")+ei(a,"N")+ei(a,"Z")+ei(a,"V")+ei(a,"C")}k.oc=function(a,b){return a[0]>b[0]?1:a[0]<b[0]?-1:0};
function pg(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.oc);0>r&&n.splice(-(r+1),0,l)}m&&(h.a=m.replace(/''/g,'"'))}a.J.push({Se:b,F:c,Uc:d,ia:e,mc:f})}function hi(a,b,c){var d=[],e=a.ca(b)>>>0;for(b=0;b<a.J.length;b++){var f=a.J[b],g=f.F>>>0,h=f.Uc;if(e>=g&&e<g+h){e=Aa(f.mc,[e-g],a.oc);0<=e?ii(a,b,e,d):c&&(e=~e,ii(a,b,e-1,d),ii(a,b,e,d));break}}return d}
function ii(a,b,c,d){var e={},f=a.J[b].mc,g=0,h=null;0<=c&&c<f.length&&(g=f[c][0],h=f[c][1]);h&&(e=a.J[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 ji(a,b){var c=b.match(/^\s*([A-Z_]?[A-Z0-9_]*)\s*(=?)\s*(.*)$/i);if(c){if(!c[1])return Fh(a)||a.j("no variables"),!0;if(!c[2])return Fh(a,c[1]);if(!c[3])return delete a.Y[c[1]],!0;b=Bh(a,c[3]);return void 0!==b?(a.Y[c[1]]=b,!0):!1}a.j("invalid assignment:"+b);return!1}
function ki(a,b,c){var d=null;if(b=Qh(a,b,!0)){a.ca(b);var e=hi(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 Xh(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=Bh(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":O(d,f);a.L=Z(d.u[7]);break;case "N":d.X=f?32768:0;break;case "Z":d.ba=
f?0:1;break;case "V":d.U=f?32768:0;break;case "C":d.T=f?65536:0;break;case "SW":if(a.f&&fc(a.f)){e=a.f;if(fc(e)){e.Va=f;for(b=0;22>b;b++)e.g["S"+b][0]=f&1<<b?1:0;Gb(e)}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.A.$();a.j("updated registers:")}a.j(gi(a));c&&(a.L=Z(d.u[7]),Yh(a,J(a,a.L.F)))}}function li(a,b){b=ya(b);var c=b.match(/^(['"])(.*?)\1$/);c?1<c[2].length?a.j(c[2]):Eh(a,null,c[2].charCodeAt(0)):Bh(a,b,!0)}
function mi(a,b,c){var d="t"!=b;c=Dh(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.jb(e,d,!1)},function(){a.f&&a.f.stop&&a.f.stop();a.A.$();rb(a,!1)})}
function Yh(a,b,c,d){if(b=Qh(a,b,!0)){void 0===d&&(d=1);var e=256;if(void 0!==c)if("l"==c.charAt(0))c=Dh(a,c.substr(1)),null!=c&&(d=c);else{d=Qh(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.S?a.K:null;var g=null!=f?"cycles":null,h=hi(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=di(a,b,g,f);a.j(f);a.L=b;e-=b.F-l;c++}}}
function ci(a,b,c){var d=!0;try{b.length&&"end"!=b?c||a.j(">> "+b):(a.R&&(a.j("ended assemble at "+J(a,a.P.F)),a.L=a.P,a.R=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.ka=null;if(tb(a)&&0<b.length){a.R&&(b="a "+J(a,a.P.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=
Qh(a,g[1],!0);if(r)if(a.P=r,void 0===g[2])a.j("begin assemble at "+J(a,r.F)),a.R=!0,a.A.$();else{var t;a.j("not supported yet");t=[];if(t.length){for(var w=0;w<t.length;w++)a.Xb(r,t[w],1);a.j(di(a,a.P))}}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 ja=y.charAt(1);if("l"==ja){var Ja;Ja=0+bi(a,a.g);Ja+=bi(a,a.N);(Ja+=bi(a,a.D))||a.j("no breakpoints")}else if("n"==ja)a.ua=Dh(a,x),a.j("break after "+a.ua+" instruction(s)");else if(void 0===x)a.j("missing breakpoint address");else{var Q=Z();if("*"!=x&&(Q=Qh(a,x,!0),!Q))break a;"c"==ja?null==Q.F?(Hh(a),a.j("all breakpoints cleared")):$h(a,a.g,Q)||$h(a,a.N,Q)||$h(a,a.D,Q)||a.j("breakpoint missing: "+J(a,Q.F)):null!=Q.F&&(Uh(a,Q,A),"p"==ja?a.nb(a.g,
Q):"r"==ja?a.nb(a.N,Q):"w"==ja?a.nb(a.D,Q):a.j("unknown breakpoint command: "+ja))}}}break;case "c":a.Ra&&(a.Ra.value="");break;case "d":a:{var fb,gb=g[0],ma=g[1],La=g[2],Fi=g[3];if("?"==ma){var hb="";for(fb in xb)a.Na[fb]&&(hb&&(hb+=","),hb+=fb);hb+=",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");
hb.length&&a.j("dump extension commands:\n\t"+hb)}else if("state"==ma){var sg=ni(a.A,!0);"console"==La?console.log(sg):(a.Ra&&(a.Ra.value=""),a.j(sg))}else if("symbols"==ma)for(var Fd=0;Fd<a.J.length;Fd++){var Gd=a.J[Fd],ib;for(ib in Gd.ia)if("."!=ib.charAt(0)){var tg=Gd.ia[ib].o;if(void 0!==tg){var ug=Gd.ia[ib].l;ug&&(ib=ug);a.j(J(a,tg)+" "+ib)}}}else{if("d"==gb){for(fb in xb)if(g[1]==fb){var vg=a.Na[fb];vg?(g.shift(),g.shift(),vg(g)):a.j("no dump registered for "+ma);break a}ma||(gb=a.Vb||"dw")}else a.Vb=
gb;if("dh"==gb){var wg=ma,xg=La,yg="",zg=0,fa=a.aa,na=a.H;if(na.length){var aa=+wg||a.ub,Jb=+xg||10;isNaN(aa)?aa=Jb:yg="more ";aa>na.length&&(a.j("note: only "+na.length+" available"),aa=na.length);fa-=aa;0>fa&&(null==na[na.length-1].F?(aa=fa+aa,fa=0):fa+=na.length);var Hd=[];"call"==xg&&(Jb=1E5,Hd=["CALL"]);for(void 0!==wg&&a.j(aa+" instructions earlier:");0<Jb&&fa!=a.aa;){var Ag=na[fa++];if(null==Ag.F)break;var Kb=Z(Ag.F),Gi=aa--,Bg=di(a,Kb,"history",Gi);(!Hd.length||0<=Bg.indexOf(Hd[0]))&&a.j(Bg);
Kb.bc&&(fa+=Kb.bc,Jb-=Kb.bc,aa-=Kb.bc);fa>=na.length&&(fa=0);a.ub=aa;zg++;Jb--}}zg||(a.j("no "+yg+"history available"),a.ub=void 0)}else{var Lb=Qh(a,ma);if(Lb){var Ac=0;La&&("l"==La.charAt(0)&&(La=La.substr(1)||Fi),Ac=Dh(a,La)>>>0,65536<Ac&&(Ac=65536));for(var Mb="dd"==gb?4:"db"==gb?1:2,Bc=Mb*Ac||128,Hi=Bc+15>>4||1,Nb="";Hi--&&0<Bc;){var Id="",Cg="",ma=J(a,Lb.F),Ob,jb,Cc=0,Pb=0;for(Ob=a.da;0<Ob&&0<Bc;Ob-=jb,Bc-=jb){jb=1;var Dc=1==Mb?a.Gb(Lb,jb):a.pa(Lb,jb=2),Cc=Cc|Dc<<(Pb<<3),Pb=Pb+jb;Pb==Mb&&(Id+=
J(a,Cc,Mb),Id+=1==Mb?9==Ob?"-":" ":" ",Cc=Pb=0);Cg+=32<=Dc&&128>Dc?String.fromCharCode(Dc):"."}Nb&&(Nb+="\n");Nb+=ma+" "+Id+(0==Ob?" "+Cg:"")}Nb&&a.j(Nb);a.mb=Lb}}}}break;case "e":if("else"==g[0])break;var kb,Jd,Kd,Ld,Md=g[0],Nd=g[1];"eb"==Md?(kb=1,Jd=255,Kd=a.Gb,Ld=a.Xb):"e"==Md||"ew"==Md?(kb=2,Jd=65535,Kd=a.pa,Ld=a.hb):Nd=null;if(null==Nd)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 Ec=Qh(a,Nd);if(Ec)for(var Fc=
2;Fc<g.length;Fc++){var Qb=Bh(a,g[Fc]);if(void 0===Qb){a.j("unrecognized value: "+g[Fc]);break}Qb&~Jd&&a.j("warning: "+p(Qb)+" exceeds "+kb+"-byte value");a.j("changing "+J(a,Ec.F)+(F(a,64)?"":" from "+J(a,Kd.call(a,Ec),kb))+" to "+J(a,Qb,kb));Ld.call(a,Ec,Qb,kb)}}break;case "g":a:{var Dg=g[1],Ii=b;if(void 0!==Dg){var Od=Qh(a,Dg,!0);if(!Od)break a;Uh(a,Od,Ii);a.nb(a.g,Od,!0)}a.ib(!0,c)}break;case "h":a.B.Z?(c||a.j("halting"),a.ha()):sb(a,!0)||c||a.j("already halted");break;case "i":if("if"==g[0]){var Pd;
var Rb=b.substr(2),Rb=ya(Rb);Bh(a,Rb)?(c||a.j("true: "+Rb),Pd=!0):(c||a.j("false: "+Rb),Pd=!1);Pd||(d=!1);break}f=!0;break;case "k":var Ji=g[0];if("?"==g[1])a.j("stack trace commands:"),a.j("\tk\tshow frame addresses"),a.j("\tks\tshow symbol information");else{var Qd=0,Rd=Z(),Sb=Z(a.b.u[6]);for(a.j("stack trace for "+J(a,Sb.F));10>Qd;){for(var Ma=null,Ki=256;65536>Sb.F>>>0;){Rd.F=a.pa(Sb,2);if(null==Sb.F||!Ki--)break;if(!(Rd.F&1)){for(var Li=a,Gc=Rd,Eg=null,Tb=Gc.F,Fg=Tb,Sd=1;6>=Sd&&Tb;Sd++){if(2<
Sd){Gc.F=Tb;var Hc=di(Li,Gc);if(0<=Hc.indexOf("JSR")){var Gg=Hc.indexOf(" ");if(Tb+(Hc.indexOf(" ",Gg+1)-Gg-1)/2==Fg){Eg=Hc;break}}}Tb-=2}Gc.F=Fg;if(Ma=Eg)break}}if(!Ma||null==Ma)break;var Hg=null;if("ks"==Ji){var Ig=Ma.match(/[0-9A-F]+$/);Ig&&(Hg=ki(a,Ig[0]))}Ma=xa(Ma,50)+" ;"+(Hg||"stack="+J(a,Sb.F));a.j(Ma);Qd++}Qd||a.j("no return addresses found")}break;case "l":if("ln"==g[0]){ki(a,g[1],!0);break}f=!0;break;case "m":a:{var oa,pa=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)pa=!0,G=null;else if("off"==G)pa=!1,G=null;else{"keys"==G&&(G="key");"kbd"==G&&(G="keyboard");for(oa in xb)if(G==oa){Da=xb[oa];pa=!!(a.oa&Da);break}if(!Da){a.j("unknown message category: "+G);break a}}if(Da)if("on"==g[2])a.oa|=Da,pa=!0;else if("off"==g[2]&&(a.oa&=~Da,pa=!1,1073741824==Da)){for(var Td=0;Td<a.wa.length;Td++)a.j(a.wa[Td]);a.wa=[]}}var Mi=0,Ub="";for(oa in xb)if(!G||G==oa){var Ni=!!(a.oa&xb[oa]);if(null===pa||pa==Ni)Ub&&(Ub+=","),++Mi%10||(Ub+="\n\t"),
"key"==oa&&(oa="keys"),Ub+=oa}void 0===G&&a.j("message commands:\n\tm [category] [on|off]\tturn categories on/off");a.j((null!==pa?pa?"messages on: ":"messages off: ":"message categories:\n\t")+(Ub||"none"));Ih(a)}break;case "p":if("print"==g[0]){li(a,b.substr(5));break}var Oi="pr"==g[0]?1:0;if(a.S)a.j("step in progress");else{var Jg=Z(a.b.u[7]);a.Gb(Jg);a.S?(a.nb(a.g,Jg,!0),a.ib()||(a.A&&a.A.rb(),a.S=0)):mi(a,Oi?"tr":"t")}break;case "r":if("reset"==b){a.A&&a.A.reset();break}Xh(a,g);break;case "s":a:switch(g[1]){case "base":if(g[2]){var Vb=
+g[2];if(8==Vb||10==Vb||16==Vb)a.da=Vb;else{a.j("invalid base: "+Vb);break}}a.j("default base: "+a.da);break;case "cs":var Wb;void 0!==g[3]&&(Wb=+g[3]);switch(g[2]){case "int":a.b.yb=Wb;break;case "start":a.b.Ib=Wb;break;case "stop":a.b.zb=Wb;break;default:a.j("unknown cs option");break a}void 0!==Wb&&jd(a.b);a.j("checksums "+(a.b.B.wb?"enabled":"disabled"));break;case "sp":void 0!==g[2]&&(md(a.b,+g[2])||a.j("warning: using 1x multiplier, previous target not reached"));a.j("target speed: "+(a.b.ob.toFixed(2)+
"Mhz")+" ("+a.b.cb+"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":mi(a,g[0],g[1]);break;case "u":Yh(a,g[1],g[2],8);break;case "v":if("var"==g[0]){ji(a,b.substr(3))||(d=!1);break}if("ver"==
g[0]){a.j("PDPjs version 1.30.2 ("+a.b.xb+",RELEASE"+(wb?",TYPEDARRAYS":",LONGARRAYS")+")");a.j(window?window.navigator.userAgent:"");break}f=!0;break;case "?":if(g[1]){li(a,b.substr(1));break}var Ud="commands:",Vd;for(Vd in Kh)Ud+="\n"+xa(Vd,9)+Kh[Vd];ke(a)||(Ud+="\nnote: history disabled if no exec breakpoints");a.j(Ud);break;default:f=!0}f&&(a.j("unknown command: "+b),d=!1)}}catch(Kg){a.j("debugger error: "+(Kg.stack||Kg.message)),d=!1}return d}
function kd(a,b,c){b=zh(a,b,c);for(var d in b)if(!ci(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 Gh(d);C(d,c)}});
function oi(a,b,c){u.call(this,"Computer",a,oi,67108864);this.B.ja=!1;pi(this,b);this.L=hd(this,"autoPower",a);this.v=0;this.Y=a.busWidth||a.buswidth;this.g=qi;this.J=null;this.D=this.R=!1;this.aa=hd(this,"url")||"";(Math.random()+.1).toString(36);this.A=ri(this);if(this.b=qb("CPU",this.id)){this.i=qb("Debugger",this.id);this.w=new ic({id:this.Qa+".bus",busWidth:this.Y},this.b,this.i);var d,e=ob(this.id);if((this.f=qb("Panel",this.id))&&this.f.Ra)for(b=0;b<e.length;b++)d=e[b],d.O=this.f.O,d.j=this.f.j,
d.Ra=this.f.Ra;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.Ea&&d.Ea(this,this.w,this.b,this.i);b=null;d=a.resume;void 0!==d&&(1<d.length?b=this.H=d:this.g=parseInt(d,10));var f;if(a=hd(this,"state")||(f=!0,a.state))b=this.N=a,f||(this.D=!0,this.g=qi),this.g&&(this.K=
new P(this,"1.30.2"),si(this.K)?b=null:delete this.K);!b&&this.g&&(b=ti(this))&&(this.D=!0);if(b){var g=this;Ea(b,null,!0,function(a,b,c){c?(g.H=null,g.D=!1,g.O("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&&ui(this,this.Jb)}else q("Unable to find CPU component")}z(oi);var qi=0;
function pi(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 hd(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 ui(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(){ui(a,b,c)});return}}b.call(a,c)}
function vi(a,b){var c=new P(a,"1.30.2","validate");if(si(c)&&wi(c)){var d=c.get("timestamp"),e=b?b.get("timestamp"):"unknown";d!=e&&(a.O("Machine state may be out-of-date\n("+d+" vs. "+e+")\nCheck your browser's local storage limits"),b||c.clear())}}k=oi.prototype;
k.Jb=function(a){void 0===a&&(a=this.g||(this.J?1:qi));if(!this.v){this.v++;var b=!1,c=!1;this.P=!1;var d=this.K||new P(this,"1.30.2");if(-1==a)b=!0;else if(a>qi){if(si(d,this.J)){this.C=new P(this,"1.30.2","failsafe");si(this.C)&&(xi(this,d),a=2,yi(this.C));this.C.set("timestamp",Ca());zi(this.C);var e=this.g&&!this.D;if(1==a||Ha("Click OK to restore the previous PDPjs machine state, or CANCEL to reset the machine.")){if(c=wi(d)){var f=d.get("code"),g=d.get("data");f&&("ok"==f?si(d,g):("error"==
f&&"no machine state"!=g?(this.O("Error: "+g),"unable to verify user"==g&&(Oa("user",""),this.A=null)):this.j(f+": "+g),yi(d),si(d)?(c=wi(d),e=!0):c=!1))}e&&vi(this,c?d:null)}else 2==a&&d.clear()}else vi(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=Ai(this,g,d,b,c));b=[d,a,c];-1!=a?ui(this,this.pc,b):this.pc(b)}};
function Ai(a,b,c,d,e){if(!b.B.ja){b.B.ja=!0;if(b.Ha){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.Ha(f,d)&&f&&(q("Unable to restore state for "+b.type),a.N&&!a.R?(c.clear(),a.g=qi,window&&window.location.reload()):a.P=!0,b.Ha(null),e=!1)}if(!d&&b.qc)for(a=b.qc.split("|"),c=0;c<a.length;c++)b.status(a[c])}return e}
k.pc=function(a){var b=a[0],c=0>a[1];a=a[2];this.da=!0;this.B.ja=!0;var d=this.G.power;d&&(d.textContent="Shutdown");this.b&&(Ai(this,this.b,b,c,a),this.$(),this.b.tb());this.P&&(xi(this,b),b.clear());!c&&this.C&&(this.C.clear(),delete this.C);this.v=0};
function xi(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.A||"";b=b.toString();var d={app:"PDPjs",ver:"1.30.2"};d.url=a.aa;d.user=c;d.type="bug";d.data=b;Ea("http://www.pcjs.org/api/v1/report",d,!0)}}
function ni(a,b,c){var d,e="none";if(a.v)return null;a.v--;var f=new P(a,"1.30.2"),g=new P(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.Ga&&(c&&a.b.ha(),d=a.b.Ga(b,c),"object"===typeof d&&f.set(a.b.id,d),c&&(a.b.B.ja=!1,!1===d&&(e=null)));for(var h=ob(a.id),l=0;l<h.length;l++){var m=h[l];m.B.ja&&(m.Ga&&(d=m.Ga(b,c),"object"===typeof d&&f.set(m.id,
d)),c&&(m.B.ja=!1,!1===d&&(e=null)))}e&&(c?(h=d=!1,b?(a.A&&Bi(a,a.A,f.toString()),zi(g)&&zi(f)||(e=null,d=h=!0)):a.g&&(d=!0,h=3==a.g),d&&f.clear(h)):e=f.toString());c&&(a.B.ja=!1,b=a.G.power)&&(b.textContent="Power");a.v=0;return e}
k.reset=function(){this.w&&this.w.reset&&(E(this,"Resetting "+this.w.type),this.w.reset());this.b&&this.b.reset&&(E(this,"Resetting "+this.b.type),this.b.reset());for(var a=ob(this.id),b=0;b<a.length;b++){var c=a[b];c!==this&&c!==this.w&&c!==this.b&&c.reset&&(E(this,"Resetting "+c.type),c.reset())}this.$(!0)};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.$(!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.$(!0)};k.$=function(a){this.b&&this.b.$(a);this.f&&this.f.$(a)};
k.ta=function(a,b,c){var d=this;switch(b){case "power":return this.G[b]=c,c.onclick=function(){d.v||(d.B.ja?ni(d,!1,!0):ui(d,d.Jb))},!0;case "reset":return this.G[b]=c,c.onclick=function(){if(d.B.ja&&!d.v)if(d.g&&!d.H){var a=Ha("Click OK to save changes to this PDPjs machine.\n\nWARNING: If you CANCEL, all disk changes will be discarded.");ni(d,a,!0);!a&&d.N?window&&window.location.reload():(a||(d.rc=!0),d.Jb(qi),d.rc=!1)}else d.reset(),d.b&&d.b.tb()},!0;case "save":if(ua(Ga(),"pcjs.org"))c.parentNode.removeChild(c);
else return this.G[b]=c,c.onclick=function(){var a=ri(d,!0);if(a){var b=!!(d.g&&!d.H||d.N),c=ni(d,b);b?Bi(d,a,c):d.O("Resume disabled, machine state not saved")}},!0}return!1};
function ri(a,b){var c=a.A;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=Ci(a,c))||a.O("The user ID is invalid.")):b&&a.O("Browser local storage is not available"));return c}
function Ci(a,b){a.A=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.A=b.data)}catch(d){q(d.message+" ("+c+")")}return a.A}function ti(a){var b=null;a.A&&(b=Ga()+"/api/v1/user?req=load&user="+a.A+"&state="+Di(a,"1.30.2"));return b}
function Bi(a,b,c){if(c){var d={req:"store"};d.user=b;d.state=Di(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.O("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.O(c),Oa("user",""),a.A=null)}}
function Ug(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.rb=function(a){if(this.Ra){var b=0,c=0;!a&&window&&(b=window.scrollX,c=window.scrollY);this.Ra.focus();!a&&window&&window.scrollTo(b,c)}};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 oi(g,d,!0);C(g,f);g.L&&ui(g,g.Jb)}});
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.B.ja&&c.Jb(-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.B.ja&&ni(c,!(!c.g||c.H),!0)}});function P(a,b,c){this.id=a.id;this.key=Di(a,b,c);this.i=a.i;yi(this,a.Sc)}function Di(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}
P.prototype={constructor:P,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){yi(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 yi(a,b){a[a.id]={};b&&a.set("parms",b);a.b=!1}function zi(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 wi(a){var b=!0;try{a[a.id]=JSON.parse(a[a.id])}catch(c){q(c.message||c),b=!1}return b}function si(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 Ei=0;
function Pi(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)):Qi(h,a,b,c,d,e,f)})}
function Qi(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?Ri(a,f,h):h(a,null):g("no data"+(b?" for file: "+b:""),null)}
function Ri(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);Ri(a,b,c)}})}else c(a,null)}
function Si(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&&(--Ei||Za(!0));l=!1}var g,h,l=!0;Ei++;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?Pi(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,--Ei||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),--Ei||Za(!0)):f("invalid machine element: "+
a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser")):f(d)}):f(d)};"<"!=b.charAt(0)?Pi(b,a,d,!0,e,m):Qi(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 Si(a,b,c,d)};window.enableEvents=Za;window.sendEvent=$a;})();//# sourceMappingURL=/tmp/pdpjs/1.30.2/pdp11-dbg.map