Made a tiny 72-bit division optimization

This commit is contained in:
Jeff 2017-04-02 11:43:54 -07:00 • committed by Jeff Parsons
commit 3fb3f44384
3 changed files with 33 additions and 34 deletions

View file

@ -43,7 +43,7 @@ e[c]&255,d.I[f++]=e[c]>>8&255,d.I[f++]=e[c]>>16&255,d.I[f++]=e[c]>>24&255;else(e
function pa(){return"http://"+(window?window.location.host:"www.pcjs.org")}function va(){if(null==wa){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}wa=a}return wa}function xa(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(c){}return b}
function ya(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function za(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)}return!1}
function Aa(a){if(!Ba){var b,c={};if(window){b||(b=window.location.search.substr(1));for(var d,e=/\+/g,f=/([^&=]+)=?([^&]*)/g;d=f.exec(b);)c[decodeURIComponent(d[1].replace(e," "))]=decodeURIComponent(d[2].replace(e," "))}Ba=c}return Ba[a]}function Ca(a,b){if(window){var c=window[a];window[a]="function"!==typeof c?b:function(){c&&c();b()}}}function Da(a){r.init.push(a)}
function Ea(a){if(Ga)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 Ha(a){!Ga&&a?(Ga=!0,Ia&&Ja("init"),Ka&&Ja("show")):Ga=a}function Ja(a){r[a]&&Ea(r[a])}var Ba=null,r={init:[],show:[],exit:[]},Ia=!1,Ka=!1,Ga=!0,wa=null;Ca("onload",function(){Ia=!0;Ea(r.init)});Ca("onpageshow",function(){Ka=!0;Ea(r.show)});Ca(za("Opera")||za("iOS")?"onunload":"onbeforeunload",function(){Ea(r.exit)});
function Fa(a){if(Ga)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 Ha(a){!Ga&&a?(Ga=!0,Ia&&Ja("init"),Ka&&Ja("show")):Ga=a}function Ja(a){r[a]&&Fa(r[a])}var Ba=null,r={init:[],show:[],exit:[]},Ia=!1,Ka=!1,Ga=!0,wa=null;Ca("onload",function(){Ia=!0;Fa(r.init)});Ca("onpageshow",function(){Ka=!0;Fa(r.show)});Ca(za("Opera")||za("iOS")?"onunload":"onbeforeunload",function(){Fa(r.exit)});
function t(a,b){this.type=a;b||(b={id:"",name:""});this.id=b.id||"";this.name=b.name;this.Va=b.comment;this.ib=b;this.exports={};this.m=this.bindings={};a=this.id.indexOf(".");0>a?this.va=this.id:(this.wa=this.id.substr(0,a),this.va=this.id.substr(a+1));this.h={ready:!1,Aa:!1,Oa:!1,F:!1,error:!1};this.Ca=null;this.h.error=!1;this.w=this.j=this.s=this.v=this.ga=null;v.push(this)}function La(a,b,c){Ma[a]&&b&&(Ma[a][b]=c)}function Na(){return Date.now()||+new Date}
function q(a){window&&window.alert(a)}function Oa(a){var b=!1;window&&(b=window.confirm(a));return b}function w(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 Pa(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 x(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 y(a){var b=null;if(a=a.getAttribute("data-value"))try{b=eval("("+a+")")}catch(c){q(c.message+" ("+a+")")}return b}
@ -101,8 +101,8 @@ function oc(a,b){this.c(b,this.b(this.a))}function pc(a,b){this.c(b,this.a)}func
function yc(a,b){var c=this.b(this.a),d=c;if(a&=384)switch(d-=d&C,a){case 256:d+=C;break;case 384:d+=c>F?C:0}c=d;this.c(this.a,c);b&&this.c(b,c)}function zc(a,b){var c=(this.b(this.a)&C)*E,d=this.b(b);this.c(b,vc(a,d,c)+c)}function Ac(a,b){var c=this.a*E,d=this.b(b);this.c(b,vc(a,d,c)+c)}function Bc(a,b){b=(this.b(b)&C)*E;var c=this.b(this.a);this.c(this.a,vc(a,c,b)+b)}function Cc(a,b){var c=this.b(this.a),d=(c&C)*E,c=vc(a,c,d)+d;this.c(this.a,c);b&&this.c(b,c)}
function Dc(a,b){var c=this.b(this.a)&C,d=this.b(b);this.c(b,Ec(a,d,c)+c)}function Fc(a,b){var c=this.b(b);this.c(b,Ec(a,c,this.a)+this.a)}function Gc(a,b){b=this.b(b)&C;var c=this.b(this.a);this.c(this.a,Ec(a,c,b)+b)}function Hc(a,b){var c=this.b(this.a),d=c;if(a&=384)switch(d&=C,a){case 256:d+=C*E;break;case 384:d+=c>ab?C*E:0}c=d;this.c(this.a,c);b&&this.c(b,c)}function Ic(a,b){var c=this.b(this.a)/E|0,d=this.b(b);this.c(b,Ec(a,d,c)+c)}function Jc(a,b){var c=this.b(b);this.c(b,Ec(a,c,0))}
function Kc(a,b){b=this.b(b)/E|0;var c=this.b(this.a);this.c(this.a,Ec(a,c,b)+b)}function Lc(a,b){var c=this.b(this.a),d=c/E|0,c=Ec(a,c,d)+d;this.c(this.a,c);b&&this.c(b,c)}function Q(a){Mc[a&7].call(this,a,a>>3&127)}function Nc(){}function Oc(){}function O(a){this.M("undefined opcode: "+ka(a));this.f=(this.f+-1)%$a;N(this)}function Pc(a){a>F&&(a!=G?a=db-a:this.g|=163840);return a}function R(a,b){var c=(a+b)%J;Qc.call(this,a,b,c);return c}
function S(a,b,c){var d=!1,e=!1;if(void 0===c){if(!a)return this.g|=131104,-1;c=b>F?I:0}else{var f=b<G?b:db-b;if((c<G?c:db-c-(f?1:0))>=(a<G?a:db-a))return this.g|=131104,-1}f=c-c%G;b=b%G+(c&1)*G;c=this.l=f+Math.trunc(c/2);a>F&&(a=J-a,d=!d);c>F&&(b?(c=I-c,b=J-b):c&&(c=J-c),e=!0,d=!d);f=this.Na;f[0]=0;f[1]=0;f=this.da;f[0]=1;f[1]=0;f=this.X;f[0]=a;f[1]=0;a=this.ea;a[0]=b;for(a[1]=c;0<Rc(this.ea,this.X);)Sc(this.X,this.X),Sc(this.da,this.da);do{if(0<=Rc(this.ea,this.X)&&(c=this.ea,a=this.X,c[0]-=a[0],
c[1]-=a[1],0>c[0]&&(c[0]+=J,c[1]--),Sc(this.Na,this.da),Tc(this.ea)))break;Uc(this.X);Uc(this.da)}while(!Tc(this.da));b=this.Na[0];this.l=this.ea[0];d&&b&&(b=J-b);e&&this.l&&(this.l=J-this.l);return b}
function S(a,b,c){var d=!1,e=!1;if(void 0===c){if(!a)return this.g|=131104,-1;c=b>F?I:0}else if((c<G?c:db-c-(b?1:0))>=(a<G?a:db-a))return this.g|=131104,-1;var f=c-c%G;b=b%G+(c&1)*G;c=this.l=f+Math.trunc(c/2);a>F&&(a=J-a,d=!d);c>F&&(b?(c=I-c,b=J-b):c&&(c=J-c),e=!0,d=!d);f=this.Na;f[0]=0;f[1]=0;f=this.da;f[0]=1;f[1]=0;f=this.X;f[0]=a;f[1]=0;a=this.ea;a[0]=b;for(a[1]=c;0<Rc(this.ea,this.X);)Sc(this.X,this.X),Sc(this.da,this.da);do{if(0<=Rc(this.ea,this.X)&&(c=this.ea,a=this.X,c[0]-=a[0],c[1]-=a[1],
0>c[0]&&(c[0]+=J,c[1]--),Sc(this.Na,this.da),Tc(this.ea)))break;Uc(this.X);Uc(this.da)}while(!Tc(this.da));b=this.Na[0];this.l=this.ea[0];d&&b&&(b=J-b);e&&this.l&&(this.l=J-this.l);return b}
function Vc(a,b,c,d){var e=a,f=b;b=!1;var g;e>F&&(d||1001!=this.Wa||e!=G)&&(e=J-e,b=!b);f>F&&(f=J-f,b=!b);if(e<E&&f<E)a=e*f,g=0;else{a=e&C;e=Math.trunc(e/E);g=f&C;var f=Math.trunc(f/E),h=a*g,m=e*g+Math.trunc(h/E);g=Math.trunc(m/E);m=(m&C)+a*f;a=(m*E+(h&C))%J;g+=Math.trunc(m/E)+e*f}b&&(a?(g=I-g,a=J-a):g&&(g=J-g));b=a;a=g;e=a-a%G;a=2*a%J+Math.trunc(b/G);b=e+b%G;a-a%G!=e&&(b=a);d?g=b:(b==G&&a==G&&(this.g|=131072),this.l=b,g=a);c&&(a=this.l,!d&&(g||a>F)&&(g!=I||a<=F)&&(this.g|=131072),g=a);return g}
function Wc(a){a?a==G?this.g|=163840:a=db-a:this.g|=98304;return a}function Xc(a,b){var c=a-b;0>c&&(c+=J);Qc.call(this,c,b,a);return c}function Qc(a,b,c){a=Math.trunc(a/cb);b=Math.trunc(b/cb);c=Math.trunc(c/cb);var d=a^(a^b)&(b^c);this.g=this.g|(d&2?65536:0)|(d&1?32768:0)|((a^c)&(b^c)&2?131072:0)}function T(a,b){return((a/K|0)&(b/K|0))*K+((a&b)>>>0)}function U(a,b){return T(a,(~(b/K|0)&15)*K+(~b>>>0))}function V(a,b){return(a<G?a:a-J)-(b<G?b:b-J)}
function Yc(a,b){return(~((a/K|0)^(b/K|0))&15)*K+(~(a^b)>>>0)}function W(a,b){return(a/K|0|b/K|0)*K+((a|b)>>>0)}function X(a){return a<G?a:a-J}function Y(a,b){return((a/K|0)^(b/K|0))*K+((a^b)>>>0)}function Z(a){return(a/E|0)+(a&C)*E}function Ec(a,b,c){switch(a&384){case 0:b-=b&C;break;case 128:b=0;break;case 256:b=C*E;break;case 384:b=c>ab?C*E:0}return b}function vc(a,b,c){switch(a&384){case 0:b&=C;break;case 128:b=0;break;case 256:b=C;break;case 384:b=c>F?C:0}return b}
@ -188,7 +188,7 @@ function Jd(a,b,c,d,e,f,g,h){function m(a,g){if(g)h(g,null);else{c&&(La(c,b,a),(
a=a.replace(/(<xsl:variable name="APPCLASS">).*?(<\/xsl:variable>)/,"$1"+d+"$2"));g=null;if("<"==a.charAt(0))try{f||(a=a.replace(/<!DOCTYPE(.|[\r\n])*]>\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(g=new window.ActiveXObject("Microsoft.XMLDOM"),g.async=!1,g.loadXML(a)):g=(new window.DOMParser).parseFromString(a,"text/xml")}catch(H){g=null,a=H.message}else a="unrecognized XML: "+(255<a.length?a.substr(0,255)+"...":a);h(a,g)}}a?f?Kd(a,g,m):m(a,null):h("no data"+(b?" for file: "+b:""),null)}
function Kd(a,b,c){var d;if(d=/<([a-z]+)\s+ref="(.*?)"(.*?)\/>/g.exec(a)){var e=d[2];b("Loading "+e+"...");p(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 m=h[0],u,D=/( [a-z]+=)(['"])(.*?)\2/g;u=D.exec(f);)m=0>m.indexOf(u[1])?m.replace(">",u[0]+">"):m.replace(new RegExp(u[1]+"(['\"])(.*?)\\1"),u[0]);h[0]!=m&&(g=g.replace(h[0],m))}else{c(a,"missing <"+d[1]+"> in "+e);return}g=g.replace(/<\?xml[^>]*>[\r\n]*/,
"");a=a.replace(d[0],g);Kd(a,b,c)}})}else c(a,null)}
function Ld(a,b,c,d,e){function f(a){if(void 0===m){var b=h&&A(h,"machine-warning");m=b&&b[0]||h}m&&(m.innerHTML=qa(a))}function g(a){f("Error: "+a);u&&(--Hd||Ha(!0));u=!1}var h,m,u=!0;Hd++;Ma[b]={};try{if(h=document.getElementById(b)){var D;if("object"==typeof resources&&(D=resources.css)){var H=document.head||document.getElementsByTagName("head")[0],Fa=document.createElement("style");Fa.type="text/css";Fa.styleSheet?Fa.styleSheet.cssText=D:Fa.appendChild(document.createTextNode(D));H.appendChild(Fa)}d||
function Ld(a,b,c,d,e){function f(a){if(void 0===m){var b=h&&A(h,"machine-warning");m=b&&b[0]||h}m&&(m.innerHTML=qa(a))}function g(a){f("Error: "+a);u&&(--Hd||Ha(!0));u=!1}var h,m,u=!0;Hd++;Ma[b]={};try{if(h=document.getElementById(b)){var D;if("object"==typeof resources&&(D=resources.css)){var H=document.head||document.getElementsByTagName("head")[0],Ea=document.createElement("style");Ea.type="text/css";Ea.styleSheet?Ea.styleSheet.cssText=D:Ea.appendChild(document.createTextNode(D));H.appendChild(Ea)}d||
(D=a,"pdp"==a.substr(0,3)&&(D="pdpjs"),d="/versions/"+D+"/1.34.3/components.xsl");D=function(e,m){m?Id(d,null,a,null,!1,f,function(a,e){e?(La(b,d,a),f("Processing "+c+"..."),window.ActiveXObject||"ActiveXObject"in window?(e=m.transformNode(e))?(h.outerHTML=e,--Hd||Ha(!0)):g("transformNodeToObject failed"):document.implementation&&document.implementation.createDocument?(a=new XSLTProcessor,a.importStylesheet(e),(e=a.transformToFragment(m,document))?h.parentNode?(h.parentNode.replaceChild(e,h),--Hd||
Ha(!0)):g("invalid machine element: "+b):g("transformToFragment failed")):g("unable to transform XML: unsupported browser")):g(a)}):g(e)};"<"!=c.charAt(0)?Id(c,b,a,e,!0,f,D):Jd(c,null,b,a,e,!1,f,D)}else g("missing machine element: "+b)}catch(Md){g(Md.message)}return u}window.embedPDP10=function(a,b,c,d){Ha(!1);return Ld("pdp10",a,b,c,d)};window.embedPDP11=function(a,b,c,d){Ha(!1);return Ld("pdp11",a,b,c,d)};window.findMachineComponent=function(a,b){return x(b,a+".machine")};
window.processMachineScript=function(a,b){var c=!1;a+=".machine";if("string"==typeof b&&!Sa[a]){for(var c=!0,d=Sa,e=a,f=b.length,g=[],h=[],m="",u=null,D=0;D<f;D++){var H=b[D];if('"'==H||"'"==H)u&&H!=u?m+=H:(u?u=null:u=H,m&&(h.push(m),m=""));else{if(!u){if("\r"==H||"\n"==H)H=";";if(" "==H||"\t"==H||";"==H){m&&(h.push(m),m="");";"==H&&h.length&&(g.push(h),h=[]);continue}}m+=H}}m&&h.push(m);h.length&&g.push(h);d[e]=g;Ra(a)||(c=!1)}return c};window.enableEvents=Ha;window.sendEvent=Ja;})();//# sourceMappingURL=/tmp/pdpjs/1.34.3/pdp10.map