Fixed the signed truncation of 36-bit values (so that "-34,359,738,368. - 1" correctly produces "34359738367. aka 0o377777777777"), added the proper the right-to-left parsing of unary operators (all two of them: negate and complement), changed the PDP-10 disassembler to honor the selected base when displaying opcodes, and updated all the number-to-string conversions to select an appropriate number of digits when rendering values without a specified number of digits.

This commit is contained in:
Jeff 2017-03-20 13:34:25 -07:00 • committed by Jeff Parsons
commit a6021441c3
13 changed files with 665 additions and 637 deletions

View file

@ -33,9 +33,9 @@ function l(a,b){function c(){}c.prototype=b.prototype;a.prototype=new c;a.protot
ia("Math.trunc",function(a){return a?a:function(a){a=Number(a);if(isNaN(a)||Infinity===a||-Infinity===a||!a)return a;var b=Math.floor(Math.abs(a));return 0>a?-b:b}});ia("Math.log2",function(a){return a?a:function(a){return Math.log(a)/Math.LN2}});
var n={Hb:0,$a:1,Jb:2,Kb:3,Lb:4,Mb:5,Nb:6,Ob:7,Ua:8,Pb:9,ab:10,Qb:11,Rb:12,bb:13,Sb:14,Tb:15,Ub:16,Vb:17,Wb:18,Xb:19,Yb:20,Zb:21,$b:22,ac:23,bc:24,cc:25,dc:26," ":32,"!":33,'"':34,"#":35,$:36,"%":37,"&":38,"'":39,"(":40,")":41,"*":42,"+":43,",":44,"-":45,".":46,"/":47,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,":":58,";":59,"<":60,"=":61,">":62,"?":63,"@":64,Ta:65,Gb:66,Ib:67,ec:68,E:69,fc:70,gc:71,hc:72,ic:73,jc:74,kc:75,lc:76,mc:77,nc:78,oc:79,pc:80,Q:81,qc:82,rc:83,sc:84,tc:85,uc:86,vc:87,
wc:88,xc:89,eb:90,"[":91,"\\":92,"]":93,"^":94,_:95,"`":96,yc:97,zc:98,Ac:99,d:100,e:101,Bc:102,Cc:103,Dc:104,Ec:105,Fc:106,k:107,Gc:108,Hc:109,n:110,Ic:111,p:112,q:113,r:114,Jc:115,t:116,Kc:117,Lc:118,Mc:119,x:120,y:121,z:122,"{":123,"|":124,"}":125,"~":126,cb:127};
function ja(a,b,c,d){var e="";isNaN(a)?a=null:null!=a&&(0>a&&-1<a&&(a=-1),0>a&&(a+=Math.pow(b,c)),a>=Math.pow(b,c)&&(c=Math.ceil(Math.log(a)/Math.log(b))));if(null==a)for(;0<c--;)e="?"+e;else for(;0<c--;){var f=a%b,f=f+(0<=f&&9>=f?48:55),e=String.fromCharCode(f)+e;a=Math.trunc(a/b)}return(void 0===d?"":d)+e}function ka(a,b){b?12<b&&(b=12):b=a&-16777216?12:a&-65536?8:6;return ja(a,8,b,"")}function la(a,b,c){b?9<b&&(b=9):b=a&-65536?8:4;return ja(a,16,b,c?"0x":"")}
function ma(a){var b=a,c=a.lastIndexOf("/");0<=c&&(b=a.substr(c+1));c=b.indexOf("&");0<c&&(b=b.substr(0,c));return b}function na(a){var b="",c=a.lastIndexOf(".");0<=c&&(b=a.substr(c+1).toLowerCase());return b}function oa(){var a=pa();return-1!==a.indexOf("pcjs.org",a.length-8)}function qa(a){return a.replace(/[&<>"']/g,function(a){return ra[a]})}function sa(a){return String.prototype.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}var ra={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};
function ta(){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 ja(a,b,c,d){var e;e=void 0===e?-1:e;var f="";isNaN(a)?a=null:null!=a&&(0>a&&-1<a&&(a=-1),0>a&&(a+=Math.pow(b,c)),a>=Math.pow(b,c)&&(c=Math.ceil(Math.log(a)/Math.log(b))));for(var g=e;0<c--;){g||(f=","+f,g=e);if(null==a)f="?"+f;else{var h=a%b,h=h+(0<=h&&9>=h?48:55),f=String.fromCharCode(h)+f;a=Math.trunc(a/b)}g--}return(void 0===d?"":d)+f}function ka(a,b){b?12<b&&(b=12):(b=Math.abs(a),b=262143>=b?6:16777215>=b?8:12);return ja(a,8,b,"")}
function la(a,b,c){b?9<b&&(b=9):(b=Math.abs(a),b=65535>=b?4:4294967295>=b?8:9);return ja(a,16,b,c?"0x":"")}function ma(a){var b=a,c=a.lastIndexOf("/");0<=c&&(b=a.substr(c+1));c=b.indexOf("&");0<c&&(b=b.substr(0,c));return b}function na(a){var b="",c=a.lastIndexOf(".");0<=c&&(b=a.substr(c+1).toLowerCase());return b}function oa(){var a=pa();return-1!==a.indexOf("pcjs.org",a.length-8)}function qa(a){return a.replace(/[&<>"']/g,function(a){return ra[a]})}
function sa(a){return String.prototype.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}var ra={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};function ta(){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 p(a,b,c,d){c=void 0===c?!1:c;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 m="",u;for(u in b)b.hasOwnProperty(u)&&(m&&(m+="&"),m+=u+"="+encodeURIComponent(b[u]));m=m.replace(/%20/g,"+");h.open("POST",a,c);h.setRequestHeader("Content-type","application/x-www-form-urlencoded");h.send(m)}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 ua(a,b){var c,d={H:null,O:null,T:null,S: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")&&0>b.indexOf("0o")&&'["'!=b.substr(0,2)?JSON.parse(b.replace(/([a-z]+):/gm,'"$1":').replace(/\/\/[^\n]*/gm,"")):eval("("+b+")");d.T=g.load;d.S=g.exec;if(e=g.bytes)d.H=e;else if(e=g.words)for(d.H=Array(2*e.length),f=c=0;c<e.length;c++)d.H[f++]=e[c]&255,d.H[f++]=e[c]>>8&255;else if(e=g.longs)for(d.H=Array(4*e.length),f=c=0;c<e.length;c++)d.H[f++]=
@ -64,8 +64,8 @@ k.U=function(a,b,c,d){if(this.v&&this.v.U(a,b,c,d)||this.j&&this.j.U(a,b,c,d))re
b);c.preventDefault()}}(this,b),a.ontouchend=function(a,b){return function(){jb(a,b)}}(this,b),!0):t.prototype.U.call(this,a,b,c,d)}};k.Z=function(a,b,c,d){this.v=a;this.s=b;this.j=c;this.w=d;kb(this);lb(this)};k.V=function(a,b){if(!b)if(this.P&&mb(),!a)this.reset(!0);else if(!this.restore(a))return!1;return!0};k.R=function(a){return a?this.save():!0};k.save=function(){var a=new L(this);a.set(0,[this.f,this.h,this.g]);return a.data()};
k.restore=function(a){if(a=a[0])nb(this,this.f=a[0]),hb(this,this.h=a[1]),ob(this,a[2]);return!0};k.xb=function(){for(var a in this.a){var b=this.a[a];b[1]=b[0]}lb(this);return!0};function pb(a,b,c){if(a=a.m[b])a.style.backgroundColor=c?"#ff0000":"#000000"}function kb(a,b){for(var c in a.l)pb(a,c,null!=b?b:a.l[c])}function qb(a,b,c){if(a=a.m[b])a.style.marginTop=c?"0px":"20px",a.style.backgroundColor=c?"#00ff00":"#228B22"}function lb(a){for(var b in a.a)qb(a,b,a.a[b][1])}
k.jb=function(a,b,c){if(ib(this,b)){if(c){var d=this;setTimeout(function(){jb(d,b);a&&a()},+c);return!1}jb(this,b)}return!0};
k.Ab=function(a,b){if("SR"==a){a=b;b=8;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)):"^"==d&&(d=a.charAt(1),"D"==d?(b=10,d=null):"O"==d?(b=8,d=null):"B"==d&&(b=2,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=0;if(e=a.match(/(-?[0-9]+)B([0-9]*)/))a=e[1],d=35-((e[2]||35)&255);var e=a,g=b;(g&&10!=g?16==g?e.match(/^-?[0-9a-f]+$/i):8==g?e.match(/^-?[0-7]+$/):2==g&&e.match(/^-?[01]+$/):e.match(/^-?[0-9]+$/))&&!isNaN(f=parseInt(a,b))&&(d&&(0>f&&(f+=Math.pow(2,36)),f=0<d?f*Math.pow(2,d):Math.trunc(f/Math.pow(2,-d))),c=f)}return ob(this,c)}return(c=this.a[a])?(c[1]=+b?1:0,qb(this,a,c[1]),!0):!1};k.Bb=function(a){return ib(this,a)?(jb(this,a),!0):!1};
k.Ab=function(a,b){if("SR"==a){a=b;b=8;var c;if(a){b||(b=10);var d,e,f=0<a.indexOf(",");f&&(a=a.replace(/,/g,""));d=e=a.charAt(0);"#"==e?(b=8,e=""):"$"==e&&(b=16,e="");d!=e?a=a.substr(1):(d=e=a.substr(0,2),"0b"==e&&f||"^B"==e?(b=2,e=""):"0o"==e||"^O"==e?(b=8,e=""):"^D"==e?(b=10,e=""):"0x"==e&&(b=16,e=""),d!=e&&(a=a.substr(2)));d=e=a.slice(-1);"Y"==e||"y"==e?(b=2,e=""):"."==e?(b=10,e=""):"H"==e||"h"==e?(b=16,e=""):"K"==e?e="000":"M"==e?e="000000":"G"==e&&(e="000000000");d!=e&&(a=a.slice(0,-1)+e);var g;
d=0;if(e=a.match(/(-?[0-9]+)B([0-9]*)/))a=e[1],d=35-((e[2]||35)&255);e=a;((f=b)&&10!=f?16==f?e.match(/^-?[0-9a-f]+$/i):8==f?e.match(/^-?[0-7]+$/):2==f&&e.match(/^-?[01]+$/):e.match(/^-?[0-9]+$/))&&!isNaN(g=parseInt(a,b))&&(d&&(0>g&&(g+=Math.pow(2,36)),g=0<d?g*Math.pow(2,d):Math.trunc(g/Math.pow(2,-d))),c=g)}return ob(this,c)}return(c=this.a[a])?(c[1]=+b?1:0,qb(this,a,c[1]),!0):!1};k.Bb=function(a){return ib(this,a)?(jb(this,a),!0):!1};
function ib(a,b){var c=a.a[b];return c?(qb(a,b,c[1]=1-c[1]),c[3]=!0,c[4]&&c[4].call(a,c[1],c[5]),b!=rb&&(a.K=b==sb,a.L=b==tb),!0):!1}function jb(a,b){var c=a.a[b];c&&(c[2]&&c[3]&&(qb(a,b,c[1]=c[0]),c[4]&&c[4].call(a,c[1],c[5])),c[3]=!1)}k.rb=function(a){a||this.j.i.B||(M(this.j,this.f),this.a[ub]&&this.a[ub][1]&&vb(this.j))};k.sb=function(){};k.mb=function(a){a||N(this.j)};
k.kb=function(a){if(!a&&!this.j.i.B)if(this.a[ub]&&this.a[ub][1])vb(this.j);else{a=this.w;var b;if(b=a)a.i.Aa&&(a.i.Na=!0),b=!a.i.Aa;if(b)Xa(a,!0),a.f(0,null),Xa(a,!1);else try{var c=this.j.Fa(1);0<c&&(wb(this.j,c),xb(this.j,c,!0),yb(this.j,c))}catch(d){"number"!=typeof d&&(c=this.j,a=d.stack||d.message,c.i.error=!0,c.G(a))}this.stop();this.v&&zb(this.v)}};k.lb=function(a){a&&!this.j.i.B&&(this.K&&Ab(this),a=hb(this,this.h=this.g),this.N==gb?Bb(this.s,this.f,a):this.j.c(this.f,a))};
k.nb=function(a){if(!a&&!this.j.i.B){this.L&&Ab(this);if(this.N==gb){a=this.s;var b=this.f,c=a.a[(b&a.g)>>>a.f];a.h++;b=c.h(b&16383,b);a.h--;a=b}else a=this.j.b(this.f);hb(this,this.h=a)}};k.pb=function(a){a||this.j.i.B||nb(this,this.g)};k.ob=function(a){a?(this.o=!0,kb(this,!0)):(this.o=!1,kb(this),ob(this,0))};k.qb=function(a,b){this.g=a?this.g|1<<b:this.g&~(1<<b)};function Ab(a){var b=1,c=a.s.g;a.a[rb]&&a.a[rb][1]||(b=-b);nb(a,a.f&~c|a.f+b&c)}