forked from cs-education/sysbuild
-
Notifications
You must be signed in to change notification settings - Fork 7
/
jor1k-worker.js
13 lines (13 loc) · 238 KB
/
jor1k-worker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
/** vim: et:ts=4:sw=4:sts=4
* @license RequireJS 2.1.22 Copyright (c) 2010-2015, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details
*/
var requirejs,require,define;!function(global){function isFunction(e){return"[object Function]"===ostring.call(e)}function isArray(e){return"[object Array]"===ostring.call(e)}function each(e,t){if(e){var i;for(i=0;i<e.length&&(!e[i]||!t(e[i],i,e));i+=1);}}function eachReverse(e,t){if(e){var i;for(i=e.length-1;i>-1&&(!e[i]||!t(e[i],i,e));i-=1);}}function hasProp(e,t){return hasOwn.call(e,t)}function getOwn(e,t){return hasProp(e,t)&&e[t]}function eachProp(e,t){var i;for(i in e)if(hasProp(e,i)&&t(e[i],i))break}function mixin(e,t,i,r){return t&&eachProp(t,function(t,s){!i&&hasProp(e,s)||(!r||"object"!=typeof t||!t||isArray(t)||isFunction(t)||t instanceof RegExp?e[s]=t:(e[s]||(e[s]={}),mixin(e[s],t,i,r)))}),e}function bind(e,t){return function(){return t.apply(e,arguments)}}function scripts(){return document.getElementsByTagName("script")}function defaultOnError(e){throw e}function getGlobal(e){if(!e)return e;var t=global;return each(e.split("."),function(e){t=t[e]}),t}function makeError(e,t,i,r){var s=new Error(t+"\nhttp://requirejs.org/docs/errors.html#"+e);return s.requireType=e,s.requireModules=r,i&&(s.originalError=i),s}function newContext(e){function t(e){var t,i;for(t=0;t<e.length;t++)if(i=e[t],"."===i)e.splice(t,1),t-=1;else if(".."===i){if(0===t||1===t&&".."===e[2]||".."===e[t-1])continue;t>0&&(e.splice(t-1,2),t-=2)}}function i(e,i,r){var s,a,n,o,c,h,u,d,f,l,p,b,v=i&&i.split("/"),m=S.map,k=m&&m["*"];if(e&&(e=e.split("/"),u=e.length-1,S.nodeIdCompat&&jsSuffixRegExp.test(e[u])&&(e[u]=e[u].replace(jsSuffixRegExp,"")),"."===e[0].charAt(0)&&v&&(b=v.slice(0,v.length-1),e=b.concat(e)),t(e),e=e.join("/")),r&&m&&(v||k)){n=e.split("/");e:for(o=n.length;o>0;o-=1){if(h=n.slice(0,o).join("/"),v)for(c=v.length;c>0;c-=1)if(a=getOwn(m,v.slice(0,c).join("/")),a&&(a=getOwn(a,h))){d=a,f=o;break e}!l&&k&&getOwn(k,h)&&(l=getOwn(k,h),p=o)}!d&&l&&(d=l,f=p),d&&(n.splice(0,f,d),e=n.join("/"))}return s=getOwn(S.pkgs,e),s?s:e}function r(e){isBrowser&&each(scripts(),function(t){if(t.getAttribute("data-requiremodule")===e&&t.getAttribute("data-requirecontext")===R.contextName)return t.parentNode.removeChild(t),!0})}function s(e){var t=getOwn(S.paths,e);if(t&&isArray(t)&&t.length>1)return t.shift(),R.require.undef(e),R.makeRequire(null,{skipMap:!0})([e]),!0}function a(e){var t,i=e?e.indexOf("!"):-1;return i>-1&&(t=e.substring(0,i),e=e.substring(i+1,e.length)),[t,e]}function n(e,t,r,s){var n,o,c,h,u=null,d=t?t.name:null,f=e,l=!0,p="";return e||(l=!1,e="_@r"+(j+=1)),h=a(e),u=h[0],e=h[1],u&&(u=i(u,d,s),o=getOwn(I,u)),e&&(u?p=o&&o.normalize?o.normalize(e,function(e){return i(e,d,s)}):e.indexOf("!")===-1?i(e,d,s):e:(p=i(e,d,s),h=a(p),u=h[0],p=h[1],r=!0,n=R.nameToUrl(p))),c=!u||o||r?"":"_unnormalized"+(M+=1),{prefix:u,name:p,parentMap:t,unnormalized:!!c,url:n,originalName:f,isDefine:l,id:(u?u+"!"+p:p)+c}}function o(e){var t=e.id,i=getOwn(T,t);return i||(i=T[t]=new R.Module(e)),i}function c(e,t,i){var r=e.id,s=getOwn(T,r);!hasProp(I,r)||s&&!s.defineEmitComplete?(s=o(e),s.error&&"error"===t?i(s.error):s.on(t,i)):"defined"===t&&i(I[r])}function h(e,t){var i=e.requireModules,r=!1;t?t(e):(each(i,function(t){var i=getOwn(T,t);i&&(i.error=e,i.events.error&&(r=!0,i.emit("error",e)))}),r||req.onError(e))}function u(){globalDefQueue.length&&(each(globalDefQueue,function(e){var t=e[0];"string"==typeof t&&(R.defQueueMap[t]=!0),E.push(e)}),globalDefQueue=[])}function d(e){delete T[e],delete D[e]}function f(e,t,i){var r=e.map.id;e.error?e.emit("error",e.error):(t[r]=!0,each(e.depMaps,function(r,s){var a=r.id,n=getOwn(T,a);!n||e.depMatched[s]||i[a]||(getOwn(t,a)?(e.defineDep(s,I[a]),e.check()):f(n,t,i))}),i[r]=!0)}function l(){var e,t,i=1e3*S.waitSeconds,a=i&&R.startTime+i<(new Date).getTime(),n=[],o=[],c=!1,u=!0;if(!k){if(k=!0,eachProp(D,function(e){var i=e.map,h=i.id;if(e.enabled&&(i.isDefine||o.push(e),!e.error))if(!e.inited&&a)s(h)?(t=!0,c=!0):(n.push(h),r(h));else if(!e.inited&&e.fetched&&i.isDefine&&(c=!0,!i.prefix))return u=!1}),a&&n.length)return e=makeError("timeout","Load timeout for modules: "+n,null,n),e.contextName=R.contextName,h(e);u&&each(o,function(e){f(e,{},{})}),a&&!t||!c||!isBrowser&&!isWebWorker||w||(w=setTimeout(function(){w=0,l()},50)),k=!1}}function p(e){hasProp(I,e[0])||o(n(e[0],null,!0)).init(e[1],e[2])}function b(e,t,i,r){e.detachEvent&&!isOpera?r&&e.detachEvent(r,t):e.removeEventListener(i,t,!1)}function v(e){var t=e.currentTarget||e.srcElement;return b(t,R.onScriptLoad,"load","onreadystatechange"),b(t,R.onScriptError,"error"),{node:t,id:t&&t.getAttribute("data-requiremodule")}}function m(){var e;for(u();E.length;){if(e=E.shift(),null===e[0])return h(makeError("mismatch","Mismatched anonymous define() module: "+e[e.length-1]));p(e)}R.defQueueMap={}}var k,g,R,y,w,S={waitSeconds:7,baseUrl:"./",paths:{},bundles:{},pkgs:{},shim:{},config:{}},T={},D={},x={},E=[],I={},A={},C={},j=1,M=1;return y={require:function(e){return e.require?e.require:e.require=R.makeRequire(e.map)},exports:function(e){if(e.usingExports=!0,e.map.isDefine)return e.exports?I[e.map.id]=e.exports:e.exports=I[e.map.id]={}},module:function(e){return e.module?e.module:e.module={id:e.map.id,uri:e.map.url,config:function(){return getOwn(S.config,e.map.id)||{}},exports:e.exports||(e.exports={})}}},g=function(e){this.events=getOwn(x,e.id)||{},this.map=e,this.shim=getOwn(S.shim,e.id),this.depExports=[],this.depMaps=[],this.depMatched=[],this.pluginMaps={},this.depCount=0},g.prototype={init:function(e,t,i,r){r=r||{},this.inited||(this.factory=t,i?this.on("error",i):this.events.error&&(i=bind(this,function(e){this.emit("error",e)})),this.depMaps=e&&e.slice(0),this.errback=i,this.inited=!0,this.ignore=r.ignore,r.enabled||this.enabled?this.enable():this.check())},defineDep:function(e,t){this.depMatched[e]||(this.depMatched[e]=!0,this.depCount-=1,this.depExports[e]=t)},fetch:function(){if(!this.fetched){this.fetched=!0,R.startTime=(new Date).getTime();var e=this.map;return this.shim?void R.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],bind(this,function(){return e.prefix?this.callPlugin():this.load()})):e.prefix?this.callPlugin():this.load()}},load:function(){var e=this.map.url;A[e]||(A[e]=!0,R.load(this.map.id,e))},check:function(){if(this.enabled&&!this.enabling){var e,t,i=this.map.id,r=this.depExports,s=this.exports,a=this.factory;if(this.inited){if(this.error)this.emit("error",this.error);else if(!this.defining){if(this.defining=!0,this.depCount<1&&!this.defined){if(isFunction(a)){try{s=R.execCb(i,a,r,s)}catch(n){e=n}if(this.map.isDefine&&void 0===s&&(t=this.module,t?s=t.exports:this.usingExports&&(s=this.exports)),e){if(this.events.error&&this.map.isDefine||req.onError!==defaultOnError)return e.requireMap=this.map,e.requireModules=this.map.isDefine?[this.map.id]:null,e.requireType=this.map.isDefine?"define":"require",h(this.error=e);"undefined"!=typeof console&&console.error?console.error(e):req.onError(e)}}else s=a;if(this.exports=s,this.map.isDefine&&!this.ignore&&(I[i]=s,req.onResourceLoad)){var o=[];each(this.depMaps,function(e){o.push(e.normalizedMap||e)}),req.onResourceLoad(R,this.map,o)}d(i),this.defined=!0}this.defining=!1,this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else hasProp(R.defQueueMap,i)||this.fetch()}},callPlugin:function(){var e=this.map,t=e.id,r=n(e.prefix);this.depMaps.push(r),c(r,"defined",bind(this,function(r){var s,a,u,f=getOwn(C,this.map.id),l=this.map.name,p=this.map.parentMap?this.map.parentMap.name:null,b=R.makeRequire(e.parentMap,{enableBuildCallback:!0});return this.map.unnormalized?(r.normalize&&(l=r.normalize(l,function(e){return i(e,p,!0)})||""),a=n(e.prefix+"!"+l,this.map.parentMap),c(a,"defined",bind(this,function(e){this.map.normalizedMap=a,this.init([],function(){return e},null,{enabled:!0,ignore:!0})})),u=getOwn(T,a.id),void(u&&(this.depMaps.push(a),this.events.error&&u.on("error",bind(this,function(e){this.emit("error",e)})),u.enable()))):f?(this.map.url=R.nameToUrl(f),void this.load()):(s=bind(this,function(e){this.init([],function(){return e},null,{enabled:!0})}),s.error=bind(this,function(e){this.inited=!0,this.error=e,e.requireModules=[t],eachProp(T,function(e){0===e.map.id.indexOf(t+"_unnormalized")&&d(e.map.id)}),h(e)}),s.fromText=bind(this,function(i,r){var a=e.name,c=n(a),u=useInteractive;r&&(i=r),u&&(useInteractive=!1),o(c),hasProp(S.config,t)&&(S.config[a]=S.config[t]);try{req.exec(i)}catch(d){return h(makeError("fromtexteval","fromText eval for "+t+" failed: "+d,d,[t]))}u&&(useInteractive=!0),this.depMaps.push(c),R.completeLoad(a),b([a],s)}),void r.load(e.name,b,s,S))})),R.enable(r,this),this.pluginMaps[r.id]=r},enable:function(){D[this.map.id]=this,this.enabled=!0,this.enabling=!0,each(this.depMaps,bind(this,function(e,t){var i,r,s;if("string"==typeof e){if(e=n(e,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap),this.depMaps[t]=e,s=getOwn(y,e.id))return void(this.depExports[t]=s(this));this.depCount+=1,c(e,"defined",bind(this,function(e){this.undefed||(this.defineDep(t,e),this.check())})),this.errback?c(e,"error",bind(this,this.errback)):this.events.error&&c(e,"error",bind(this,function(e){this.emit("error",e)}))}i=e.id,r=T[i],hasProp(y,i)||!r||r.enabled||R.enable(e,this)})),eachProp(this.pluginMaps,bind(this,function(e){var t=getOwn(T,e.id);t&&!t.enabled&&R.enable(e,this)})),this.enabling=!1,this.check()},on:function(e,t){var i=this.events[e];i||(i=this.events[e]=[]),i.push(t)},emit:function(e,t){each(this.events[e],function(e){e(t)}),"error"===e&&delete this.events[e]}},R={config:S,contextName:e,registry:T,defined:I,urlFetched:A,defQueue:E,defQueueMap:{},Module:g,makeModuleMap:n,nextTick:req.nextTick,onError:h,configure:function(e){e.baseUrl&&"/"!==e.baseUrl.charAt(e.baseUrl.length-1)&&(e.baseUrl+="/");var t=S.shim,i={paths:!0,bundles:!0,config:!0,map:!0};eachProp(e,function(e,t){i[t]?(S[t]||(S[t]={}),mixin(S[t],e,!0,!0)):S[t]=e}),e.bundles&&eachProp(e.bundles,function(e,t){each(e,function(e){e!==t&&(C[e]=t)})}),e.shim&&(eachProp(e.shim,function(e,i){isArray(e)&&(e={deps:e}),!e.exports&&!e.init||e.exportsFn||(e.exportsFn=R.makeShimExports(e)),t[i]=e}),S.shim=t),e.packages&&each(e.packages,function(e){var t,i;e="string"==typeof e?{name:e}:e,i=e.name,t=e.location,t&&(S.paths[i]=e.location),S.pkgs[i]=e.name+"/"+(e.main||"main").replace(currDirRegExp,"").replace(jsSuffixRegExp,"")}),eachProp(T,function(e,t){e.inited||e.map.unnormalized||(e.map=n(t,null,!0))}),(e.deps||e.callback)&&R.require(e.deps||[],e.callback)},makeShimExports:function(e){function t(){var t;return e.init&&(t=e.init.apply(global,arguments)),t||e.exports&&getGlobal(e.exports)}return t},makeRequire:function(t,s){function a(i,r,c){var u,d,f;return s.enableBuildCallback&&r&&isFunction(r)&&(r.__requireJsBuild=!0),"string"==typeof i?isFunction(r)?h(makeError("requireargs","Invalid require call"),c):t&&hasProp(y,i)?y[i](T[t.id]):req.get?req.get(R,i,t,a):(d=n(i,t,!1,!0),u=d.id,hasProp(I,u)?I[u]:h(makeError("notloaded",'Module name "'+u+'" has not been loaded yet for context: '+e+(t?"":". Use require([])")))):(m(),R.nextTick(function(){m(),f=o(n(null,t)),f.skipMap=s.skipMap,f.init(i,r,c,{enabled:!0}),l()}),a)}return s=s||{},mixin(a,{isBrowser:isBrowser,toUrl:function(e){var r,s=e.lastIndexOf("."),a=e.split("/")[0],n="."===a||".."===a;return s!==-1&&(!n||s>1)&&(r=e.substring(s,e.length),e=e.substring(0,s)),R.nameToUrl(i(e,t&&t.id,!0),r,!0)},defined:function(e){return hasProp(I,n(e,t,!1,!0).id)},specified:function(e){return e=n(e,t,!1,!0).id,hasProp(I,e)||hasProp(T,e)}}),t||(a.undef=function(e){u();var i=n(e,t,!0),s=getOwn(T,e);s.undefed=!0,r(e),delete I[e],delete A[i.url],delete x[e],eachReverse(E,function(t,i){t[0]===e&&E.splice(i,1)}),delete R.defQueueMap[e],s&&(s.events.defined&&(x[e]=s.events),d(e))}),a},enable:function(e){var t=getOwn(T,e.id);t&&o(e).enable()},completeLoad:function(e){var t,i,r,a=getOwn(S.shim,e)||{},n=a.exports;for(u();E.length;){if(i=E.shift(),null===i[0]){if(i[0]=e,t)break;t=!0}else i[0]===e&&(t=!0);p(i)}if(R.defQueueMap={},r=getOwn(T,e),!t&&!hasProp(I,e)&&r&&!r.inited){if(!(!S.enforceDefine||n&&getGlobal(n)))return s(e)?void 0:h(makeError("nodefine","No define call for "+e,null,[e]));p([e,a.deps||[],a.exportsFn])}l()},nameToUrl:function(e,t,i){var r,s,a,n,o,c,h,u=getOwn(S.pkgs,e);if(u&&(e=u),h=getOwn(C,e))return R.nameToUrl(h,t,i);if(req.jsExtRegExp.test(e))o=e+(t||"");else{for(r=S.paths,s=e.split("/"),a=s.length;a>0;a-=1)if(n=s.slice(0,a).join("/"),c=getOwn(r,n)){isArray(c)&&(c=c[0]),s.splice(0,a,c);break}o=s.join("/"),o+=t||(/^data\:|\?/.test(o)||i?"":".js"),o=("/"===o.charAt(0)||o.match(/^[\w\+\.\-]+:/)?"":S.baseUrl)+o}return S.urlArgs?o+((o.indexOf("?")===-1?"?":"&")+S.urlArgs):o},load:function(e,t){req.load(R,e,t)},execCb:function(e,t,i,r){return t.apply(r,i)},onScriptLoad:function(e){if("load"===e.type||readyRegExp.test((e.currentTarget||e.srcElement).readyState)){interactiveScript=null;var t=v(e);R.completeLoad(t.id)}},onScriptError:function(e){var t=v(e);if(!s(t.id)){var i=[];return eachProp(T,function(e,r){0!==r.indexOf("_@r")&&each(e.depMaps,function(e){return e.id===t.id&&i.push(r),!0})}),h(makeError("scripterror",'Script error for "'+t.id+(i.length?'", needed by: '+i.join(", "):'"'),e,[t.id]))}}},R.require=R.makeRequire(),R}function getInteractiveScript(){return interactiveScript&&"interactive"===interactiveScript.readyState?interactiveScript:(eachReverse(scripts(),function(e){if("interactive"===e.readyState)return interactiveScript=e}),interactiveScript)}var req,s,head,baseElement,dataMain,src,interactiveScript,currentlyAddingScript,mainScript,subPath,version="2.1.22",commentRegExp=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/gm,cjsRequireRegExp=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,jsSuffixRegExp=/\.js$/,currDirRegExp=/^\.\//,op=Object.prototype,ostring=op.toString,hasOwn=op.hasOwnProperty,ap=Array.prototype,isBrowser=!("undefined"==typeof window||"undefined"==typeof navigator||!window.document),isWebWorker=!isBrowser&&"undefined"!=typeof importScripts,readyRegExp=isBrowser&&"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,defContextName="_",isOpera="undefined"!=typeof opera&&"[object Opera]"===opera.toString(),contexts={},cfg={},globalDefQueue=[],useInteractive=!1;if("undefined"==typeof define){if("undefined"!=typeof requirejs){if(isFunction(requirejs))return;cfg=requirejs,requirejs=void 0}"undefined"==typeof require||isFunction(require)||(cfg=require,require=void 0),req=requirejs=function(e,t,i,r){var s,a,n=defContextName;return isArray(e)||"string"==typeof e||(a=e,isArray(t)?(e=t,t=i,i=r):e=[]),a&&a.context&&(n=a.context),s=getOwn(contexts,n),s||(s=contexts[n]=req.s.newContext(n)),a&&s.configure(a),s.require(e,t,i)},req.config=function(e){return req(e)},req.nextTick="undefined"!=typeof setTimeout?function(e){setTimeout(e,4)}:function(e){e()},require||(require=req),req.version=version,req.jsExtRegExp=/^\/|:|\?|\.js$/,req.isBrowser=isBrowser,s=req.s={contexts:contexts,newContext:newContext},req({}),each(["toUrl","undef","defined","specified"],function(e){req[e]=function(){var t=contexts[defContextName];return t.require[e].apply(t,arguments)}}),isBrowser&&(head=s.head=document.getElementsByTagName("head")[0],baseElement=document.getElementsByTagName("base")[0],baseElement&&(head=s.head=baseElement.parentNode)),req.onError=defaultOnError,req.createNode=function(e,t,i){var r=e.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script");return r.type=e.scriptType||"text/javascript",r.charset="utf-8",r.async=!0,r},req.load=function(e,t,i){var r,s=e&&e.config||{};if(isBrowser)return r=req.createNode(s,t,i),s.onNodeCreated&&s.onNodeCreated(r,s,t,i),r.setAttribute("data-requirecontext",e.contextName),r.setAttribute("data-requiremodule",t),!r.attachEvent||r.attachEvent.toString&&r.attachEvent.toString().indexOf("[native code")<0||isOpera?(r.addEventListener("load",e.onScriptLoad,!1),r.addEventListener("error",e.onScriptError,!1)):(useInteractive=!0,r.attachEvent("onreadystatechange",e.onScriptLoad)),r.src=i,currentlyAddingScript=r,baseElement?head.insertBefore(r,baseElement):head.appendChild(r),currentlyAddingScript=null,r;if(isWebWorker)try{importScripts(i),e.completeLoad(t)}catch(a){e.onError(makeError("importscripts","importScripts failed for "+t+" at "+i,a,[t]))}},isBrowser&&!cfg.skipDataMain&&eachReverse(scripts(),function(e){if(head||(head=e.parentNode),dataMain=e.getAttribute("data-main"))return mainScript=dataMain,cfg.baseUrl||(src=mainScript.split("/"),mainScript=src.pop(),subPath=src.length?src.join("/")+"/":"./",cfg.baseUrl=subPath),mainScript=mainScript.replace(jsSuffixRegExp,""),req.jsExtRegExp.test(mainScript)&&(mainScript=dataMain),cfg.deps=cfg.deps?cfg.deps.concat(mainScript):[mainScript],!0}),define=function(e,t,i){var r,s;"string"!=typeof e&&(i=t,t=e,e=null),isArray(t)||(i=t,t=null),!t&&isFunction(i)&&(t=[],i.length&&(i.toString().replace(commentRegExp,"").replace(cjsRequireRegExp,function(e,i){t.push(i)}),t=(1===i.length?["require"]:["require","exports","module"]).concat(t))),useInteractive&&(r=currentlyAddingScript||getInteractiveScript(),r&&(e||(e=r.getAttribute("data-requiremodule")),s=contexts[r.getAttribute("data-requirecontext")])),s?(s.defQueue.push([e,t,i]),s.defQueueMap[e]=!0):globalDefQueue.push([e,t,i])},define.amd={jQuery:!0},req.exec=function(text){return eval(text)},req(cfg)}}(this),define("requireLib",function(){}),define("amd-loader",[],function(){var e=function(t,i,r,s){return 3==arguments.length?(s=r,r=void 0):2==arguments.length&&(s=i,i=r=void 0),{buildCache:{},load:function(a,n,o,c){var h=n.toUrl(a);if(c.precompiled instanceof Array){for(var u=0;u<c.precompiled.length;u++)if(h.substr(0,c.precompiled[u].length)==c.precompiled[u])return require([h+"."+t+".js"],o,o.error)}else if(c.precompiled===!0)return require([h+"."+t+".js"],o,o.error);if(i&&"/"!=a.substr(0,1)&&!a.match(/:\/\//)){var d=!1;if(r)for(var u=0;u<r.length;u++)a.substr(a.length-r[u].length-1)=="."+r[u]&&(d=!0);d||(h+="."+i)}var f=this;e.fetch(h,function(e){s(a,e,n,function(e){"string"==typeof e?(c.isBuild&&(f.buildCache[a]=e),o.fromText(e)):o(e)},o.error,c)},o.error)},write:function(e,t,i){var r=this.buildCache[t];r&&i.asModule(e+"!"+t,r)},writeFile:function(e,i,r,s){s.asModule(e+"!"+i,r.toUrl(i+"."+t+".js"),this.buildCache[i])}}};if("undefined"!=typeof window){var t=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],i=function(e){var i=!0,r=/^(\w+:)?\/\/([^\/]+)/.exec(e);"undefined"!=typeof window&&r&&(i=r[2]===window.location.host,r[1]&&(i&=r[1]===window.location.protocol));var s;if("undefined"!=typeof XMLHttpRequest)s=new XMLHttpRequest;else for(var a,n=0;n<3;n+=1){a=t[n];try{s=new ActiveXObject(a)}catch(o){}if(s){t=[a];break}}if(!i)if("undefined"!=typeof XDomainRequest)s=new XDomainRequest;else if(!("withCredentials"in s))throw new Error("getXhr(): Cross Origin XHR not supported.");if(!s)throw new Error("getXhr(): XMLHttpRequest not available");return s};e.fetch=function(e,t,r){var s=i(e);s.open("GET",e,!requirejs.inlineRequire),s.onreadystatechange=function(i){var a,n;if(4===s.readyState)if(a=s.status,a>399&&a<600)n=new Error(e+" HTTP status: "+a),n.xhr=s,r&&r(n);else{if(""==s.responseText)return r(new Error(e+" empty response"));t(s.responseText)}},s.send(null)}}else if("undefined"!=typeof process&&process.versions&&process.versions.node){var r=requirejs.nodeRequire("fs");e.fetch=function(e,t){t(r.readFileSync(e,"utf8"))}}else"undefined"!=typeof Packages?e.fetch=function(e,t,i){var r,s,a="utf-8",n=new java.io.File(e),o=java.lang.System.getProperty("line.separator"),c=new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(n),a)),h="";try{for(r=new java.lang.StringBuffer,s=c.readLine(),s&&s.length()&&65279===s.charAt(0)&&(s=s.substring(1)),r.append(s);null!==(s=c.readLine());)r.append(o),r.append(s);h=String(r.toString())}catch(u){i&&i(u)}finally{c.close()}t(h)}:e.fetch=function(){throw new Error("Environment unsupported.")};return e}),define("cjs",["amd-loader"],function(e){var t=/\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g;return e("cjs","js",function(e,i,r,s,a,n){i=i.replace(t,function(e,t){return"."==t.substr(0,1)?" require('cjs!"+t+"')":" require('"+t+"')"}),s("define(function(require, exports, module) { (function(){var define=undefined;"+i+" \n//# sourceURL="+r.toUrl(e)+"\n})() });")})}),define("cjs!jor1k/worker/messagehandler",["require","exports","module"],function(e,t,i){!function(){function e(e,t){postMessage({command:e,data:t})}function t(t){e("Debug",t)}function r(){throw t("Worker: Abort execution."),"function"==typeof c.PrintOnAbort&&c.PrintOnAbort(),e("Abort",{}),o=!1,new Error("Kill worker")}function s(t){e("Debug","Error: "+t),r()}function a(t){e("Debug","Warning: "+t)}function n(e,t){c[e]=t}var o=!0,c=new Object;onmessage=function(e){if(o){var i=e.data.command;if("function"!=typeof c[i]);else try{c[i](e.data.data)}catch(r){t('Worker: Unhandled exception in command "'+i+'": '+r.message),o=!1}}},n("Abort",function(){o=!1}),i.exports.Register=n,i.exports.Debug=t,i.exports.Error=s,i.exports.Warning=a,i.exports.Abort=r,i.exports.Send=e}()}),define("cjs!jor1k/worker/utils",["require","exports","module"],function(e,t,i){!function(){function e(){return(new Date).getTime()}function t(e){return(255&e)<<24|(65280&e)<<8|e>>>8&65280|e>>>24&255}function r(e){return(255&e)<<8|e>>8&255}function s(e){return e>>0}function a(e){return e>>>0}function n(e){var t=a(e);return"0x"+("00000000"+t.toString(16)).substr(-8).toUpperCase()}function o(e){var t=a(e),i=("00000000000000000000000000000000"+t.toString(2)).substr(-32)+"b";return i.replace(/./g,function(e,t){return 3==(3&t)?e+" ":e})}function c(e,t,i){var r=new XMLHttpRequest;try{r.open("GET",e,!0)}catch(s){return void i(s)}r.responseType="arraybuffer",r.onreadystatechange=function(){if(4==r.readyState){if(200!=r.status&&0!=r.status)return void i("Error: Could not load file "+e);var s=r.response;s?t(s):i("Error: No data received from: "+e)}},r.send(null)}function h(e,t,i,r){var s=new XMLHttpRequest;try{s.open("GET",e,i)}catch(a){return void r(a)}s.responseType="arraybuffer",s.onreadystatechange=function(){if(4==s.readyState){if(200!=s.status&&0!=s.status)return void r("Error: Could not load file "+e);var i=s.response;i?t(i):r("Error: No data received from: "+e)}},s.send(null)}function u(e,t,i){var r=new XMLHttpRequest;r.open("GET",e,!0),r.onreadystatechange=function(){if(4==r.readyState)return 200!=r.status&&0!=r.status?void i("Error: Could not load text file "+e):void t(r.responseText)},r.send(null)}i.exports.GetMilliseconds=e,i.exports.Swap32=t,i.exports.Swap16=r,i.exports.int32=s,i.exports.uint32=a,i.exports.ToHex=n,i.exports.ToBin=o,i.exports.LoadBinaryResource=c,i.exports.LoadBinaryResourceII=h,i.exports.LoadTextResource=u}()}),define("cjs!jor1k/worker/ram",["require","exports","module","cjs!./messagehandler","cjs!./utils"],function(e,t,i){!function(){function t(e,t){this.heap=e,this.int32mem=new Int32Array(this.heap,t),this.uint8mem=new Uint8Array(this.heap,t),this.sint8mem=new Int8Array(this.heap,t),this.devices=new Array(256),this.nativeendian="little",this.Read32Little=this.Read32LittleTemplate,this.Write32Little=this.Write32LittleTemplate,this.Read16Little=this.Read16LittleTemplate,this.Write16Little=this.Write16LittleTemplate,this.Read8Little=this.Read8LittleTemplate,this.Write8Little=this.Write8LittleTemplate,this.Read32=this.Read32LittleTemplate,this.Write32=this.Write32LittleTemplate,this.Read16=this.Read16LittleTemplate,this.Write16=this.Write16LittleTemplate,this.Read8=this.Read8LittleTemplate,this.Write8=this.Write8LittleTemplate,this.Read32Big=this.Read32BigTemplate,this.Write32Big=this.Write32BigTemplate,this.Read16Big=this.Read16BigTemplate,this.Write16Big=this.Write16BigTemplate,this.Read8Big=this.Read8BigTemplate,this.Write8Big=this.Write8BigTemplate}var r=e("cjs!./messagehandler"),s=e("cjs!./utils");t.prototype.AddDevice=function(e,t,i){16777215&t&&(r.Debug("Error: The device address not in the allowed memory region"),r.Abort()),this.devices[t>>24&255]=e},t.prototype.Little2Big=function(e){for(var t=0;t<e>>2;t++)this.int32mem[t]=s.Swap32(this.int32mem[t]);this.Read32=this.Read32BigTemplate,this.Write32=this.Write32BigTemplate,this.Read16=this.Read16BigTemplate,this.Write16=this.Write16BigTemplate,this.Read8=this.Read8BigTemplate,this.Write8=this.Write8BigTemplate,this.Read32Little=function(e){return s.Swap32(this.Read32BigTemplate(e))}.bind(this),this.Write32Little=function(e,t){this.Write32BigTemplate(e,s.Swap32(t))}.bind(this),this.Read16Little=function(e){return s.Swap16(this.Read16BigTemplate(e))}.bind(this),this.Write16Little=function(e,t){this.Write16BigTemplate(e,s.Swap16(t))}.bind(this),this.Read8Little=this.Read8BigTemplate.bind(this),this.Write8Little=this.Write8BigTemplate.bind(this),this.nativeendian="big"},t.prototype.Read32BigTemplate=function(e){return e=0|e,e>=0?(this.int32mem.byteLength<=e&&(r.Debug("Error in Read32Big: read above upper boundary"),r.Abort()),this.int32mem[e>>2]):this.devices[e>>24&255].ReadReg32(16777215&e)},t.prototype.Read32LittleTemplate=function(e){return e=0|e,e>=0?(this.int32mem.byteLength<=e&&(r.Debug("Error in Read32Little: read above upper boundary"),r.Abort()),this.int32mem[e>>2]):this.devices[e>>24&255].ReadReg32(16777215&e)},t.prototype.Write32BigTemplate=function(e,t){return e=0|e,e>=0?(this.int32mem.byteLength<=e&&(r.Debug("Error in Write32Big: write above upper boundary"),r.Abort()),void(this.int32mem[e>>2]=0|t)):void this.devices[e>>24&255].WriteReg32(16777215&e,0|t)},t.prototype.Write32LittleTemplate=function(e,t){return e=0|e,e>=0?(this.int32mem.byteLength<=e&&(r.Debug("Error in Write32Little: write above upper boundary"),r.Abort()),void(this.int32mem[e>>2]=0|t)):void this.devices[e>>24&255].WriteReg32(16777215&e,0|t)},t.prototype.Read8BigTemplate=function(e){return e=0|e,e>=0?(this.uint8mem.byteLength<=e&&(r.Debug("Error in Read8Big: read above upper boundary"),r.Abort()),this.uint8mem[3^e]):this.devices[e>>24&255].ReadReg8(16777215&e)},t.prototype.Read8LittleTemplate=function(e){return e=0|e,e>=0?(this.uint8mem.byteLength<=e&&(r.Debug("Error in Read8Little: read above upper boundary"),r.Abort()),this.uint8mem[e]):this.devices[e>>24&255].ReadReg8(16777215&e)},t.prototype.Write8BigTemplate=function(e,t){return e=0|e,e>=0?(this.uint8mem.byteLength<=e&&(r.Debug("Error in Write8Big: write above upper boundary"),r.Abort()),void(this.uint8mem[3^e]=0|t)):void this.devices[e>>24&255].WriteReg8(16777215&e,0|t)},t.prototype.Write8LittleTemplate=function(e,t){return e=0|e,e>=0?(this.uint8mem.byteLength<=e&&(r.Debug("Error in Write8Little: write above upper boundary"),r.Abort()),void(this.uint8mem[e]=0|t)):void this.devices[e>>24&255].WriteReg8(16777215&e,0|t)},t.prototype.Read16BigTemplate=function(e){return e=0|e,e>=0?(this.uint8mem.byteLength<=e&&(r.Debug("Error in Read16Big: read above upper boundary"),r.Abort()),this.uint8mem[(2^e)+1]<<8|this.uint8mem[2^e]):this.devices[e>>24&255].ReadReg16(16777215&e)},t.prototype.Read16LittleTemplate=function(e){return e=0|e,e>=0?(this.uint8mem.byteLength<=e&&(r.Debug("Error in Read16Little: read above upper boundary"),r.Abort()),this.uint8mem[e+1]<<8|this.uint8mem[e]):this.devices[e>>24&255].ReadReg16(16777215&e)},t.prototype.Write16BigTemplate=function(e,t){return e=0|e,e>=0?(this.uint8mem.byteLength<=e&&(r.Debug("Error in Write16Big: write above upper boundary"),r.Abort()),this.uint8mem[(2^e)+1]=t>>8&255,void(this.uint8mem[2^e]=255&t)):void this.devices[e>>24&255].WriteReg16(16777215&e,0|t)},t.prototype.Write16LittleTemplate=function(e,t){return e=0|e,e>=0?(this.uint8mem.byteLength<=e&&(r.Debug("Error in Write16Little: write above upper boundary"),r.Abort()),this.uint8mem[e+1]=t>>8&255,void(this.uint8mem[e]=255&t)):void this.devices[e>>24&255].WriteReg16(16777215&e,0|t)},i.exports=t}()}),define("cjs!jor1k/worker/bzip2",["require","exports","module","cjs!./messagehandler"],function(e,t,i){!function(){var t=e("cjs!./messagehandler"),r={};r.crcTable=[0,79764919,159529838,222504665,319059676,398814059,445009330,507990021,638119352,583659535,797628118,726387553,890018660,835552979,1015980042,944750013,1276238704,1221641927,1167319070,1095957929,1595256236,1540665371,1452775106,1381403509,1780037320,1859660671,1671105958,1733955601,2031960084,2111593891,1889500026,1952343757,2552477408,2632100695,2443283854,2506133561,2334638140,2414271883,2191915858,2254759653,3190512472,3135915759,3081330742,3009969537,2905550212,2850959411,2762807018,2691435357,3560074640,3505614887,3719321342,3648080713,3342211916,3287746299,3467911202,3396681109,4063920168,4143685023,4223187782,4286162673,3779000052,3858754371,3904687514,3967668269,881225847,809987520,1023691545,969234094,662832811,591600412,771767749,717299826,311336399,374308984,453813921,533576470,25881363,88864420,134795389,214552010,2023205639,2086057648,1897238633,1976864222,1804852699,1867694188,1645340341,1724971778,1587496639,1516133128,1461550545,1406951526,1302016099,1230646740,1142491917,1087903418,2896545431,2825181984,2770861561,2716262478,3215044683,3143675388,3055782693,3001194130,2326604591,2389456536,2200899649,2280525302,2578013683,2640855108,2418763421,2498394922,3769900519,3832873040,3912640137,3992402750,4088425275,4151408268,4197601365,4277358050,3334271071,3263032808,3476998961,3422541446,3585640067,3514407732,3694837229,3640369242,1762451694,1842216281,1619975040,1682949687,2047383090,2127137669,1938468188,2001449195,1325665622,1271206113,1183200824,1111960463,1543535498,1489069629,1434599652,1363369299,622672798,568075817,748617968,677256519,907627842,853037301,1067152940,995781531,51762726,131386257,177728840,240578815,269590778,349224269,429104020,491947555,4046411278,4126034873,4172115296,4234965207,3794477266,3874110821,3953728444,4016571915,3609705398,3555108353,3735388376,3664026991,3290680682,3236090077,3449943556,3378572211,3174993278,3120533705,3032266256,2961025959,2923101090,2868635157,2813903052,2742672763,2604032198,2683796849,2461293480,2524268063,2284983834,2364738477,2175806836,2238787779,1569362073,1498123566,1409854455,1355396672,1317987909,1246755826,1192025387,1137557660,2072149281,2135122070,1912620623,1992383480,1753615357,1816598090,1627664531,1707420964,295390185,358241886,404320391,483945776,43990325,106832002,186451547,266083308,932423249,861060070,1041341759,986742920,613929101,542559546,756411363,701822548,3316196985,3244833742,3425377559,3370778784,3601682597,3530312978,3744426955,3689838204,3819031489,3881883254,3928223919,4007849240,4037393693,4100235434,4180117107,4259748804,2310601993,2373574846,2151335527,2231098320,2596047829,2659030626,2470359227,2550115596,2947551409,2876312838,2788305887,2733848168,3165939309,3094707162,3040238851,2985771188],r.array=function(e){var t=0,i=0,r=[0,1,3,7,15,31,63,127,255];return function(s){for(var a=0;s>0;){var n=8-t;s>=n?(a<<=n,a|=r[n]&e[i++],t=0,s-=n):(a<<=s,a|=(e[i]&r[s]<<8-s-t)>>8-s-t,t+=s,s=0)}return a}},r.IsBZIP2=function(e){return 66==e[0]&&90==e[1]&&104==e[2]},r.simple=function(e,t){var i=r.array(e),s=r.header(i),a=!1,n=1e5*s,o=new Int32Array(n);this.byteCount=new Int32Array(256),this.symToByte=new Uint8Array(256),this.mtfSymbol=new Int32Array(256),this.selectors=new Uint8Array(32768);do a=r.decompress(i,t,o,n);while(!a)},r.header=function(e){4348520!=e(24)&&t.Error("No magic number found");var i=e(8)-48;return(i<1||i>9)&&t.Error("Not a BZIP archive"),i},r.decompress=function(e,i,r,s){for(var a=20,n=258,o=0,c=1,h=50,u=-1,d="",f=0;f<6;f++)d+=e(8).toString(16);if("177245385090"==d)return!0;"314159265359"!=d&&t.Error("eek not valid bzip data");var l=0|e(32);e(1)&&t.Error("unsupported obsolete version");var p=e(24);p>s&&t.Error("Initial position larger than buffer size");var b=e(16),v=0;for(f=0;f<16;f++)if(b&1<<15-f){var m=e(16);for(R=0;R<16;R++)m&1<<15-R&&(this.symToByte[v++]=16*f+R)}var k=e(3);(k<2||k>6)&&t.Error("another error");var g=e(15);0==g&&t.Error("meh");for(var f=0;f<k;f++)this.mtfSymbol[f]=f;
for(var f=0;f<g;f++){for(var R=0;e(1);R++)R>=k&&t.Error("whoops another error");for(var y=this.mtfSymbol[R],m=R-1;m>=0;m--)this.mtfSymbol[m+1]=this.mtfSymbol[m];this.mtfSymbol[0]=y,this.selectors[f]=y}for(var w,S=v+2,T=[],D=new Uint8Array(n),x=new Uint8Array(a+1),R=0;R<k;R++){b=e(5);for(var f=0;f<S;f++){for(;;){if((b<1||b>a)&&t.Error("I gave up a while ago on writing error messages"),!e(1))break;e(1)?b--:b++}D[f]=b}var E,I;E=I=D[0];for(var f=1;f<S;f++)D[f]>I?I=D[f]:D[f]<E&&(E=D[f]);w=T[R]={},w.permute=new Int32Array(n),w.limit=new Int32Array(a+1),w.base=new Int32Array(a+1),w.minLen=E,w.maxLen=I;for(var A=w.base.subarray(1),C=w.limit.subarray(1),j=0,f=E;f<=I;f++)for(var b=0;b<S;b++)D[b]==f&&(w.permute[j++]=b);for(f=E;f<=I;f++)x[f]=C[f]=0;for(f=0;f<S;f++)x[D[f]]++;for(j=b=0,f=E;f<I;f++)j+=x[f],C[f]=j-1,j<<=1,A[f+1]=j-(b+=x[f]);C[I]=j+x[I]-1,A[E]=0}for(var f=0;f<256;f++)this.mtfSymbol[f]=f,this.byteCount[f]=0;var M,_,S,H;for(M=_=S=H=0;;){for(S--||(S=h-1,H>=g&&t.Error("meow i'm a kitty, that's an error"),w=T[this.selectors[H++]],A=w.base.subarray(1),C=w.limit.subarray(1)),f=w.minLen,R=e(f);;){if(f>w.maxLen&&t.Error("rawr i'm a dinosaur"),R<=C[f])break;f++,R=R<<1|e(1)}R-=A[f],(R<0||R>=n)&&t.Error("moo i'm a cow");var q=w.permute[R];if(q!=o&&q!=c){if(M)for(M=0,_+b>=s&&t.Error("Boom."),y=this.symToByte[this.mtfSymbol[0]],this.byteCount[y]+=b;b--;)r[_++]=y;if(q>v)break;_>=s&&t.Error("I can't think of anything. Error"),f=q-1,y=this.mtfSymbol[f];for(var m=f-1;m>=0;m--)this.mtfSymbol[m+1]=this.mtfSymbol[m];this.mtfSymbol[0]=y,y=this.symToByte[y],this.byteCount[y]++,r[_++]=y}else M||(M=1,b=0),b+=q==o?M:2*M,M<<=1}(p<0||p>=_)&&t.Error("I'm a monkey and I'm throwing something at someone, namely you");for(var R=0,f=0;f<256;f++)m=R+this.byteCount[f],this.byteCount[f]=R,R=m;for(var f=0;f<_;f++)y=255&r[f],r[this.byteCount[y]]|=f<<8,this.byteCount[y]++;var L=0,U=0,P=0;_&&(L=r[p],U=255&L,L>>=8,P=-1),_=_;for(var W,B,F;_;){for(_--,B=U,L=r[L],U=255&L,L>>=8,3==P++?(W=U,F=B,U=-1):(W=1,F=U);W--;)u=4294967295&(u<<8^this.crcTable[255&(u>>24^F)]),i(F);U!=B&&(P=0)}return u=(u^-1)>>>0,(0|u)!=(0|l)&&t.Error("Error in bzip2: crc32 do not match"),!1},i.exports=r}()}),define("cjs!jor1k/lib/utf8",["require","exports","module"],function(e,t,i){!function(){function e(){this.stream=new Uint8Array(5),this.ofs=0,this.Put=function(e){switch(this.stream[this.ofs]=e,this.ofs++,this.ofs){case 1:if(this.stream[0]<128)return this.ofs=0,this.stream[0];break;case 2:if(192==(224&this.stream[0])&&128==(192&this.stream[1]))return this.ofs=0,(31&this.stream[0])<<6|(63&this.stream[1])<<0;break;case 3:if(224==(240&this.stream[0])&&128==(192&this.stream[1])&&128==(192&this.stream[2]))return this.ofs=0,(15&this.stream[0])<<12|(63&this.stream[1])<<6|(63&this.stream[2])<<0;break;case 4:return 240==(248&this.stream[0])&&128==(192&this.stream[1])&&128==(192&this.stream[2])&&128==(192&this.stream[3])?(this.ofs=0,(7&this.stream[0])<<18|(63&this.stream[1])<<12|(63&this.stream[2])<<6|(63&this.stream[3])<<0):(this.ofs=0,-1);default:return this.ofs=0,-1}return-1}}function t(e){return e=0|e,e<128?[e]:e<=2047?[e>>6|192,63&e|128]:e<=65535?[e>>12|224,e>>6&63|128,63&e|128]:e<=1114111?[e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128]:[]}function r(e){for(var t=0,i=0;i<e.length;i++){var r=e.charCodeAt(i);r<128?t+=1:r<=2047?t+=2:r<=65535?t+=3:r<=1114111&&(t+=4)}return t}i.exports.UTF8StreamToUnicode=e,i.exports.UTF8Length=r,i.exports.UnicodeToUTF8Stream=t}()}),define("cjs!jor1k/worker/dev/virtio/marshall",["require","exports","module","cjs!../../../lib/utf8","cjs!../../messagehandler"],function(e,t,i){!function(){function t(e,i,r,s){for(var o,c=0,h=0;h<e.length;h++)switch(o=i[h],e[h]){case"w":r[s++]=255&o,r[s++]=o>>8&255,r[s++]=o>>16&255,r[s++]=o>>24&255,c+=4;break;case"d":r[s++]=255&o,r[s++]=o>>8&255,r[s++]=o>>16&255,r[s++]=o>>24&255,r[s++]=0,r[s++]=0,r[s++]=0,r[s++]=0,c+=8;break;case"h":r[s++]=255&o,r[s++]=o>>8,c+=2;break;case"b":r[s++]=o,c+=1;break;case"s":var u=s,d=0;r[s++]=0,r[s++]=0,c+=2;for(var f in o){var l=a.UnicodeToUTF8Stream(o.charCodeAt(f));l.forEach(function(e){r[s++]=e,c+=1,d++})}r[u+0]=255&d,r[u+1]=d>>8&255;break;case"Q":t(["b","w","d"],[o.type,o.version,o.path],r,s),s+=13,c+=13;break;default:n.Debug("Marshall: Unknown type="+type[h])}return c}function r(e,t,i){for(var r=[],s=0;s<e.length;s++)switch(e[s]){case"w":var o=t[i++];o+=t[i++]<<8,o+=t[i++]<<16,o+=t[i++]<<24>>>0,r.push(o);break;case"d":var o=t[i++];o+=t[i++]<<8,o+=t[i++]<<16,o+=t[i++]<<24>>>0,i+=4,r.push(o);break;case"h":var o=t[i++];r.push(o+(t[i++]<<8));break;case"b":r.push(t[i++]);break;case"s":var c=t[i++];c+=t[i++]<<8;for(var h="",u=new a.UTF8StreamToUnicode,d=0;d<c;d++){var f=u.Put(t[i++]);f!=-1&&(h+=String.fromCharCode(f))}r.push(h);break;default:n.Debug("Error in Unmarshall: Unknown type="+e[s])}return r}function s(e,t){for(var i=[],r=0;r<e.length;r++)switch(e[r]){case"w":var s=t();s+=t()<<8,s+=t()<<16,s+=t()<<24>>>0,i.push(s);break;case"d":var s=t();s+=t()<<8,s+=t()<<16,s+=t()<<24>>>0,t(),t(),t(),t(),i.push(s);break;case"h":var s=t();i.push(s+(t()<<8));break;case"b":i.push(t());break;case"s":var o=t();o+=t()<<8;for(var c="",h=new a.UTF8StreamToUnicode,u=0;u<o;u++){var d=h.Put(t());d!=-1&&(c+=String.fromCharCode(d))}i.push(c);break;default:n.Debug("Error in Unmarshall2: Unknown type="+e[r])}return i}var a=e("cjs!../../../lib/utf8"),n=e("cjs!../../messagehandler");i.exports.Marshall=t,i.exports.Unmarshall=r,i.exports.Unmarshall2=s}()}),define("cjs!jor1k/worker/elf",["require","exports","module","cjs!./messagehandler","cjs!./utils","cjs!./dev/virtio/marshall"],function(e,t,i){!function(){var t=e("cjs!./messagehandler"),r=(e("cjs!./utils"),e("cjs!./dev/virtio/marshall")),s={};s.IsELF=function(e){return 127==e[0]&&69==e[1]&&76==e[2]&&70==e[3]},s.Extract=function(e,i){var s=0,a=[];a=r.Unmarshall(["w","b","b","b","b"],e,s);var n=a[1];1!=n&&(t.Debug("Error reading elf binary: 64-Bit not supported"),t.Abort()),s=16,a=r.Unmarshall(["h","h","w","w","w","w"],e,s);var o=(a[3],a[4],a[5]);s=46,a=r.Unmarshall(["h","h","h"],e,s);for(var c=a[0],h=a[1],u=(a[2],[]),d=0;d<h;d++){s=o+d*c,a=r.Unmarshall(["w","w","w","w","w","w"],e,s);var f={};f.name=a[0],f.type=a[1],f.flags=a[2],f.addr=a[3],f.offs=a[4],f.size=a[5],u.push(f)}for(var d=0;d<u.length;d++)if(1==(u[d].flags>>1&1)&&8!=u[d].type)for(var l=0;l<u[d].size;l++)i[u[d].addr+l]=e[u[d].offs+l];else if(1==(u[d].flags>>1&1)&&8==u.type)for(var l=0;l<u[d].size;l++)i[u[d].addr+l]=0},i.exports=s}()}),define("cjs!jor1k/worker/timer",["require","exports","module","cjs!./messagehandler","cjs!./utils"],function(e,t,i){!function(){function t(e,t){this.ticksperms=e,this.loopspersecond=t,this.baserealtime=0,this.realtime=0,this.lastsystemticks=0,this.systemtime=0,this.correction=1,this.oldcorrection=1,this.steps=0,this.nins=0,this.lastlooptime=-1,this.ipms=5e3,this.instructionsperloop=0,this.timercyclesperinstruction=10,this.UpdateTimings()}var r=(e("cjs!./messagehandler"),e("cjs!./utils"));t.prototype.Update=function(e,t,i){this.GlobalUpdate(t),this.LocalUpdate(e,i)},t.prototype.UpdateTimings=function(e,t){this.instructionsperloop=Math.floor(1e3*this.ipms/this.loopspersecond),this.instructionsperloop=this.instructionsperloop<2e3?2e3:this.instructionsperloop,this.instructionsperloop=this.instructionsperloop>4e6?4e6:this.instructionsperloop,this.timercyclesperinstruction=Math.floor(64*this.ticksperms/this.ipms*this.correction),this.timercyclesperinstruction=this.timercyclesperinstruction<=1?1:this.timercyclesperinstruction,this.timercyclesperinstruction=this.timercyclesperinstruction>=1e3?1e3:this.timercyclesperinstruction},t.prototype.LocalUpdate=function(e,t){if(this.nins+=e,t)return this.lastlooptime=-1,void(this.nins=0);if(this.lastlooptime<0)return this.lastlooptime=r.GetMilliseconds(),void(this.nins=0);var i=r.GetMilliseconds()-this.lastlooptime;i>50&&this.nins>2e3&&(this.ipms=this.nins/i,this.UpdateTimings(),this.lastlooptime=r.GetMilliseconds(),this.nins=0)},t.prototype.GlobalUpdate=function(e){if(!(e<0)){e/=this.ticksperms,this.baserealtime<=0&&(this.baserealtime=r.GetMilliseconds()),this.realtime=r.GetMilliseconds()-this.baserealtime,this.lastsystemticks>e?this.systemtime+=e-this.lastsystemticks+268435456/this.ticksperms:this.systemtime+=e-this.lastsystemticks,this.lastsystemticks=e;var t=Math.abs(this.systemtime-this.realtime);t>500&&(this.baserealtime=r.GetMilliseconds(),this.systemtime=0,this.lastsystemticks=0),this.correction=1,this.systemtime>this.realtime+50&&(this.correction=.9),this.realtime>this.systemtime+50&&(this.correction=1.1),t>200&&(this.correction=this.correction*this.correction),t>400&&(this.correction=this.correction*this.correction),this.oldcorrection!=this.correction&&(this.UpdateTimings(),this.oldcorrection=this.correction)}},i.exports=t}()}),define("cjs!jor1k/worker/riscv/syscalls",["require","exports","module","cjs!../messagehandler","cjs!../utils"],function(e,t,i){!function(){function t(e){this.ram=e,this.elf8mem=[],this.file_descriptor_table=[],this.file_size=[],this.file_pointer=[],this.file_descriptor_offset=9,this.elf8mem_offset=0}var r=e("cjs!../messagehandler"),s=e("cjs!../utils"),a=56,n=57,o=67,c=64,h=80,u=93,d=2011;t.prototype.HandleSysCall=function(e){e=0|e;var t=(this.ram,this.ram.Read32(e)),i=["spike","-m31","-p1","vmlinux"];switch(t){case a:for(var f,l=this.ram.Read32(e+16),p="",b=0;f=this.ram.Read8(l+b),0!=f;b++)p+=String.fromCharCode(f);var v=p;s.LoadBinaryResourceII("../sys/riscv/"+v,this.OnFileLoaded.bind(this),!1,function(e){throw e}),this.ram.Write32(e,this.file_descriptor_offset);break;case o:for(var m,k=this.ram.Read32(e+8),g=this.file_descriptor_table[k],R=this.ram.Read32(e+16),y=this.ram.Read32(e+24),w=this.ram.Read32(e+32),S=this.file_size[k],b=0;b<y&&!(b+w>=S);b++)m=this.elf8mem[g+b+w],this.ram.Write8(R+b,m);this.file_pointer[k]+=b,this.ram.Write32(e,b);break;case n:this.ram.Write32(e,0);break;case h:var k=this.ram.Read32(e+8),T=this.ram.Read32(e+16);this.ram.Write32(T,0),this.ram.Write32(T+4,0),this.ram.Write16(T+8,33279),this.ram.Write16(T+10,0),this.ram.Write16(T+12,0),this.ram.Write16(T+14,0),this.ram.Write32(T+16,0),this.ram.Write32(T+20,0),this.ram.Write32(T+24,this.file_size[k]),this.ram.Write16(T+28,512),this.ram.Write16(T+30,0),this.ram.Write32(T+32,0),this.ram.Write32(T+36,0),this.ram.Write32(T+40,0),this.ram.Write32(T+44,0),this.ram.Write32(T+48,0),this.ram.Write32(T+52,0),this.ram.Write32(T+56,0),this.ram.Write16(T+60,0),this.ram.Write16(T+62,0),this.ram.Write32(e,1);break;case c:for(var D=this.ram.Read32(e+24),b=0,x=this.ram.Read32(e+16);b<D;){var f=this.ram.Read8(x+b++);this.ram.Write8Little(-1879048192,f),10==f&&this.ram.Write8(-1879048192,13)}this.ram.Write32(e,b);break;case u:r.Debug("Program exited with sys_exit for inst at PC "+s.ToHex(this.pc)),r.Abort();break;case d:var E=this.ram.Read32(e+8),D=this.ram.Read32(e+16);this.ram.Write32(E,i.length);for(var I=8*i.length+32,b=0;b<i.length;b++)this.ram.Write32(E+8+8*b,E+I),I+=i[b].length+1;I=8*i.length+32;for(var b=0;b<i.length;b++){for(var A=0;A<i[b].length;A++)this.ram.Write8(E+I,i[b].charCodeAt(A)),I++;I++}this.ram.Write32(e,0);break;default:r.Debug("unkown SysCall "+s.ToHex(t)+" at PC "+s.ToHex(this.pc)),r.Abort()}},t.prototype.OnFileLoaded=function(e){var t=new Uint8Array(e),i=t.length;r.Debug("On File Loaded "+i);for(var s=0;s<i;s++)this.elf8mem[s+this.elf8mem_offset]=t[s];this.file_descriptor_table[++this.file_descriptor_offset]=this.elf8mem_offset,this.elf8mem_offset+=i,this.file_size[this.file_descriptor_offset]=i,this.file_pointer[this.file_descriptor_offset]=0},i.exports=t}()}),define("cjs!jor1k/worker/riscv/htif",["require","exports","module","cjs!../messagehandler","cjs!../utils","cjs!../bzip2","cjs!./syscalls"],function(e,t,i){!function(){function t(e,t,i){for(var r=0;r<e.length;r++)t.Write8(i+r,e.charCodeAt(r));t.Write8(i+e.length,0)}function r(e,t){this.ram=e,this.identify="rfb",this.Send=t,this.width=640,this.height=400,this.paddr=0,this.Read=function(e){this.width=e>>0&65535,this.height=e>>16&65535,this.n=this.width*this.height>>1,this.buffer=new Int32Array(this.n),this.Send(3,0,1)},this.Write=function(e){this.paddr=e,this.Send(3,1,1)},this.OnGetFB=function(){0!=this.paddr&&c.Send("GetFB",this.GetBuffer())},this.GetBuffer=function(){var e=0,t=this.buffer.length,i=this.buffer,r=this.ram.int32mem,s=this.paddr>>2;for(e=0;e<t;++e)i[e]=r[s+e];return this.buffer},c.Register("GetFB",this.OnGetFB.bind(this))}function s(e,t){this.ram=e,this.identify="bcd",this.Send=t,this.charqueue=[],this.readpresent=!1,this.Read=function(e){this.readpresent=!0,0!=this.charqueue.length&&(this.Send(1,0,this.charqueue.shift()),this.readpresent=!1)},this.Write=function(e){this.ram.Write8(-1879048192,e),10==e&&this.ram.Write8(-1879048192,13),this.Send(1,1,1)},this.ReceiveChar=function(e){this.charqueue=this.charqueue.concat(e),this.readpresent&&(this.Send(1,0,this.charqueue.shift()),this.readpresent=!1)},c.Register("htif.term0.Transfer",this.ReceiveChar.bind(this))}function a(e,t){this.ram=e,this.Send=t,this.syscallHandler=new d(this.ram),this.identify="syscall_proxy",this.Read=function(e){e>>>0>256?this.syscallHandler.HandleSysCall(e):(this.ram.Write8(-1879048192,e+48),c.Debug("return value: "+e),c.Abort()),this.Send(0,0,1)}}function n(e,t){this.ram=e,this.Send=t,this.buffer=new Uint8Array(1048576),this.identify="disk size="+this.buffer.length,h.LoadBinaryResourceII("../sys/riscv/ext2fsimage.bz2",function(e){this.buffer=new Uint8Array(20971520);var t=0,i=new Uint8Array(e);u.simple(i,function(e){this.buffer[t++]=e}.bind(this)),this.identify="disk size="+this.buffer.length}.bind(this),!1,function(e){throw e}),this.Read=function(e){for(var t=this.ram.Read32(e+0),i=this.ram.Read32(e+8),r=this.ram.Read32(e+16),s=this.ram.Read32(e+24),a=0;a<r;a++)this.ram.Write8(t+a,this.buffer[i+a]);this.Send(2,0,s)},this.Write=function(e){for(var t=this.ram.Read32(e+0),i=this.ram.Read32(e+8),r=this.ram.Read32(e+16),s=this.ram.Read32(e+24),a=0;a<r;a++)this.buffer[i+a]=this.ram.Read8(t+a);this.Send(2,1,s)}}function o(e,t){this.ram=e,this.irqdev=t,this.device=[],this.device.push(new a(this.ram,this.Send.bind(this))),this.device.push(new s(this.ram,this.Send.bind(this))),this.device.push(new n(this.ram,this.Send.bind(this))),this.device.push(new r(this.ram,this.Send.bind(this))),this.devid=0,this.cmd=0,this.reg_tohost=0,this.reg_devcmdfromhost=0,this.fromhostqueue=[]}var c=e("cjs!../messagehandler"),h=e("cjs!../utils"),u=e("cjs!../bzip2"),d=e("cjs!./syscalls");o.prototype.Send=function(e,t,i){this.fromhostqueue.push({devid:e,cmd:t,data:i}),1==this.fromhostqueue.length&&(this.reg_devcmdfromhost=this.fromhostqueue[0].devid<<16|this.fromhostqueue[0].cmd),this.irqdev.RaiseInterrupt(15)},o.prototype.ReadDEVCMDToHost=function(){return this.devid<<16|this.cmd},o.prototype.WriteDEVCMDToHost=function(e){this.devid=e>>>16,this.cmd=65535&e},o.prototype.WriteDEVCMDFromHost=function(e){this.reg_devcmdfromhost=e},o.prototype.ReadDEVCMDFromHost=function(){return 0!=this.fromhostqueue.length?this.reg_devcmdfromhost:0},o.prototype.ReadToHost=function(){return 0},o.prototype.WriteToHost=function(e){this.reg_tohost=0|e,this.HandleRequest()},o.prototype.ReadFromHost=function(){return 0!=this.fromhostqueue.length?this.fromhostqueue[0].data:0},o.prototype.WriteFromHost=function(e){0==e&&0==this.reg_devcmdfromhost&&(this.fromhostqueue.shift(),this.fromhostqueue.length>0&&(this.reg_devcmdfromhost=this.fromhostqueue[0].devid<<16|this.fromhostqueue[0].cmd,this.irqdev.RaiseInterrupt(15)))},o.prototype.IsQueueEmpty=function(){return 0==this.fromhostqueue.length},o.prototype.HandleRequest=function(){if(255==this.cmd){var e=this.reg_tohost;return this.device[this.devid]?t(this.device[this.devid].identify,this.ram,e):this.ram.Write8(e+0,0),this.Send(this.devid,255,1),void(this.reg_tohost=0)}return 0==this.cmd?(this.device[this.devid]?this.device[this.devid].Read(this.reg_tohost):(c.Debug("Error in HTIF: unknown read from device"),c.Abort()),void(this.reg_tohost=0)):1==this.cmd?(this.device[this.devid]?this.device[this.devid].Write(this.reg_tohost):(c.Debug("Error in HTIF: unknown write from device"),c.Abort()),void(this.reg_tohost=0)):(c.Debug("Error HTIF: unknown request"),void c.Abort())},i.exports=o}()}),define("cjs!jor1k/worker/imul",["require","exports","module"],function(e,t,i){!function(){i.exports=Math.imul||function(e,t){var i=e>>>16&65535,r=65535&e,s=t>>>16&65535,a=65535&t;return r*a+(i*a+r*s<<16>>>0)|0}}()}),define("cjs!jor1k/worker/or1k/fastcpu",["require","exports","module","cjs!../messagehandler"],function(e,t,i){!function(){function t(e,t,i){"use asm";var r=e.Math.floor;var s=t.imul;var a=t.DebugMessage;var n=t.abort;var o=t.Read32;var c=t.Write32;var h=t.Read16;var u=t.Write16;var d=t.Read8;var f=t.Write8;var l=0;var p=1;var b=2;var v=3;var m=4;var k=5;var g=6;var R=7;var y=8;var w=1;var S=17;var T=48;var D=32;var x=64;var E=4;var I=3;var A=6;var C=5;var j=0;var M=0xA00;var _=0x400;var H=0x100;var q=0x900;var L=0x300;var U=0x200;var P=0x500;var W=0x800;var B=0xC00;var F=0xE00;var z=new e.Int32Array(i);var O=new e.Float32Array(i);var G=new e.Int32Array(i);var N=new e.Uint8Array(i);var V=new e.Uint16Array(i);var X=0x0;var Q=0x100000;var K=0x2000;var Y=0x4000;var J=0x6000;var Z=0x0;var $=0;var ee=0;var te=-4;var ie=0;var re=0;var se=0x0;var ae=0x0;var ne=0;var oe=-1;var ce=-1;var he=-1;var ue=-1;var de=-1;var fe=-1;var le=-1;var pe=-1;var be=-1;var ve=-1;var me=-1;var ke=-1;var ge=-1;var Re=-1;var ye=-1;var we=-1;var Se=-1;var Te=-1;var De=-1;var xe=0x0;var Ee=0x0;var Ie=0x3;var Ae=0x0;var Ce=1;var je=0;var Me=0;var _e=0;var He=0;var qe=0;var Le=0;var Ue=0;var Pe=0;var We=0;var Be=0;var Fe=0;var ze=0;var Oe=0;var Ge=0;var Ne=1;var Ve=0;var Xe=0x0;var Qe=0x0;var Ke=0x0;var Ye=0x0;var Je=0;var Ze=0x0;function $e(){ct();et()}function et(){xe=0x0;Ee=0x0;Ie=0x3;Ae=0x0;G[K+(E<<2)>>2]=0x18;G[K+(I<<2)>>2]=0x18;G[K+(A<<2)>>2]=0x48;G[K+(C<<2)>>2]=0x48;G[K+(j<<2)>>2]=0x12000001;G[K+(w<<2)>>2]=0x619;$=0;ee=0;te=-4;vt(H,0x0)}function tt(){oe=-1;ce=-1;he=-1;ue=-1;de=-1;fe=-1;le=-1;pe=-1;be=-1;ve=-1;me=-1;ke=-1;ge=-1;Re=-1;ye=-1;we=-1;Se=-1;Te=-1}function it(){return Z>>>2|0}function rt(){Z=G[0x100+0>>2]<<2;se=G[0x100+4>>2]<<2;re=G[0x100+8>>2]|0;xe=G[0x100+16>>2]|0;Ee=G[0x100+20>>2]|0;Ie=G[0x100+24>>2]|0;Ae=G[0x100+28>>2]|0;Qe=G[0x100+32>>2]|0;Ke=G[0x100+36>>2]|0;Ye=G[0x100+40>>2]|0;$=0x0;ee=0x0;ie=0x0;if(re|0){}se=Z}function st(){G[0x100+0>>2]=Z>>>2;G[0x100+4>>2]=Z+4>>>2;if(($|0)==(ie|0)){G[0x100+4>>2]=se>>>2}G[0x100+8>>2]=re|0;G[0x100+12>>2]=0;G[0x100+16>>2]=xe|0;G[0x100+20>>2]=Ee|0;G[0x100+24>>2]=Ie|0;G[0x100+28>>2]=Ae|0;G[0x100+32>>2]=Qe|0;G[0x100+36>>2]=Ke|0;G[0x100+40>>2]=Ye|0}function at(){var e=0x0;if(xe>>30==0)return-1;e=(xe&0xFFFFFFF)-(Ee&0xFFFFFFF)|0;if((e|0)<0){e=e+0xFFFFFFF|0}return e|0}function nt(e){e=e|0;Ee=Ee+e|0}function ot(){if(xe>>30==0)return-1;return Ee&0xFFFFFFF|0}function ct(){Qe=G[Q+0x900>>2]|0;Ke=G[Q+0xA00>>2]|0;Ye=(G[Q+0x2010>>2]&0xFFF)<<16|G[Q+0x2014>>2]&0xFFFF|0}function ht(e){e=e|0;var t=0;t=Me;Ce=e&1<<0;je=e&1<<1;Me=e&1<<2;_e=e&1<<3;He=e&1<<4;qe=e&1<<5;Le=e&1<<6;Ue=e&1<<7;Pe=e&1<<8;We=e&1<<9;Be=e&1<<10;Fe=e&1<<11;ze=e&1<<12;Oe=e&1<<13;Ge=e&1<<14;Ne=1;Ve=e&1<<16;Xe=e>>28&0xF;if(Ue){a(l|0);n()}if(Xe){a(p|0);n()}if(Ge){a(b|0);n()}if(Oe){a(v|0);n()}if(Me){if((t|0)==(0|0)){dt()}}}function ut(){var e=0x0;e=e|(Ce?1<<0:0);e=e|(je?1<<1:0);e=e|(Me?1<<2:0);e=e|(_e?1<<3:0);e=e|(He?1<<4:0);e=e|(qe?1<<5:0);e=e|(Le?1<<6:0);e=e|(Ue?1<<7:0);e=e|(Pe?1<<8:0);e=e|(We?1<<9:0);e=e|(Be?1<<10:0);e=e|(Fe?1<<11:0);e=e|(ze?1<<12:0);e=e|(Oe?1<<13:0);e=e|(Ge?1<<14:0);e=e|(Ne?1<<15:0);e=e|(Ve?1<<16:0);e=e|Xe<<28;return e|0}function dt(){if(!Me){return}if(Ie&Ae){Je=1}}function ft(e,t){e=e|0;t=t|0;var i=0;i=1<<e|0;Ae=Ae|i;dt()}function lt(e,t){e=e|0;t=t|0;Ae=Ae&~(1<<e)}function pt(e,t){e=e|0;t=t|0;var i=0;var r=0;i=e&0x7FF;r=e>>11&0x1F;switch(r|0){case 0:if((i|0)==(S|0)){ht(t)}G[K+(i<<2)>>2]=t;break;case 1:G[Y+(i<<2)>>2]=t;break;case 2:G[J+(i<<2)>>2]=t;break;case 3:case 4:break;case 8:Ze=0x1;break;case 9:switch(i|0){case 0:Ie=t|0x3;if(Me){if(Ie&Ae){a(m|0);n()}}break;case 2:break;default:a(k|0);n()}break;case 10:switch(i|0){case 0:xe=t|0;if((xe>>30&3)!=0x3){a(g|0);n()}break;case 1:Ee=t|0;break;default:a(y|0);n();break}break;default:a(y|0);n();break}}function bt(e){e=e|0;var t=0;var i=0;t=e&0x7FF;i=e>>11&0x1F;switch(i|0){case 0:if((t|0)==(S|0)){return ut()|0}return G[K+(t<<2)>>2]|0;case 1:return G[Y+(t<<2)>>2]|0;case 2:return G[J+(t<<2)>>2]|0;case 8:return 0x0;case 9:switch(t|0){case 0:return Ie|0;case 2:return Ae|0;default:a(y|0);n();break}break;case 10:switch(t|0){case 0:return xe|0;case 1:return Ee|0;default:a(y|0);n();break}break;default:a(y|0);n();break}return 0|0}function vt(e,t){e=e|0;t=t|0;var i=0;i=e|(Ge?0xf0000000:0x0);pt(T,t);pt(x,ut()|0);De=-1;ze=0;Ce=1;Me=0;je=0;qe=0;oe=0;ce=0;he=0;ue=0;de=0;fe=0;le=0;pe=0;be=0;ve=0;me=0;ge=0;ke=0;ye=0;Re=0;we=0;Se=0;Te=0;ie=$|0;se=i;switch(e|0){case 0x100:break;case 0x300:case 0x900:case 0xE00:case 0x200:Z=te+$|0;pt(D,Z-(re?4:0)|0);break;case 0xA00:case 0x400:case 0x500:case 0x800:pt(D,Z-(re?4:0)|0);break;case 0xC00:Z=te+$|0;pt(D,Z+4-(re?4:0)|0);break;default:a(R|0);n()}re=0;Le=0}function mt(e,t){e=e|0;t=t|0;var i=0;var r=0;var s=0;var a=0;if((G[Q+0x900>>2]|0)==(Qe|0)){vt(q,e);return 0|0}i=e;r=G[Q+Ye>>2]|0;s=i>>>0x18<<2;a=s+r|0;s=0x40000000+a&0xFFFFFFFF;r=G[Q+s>>2]|0;if((r|0)==0){vt(L,e);return 0|0}r=0xffffe000;s=G[Q+s>>2]|0;s=s&r;a=i>>>0xD;r=a&0x7FF;r=r<<0x2;r=r+s|0;i=G[Q+r>>2]|0;if((i&1)==0){vt(L,e);return 0|0}s=i&0xFFFFe3fa;a=a&t-1;G[Y+((0x280|a)<<2)>>2]=s;i=e;s=i&0xFFFFE000;s=s|0x1;G[Y+((0x200|a)<<2)>>2]=s;return 1|0}function kt(e,t){e=e|0;t=t|0;var i=0;var r=0;var s=0;var a=0;if((G[Q+0xA00>>2]|0)==(Ke|0)){vt(M,e);return 0|0}i=e;r=G[Q+Ye>>2]|0;s=i>>>0x18<<2;a=s+r|0;s=0x40000000+a&0xFFFFFFFF;r=G[Q+s>>2]|0;if((r|0)==0){vt(_,e);return 0|0}r=0xffffe000;s=G[Q+s>>2]|0;s=s&r;a=i>>>0xD;r=a&0x7FF;r=r<<0x2;r=r+s|0;i=G[Q+r>>2]|0;if((i&1)==0){vt(_,e);return 0|0}s=i&0xFFFFe03a;r=i&0x7c0;if((r|0)!=0x0){a=a&t-1;s=s|0xc0}G[J+((0x280|a)<<2)>>2]=s;i=e;s=i&0xFFFFE000;s=s|0x1;G[J+((0x200|a)<<2)>>2]=s;return 1|0}function gt(e,t){e=e|0;t=t|0;var i=0;var r=0;var s=0;if(!qe){return e|0}i=e>>13&63;r=G[Y+((0x200|i)<<2)>>2]|0;if((r&1)==0){if(mt(e,64)|0){r=G[Y+(0x200+i<<2)>>2]|0}else{return-1|0}}if(r>>19!=e>>19){if(mt(e,64)|0){r=G[Y+(0x200+i<<2)>>2]|0}else{return-1|0}}s=G[Y+((0x280|i)<<2)>>2]|0;if(Ce){if(!t){if(!(s&0x100)){vt(L,e);return-1|0}}else{if(!(s&0x200)){vt(L,e);return-1|0}}}else{if(!t){if(!(s&0x40)){vt(L,e);return-1|0}}else{if(!(s&0x80)){vt(L,e);return-1|0}}}return s&0xFFFFE000|e&0x1FFF|0}function Rt(e,t){e=e|0;t=t|0;var i=0x0;var l=0x0;var p=0;var b=0x0;var v=0x0,m=0x0,k=0x0;var g=0x0;var R=0x0;var w=0x0;var S=0x0;var E=0x0;var I=0x0;var A=0;for(;;){if(($|0)!=(ie|0)){i=G[$>>2]|0;$=$+4|0;switch(i>>26&0x3F){case 0x0:Z=te+$|0;ae=Z+(i<<6>>4)|0;if((ie|0)==($|0)){ne=1}else{ie=$+4|0;se=ae|0}re=1;continue;case 0x1:Z=te+$|0;ae=Z+(i<<6>>4)|0;z[9]=Z+8|0;if((ie|0)==($|0)){ne=1}else{ie=$+4|0;se=ae|0}re=1;continue;case 0x3:if(We){break}Z=te+$|0;ae=Z+(i<<6>>4)|0;if((ie|0)==($|0)){ne=1}else{ie=$+4|0;se=ae|0}re=1;continue;case 0x4:if(!We){continue}Z=te+$|0;ae=Z+(i<<6>>4)|0;if((ie|0)==($|0)){ne=1}else{ie=$+4|0;se=ae|0}re=1;continue;case 0x5:continue;case 0x6:b=i>>21&0x1F;z[b<<2>>2]=(i&0xFFFF)<<16;continue;case 0x8:if((i&0xFFFF0000)==0x21000000){vt(F,G[K+T>>2]|0)}else{vt(B,G[K+T>>2]|0)}continue;case 0x9:ae=bt(D)|0;tt();ie=$;se=ae;ht(bt(x)|0);continue;case 0x11:ae=z[(i>>9&0x7C)>>2]|0;if((ie|0)==($|0)){ne=1}else{ie=$+4|0;se=ae|0}re=1;continue;case 0x12:Z=te+$|0;ae=z[(i>>9&0x7C)>>2]|0;z[9]=Z+8|0;if((ie|0)==($|0)){ne=1}else{ie=$+4|0;se=ae|0}re=1;continue;case 0x1B:g=(z[(i>>14&0x7C)>>2]|0)+(i<<16>>16)|0;if((me^g)>>13){R=gt(g,0)|0;if((R|0)==-1){break}me=g;ce=(R^g)>>13<<13}R=ce^g;De=R;z[(i>>19&0x7C)>>2]=(R|0)>0?G[Q+R>>2]|0:o(R|0)|0;continue;case 0x21:g=(z[(i>>14&0x7C)>>2]|0)+(i<<16>>16)|0;if((me^g)>>13){R=gt(g,0)|0;if((R|0)==-1){break}me=g;ce=(R^g)>>13<<13}R=ce^g;z[(i>>19&0x7C)>>2]=(R|0)>0?G[Q+R>>2]|0:o(R|0)|0;continue;case 0x23:g=(z[(i>>14&0x7C)>>2]|0)+(i<<16>>16)|0;if((ge^g)>>13){R=gt(g,0)|0;if((R|0)==-1){break}ge=g;ue=(R^g)>>13<<13}R=ue^g;if((R|0)>=0){z[(i>>19&0x7C)>>2]=N[Q+(R^3)|0]|0}else{z[(i>>19&0x7C)>>2]=d(R|0)|0}continue;case 0x24:g=(z[(i>>14&0x7C)>>2]|0)+(i<<16>>16)|0;if((ke^g)>>13){R=gt(g,0)|0;if((R|0)==-1){break}ke=g;he=(R^g)>>13<<13}R=he^g;if((R|0)>=0){z[(i>>19&0x7C)>>2]=N[Q+(R^3)|0]<<24>>24}else{z[(i>>19&0x7C)>>2]=(d(R|0)|0)<<24>>24}continue;case 0x25:g=(z[(i>>14&0x7C)>>2]|0)+(i<<16>>16)|0;if((ye^g)>>13){R=gt(g,0)|0;if((R|0)==-1){break}ye=g;fe=(R^g)>>13<<13}R=fe^g;if((R|0)>=0){z[(i>>19&0x7C)>>2]=V[Q+(R^2)>>1]}else{z[(i>>19&0x7C)>>2]=h(R|0)|0}continue;case 0x26:g=(z[(i>>14&0x7C)>>2]|0)+(i<<16>>16)|0;if((Re^g)>>13){R=gt(g,0)|0;if((R|0)==-1){break}Re=g;de=(R^g)>>13<<13}R=de^g;if((R|0)>=0){z[(i>>19&0x7C)>>2]=V[Q+(R^2)>>1]<<16>>16}else{z[(i>>19&0x7C)>>2]=(h(R|0)|0)<<16>>16}continue;case 0x27:v=z[(i>>14&0x7C)>>2]|0;z[(i>>19&0x7C)>>2]=v+(i<<16>>16)|0;continue;case 0x29:z[(i>>19&0x7C)>>2]=z[(i>>14&0x7C)>>2]&(i&0xFFFF);continue;case 0x2A:z[(i>>19&0x7C)>>2]=z[(i>>14&0x7C)>>2]|i&0xFFFF;continue;case 0x2B:v=z[(i>>14&0x7C)>>2]|0;z[(i>>19&0x7C)>>2]=v^i<<16>>16;continue;case 0x2D:z[(i>>19&0x7C)>>2]=bt(z[(i>>14&0x7C)>>2]|i&0xFFFF)|0;continue;case 0x2E:switch(i>>6&0x3){case 0:z[(i>>19&0x7C)>>2]=z[(i>>14&0x7C)>>2]<<(i&0x1F);continue;case 1:z[(i>>19&0x7C)>>2]=z[(i>>14&0x7C)>>2]>>>(i&0x1F);continue;case 2:z[(i>>19&0x7C)>>2]=z[(i>>14&0x7C)>>2]>>(i&0x1F);continue;default:a(y|0);n();break}break;case 0x2F:l=i<<16>>16;switch(i>>21&0x1F){case 0x0:We=(z[(i>>14&0x7C)>>2]|0)==(l|0);continue;case 0x1:We=(z[(i>>14&0x7C)>>2]|0)!=(l|0);continue;case 0x2:We=z[(i>>14&0x7C)>>2]>>>0>l>>>0;continue;case 0x3:We=z[(i>>14&0x7C)>>2]>>>0>=l>>>0;continue;case 0x4:We=z[(i>>14&0x7C)>>2]>>>0<l>>>0;continue;case 0x5:We=z[(i>>14&0x7C)>>2]>>>0<=l>>>0;continue;case 0xa:We=(z[(i>>14&0x7C)>>2]|0)>(l|0);continue;case 0xb:We=(z[(i>>14&0x7C)>>2]|0)>=(l|0);continue;case 0xc:We=(z[(i>>14&0x7C)>>2]|0)<(l|0);continue;case 0xd:We=(z[(i>>14&0x7C)>>2]|0)<=(l|0);continue;default:a(y|0);n();break}break;case 0x30:l=i&0x7FF|i>>10&0xF800;pt(z[(i>>14&0x7C)>>2]|l,z[(i>>9&0x7C)>>2]|0);if(Ze){Ze=0x0;if((Je|0)==0)if(!(xe&1<<28)){return e|0}}continue;case 0x32:v=i>>14&0x7C;m=i>>9&0x7C;k=i>>19&0x7C;switch(i&0xFF){case 0x0:O[k>>2]=+O[v>>2]+ +O[m>>2];continue;case 0x1:O[k>>2]=+O[v>>2]-+O[m>>2];continue;case 0x2:O[k>>2]=+O[v>>2]*+O[m>>2];continue;case 0x3:O[k>>2]=+O[v>>2]/+O[m>>2];continue;case 0x4:O[k>>2]=+(z[v>>2]|0);continue;case 0x5:z[k>>2]=~~+r(+O[v>>2]);continue;case 0x7:O[k>>2]=+O[k>>2]+ +O[v>>2]*+O[m>>2];continue;case 0x8:We=+O[v>>2]==+O[m>>2];continue;case 0x9:We=+O[v>>2]!=+O[m>>2];continue;case 0xa:We=+O[v>>2]>+O[m>>2];continue;case 0xb:We=+O[v>>2]>=+O[m>>2];continue;case 0xc:We=+O[v>>2]<+O[m>>2];continue;case 0xd:We=+O[v>>2]<=+O[m>>2];continue;default:a(y|0);n();break}break;case 0x33:l=(i>>10&0xF800|i&0x7FF)<<16>>16;g=(z[(i>>14&0x7C)>>2]|0)+l|0;if((we^g)>>13){R=gt(g,1)|0;if((R|0)==-1){break}we=g;le=(R^g)>>13<<13}R=le^g;We=(R|0)==(De|0)?1|0:0|0;De=-1;if((We|0)==0){break}if((R|0)>0){G[Q+R>>2]=z[(i>>9&0x7C)>>2]|0}else{c(R|0,z[(i>>9&0x7C)>>2]|0)}continue;case 0x35:l=(i>>10&0xF800|i&0x7FF)<<16>>16;g=(z[(i>>14&0x7C)>>2]|0)+l|0;if((we^g)>>13){R=gt(g,1)|0;if((R|0)==-1){break}we=g;le=(R^g)>>13<<13}R=le^g;if((R|0)>0){G[Q+R>>2]=z[(i>>9&0x7C)>>2]|0}else{c(R|0,z[(i>>9&0x7C)>>2]|0)}continue;case 0x36:l=(i>>10&0xF800|i&0x7FF)<<16>>16;g=(z[(i>>14&0x7C)>>2]|0)+l|0;if((Se^g)>>13){R=gt(g,1)|0;if((R|0)==-1){break}Se=g;pe=(R^g)>>13<<13}R=pe^g;if((R|0)>0){N[Q+(R^3)|0]=z[(i>>9&0x7C)>>2]|0}else{f(R|0,z[(i>>9&0x7C)>>2]|0)}continue;case 0x37:l=(i>>10&0xF800|i&0x7FF)<<16>>16;g=(z[(i>>14&0x7C)>>2]|0)+l|0;if((Te^g)>>13){R=gt(g,1)|0;if((R|0)==-1){break}Te=g;be=(R^g)>>13<<13}R=be^g;if((R|0)>=0){V[Q+(R^2)>>1]=z[(i>>9&0x7C)>>2]}else{u(R|0,z[(i>>9&0x7C)>>2]|0)}continue;case 0x38:v=z[(i>>14&0x7C)>>2]|0;m=z[(i>>9&0x7C)>>2]|0;b=i>>19&0x7C;switch(i&0x3CF){case 0x0:z[b>>2]=v+m;continue;case 0x2:z[b>>2]=v-m;continue;case 0x3:z[b>>2]=v&m;continue;case 0x4:z[b>>2]=v|m;continue;case 0x5:z[b>>2]=v^m;continue;case 0x8:z[b>>2]=v<<(m&0x1F);break;case 0x48:z[b>>2]=v>>>(m&0x1F);continue;case 0xf:z[b>>2]=0;for(p=0;(p|0)<32;p=p+1|0){if(v&1<<p){z[b>>2]=p+1;break}}continue;case 0x88:z[b>>2]=v>>(m&0x1F);continue;case 0x10f:z[b>>2]=0;for(p=31;(p|0)>=0;p=p-1|0){if(v&1<<p){z[b>>2]=p+1;break}}continue;case 0x306:z[b>>2]=s(v|0,m|0)|0;continue;case 0x30a:Be=(m|0)==0;Fe=0;if(!Be){z[b>>2]=(v>>>0)/(m>>>0)}continue;case 0x309:Be=(m|0)==0;Fe=0;if(!Be){z[b>>2]=(v|0)/(m|0)}continue;default:a(y|0);n();break}break;case 0x39:switch(i>>21&0x1F){case 0x0:We=(z[(i>>14&0x7C)>>2]|0)==(z[(i>>9&0x7C)>>2]|0);continue;case 0x1:We=(z[(i>>14&0x7C)>>2]|0)!=(z[(i>>9&0x7C)>>2]|0);continue;case 0x2:We=z[(i>>14&0x7C)>>2]>>>0>z[(i>>9&0x7C)>>2]>>>0;continue;case 0x3:We=z[(i>>14&0x7C)>>2]>>>0>=z[(i>>9&0x7C)>>2]>>>0;continue;case 0x4:We=z[(i>>14&0x7C)>>2]>>>0<z[(i>>9&0x7C)>>2]>>>0;continue;case 0x5:We=z[(i>>14&0x7C)>>2]>>>0<=z[(i>>9&0x7C)>>2]>>>0;continue;case 0xa:We=(z[(i>>14&0x7C)>>2]|0)>(z[(i>>9&0x7C)>>2]|0);continue;case 0xb:We=(z[(i>>14&0x7C)>>2]|0)>=(z[(i>>9&0x7C)>>2]|0);continue;case 0xc:We=(z[(i>>14&0x7C)>>2]|0)<(z[(i>>9&0x7C)>>2]|0);continue;case 0xd:We=(z[(i>>14&0x7C)>>2]|0)<=(z[(i>>9&0x7C)>>2]|0);continue;default:a(y|0);n()}break;default:a(y|0);n();break}}else{Z=se;if(!ne|0){re=0}A=A+($-ee>>2)|0;if((A|0)>=64)if(!(ne|0)){A=A-64|0;e=e-64|0;if((e|0)<0)return 0x0;if(xe>>30!=0){I=(xe&0xFFFFFFF)-(Ee&0xFFFFFFF)|0;if((I|0)<0){I=I+0xFFFFFFF|0}Ee=Ee+t|0;if((I|0)<(t|0)){if(xe&1<<29){xe=xe|1<<28}}}if(xe&1<<28){if(je){vt(P,G[K+(T<<2)>>2]|0);Z=se}}else if(Me|0)if(Je|0){Je=0;vt(W,G[K+(T<<2)>>2]|0);Z=se}}if((ve^Z)&0xFFFFE000){ve=Z;if(!Le){oe=0x0}else{w=Z>>13&63;S=G[J+((0x200|w)<<2)>>2]|0;if((S&1)==0){if(kt(Z,64)|0){S=G[J+((0x200|w)<<2)>>2]|0}else{ee=$;ne=0;continue}}if(S>>19!=Z>>19){if(kt(Z,64)|0){S=G[J+((0x200|w)<<2)>>2]|0}else{ee=$;ne=0;continue}}E=G[J+((0x280|w)<<2)>>2]|0;oe=(E^S)>>13<<13}}$=Q+(oe^Z)|0;ee=$;te=Z-4-ee|0;if(ne|0){ne=0;ie=$+4|0;se=ae}else{ie=($>>13)+1<<13;se=(Z>>13)+1<<13}}}return e|0}return{Init:$e,Reset:et,InvalidateTLB:tt,Step:Rt,GetFlags:ut,SetFlags:ht,PutState:rt,GetState:st,GetTimeToNextInterrupt:at,ProgressTime:nt,GetTicks:ot,RaiseInterrupt:ft,ClearInterrupt:lt,AnalyzeImage:ct,GetStat:it}}e("cjs!../messagehandler");i.exports=t}()}),define("cjs!jor1k/worker/or1k/safecpu",["require","exports","module","cjs!../messagehandler","cjs!../utils"],function(e,t,i){!function(){function t(e){this.ram=e,this.r=new Int32Array(this.ram.heap,0,136),this.f=new Float32Array(this.ram.heap,0,128),this.group0=new Int32Array(this.ram.heap,8192,8192),this.group1=new Int32Array(this.ram.heap,16384,8192),this.group2=new Int32Array(this.ram.heap,24576,8192),this.pc=0,this.nextpc=0,this.delayedins=!1,this.clock=0,this.EA=-1,this.TTMR=0,this.TTCR=0,this.PICMR=3,this.PICSR=0,this.SR_SM=!0,this.SR_TEE=!1,this.SR_IEE=!1,this.SR_DCE=!1,this.SR_ICE=!1,this.SR_DME=!1,this.SR_IME=!1,this.SR_LEE=!1,this.SR_CE=!1,this.SR_F=!1,this.SR_CY=!1,this.SR_OV=!1,this.SR_OVE=!1,this.SR_DSX=!1,this.SR_EPH=!1,this.SR_FO=!0,this.SR_SUMRA=!1,this.SR_CID=0,this.Reset()}var r=e("cjs!../messagehandler"),s=e("cjs!../utils"),a=1,n=17,o=48,c=32,h=64,u=4,d=3,f=6,l=5,p=0,b=2560,v=1024,m=256,k=2304,g=768,R=512,y=1280,w=2048,S=3072,T=3584;t.prototype.Reset=function(){this.TTMR=0,this.TTCR=0,this.PICMR=3,this.PICSR=0,this.group0[u]=24,this.group0[d]=24,this.group0[f]=72,this.group0[l]=72,this.group0[p]=301989889,this.group0[a]=1561,this.Exception(m,0),this.pc=this.nextpc,this.nextpc++},t.prototype.InvalidateTLB=function(){},t.prototype.GetTimeToNextInterrupt=function(){if(this.TTMR>>30==0)return-1;var e=(268435455&this.TTMR)-(268435455&this.TTCR);return e+=e<0?268435455:0},t.prototype.GetTicks=function(){return this.TTMR>>30==0?-1:268435455&this.TTCR},t.prototype.ProgressTime=function(e){this.TTCR=this.TTCR+e&4294967295},t.prototype.AnalyzeImage=function(){this.boot_dtlb_misshandler_address=0,this.boot_itlb_misshandler_address=0,this.current_pgd=0},t.prototype.SetFlags=function(e){this.SR_SM=!!(1&e),
this.SR_TEE=!!(2&e);var t=this.SR_IEE;this.SR_IEE=!!(4&e),this.SR_DCE=!!(8&e),this.SR_ICE=!!(16&e);this.SR_DME;this.SR_DME=!!(32&e);this.SR_IME;this.SR_IME=!!(64&e),this.SR_LEE=!!(128&e),this.SR_CE=!!(256&e),this.SR_F=!!(512&e),this.SR_CY=!!(1024&e),this.SR_OV=!!(2048&e),this.SR_OVE=!!(4096&e),this.SR_DSX=!!(8192&e),this.SR_EPH=!!(16384&e),this.SR_FO=!0,this.SR_SUMRA=!!(65536&e),this.SR_CID=e>>28&15,this.SR_LEE&&(r.Debug("little endian not supported"),r.Abort()),this.SR_CID&&(r.Debug("context id not supported"),r.Abort()),this.SR_EPH&&(r.Debug("exception prefix not supported"),r.Abort()),this.SR_DSX&&(r.Debug("delay slot exception not supported"),r.Abort()),this.SR_IEE&&!t&&this.CheckForInterrupt()},t.prototype.GetFlags=function(){var e=0;return e|=this.SR_SM?1:0,e|=this.SR_TEE?2:0,e|=this.SR_IEE?4:0,e|=this.SR_DCE?8:0,e|=this.SR_ICE?16:0,e|=this.SR_DME?32:0,e|=this.SR_IME?64:0,e|=this.SR_LEE?128:0,e|=this.SR_CE?256:0,e|=this.SR_F?512:0,e|=this.SR_CY?1024:0,e|=this.SR_OV?2048:0,e|=this.SR_OVE?4096:0,e|=this.SR_DSX?8192:0,e|=this.SR_EPH?16384:0,e|=this.SR_FO?32768:0,e|=this.SR_SUMRA?65536:0,e|=this.SR_CID<<28},t.prototype.CheckForInterrupt=function(){this.SR_IEE&&this.PICMR&this.PICSR&&(this.Exception(w,this.group0[o]),this.pc=this.nextpc++)},t.prototype.RaiseInterrupt=function(e,t){var i=1<<e;this.PICSR|=i,this.CheckForInterrupt()},t.prototype.ClearInterrupt=function(e,t){this.PICSR&=~(1<<e)},t.prototype.SetSPR=function(e,t){var i=2047&e,s=e>>11&31;switch(s){case 0:i==n&&this.SetFlags(t),this.group0[i]=t;break;case 1:this.group1[i]=t;break;case 2:this.group2[i]=t;break;case 3:case 4:break;case 8:break;case 9:switch(i){case 0:this.PICMR=3|t,this.SR_IEE&&this.PICMR&this.PICSR&&(r.Debug("Error in SetSPR: Direct triggering of interrupt exception not supported?"),r.Abort());break;case 2:break;default:r.Debug("Error in SetSPR: interrupt address not supported"),r.Abort()}break;case 10:switch(i){case 0:this.TTMR=t,3!=(this.TTMR>>30&3);break;case 1:this.TTCR=t;break;default:r.Debug("Error in SetSPR: Tick timer address not supported"),r.Abort()}break;default:r.Debug("Error in SetSPR: group "+s+" not found"),r.Abort()}},t.prototype.GetSPR=function(e){var t=2047&e,i=e>>11&31;switch(i){case 0:return t==n?this.GetFlags():this.group0[t];case 1:return this.group1[t];case 2:return this.group2[t];case 8:return 0;case 9:switch(t){case 0:return this.PICMR;case 2:return this.PICSR;default:r.Debug("Error in GetSPR: PIC address unknown"),r.Abort()}break;case 10:switch(t){case 0:return this.TTMR;case 1:return this.TTCR;default:r.Debug("Error in GetSPR: Tick timer address unknown"),r.Abort()}break;default:r.Debug("Error in GetSPR: group "+i+" unknown"),r.Abort()}},t.prototype.Exception=function(e,t){var i=e|(this.SR_EPH?4026531840:0);switch(this.SetSPR(o,t),this.SetSPR(h,this.GetFlags()),this.EA=-1,this.SR_OVE=!1,this.SR_SM=!0,this.SR_IEE=!1,this.SR_TEE=!1,this.SR_DME=!1,this.nextpc=i>>2,e){case m:break;case b:case v:case k:case g:case R:case y:case w:case T:this.SetSPR(c,(this.pc<<2)-(this.delayedins?4:0));break;case S:this.SetSPR(c,(this.pc<<2)+4-(this.delayedins?4:0));break;default:r.Debug("Error in Exception: exception type not supported"),r.Abort()}e==y&&this.TTMR>>30==1&&(this.TTCR=0),this.delayedins=!1,this.SR_IME=!1},t.prototype.DTLBLookup=function(e,t){if(!this.SR_DME)return e;var i=e>>13&63,s=this.group1[512|i];if(0==(1&s)||s>>19!=e>>19)return this.Exception(k,e),-1;192&s&&(r.Debug("Error: LRU ist not supported"),r.Abort());var a=this.group1[640|i];if(this.SR_SM){if(!t&&!(256&a)||t&&!(512&a))return this.Exception(g,e),-1}else if(!t&&!(64&a)||t&&!(128&a))return this.Exception(g,e),-1;return 4294959104&a|8191&e},t.prototype.GetInstruction=function(e){if(!this.SR_IME)return this.ram.Read32Big(e);var t=e>>13&63;t&=63;var i=this.group2[512|t];if(0==(1&i)||i>>19!=e>>19)return this.Exception(b,this.pc<<2),-1;192&i&&(r.Debug("Error: LRU ist not supported"),r.Abort());var s=this.group2[640|t];if(this.SR_SM){if(!(64&s))return this.Exception(v,this.pc<<2),-1}else if(!(128&s))return this.Exception(v,this.pc<<2),-1;return this.ram.Read32Big(4294959104&s|8191&e)},t.prototype.Step=function(e,t){var i=0,a=0,n=0,u=0,d=0,f=0,l=0,p=this.r,b=this.f,v=this.ram,m=this.ram.int32mem,k=(this.group2,0),g=0;do if(this.clock++,63&e||(this.TTMR>>30!=0&&(g=(268435455&this.TTMR)-(268435455&this.TTCR),g+=g<0?268435455:0,this.TTCR=this.TTCR+t&4294967295,g<t&&this.TTMR&1<<29&&(this.TTMR|=1<<28)),this.SR_TEE&&this.TTMR&1<<28&&(this.Exception(y,this.group0[o]),this.pc=this.nextpc++)),i=this.GetInstruction(this.pc<<2),i!=-1){switch(i>>26&63){case 0:k=this.pc+(i<<6>>6),this.pc=this.nextpc,this.nextpc=k,this.delayedins=!0;continue;case 1:k=this.pc+(i<<6>>6),p[9]=(this.nextpc<<2)+4,this.pc=this.nextpc,this.nextpc=k,this.delayedins=!0;continue;case 3:if(this.SR_F)break;k=this.pc+(i<<6>>6),this.pc=this.nextpc,this.nextpc=k,this.delayedins=!0;continue;case 4:if(!this.SR_F)break;k=this.pc+(i<<6>>6),this.pc=this.nextpc,this.nextpc=k,this.delayedins=!0;continue;case 5:break;case 6:u=i>>21&31,65536&i?(r.Debug("Error: macrc not supported\n"),r.Abort()):p[u]=(65535&i)<<16;break;case 8:553648128==(4294901760&i)?(r.Debug("Trap at "+s.ToHex(this.pc<<2)),this.Exception(T,this.group0[o])):this.Exception(S,this.group0[o]);break;case 9:this.nextpc=this.GetSPR(c)>>2,this.pc=this.nextpc++,this.delayedins=!1,this.SetFlags(this.GetSPR(h));continue;case 17:k=p[i>>11&31]>>2,this.pc=this.nextpc,this.nextpc=k,this.delayedins=!0;continue;case 18:k=p[i>>11&31]>>2,p[9]=(this.nextpc<<2)+4,this.pc=this.nextpc,this.nextpc=k,this.delayedins=!0;continue;case 27:if(p[32]=p[i>>16&31]+(i<<16>>16),0!=(3&p[32])&&(r.Debug("Error in lwz: no unaligned access allowed"),abort()),p[33]=this.DTLBLookup(p[32],!1),p[33]==-1)break;this.EA=p[33],p[i>>21&31]=p[33]>0?v.int32mem[p[33]>>2]:v.Read32Big(p[33]);break;case 33:if(p[32]=p[i>>16&31]+(i<<16>>16),0!=(3&p[32])&&(r.Debug("Error in lwz: no unaligned access allowed"),abort()),p[33]=this.DTLBLookup(p[32],!1),p[33]==-1)break;p[i>>21&31]=p[33]>0?v.int32mem[p[33]>>2]:v.Read32Big(p[33]);break;case 35:if(p[32]=p[i>>16&31]+(i<<16>>16),p[33]=this.DTLBLookup(p[32],!1),p[33]==-1)break;p[i>>21&31]=v.Read8Big(p[33]);break;case 36:if(p[32]=p[i>>16&31]+(i<<16>>16),p[33]=this.DTLBLookup(p[32],!1),p[33]==-1)break;p[i>>21&31]=v.Read8Big(p[33])<<24>>24;break;case 37:if(p[32]=p[i>>16&31]+(i<<16>>16),p[33]=this.DTLBLookup(p[32],!1),p[33]==-1)break;p[i>>21&31]=v.Read16Big(p[33]);break;case 38:if(p[32]=p[i>>16&31]+(i<<16>>16),p[33]=this.DTLBLookup(p[32],!1),p[33]==-1)break;p[i>>21&31]=v.Read16Big(p[33])<<16>>16;break;case 39:a=i<<16>>16,d=p[i>>16&31],u=i>>21&31,p[u]=d+a,this.SR_CY=p[u]<d,this.SR_OV=!!((d^a^-1)&(d^p[u])&2147483648);break;case 41:p[i>>21&31]=p[i>>16&31]&(65535&i);break;case 42:p[i>>21&31]=p[i>>16&31]|65535&i;break;case 43:d=p[i>>16&31],p[i>>21&31]=d^i<<16>>16;break;case 45:p[i>>21&31]=this.GetSPR(p[i>>16&31]|65535&i);break;case 46:switch(i>>6&3){case 0:p[i>>21&31]=p[i>>16&31]<<(31&i);break;case 1:p[i>>21&31]=p[i>>16&31]>>>(31&i);break;case 2:p[i>>21&31]=p[i>>16&31]>>(31&i);break;default:r.Debug("Error: opcode 2E function not implemented"),abort()}break;case 47:switch(a=i<<16>>16,i>>21&31){case 0:this.SR_F=p[i>>16&31]==a;break;case 1:this.SR_F=p[i>>16&31]!=a;break;case 2:this.SR_F=p[i>>16&31]>>>0>a>>>0;break;case 3:this.SR_F=p[i>>16&31]>>>0>=a>>>0;break;case 4:this.SR_F=p[i>>16&31]>>>0<a>>>0;break;case 5:this.SR_F=p[i>>16&31]>>>0<=a>>>0;break;case 10:this.SR_F=p[i>>16&31]>a;break;case 11:this.SR_F=p[i>>16&31]>=a;break;case 12:this.SR_F=p[i>>16&31]<a;break;case 13:this.SR_F=p[i>>16&31]<=a;break;default:r.Debug("Error: sf...i not supported yet"),abort()}break;case 48:a=2047&i|i>>10&63488,this.pc=this.nextpc++,this.delayedins=!1,this.SetSPR(p[i>>16&31]|a,p[i>>11&31]);continue;case 50:switch(d=i>>16&31,f=i>>11&31,l=i>>21&31,255&i){case 0:b[l]=b[d]+b[f];break;case 1:b[l]=b[d]-b[f];break;case 2:b[l]=b[d]*b[f];break;case 3:b[l]=b[d]/b[f];break;case 4:b[l]=p[d];break;case 5:p[l]=b[d];break;case 7:b[l]+=b[d]*b[f];break;case 8:this.SR_F=b[d]==b[f];break;case 9:this.SR_F=b[d]!=b[f];break;case 10:this.SR_F=b[d]>b[f];break;case 11:this.SR_F=b[d]>=b[f];break;case 12:this.SR_F=b[d]<b[f];break;case 13:this.SR_F=b[d]<=b[f];break;default:r.Debug("Error: lf. function "+s.ToHex(255&i)+" not supported yet"),r.Abort()}break;case 51:if(a=(i>>10&63488|2047&i)<<16>>16,p[32]=p[i>>16&31]+a,3&p[32]&&(r.Debug("Error in sw: no aligned memory access"),abort()),p[33]=this.DTLBLookup(p[32],!0),p[33]==-1)break;if(this.SR_F=p[33]==this.EA,this.EA=-1,0==this.SR_F)break;p[33]>0?m[p[33]>>2]=p[i>>11&31]:v.Write32Big(p[33],p[i>>11&31]);break;case 53:if(a=(i>>10&63488|2047&i)<<16>>16,p[32]=p[i>>16&31]+a,3&p[32]&&(r.Debug("Error in sw: no aligned memory access"),r.Abort()),p[33]=this.DTLBLookup(p[32],!0),p[33]==-1)break;p[33]>0?m[p[33]>>2]=p[i>>11&31]:v.Write32Big(p[33],p[i>>11&31]);break;case 54:if(a=(i>>10&63488|2047&i)<<16>>16,p[32]=p[i>>16&31]+a,p[33]=this.DTLBLookup(p[32],!0),p[33]==-1)break;v.Write8Big(p[33],p[i>>11&31]);break;case 55:if(a=(i>>10&63488|2047&i)<<16>>16,p[32]=p[i>>16&31]+a,p[33]=this.DTLBLookup(p[32],!0),p[33]==-1)break;v.Write16Big(p[33],p[i>>11&31]);break;case 56:switch(d=p[i>>16&31],f=p[i>>11&31],u=i>>21&31,975&i){case 0:p[u]=d+f,this.SR_CY=p[u]<d,this.SR_OV=!!((d^f^-1)&(d^p[u])&2147483648);break;case 2:p[u]=d-f,this.SR_CY=f>d,this.SR_OV=!!((d^f)&(d^p[u])&2147483648);break;case 3:p[u]=d&f;break;case 4:p[u]=d|f;break;case 5:p[u]=d^f;break;case 8:p[u]=d<<(31&f);break;case 72:p[u]=d>>>(31&f);break;case 15:for(p[u]=0,n=0;n<32;n++)if(d&1<<n){p[u]=n+1;break}break;case 136:p[u]=d>>(31&f);break;case 271:for(p[u]=0,n=31;n>=0;n--)if(d&1<<n){p[u]=n+1;break}break;case 774:p[u]=s.int32(d>>0)*s.int32(f);var R=65535&d,w=65535&f;p[u]=4294901760&p[u]|R*w&65535;var D=Number(s.int32(d))*Number(s.int32(f));this.SR_OV=D<-2147483648||D>2147483647;var x=s.uint32(d)*s.uint32(f);this.SR_CY=x>4294967295;break;case 778:this.SR_CY=0==f,this.SR_OV=!1,this.SR_CY||(p[u]=(d>>>0)/(f>>>0));break;case 777:this.SR_CY=0==f,this.SR_OV=!1,this.SR_CY||(p[u]=d/f);break;default:r.Debug("Error: op38 opcode not supported yet"),r.Abort()}break;case 57:switch(i>>21&31){case 0:this.SR_F=p[i>>16&31]==p[i>>11&31];break;case 1:this.SR_F=p[i>>16&31]!=p[i>>11&31];break;case 2:this.SR_F=p[i>>16&31]>>>0>p[i>>11&31]>>>0;break;case 3:this.SR_F=p[i>>16&31]>>>0>=p[i>>11&31]>>>0;break;case 4:this.SR_F=p[i>>16&31]>>>0<p[i>>11&31]>>>0;break;case 5:this.SR_F=p[i>>16&31]>>>0<=p[i>>11&31]>>>0;break;case 10:this.SR_F=p[i>>16&31]>p[i>>11&31];break;case 11:this.SR_F=p[i>>16&31]>=p[i>>11&31];break;case 12:this.SR_F=p[i>>16&31]<p[i>>11&31];break;case 13:this.SR_F=p[i>>16&31]<=p[i>>11&31];break;default:r.Debug("Error: sf.... function supported yet"),r.Abort()}break;default:r.Debug("Error: Instruction with opcode "+s.ToHex(i>>>26)+" not supported"),r.Abort()}this.pc=this.nextpc++,this.delayedins=!1}else this.pc=this.nextpc++;while(--e);return 0},i.exports=t}()}),define("cjs!jor1k/worker/or1k/smpcpu",["require","exports","module","cjs!../messagehandler"],function(e,t,i){!function(){function t(e,t,i){"use asm";var r=e.Math.floor;var s=t.imul;var a=t.DebugMessage;var n=t.abort;var o=t.Read32;var c=t.Write32;var h=t.Read16;var u=t.Write16;var d=t.Read8;var f=t.Write8;var l=0;var p=1;var b=2;var v=3;var m=4;var k=5;var g=6;var R=7;var y=8;var w=9;var S=1;var T=17;var D=48;var x=32;var E=64;var I=4;var A=3;var C=6;var j=5;var M=0;var _=128;var H=129;var q=0xA00;var L=0x400;var U=0x100;var P=0x900;var W=0x300;var B=0x200;var F=0x500;var z=0x800;var O=0xC00;var G=0xE00;var N=new e.Int32Array(i);var V=new e.Float32Array(i);var X=new e.Int32Array(i);var Q=new e.Uint8Array(i);var K=new e.Uint16Array(i);var Y=4;var J=0xF;var Z=0xF;var $=0;var ee=0x0;var te=0x0;var ie=0x100000;var re=0x2000;var se=0x4000;var ae=0x6000;var ne=0x0;var oe=0;var ce=0;var he=-4;var ue=0;var de=0;var fe=0x0;var le=0x0;var pe=0;var be=-1;var ve=-1;var me=-1;var ke=-1;var ge=-1;var Re=-1;var ye=-1;var we=-1;var Se=-1;var Te=-1;var De=-1;var xe=-1;var Ee=-1;var Ie=-1;var Ae=-1;var Ce=-1;var je=-1;var Me=-1;var _e=0x100;var He=0x104;var qe=0x108;var Le=0x10C;var Ue=0x110;var Pe=0x114;var We=1;var Be=0;var Fe=0;var ze=0;var Oe=0;var Ge=0;var Ne=0;var Ve=0;var Xe=0;var Qe=0;var Ke=0;var Ye=0;var Je=0;var Ze=0;var $e=0;var et=1;var tt=0;var it=0x0;var rt=0x0;var st=0x0;var at=0x0;var nt=0x0;function ot(e){e=e|0;Y=e|0;if((Y|0)==32)J=0xFFFFFFFF;else J=(1<<Y)-1|0;gt();ct()}function ct(){var e=0;Z=J;nt=0x0;for(e=0;(e|0)<(Y|0);e=e+1|0){X[ee+_e>>2]=0x0;X[ee+He>>2]=0x0;X[ee+qe>>2]=0x3;X[ee+Le>>2]=0x0;X[ee+re+(I<<2)>>2]=0x18;X[ee+re+(A<<2)>>2]=0x18;X[ee+re+(C<<2)>>2]=0x0;X[ee+re+(j<<2)>>2]=0x0;X[ee+re+(M<<2)>>2]=0x12000001;X[ee+re+(_<<2)>>2]=$|0;X[ee+re+(H<<2)>>2]=2|0;X[ee+re+(S<<2)>>2]=0x619;oe=0;ce=0;he=-4;It(U,0x0);ht()}}function ht(){var e=0;var t=0;if((Y|0)==1)return;e=$|0;if((Z|0)==0){a(w|0);n()}if((Z&Z-1)==0)if(Z&1<<$){return}do{e=e+1|0;if((e|0)>=(Y|0))e=0}while((Z&1<<e)==0);if((e|0)==($|0))return;X[ee+0x120>>2]=wt()|0;X[ee+0x124>>2]=ne;X[ee+0x128>>2]=oe;X[ee+0x12C>>2]=ce;X[ee+0x130>>2]=he;X[ee+0x134>>2]=ue;X[ee+0x138>>2]=fe;X[ee+0x13C>>2]=le;X[ee+0x190>>2]=de;X[ee+0x194>>2]=pe;X[ee+0x140>>2]=be;X[ee+0x144>>2]=ve;X[ee+0x148>>2]=me;X[ee+0x14C>>2]=ke;X[ee+0x150>>2]=ge;X[ee+0x154>>2]=Re;X[ee+0x158>>2]=ye;X[ee+0x15C>>2]=we;X[ee+0x160>>2]=Se;X[ee+0x164>>2]=Te;X[ee+0x168>>2]=De;X[ee+0x16C>>2]=xe;X[ee+0x170>>2]=Ee;X[ee+0x174>>2]=Ie;X[ee+0x178>>2]=Ae;X[ee+0x17C>>2]=Ce;X[ee+0x180>>2]=je;X[ee+0x184>>2]=Me;$=e|0;ee=$<<15;Rt(X[ee+0x120>>2]|0);ne=X[ee+0x124>>2]|0;oe=X[ee+0x128>>2]|0;ce=X[ee+0x12C>>2]|0;he=X[ee+0x130>>2]|0;ue=X[ee+0x134>>2]|0;fe=X[ee+0x138>>2]|0;le=X[ee+0x13C>>2]|0;de=X[ee+0x190>>2]|0;pe=X[ee+0x194>>2]|0;be=X[ee+0x140>>2]|0;ve=X[ee+0x144>>2]|0;me=X[ee+0x148>>2]|0;ke=X[ee+0x14C>>2]|0;ge=X[ee+0x150>>2]|0;Re=X[ee+0x154>>2]|0;ye=X[ee+0x158>>2]|0;we=X[ee+0x15C>>2]|0;Se=X[ee+0x160>>2]|0;Te=X[ee+0x164>>2]|0;De=X[ee+0x168>>2]|0;xe=X[ee+0x16C>>2]|0;Ee=X[ee+0x170>>2]|0;Ie=X[ee+0x174>>2]|0;Ae=X[ee+0x178>>2]|0;Ce=X[ee+0x17C>>2]|0;je=X[ee+0x180>>2]|0;Me=X[ee+0x184>>2]|0}function ut(){be=-1;ve=-1;me=-1;ke=-1;ge=-1;Re=-1;ye=-1;we=-1;Se=-1;Te=-1;De=-1;xe=-1;Ee=-1;Ie=-1;Ae=-1;Ce=-1;je=-1;Me=-1}function dt(){}function ft(){}function lt(e){e=e|0;Z=Z|1<<e;X[(e<<15)+_e>>2]=X[(e<<15)+_e>>2]|0|1<<28}function pt(e){e=e|0;var t=0;t=X[(e<<15)+_e>>2]>>29?1:0;return t|0}function bt(e){e=e|0;var t=0;t=(X[(e<<15)+_e>>2]&0xFFFFFFF)-(X[He>>2]&0xFFFFFFF)|0;if((t|0)<0)t=t+0xFFFFFFF|0;return t|0}function vt(){var e=0xFFFFFFF;var t=0x0;var i=0;for(i=0;(i|0)<(Y|0);i=i+1|0){if(!(pt(i)|0))continue;t=bt(i)|0;if((t|0)<(e|0))e=t|0}return e|0}function mt(e){e=e|0;var t=0;X[He>>2]=(X[He>>2]|0)+e|0;Z=J}function kt(){return X[He>>2]&0xFFFFFFF|0}function gt(){rt=X[ie+0x900>>2]|0;st=X[ie+0xA00>>2]|0;at=(X[ie+0x2010>>2]&0xFFF)<<16|X[ie+0x2014>>2]&0xFFFF|0}function Rt(e){e=e|0;We=e&1<<0;Be=e&1<<1;Fe=e&1<<2;ze=e&1<<3;Oe=e&1<<4;Ge=e&1<<5;Ne=e&1<<6;Ve=e&1<<7;Xe=e&1<<8;Qe=e&1<<9;Ke=e&1<<10;Ye=e&1<<11;Je=e&1<<12;Ze=e&1<<13;$e=e&1<<14;et=1;tt=e&1<<16;it=e>>28&0xF}function yt(e){e=e|0;var t=0;t=Fe;Rt(e);if(Ve){a(l|0);n()}if(it){a(p|0);n()}if($e){a(b|0);n()}if(Ze){a(v|0);n()}if(Fe){if((t|0)==(0|0)){St($)}}}function wt(){var e=0x0;e=e|(We?1<<0:0);e=e|(Be?1<<1:0);e=e|(Fe?1<<2:0);e=e|(ze?1<<3:0);e=e|(Oe?1<<4:0);e=e|(Ge?1<<5:0);e=e|(Ne?1<<6:0);e=e|(Ve?1<<7:0);e=e|(Xe?1<<8:0);e=e|(Qe?1<<9:0);e=e|(Ke?1<<10:0);e=e|(Ye?1<<11:0);e=e|(Je?1<<12:0);e=e|(Ze?1<<13:0);e=e|($e?1<<14:0);e=e|(et?1<<15:0);e=e|(tt?1<<16:0);e=e|it<<28;return e|0}function St(e){e=e|0;var t=0;X[ee+0x120>>2]=wt()|0;t=X[(e<<15)+0x120>>2]|0;if(t&1<<2){if(X[(e<<15)+qe>>2]&X[(e<<15)+Le>>2]){Z=Z|1<<e;X[(e<<15)+Ue>>2]=1}}}function Tt(e,t){e=e|0;t=t|0;var i=0;var r=0;var s=0;r=1<<e|0;if((t|0)==-1){for(i=0;(i|0)<(Y|0);i=i+1|0){s=(i<<15)+Le|0;X[s>>2]=X[s>>2]|0|r;St(i)}}else{s=(t<<15)+Le|0;X[s>>2]=X[s>>2]|0|r;St(t)}}function Dt(e,t){e=e|0;t=t|0;var i=0;var r=0;var s=0;r=1<<e|0;if((t|0)==-1){for(i=0;(i|0)<(Y|0);i=i+1|0){s=(i<<15)+Le|0;X[s>>2]=X[s>>2]&~r}}else{s=(t<<15)+Le|0;X[s>>2]=X[s>>2]&~r}}function xt(e,t){e=e|0;t=t|0;var i=0;var r=0;i=e&0x7FF;r=e>>11&0x1F;switch(r|0){case 0:if((i|0)==(T|0)){yt(t)}X[ee+re+(i<<2)>>2]=t;break;case 1:X[ee+se+(i<<2)>>2]=t;break;case 2:X[ee+ae+(i<<2)>>2]=t;break;case 3:case 4:break;case 8:Z=Z&~(1<<$);break;case 9:switch(i|0){case 0:X[ee+qe>>2]=t|0x3;if(Fe){if(X[ee+qe>>2]&X[ee+Le>>2]){a(m|0);n()}}break;case 2:break;default:a(k|0);n()}break;case 10:switch(i|0){case 0:X[ee+_e>>2]=t|0;if((X[ee+_e>>2]>>30&3)!=0x3){a(g|0);n()}break;case 1:break;default:a(y|0);n();break}break;default:a(y|0);n();break}}function Et(e){e=e|0;var t=0;var i=0;t=e&0x7FF;i=e>>11&0x1F;switch(i|0){case 0:if((t|0)==(T|0)){return wt()|0}return X[ee+re+(t<<2)>>2]|0;case 1:return X[ee+se+(t<<2)>>2]|0;case 2:return X[ee+ae+(t<<2)>>2]|0;case 8:return 0x0;case 9:switch(t|0){case 0:return X[ee+qe>>2]|0;case 2:return X[ee+Le>>2]|0;default:a(y|0);n();break}break;case 10:switch(t|0){case 0:return X[ee+_e>>2]|0;case 1:return X[He>>2]|0;default:a(y|0);n();break}break;default:a(y|0);n();break}return 0|0}function It(e,t){e=e|0;t=t|0;var i=0;i=e|($e?0xf0000000:0x0);Z=Z|1<<$;xt(D,t);xt(E,wt()|0);Je=0;We=1;Fe=0;Be=0;Ge=0;be=0;ve=0;me=0;ke=0;ge=0;Re=0;ye=0;we=0;Se=0;Te=0;De=0;Ee=0;xe=0;Ae=0;Ie=0;Ce=0;je=0;Me=0;ue=oe|0;fe=i;switch(e|0){case 0x100:break;case 0x300:case 0x900:case 0xE00:case 0x200:ne=he+oe|0;xt(x,ne-(de?4:0)|0);break;case 0xA00:case 0x400:case 0x500:case 0x800:xt(x,ne-(de?4:0)|0);break;case 0xC00:ne=he+oe|0;xt(x,ne+4-(de?4:0)|0);break;default:a(R|0);n()}de=0;Ne=0;X[ee+Pe>>2]=-1;nt=nt&~(1<<$)}function At(e,t){e=e|0;t=t|0;var i=0;var r=0;var s=0;var a=0;if((X[ie+0x900>>2]|0)==(rt|0)){It(P,e);return 0|0}i=e;r=X[ie+at+($<<2)>>2]|0;s=i>>>0x18<<2;a=s+r|0;s=0x40000000+a&0xFFFFFFFF;r=X[ie+s>>2]|0;if((r|0)==0){It(W,e);return 0|0}r=0xffffe000;s=X[ie+s>>2]|0;s=s&r;a=i>>>0xD;r=a&0x7FF;r=r<<0x2;r=r+s|0;i=X[ie+r>>2]|0;if((i&1)==0){It(W,e);return 0|0}s=i&0xFFFFe3fa;a=a&t-1;X[ee+se+((0x280|a)<<2)>>2]=s;i=e;s=i&0xFFFFE000;s=s|0x1;X[ee+se+((0x200|a)<<2)>>2]=s;return 1|0}function Ct(e,t){e=e|0;t=t|0;var i=0;var r=0;var s=0;var a=0;if((X[ie+0xA00>>2]|0)==(st|0)){It(q,e);return 0|0}i=e;r=X[ie+at+($<<2)>>2]|0;s=i>>>0x18<<2;a=s+r|0;s=0x40000000+a&0xFFFFFFFF;r=X[ie+s>>2]|0;if((r|0)==0){It(L,e);return 0|0}r=0xffffe000;s=X[ie+s>>2]|0;s=s&r;a=i>>>0xD;r=a&0x7FF;r=r<<0x2;r=r+s|0;i=X[ie+r>>2]|0;if((i&1)==0){It(L,e);return 0|0}s=i&0xFFFFe03a;r=i&0x7c0;if((r|0)!=0x0){a=a&t-1;s=s|0xc0}X[ee+ae+((0x280|a)<<2)>>2]=s;i=e;s=i&0xFFFFE000;s=s|0x1;X[ee+ae+((0x200|a)<<2)>>2]=s;return 1|0}function jt(e,t){e=e|0;t=t|0;var i=0;var r=0;var s=0;if(!Ge){return e|0}i=e>>13&63;r=X[ee+se+((0x200|i)<<2)>>2]|0;if((r&1)==0){if(At(e,64)|0){r=X[ee+se+(0x200+i<<2)>>2]|0}else{return-1|0}}if(r>>19!=e>>19){if(At(e,64)|0){r=X[ee+se+(0x200+i<<2)>>2]|0}else{return-1|0}}s=X[ee+se+((0x280|i)<<2)>>2]|0;if(We){if(!t){if(!(s&0x100)){It(W,e);return-1|0}}else{if(!(s&0x200)){It(W,e);return-1|0}}}else{if(!t){if(!(s&0x40)){It(W,e);return-1|0}}else{if(!(s&0x80)){It(W,e);return-1|0}}}return s&0xFFFFE000|e&0x1FFF|0}function Mt(e,t){e=e|0;t=t|0;var i=0x0;var l=0x0;var p=0;var b=0x0;var v=0x0,m=0x0,k=0x0;var g=0x0;var R=0x0;var w=0;var S=0x0;var T=0x0;var I=0x0;var A=0x0;var C=0;for(;;){if((oe|0)==(ue|0)){ne=fe;if(!pe|0){de=0}C=C-(oe-ce>>2)|0;if((C|0)<=0)if(!(pe|0)){C=C+64|0;e=e-64|0;for(p=0;(p|0)<(Y|0);p=p+1|0){if(!(pt(p)|0))continue;A=bt(p)|0;if((A|0)<(t|0)){lt(p)}}X[He>>2]=(X[He>>2]|0)+t|0;if((e|0)<0)return 0x0}if(Fe|0){if(X[ee+_e>>2]&1<<28){It(F,X[ee+re+(D<<2)>>2]|0);ne=fe}else if(X[ee+Ue>>2]|0){X[ee+Ue>>2]=0;It(z,X[ee+re+(D<<2)>>2]|0);ne=fe}}if((Te^ne)&0xFFFFE000){Te=ne;if(!Ne){be=0x0}else{S=ne>>13&63;T=X[ee+ae+((0x200|S)<<2)>>2]|0;if((T&1)==0){if(Ct(ne,64)|0){T=X[ee+ae+((0x200|S)<<2)>>2]|0}else{ce=oe;pe=0;continue}}if(T>>19!=ne>>19){if(Ct(ne,64)|0){T=X[ee+ae+((0x200|S)<<2)>>2]|0}else{ce=oe;pe=0;continue}}I=X[ee+ae+((0x280|S)<<2)>>2]|0;be=(I^T)>>13<<13}}oe=ie+(be^ne)|0;ce=oe;he=ne-4-ce|0;if(pe|0){pe=0;ue=oe+4|0;fe=le}else{ue=(oe>>13)+1<<13;fe=(ne>>13)+1<<13}w=w+1|0;if((w&7)==0){ht();continue}}i=X[oe>>2]|0;oe=oe+4|0;switch(i>>26&0x3F){case 0x0:ne=he+oe|0;le=ne+(i<<6>>4)|0;if((ue|0)==(oe|0)){pe=1}else{ue=oe+4|0;fe=le|0}de=1;break;case 0x1:ne=he+oe|0;le=ne+(i<<6>>4)|0;N[ee+(9<<2)>>2]=ne+8|0;if((ue|0)==(oe|0)){pe=1}else{ue=oe+4|0;fe=le|0}de=1;break;case 0x3:if(Qe){break}ne=he+oe|0;le=ne+(i<<6>>4)|0;if((ue|0)==(oe|0)){pe=1}else{ue=oe+4|0;fe=le|0}de=1;break;case 0x4:if(!Qe){break}ne=he+oe|0;le=ne+(i<<6>>4)|0;if((ue|0)==(oe|0)){pe=1}else{ue=oe+4|0;fe=le|0}de=1;break;case 0x5:break;case 0x6:b=i>>21&0x1F;N[ee+(b<<2)>>2]=(i&0xFFFF)<<16;break;case 0x8:if((i&0xFFFF0000)==0x21000000){It(G,X[ee+re+D>>2]|0)}else{It(O,X[ee+re+D>>2]|0)}break;case 0x9:le=Et(x)|0;ut();ue=oe;fe=le;yt(Et(E)|0);break;case 0x11:le=N[ee+(i>>9&0x7C)>>2]|0;if((ue|0)==(oe|0)){pe=1}else{ue=oe+4|0;fe=le|0}de=1;break;case 0x12:ne=he+oe|0;le=N[ee+(i>>9&0x7C)>>2]|0;N[ee+(9<<2)>>2]=ne+8|0;if((ue|0)==(oe|0)){pe=1}else{ue=oe+4|0;fe=le|0}de=1;break;case 0x1B:g=(N[ee+(i>>14&0x7C)>>2]|0)+(i<<16>>16)|0;if((De^g)>>13){R=jt(g,0)|0;if((R|0)==-1){break}De=g;ve=(R^g)>>13<<13}R=ve^g;nt=nt|1<<$;X[ee+Pe>>2]=R;N[ee+(i>>19&0x7C)>>2]=(R|0)>0?X[ie+R>>2]|0:o(R|0)|0;break;case 0x21:g=(N[ee+(i>>14&0x7C)>>2]|0)+(i<<16>>16)|0;if((De^g)>>13){R=jt(g,0)|0;if((R|0)==-1){break}De=g;ve=(R^g)>>13<<13}R=ve^g;N[ee+(i>>19&0x7C)>>2]=(R|0)>0?X[ie+R>>2]|0:o(R|0)|0;break;case 0x23:g=(N[ee+(i>>14&0x7C)>>2]|0)+(i<<16>>16)|0;if((Ee^g)>>13){R=jt(g,0)|0;if((R|0)==-1){break}Ee=g;ke=(R^g)>>13<<13}R=ke^g;if((R|0)>=0){N[ee+(i>>19&0x7C)>>2]=Q[ie+(R^3)|0]|0}else{N[ee+(i>>19&0x7C)>>2]=d(R|0)|0}break;case 0x24:g=(N[ee+(i>>14&0x7C)>>2]|0)+(i<<16>>16)|0;if((xe^g)>>13){R=jt(g,0)|0;if((R|0)==-1){break}xe=g;me=(R^g)>>13<<13}R=me^g;if((R|0)>=0){N[ee+(i>>19&0x7C)>>2]=Q[ie+(R^3)|0]<<24>>24}else{N[ee+(i>>19&0x7C)>>2]=(d(R|0)|0)<<24>>24}break;case 0x25:g=(N[ee+(i>>14&0x7C)>>2]|0)+(i<<16>>16)|0;if((Ae^g)>>13){R=jt(g,0)|0;if((R|0)==-1){break}Ae=g;Re=(R^g)>>13<<13}R=Re^g;if((R|0)>=0){N[ee+(i>>19&0x7C)>>2]=K[ie+(R^2)>>1]}else{N[ee+(i>>19&0x7C)>>2]=h(R|0)|0}break;case 0x26:g=(N[ee+(i>>14&0x7C)>>2]|0)+(i<<16>>16)|0;if((Ie^g)>>13){R=jt(g,0)|0;if((R|0)==-1){break}Ie=g;ge=(R^g)>>13<<13}R=ge^g;if((R|0)>=0){N[ee+(i>>19&0x7C)>>2]=K[ie+(R^2)>>1]<<16>>16}else{N[ee+(i>>19&0x7C)>>2]=(h(R|0)|0)<<16>>16}break;case 0x27:l=i<<16>>16;v=N[ee+(i>>14&0x7C)>>2]|0;N[ee+(i>>19&0x7C)>>2]=v+l|0;break;case 0x29:N[ee+(i>>19&0x7C)>>2]=N[ee+(i>>14&0x7C)>>2]&(i&0xFFFF);break;case 0x2A:N[ee+(i>>19&0x7C)>>2]=N[ee+(i>>14&0x7C)>>2]|i&0xFFFF;break;case 0x2B:v=N[ee+(i>>14&0x7C)>>2]|0;N[ee+(i>>19&0x7C)>>2]=v^i<<16>>16;break;case 0x2D:N[ee+(i>>19&0x7C)>>2]=Et(N[ee+(i>>14&0x7C)>>2]|i&0xFFFF)|0;break;case 0x2E:switch(i>>6&0x3){case 0:N[ee+(i>>19&0x7C)>>2]=N[ee+(i>>14&0x7C)>>2]<<(i&0x1F);break;case 1:N[ee+(i>>19&0x7C)>>2]=N[ee+(i>>14&0x7C)>>2]>>>(i&0x1F);break;case 2:N[ee+(i>>19&0x7C)>>2]=N[ee+(i>>14&0x7C)>>2]>>(i&0x1F);break;default:a(y|0);n();break}break;case 0x2F:l=i<<16>>16;switch(i>>21&0x1F){case 0x0:Qe=(N[ee+(i>>14&0x7C)>>2]|0)==(l|0);break;case 0x1:Qe=(N[ee+(i>>14&0x7C)>>2]|0)!=(l|0);break;case 0x2:Qe=N[ee+(i>>14&0x7C)>>2]>>>0>l>>>0;break;case 0x3:Qe=N[ee+(i>>14&0x7C)>>2]>>>0>=l>>>0;break;case 0x4:Qe=N[ee+(i>>14&0x7C)>>2]>>>0<l>>>0;break;case 0x5:Qe=N[ee+(i>>14&0x7C)>>2]>>>0<=l>>>0;break;case 0xa:Qe=(N[ee+(i>>14&0x7C)>>2]|0)>(l|0);break;case 0xb:Qe=(N[ee+(i>>14&0x7C)>>2]|0)>=(l|0);break;case 0xc:Qe=(N[ee+(i>>14&0x7C)>>2]|0)<(l|0);break;case 0xd:Qe=(N[ee+(i>>14&0x7C)>>2]|0)<=(l|0);break;default:a(y|0);n();break}break;case 0x30:l=i&0x7FF|i>>10&0xF800;xt(N[ee+(i>>14&0x7C)>>2]|l,N[ee+(i>>9&0x7C)>>2]|0);if((Z|0)==0){Z=J;if(X[($<<15)+_e>>2]&1<<28)break;return e|0}else if((Z&1<<$)==0){ht()}break;case 0x32:v=i>>14&0x7C;m=i>>9&0x7C;k=i>>19&0x7C;switch(i&0xFF){case 0x0:V[ee+k>>2]=+V[ee+v>>2]+ +V[ee+m>>2];break;case 0x1:V[ee+k>>2]=+V[ee+v>>2]-+V[ee+m>>2];break;case 0x2:V[ee+k>>2]=+V[ee+v>>2]*+V[ee+m>>2];break;case 0x3:V[ee+k>>2]=+V[ee+v>>2]/+V[ee+m>>2];break;case 0x4:V[ee+k>>2]=+(N[ee+v>>2]|0);break;case 0x5:N[ee+k>>2]=~~+r(+V[ee+v>>2]);break;case 0x7:V[ee+k>>2]=+V[ee+k>>2]+ +V[ee+v>>2]*+V[ee+m>>2];break;case 0x8:Qe=+V[ee+v>>2]==+V[ee+m>>2];break;case 0x9:Qe=+V[ee+v>>2]!=+V[ee+m>>2];break;case 0xa:Qe=+V[ee+v>>2]>+V[ee+m>>2];break;case 0xb:Qe=+V[ee+v>>2]>=+V[ee+m>>2];break;case 0xc:Qe=+V[ee+v>>2]<+V[ee+m>>2];break;case 0xd:Qe=+V[ee+v>>2]<=+V[ee+m>>2];break;default:a(y|0);n();break}break;case 0x33:l=(i>>10&0xF800|i&0x7FF)<<16>>16;g=(N[ee+(i>>14&0x7C)>>2]|0)+l|0;if((Ce^g)>>13){R=jt(g,1)|0;if((R|0)==-1){break}Ce=g;ye=(R^g)>>13<<13}R=ye^g;Qe=(R|0)==(X[ee+Pe>>2]|0)?1|0:0|0;X[ee+Pe>>2]=-1;nt=nt&~(1<<$);if(nt)for(p=0;(p|0)<(Y|0);p=p+1|0){if((X[(p<<15)+Pe>>2]|0)==(R|0)){X[(p<<15)+Pe>>2]=-1;nt=nt&~(1<<p)}}if((Qe|0)==0){break}if((R|0)>0){X[ie+R>>2]=N[ee+(i>>9&0x7C)>>2]|0}else{c(R|0,N[ee+(i>>9&0x7C)>>2]|0)}break;case 0x35:l=(i>>10&0xF800|i&0x7FF)<<16>>16;g=(N[ee+(i>>14&0x7C)>>2]|0)+l|0;if((Ce^g)>>13){R=jt(g,1)|0;if((R|0)==-1){break}Ce=g;ye=(R^g)>>13<<13}R=ye^g;if(nt)for(p=0;(p|0)<(Y|0);p=p+1|0){if((X[(p<<15)+Pe>>2]|0)==(R|0)){X[(p<<15)+Pe>>2]=-1;nt=nt&~(1<<p)}}if((R|0)>0){X[ie+R>>2]=N[ee+(i>>9&0x7C)>>2]|0}else{c(R|0,N[ee+(i>>9&0x7C)>>2]|0)}break;case 0x36:l=(i>>10&0xF800|i&0x7FF)<<16>>16;g=(N[ee+(i>>14&0x7C)>>2]|0)+l|0;if((je^g)>>13){R=jt(g,1)|0;if((R|0)==-1){break}je=g;we=(R^g)>>13<<13}R=we^g;if(nt)for(p=0;(p|0)<(Y|0);p=p+1|0){if((X[(p<<15)+Pe>>2]|0)==(R&~3)){X[(p<<15)+Pe>>2]=-1;nt=nt&~(1<<p)}}if((R|0)>0){Q[ie+(R^3)|0]=N[ee+(i>>9&0x7C)>>2]|0}else{f(R|0,N[ee+(i>>9&0x7C)>>2]|0)}break;case 0x37:l=(i>>10&0xF800|i&0x7FF)<<16>>16;g=(N[ee+(i>>14&0x7C)>>2]|0)+l|0;if((Me^g)>>13){R=jt(g,1)|0;if((R|0)==-1){break}Me=g;Se=(R^g)>>13<<13}R=Se^g;if(nt)for(p=0;(p|0)<(Y|0);p=p+1|0){if((X[(p<<15)+Pe>>2]|0)==(R&~3)){X[(p<<15)+Pe>>2]=-1;nt=nt&~(1<<p)}}if((R|0)>=0){K[ie+(R^2)>>1]=N[ee+(i>>9&0x7C)>>2]}else{u(R|0,N[ee+(i>>9&0x7C)>>2]|0)}break;case 0x38:v=N[ee+(i>>14&0x7C)>>2]|0;m=N[ee+(i>>9&0x7C)>>2]|0;b=i>>19&0x7C;switch(i&0x3CF){case 0x0:N[ee+b>>2]=v+m;break;case 0x2:N[ee+b>>2]=v-m;break;case 0x3:N[ee+b>>2]=v&m;break;case 0x4:N[ee+b>>2]=v|m;break;case 0x5:N[ee+b>>2]=v^m;break;case 0x8:N[ee+b>>2]=v<<(m&0x1F);break;case 0x48:N[ee+b>>2]=v>>>(m&0x1F);break;case 0xf:N[ee+b>>2]=0;for(p=0;(p|0)<32;p=p+1|0){if(v&1<<p){N[ee+b>>2]=p+1;break}}break;case 0x88:N[ee+b>>2]=v>>(m&0x1F);break;case 0x10f:N[ee+b>>2]=0;for(p=31;(p|0)>=0;p=p-1|0){if(v&1<<p){N[ee+b>>2]=p+1;break}}break;case 0x306:{N[ee+b>>2]=s(v|0,m|0)|0}break;case 0x30a:Ke=(m|0)==0;Ye=0;if(!Ke){N[ee+b>>2]=(v>>>0)/(m>>>0)}break;case 0x309:Ke=(m|0)==0;Ye=0;if(!Ke){N[ee+b>>2]=(v|0)/(m|0)}break;default:a(y|0);n();break}break;case 0x39:switch(i>>21&0x1F){case 0x0:Qe=(N[ee+(i>>14&0x7C)>>2]|0)==(N[ee+(i>>9&0x7C)>>2]|0);break;case 0x1:Qe=(N[ee+(i>>14&0x7C)>>2]|0)!=(N[ee+(i>>9&0x7C)>>2]|0);break;case 0x2:Qe=N[ee+(i>>14&0x7C)>>2]>>>0>N[ee+(i>>9&0x7C)>>2]>>>0;break;case 0x3:Qe=N[ee+(i>>14&0x7C)>>2]>>>0>=N[ee+(i>>9&0x7C)>>2]>>>0;break;case 0x4:Qe=N[ee+(i>>14&0x7C)>>2]>>>0<N[ee+(i>>9&0x7C)>>2]>>>0;break;case 0x5:Qe=N[ee+(i>>14&0x7C)>>2]>>>0<=N[ee+(i>>9&0x7C)>>2]>>>0;break;case 0xa:Qe=(N[ee+(i>>14&0x7C)>>2]|0)>(N[ee+(i>>9&0x7C)>>2]|0);break;case 0xb:Qe=(N[ee+(i>>14&0x7C)>>2]|0)>=(N[ee+(i>>9&0x7C)>>2]|0);break;case 0xc:Qe=(N[ee+(i>>14&0x7C)>>2]|0)<(N[ee+(i>>9&0x7C)>>2]|0);break;case 0xd:Qe=(N[ee+(i>>14&0x7C)>>2]|0)<=(N[ee+(i>>9&0x7C)>>2]|0);break;default:a(y|0);n()}break;default:a(y|0);n();break}}return e|0}return{Init:ot,Reset:ct,InvalidateTLB:ut,Step:Mt,GetFlags:wt,SetFlags:yt,PutState:dt,GetState:ft,GetTimeToNextInterrupt:vt,ProgressTime:mt,GetTicks:kt,RaiseInterrupt:Tt,ClearInterrupt:Dt,AnalyzeImage:gt}}e("cjs!../messagehandler");i.exports=t}()}),define("cjs!jor1k/worker/or1k/index",["require","exports","module","cjs!../messagehandler","cjs!../utils","cjs!../imul","cjs!./fastcpu","cjs!./safecpu","cjs!./smpcpu"],function(e,t,i){!function(){function t(e,t,i,r){var s={DebugMessage:a.Debug,abort:a.Abort,imul:Math.imul||o,Read32:t.Read32Big.bind(t),Write32:t.Write32Big.bind(t),Read16:t.Read16Big.bind(t),Write16:t.Write16Big.bind(t),Read8:t.Read8Big.bind(t),Write8:t.Write8Big.bind(t)};return"asm"===e?(null===d&&(d=c(l,s,i),d.Init()),d):"smp"===e?(null===f&&(f=u(l,s,i),f.Init(r)),f):void 0}function r(e,i,r,s){var a=null;if("safe"===e)return new h(i);if("asm"===e)return a=t(e,i,r,s),a.Init(),a;if("smp"===e)return a=t(e,i,r,s),a.Init(s),a;throw new Error("invalid CPU name:"+e)}function s(e,t,i,s){return this.cpu=r(e,t,i,s),this.name=e,this.ncores=s,this.ram=t,this.heap=i,this.littleendian=!1,this}var a=e("cjs!../messagehandler"),n=e("cjs!../utils").ToHex,o=e("cjs!../imul"),c=e("cjs!./fastcpu"),h=e("cjs!./safecpu"),u=e("cjs!./smpcpu"),d=null,f=null,l={Int32Array:Int32Array,Float32Array:Float32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array,Math:Math};s.prototype.switchImplementation=function(e){var t=this.cpu,i=this.name;if("smp"!=i){this.cpu=r(e,this.ram,this.heap,this.ncores),this.cpu.InvalidateTLB();var s=t.GetFlags();this.cpu.SetFlags(0|s);var a;"asm"===i?(a=new Int32Array(this.heap),t.GetState(),this.cpu.pc=a[64],this.cpu.nextpc=a[65],this.cpu.delayedins=!!a[66],this.cpu.TTMR=a[68],this.cpu.TTCR=a[69],this.cpu.PICMR=a[70],this.cpu.PICSR=a[71],this.cpu.boot_dtlb_misshandler_address=a[72],this.cpu.boot_itlb_misshandler_address=a[73],this.cpu.current_pgd=a[74]):"asm"===e?(a=new Int32Array(this.heap),a[64]=t.pc,a[65]=t.nextpc,a[66]=t.delayedins,a[67]=0,a[68]=t.TTMR,a[69]=t.TTCR,a[70]=t.PICMR,a[71]=t.PICSR,a[72]=t.boot_dtlb_misshandler_address,a[73]=t.boot_itlb_misshandler_address,a[74]=t.current_pgd,this.cpu.PutState()):(this.cpu.pc=t.pc,this.cpu.nextpc=t.nextpc,this.cpu.delayedins=t.delayedins,this.cpu.TTMR=t.TTMR,this.cpu.TTCR=t.TTCR,this.cpu.PICMR=t.PICMR,this.cpu.PICSR=t.PICSR,this.cpu.boot_dtlb_misshandler_address=t.boot_dtlb_misshandler_address,this.cpu.boot_itlb_misshandler_address=t.itlb_misshandler_address,this.cpu.current_pgd=t.current_pgd)}},s.prototype.toString=function(){var e=new Uint32Array(this.heap),t="";t+="Current state of the machine\n",t+="PC: "+n(this.cpu.pc<<2)+"\n",t+="next PC: "+n(this.cpu.nextpc<<2)+"\n";for(var i=0;i<32;i+=4)t+=" r"+(i+0)+": "+n(e[i+0])+" r"+(i+1)+": "+n(e[i+1])+" r"+(i+2)+": "+n(e[i+2])+" r"+(i+3)+": "+n(e[i+3])+"\n";return this.cpu.delayedins&&(t+="delayed instruction\n"),t+=this.cpu.SR_SM?"Supervisor mode\n":"User mode\n",this.cpu.SR_TEE&&(t+="tick timer exception enabled\n"),this.cpu.SR_IEE&&(t+="interrupt exception enabled\n"),this.cpu.SR_DME&&(t+="data mmu enabled\n"),this.cpu.SR_IME&&(t+="instruction mmu enabled\n"),this.cpu.SR_LEE&&(t+="little endian enabled\n"),this.cpu.SR_CID&&(t+="context id enabled\n"),this.cpu.SR_F&&(t+="flag set\n"),this.cpu.SR_CY&&(t+="carry set\n"),this.cpu.SR_OV&&(t+="overflow set\n"),t};var p=["Reset","Step","RaiseInterrupt","Step","AnalyzeImage","GetTicks","GetTimeToNextInterrupt","ProgressTime","ClearInterrupt"];p.forEach(function(e){s.prototype[e]=function(){return this.cpu[e].apply(this.cpu,arguments)}}),i.exports=s}()}),define("cjs!jor1k/worker/riscv/disassemble",["require","exports","module","cjs!../messagehandler","cjs!../utils"],function(e,t,i){!function(){function t(e,t,i,u){switch(127&e){case 3:switch(e>>12&7){case 0:r.Debug("lb - "+s.ToHex(e));break;case 1:r.Debug("lh - "+s.ToHex(e));break;case 2:r.Debug("lw - "+s.ToHex(e));break;case 4:r.Debug("lbu - "+s.ToHex(e));break;case 5:r.Debug("lhu - "+s.ToHex(e));break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(e)+"not found")}break;case 35:switch(e>>12&7){case 0:r.Debug("sb - "+s.ToHex(e));break;case 1:r.Debug("sh - "+s.ToHex(e));break;case 2:r.Debug("sw - "+s.ToHex(e));break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(e)+"not found")}break;case 19:switch(e>>12&7){case 0:r.Debug("addi - "+s.ToHex(e));break;case 2:r.Debug("slti - "+s.ToHex(e));break;case 3:r.Debug("sltiu - "+s.ToHex(e));break;case 4:r.Debug("xori - "+s.ToHex(e));break;case 6:r.Debug("ori - "+s.ToHex(e));break;case 7:r.Debug("andi - "+s.ToHex(e));break;case 1:r.Debug("slli - "+s.ToHex(e));break;case 5:0==(e>>25&127)?r.Debug("srli - "+s.ToHex(e)):32==(e>>25&127)&&r.Debug("srai - "+s.ToHex(e));
break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(e)+"not found")}break;case 51:switch(e>>25&127){case 0:switch(e>>12&7){case 0:r.Debug("add - "+s.ToHex(e));break;case 2:r.Debug("slt - "+s.ToHex(e));break;case 3:r.Debug("sltu - "+s.ToHex(e));break;case 7:r.Debug("and - "+s.ToHex(e));break;case 6:r.Debug("or - "+s.ToHex(e));break;case 4:r.Debug("xor - "+s.ToHex(e));break;case 1:r.Debug("sll - "+s.ToHex(e));break;case 5:r.Debug("srl - "+s.ToHex(e))}break;case 32:switch(e>>12&7){case 0:r.Debug("sub - "+s.ToHex(e));break;case 5:r.Debug("sra - "+s.ToHex(e))}break;case 1:switch(e>>12&7){case 0:r.Debug("mul - "+s.ToHex(e));break;case 1:r.Debug("mulh - "+s.ToHex(e));break;case 2:r.Debug("mulhsu - "+s.ToHex(e));break;case 3:r.Debug("mulhu - "+s.ToHex(e));break;case 4:r.Debug("div - "+s.ToHex(e));break;case 5:r.Debug("divu - "+s.ToHex(e));break;case 6:r.Debug("rem - "+s.ToHex(e));break;case 7:r.Debug("remu - "+s.ToHex(e))}break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(e)+"not found")}break;case 55:r.Debug("Lui - "+s.ToHex(e));break;case 23:r.Debug("auipc - "+s.ToHex(e));break;case 111:r.Debug("jal - "+s.ToHex(e));break;case 103:r.Debug("jalr - "+s.ToHex(e));break;case 99:switch(e>>12&7){case 0:r.Debug("beq - "+s.ToHex(e));break;case 1:r.Debug("bne - "+s.ToHex(e));break;case 4:r.Debug("blt - "+s.ToHex(e));break;case 5:r.Debug("bge - "+s.ToHex(e));break;case 6:r.Debug("bltu - "+s.ToHex(e));break;case 7:r.Debug("bgeu - "+s.ToHex(e));break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(e)+"not found")}break;case 115:switch(e>>12&7){case 1:r.Debug("csrrw - "+s.ToHex(e));break;case 2:r.Debug("csrrs - "+s.ToHex(e));break;case 3:r.Debug("csrrc - "+s.ToHex(e));break;case 5:r.Debug("csrrwi - "+s.ToHex(e));break;case 6:r.Debug("csrrsi - "+s.ToHex(e));break;case 7:r.Debug("csrrci - "+s.ToHex(e));break;case 0:switch(e>>20&4095){case 0:var d=(6&i[h])>>1;switch(d){case a:r.Debug("ecall PRV_U -"+s.ToHex(e));break;case n:r.Debug("ecall PRV_S -"+s.ToHex(e));break;case o:r.Debug("Not supported ecall PRV_H -"+s.ToHex(e));break;case c:r.Debug("ecall PRV_M -"+s.ToHex(e));break;default:r.Debug("Error in ecall: Don't know how to handle privilege level "+d)}break;case 1:r.Debug("ebreak - "+s.ToHex(e)+" at PC"+s.ToHex(this.pc));break;case 256:var d=(6&i[h])>>1;if(d<n){r.Debug("Error in eret: current_privilege_level isn't allowed access");break}switch(d){case n:r.Debug("eret PRV_S -"+s.ToHex(e));break;case o:r.Debug("Not supported eret PRV_H -"+s.ToHex(e));break;case c:r.Debug("eret PRV_M -"+s.ToHex(e));break;default:r.Debug("Error in eret: Don't know how to handle privilege level "+d)}break;case 773:if(d!=c){r.Debug("Error in mrts: current_privilege_level isn't allowed access");break}r.Debug("mrts - "+s.ToHex(e));break;case 257:r.Debug("sfence.vm - "+s.ToHex(e));break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(e)+"not found")}break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(e)+"not found")}break;case 7:switch(e>>12&7){case 2:r.Debug("flw - "+s.ToHex(e));break;case 3:r.Debug("fld - "+s.ToHex(e));break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(e)+"not found")}break;case 39:switch(e>>12&7){case 2:r.Debug("fsw - "+s.ToHex(e));break;case 3:r.Debug("fsw - "+s.ToHex(e));break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(e)+"not found")}break;case 83:switch(e>>25&127){case 0:r.Debug("fadd.s - "+s.ToHex(e));break;case 4:r.Debug("fsub.s - "+s.ToHex(e));break;case 96:r.Debug("fcvt.w.s - "+s.ToHex(e));break;case 1:r.Debug("fadd.d - "+s.ToHex(e));break;case 5:r.Debug("fsub.d - "+s.ToHex(e));break;case 97:r.Debug("fcvt.w.s - "+s.ToHex(e));break;case 120:r.Debug("fmv.s.x - "+s.ToHex(e));break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(e)+"not found")}break;case 47:switch(e>>27&31){case 1:r.Debug("amoswap - "+s.ToHex(e));break;case 0:r.Debug("amoadd - "+s.ToHex(e));break;case 4:r.Debug("amoxor - "+s.ToHex(e));break;case 12:r.Debug("amoand - "+s.ToHex(e));break;case 8:r.Debug("amoor - "+s.ToHex(e));break;case 16:r.Debug("amomin - "+s.ToHex(e));break;case 20:r.Debug("amomax - "+s.ToHex(e));break;case 24:r.Debug("amominu - "+s.ToHex(e));break;case 28:r.Debug("amomaxu - "+s.ToHex(e));break;case 2:r.Debug("lr.d - "+s.ToHex(e));break;case 3:r.Debug("sc.d - "+s.ToHex(e));break;default:r.Debug("Error in Atomic Memory Instruction "+s.ToHex(e)+"not found")}break;case 15:r.Debug("fence - "+s.ToHex(e));break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(e)+" not found at "+s.ToHex(this.pc))}r.Debug(s.ToHex(u))}var r=e("cjs!../messagehandler"),s=e("cjs!../utils"),a=0,n=1,o=2,c=3,h=768;i.exports.Disassemble=t}()}),define("cjs!jor1k/worker/riscv/safecpu",["require","exports","module","cjs!../messagehandler","cjs!../utils","cjs!./disassemble"],function(e,t,i){!function(){function t(e,t){r.Debug("Initialize RISCV CPU"),this.ram=e,this.htif=t,this.r=new Int32Array(this.ram.heap,0,32),this.f=new Float64Array(this.ram.heap,128,32),this.fi=new Int32Array(this.ram.heap,128,64),this.ff=new Float32Array(this.ram.heap,0,1),this.csr=new Int32Array(this.ram.heap,8192,4096),this.pc=512,this.Reset()}var r=e("cjs!../messagehandler"),s=e("cjs!../utils"),a=(e("cjs!./disassemble"),0),n=1,o=2,c=3,h=0,u=1,d=2,f=1<<31|1,l=1<<31|2,p=1<<31|0,b=1,v=3,m=5,k=7,g=8,R=9,y=10,w=11,S=3072,T=2304,D=1,x=2,E=3,I=256,A=257,C=260,j=289,M=320,_=321,H=324,q=384,L=577,U=768,P=769,W=772,B=801,F=865,z=833,O=832,G=834,N=835,V=836,X=837,Q=1793,K=1857,Y=1920,J=1921,Z=1936,$=1937,ee=2305,te=2561,ie=3457,re=2689,se=3329,ae=3394,ne=3395,oe=3840,ce=3841,he=3856,oe=3840,ce=3841,he=3856,ue=3073;t.prototype.Reset=function(){this.ticks=0,this.csr[U]=150,this.csr[Y]=1920,this.csr[oe]=266541,this.csr[ce]=1,this.csr[he]=0,this.csr[P]=256,this.csr[W]=0,this.csr[z]=0,this.csr[G]=0,this.csr[N]=0,this.csr[I]=12304,this.csr[A]=0,this.csr[C]=0,this.csr[ue]=0,this.csr[q]=262144,this.amoaddr=0,this.amovalue=0},t.prototype.InvalidateTLB=function(){},t.prototype.GetTimeToNextInterrupt=function(){var e=(this.csr[B]>>>0)-(4294967295&this.ticks);return e=e+(e<0?4294967295:0)|0},t.prototype.GetTicks=function(){return this.ticks},t.prototype.ProgressTime=function(e){this.ticks=this.ticks+e|0},t.prototype.AnalyzeImage=function(){},t.prototype.CheckForInterrupt=function(){},t.prototype.RaiseInterrupt=function(e,t){},t.prototype.ClearInterrupt=function(e,t){},t.prototype.Trap=function(e,t){var i=(6&this.csr[U])>>1;this.PushPrivilegeStack(),this.csr[z]=t,this.csr[G]=e,this.pc=256+64*i|0},t.prototype.MemTrap=function(e,t){switch(this.csr[N]=e,t){case h:this.Trap(m,this.pc-4|0);break;case u:this.Trap(k,this.pc-4|0);break;case d:this.Trap(b,this.pc)}},t.prototype.CheckVMPrivilege=function(e,t){var i=(6&this.csr[U])>>1;switch(e){case 2:return t==h||i==a&&t==d;case 3:if(i!=n||t!=d)return!0;break;case 4:return t==h;case 5:if(t!=d)return!0;break;case 6:if(t!=u)return!0;break;case 7:return!0;case 11:return i==n;case 13:if(i==n&&t!=d)return!0;break;case 14:if(i==n&&t!=u)return!0;break;case 15:if(i==n)return!0}return r.Debug("Inside CheckVMPrivilege for PC "+s.ToHex(this.pc)+" and type "+e+" and op "+t),r.Abort(),!1},t.prototype.TranslateVM=function(e,t){var i=this.csr[U]>>17&31,a=(6&this.csr[U])>>1,n=1;if(0==i||a==c)return e;8!=i&&(r.Debug("unkown VM Mode "+i+" at PC "+s.ToHex(this.pc)),r.Abort());var o=4095&e,h=this.ram.Read32(this.csr[q]+(e>>>22<<2)),u=h>>1&15,d=1&h;if(0==d)return this.MemTrap(e,t),-1;if(u>=2)return this.CheckVMPrivilege(u,t)?h>>10<<12|4194303&e:(this.MemTrap(e,t),-1);n-=1;var o=4095&e,f=(4294966272&h)<<2,l=e>>12&1023,p=this.ram.Read32(f+(l<<2)),b=p>>1&15,v=1&p;return 0==v?(this.MemTrap(e,t),-1):this.CheckVMPrivilege(b,t)?p>>10<<12|o:(this.MemTrap(e,t),-1)},t.prototype.SetCSR=function(e,t){var i=this.csr;switch(e){case E:i[e]=t;break;case Z:i[e]=t,this.htif.WriteDEVCMDToHost(t);break;case $:i[e]=t,this.htif.WriteDEVCMDFromHost(t);break;case Y:i[e]=t,this.htif.WriteToHost(t);break;case X:this.ram.Write8(-1879048192,t),10==t&&this.ram.Write8(-1879048192,13);break;case J:i[e]=t,this.htif.WriteFromHost(t);break;case U:i[e]=t;break;case oe:break;case ce:i[e]=t;break;case he:i[e]=t;break;case P:i[e]=t;break;case V:var a=10;i[V]=i[V]&~a|t&a;break;case W:var a=42;i[W]=i[W]&~a|t&a;break;case _:case z:i[e]=t;break;case G:i[e]=t;break;case ae:i[e]=t;break;case N:i[e]=t;break;case ne:i[e]=t;break;case I:i[e]=t,i[U]&=-127034,i[U]|=1&i[I],i[U]|=8&i[I],i[U]|=16&i[I],i[U]|=61440&i[I],i[U]|=65536&i[I];break;case A:i[e]=t;break;case H:var a=2;i[V]=i[V]&~a|t&a;break;case C:var a=34;i[W]=i[W]&~a|t&a;break;case O:i[e]=t;break;case M:i[e]=t;break;case T:i[e]=t;break;case S:this.ticks=t,i[e]=t;break;case Q:case se:case te:i[e]=t;break;case K:case ie:case re:i[e]=t;break;case ue:case ee:i[e]=t;break;case B:case j:i[V]&=-33,i[e]=t;break;case F:i[e]=t;break;case q:i[e]=t;break;case x:i[e]=t;break;case D:i[e]=t;break;case E:i[e]=t;break;default:i[e]=t,r.Debug("Error in SetCSR: PC "+s.ToHex(this.pc)+" Address "+s.ToHex(e)+" unkown"),r.Abort()}},t.prototype.GetCSR=function(e){var t=this.csr;(6&t[U])>>1;switch(e){case E:return 0;case Z:return this.htif.ReadDEVCMDToHost();case $:return this.htif.ReadDEVCMDFromHost();case Y:return this.htif.ReadToHost();case X:return 0;case J:return this.htif.ReadFromHost();case U:return t[e];case oe:return t[e];case ce:return t[e];case he:return t[e];case P:return t[e];case W:return t[e];case _:case z:return t[e];case G:return t[e];case ae:return t[e];case N:return t[e];case ne:return t[e];case I:return t[I]=0,t[I]|=1&t[U],t[I]|=8&t[U],t[I]|=16&t[U],t[I]|=61440&t[U],t[I]|=65536&t[U],t[I];case A:return t[e];case V:return t[e];case W:return t[e];case H:return 34&t[V];case C:return 34&t[W];case O:return t[e];case M:return t[e];case T:return this.ticks;case S:return this.ticks;case Q:case se:case te:return this.ticks;case K:case ie:case re:return this.ticks>>32;case ue:case ee:return this.ticks;case B:case j:case F:return t[e];case q:return t[e];case x:return t[e];case D:return t[e];case E:return t[e];default:return r.Debug("Error in GetCSR: PC "+s.ToHex(this.pc)+" Address "+s.ToHex(e)+" unkown"),r.Abort(),t[e]}},t.prototype.UMul64=function(e,t){var i=[0,0];if(e>>>=0,t>>>=0,e<32767&&t<65536)return i[0]=e*t,i[1]=i[0]<0?-1:0,i;var r=65535&e,s=e>>>16,a=65535&t,n=t>>>16,o=r*a,c=(o>>>16)+s*a,h=c>>>16;c=(65535&c)+r*n,h+=c>>>16;var u=h>>>16;return h=(65535&h)+s*n,u+=h>>>16,i[0]=(65535&c)<<16|65535&o,i[1]=(65535&u)<<16|65535&h,i},t.prototype.IMul64=function(e,t){var i=[0,0];if(0==e)return i[0]=i[1]=0,i;if(0==t)return i[0]=i[1]=0,i;if(e|=0,t|=0,e>=-32768&&e<=32767&&t>=-32768&&t<=32767)return i[0]=e*t,i[1]=i[0]<0?-1:0,i;var r=e<0^t<0;return i=this.UMul64(Math.abs(e),Math.abs(t)),r&&(i[0]=~i[0],i[1]=~i[1],i[0]=i[0]+1|0,0==i[0]&&(i[1]=i[1]+1|0)),i},t.prototype.SUMul64=function(e,t){var i=[0,0];if(0==e)return i[0]=i[1]=0,i;if(0==t)return i[0]=i[1]=0,i;if(e|=0,t>>>=0,e>=-32768&&e<=32767&&t<65536)return i[0]=e*t,i[1]=i[0]<0?-1:0,i;var r=e<0;return i=this.UMul64(Math.abs(e),Math.abs(t)),r&&(i[0]=~i[0],i[1]=~i[1],i[0]=i[0]+1|0,0==i[0]&&(i[1]=i[1]+1|0)),i},t.prototype.PushPrivilegeStack=function(){var e=this.csr,t=e[U],i=511&t,r=(i<<2|c)<<1&511;e[U]=(t&-4096)+r&4294901759},t.prototype.PopPrivilegeStack=function(){var e=this.csr,t=e[U],i=511&t,r=i>>>3|(a<<1|1)<<6;e[U]=(t&-4096)+r},t.prototype.Step=function(e,t){var i=this.r,b=this.fi,m=this.ff,k=this.f,S=this.csr,T=0,D=0,x=0,E=0,I=0,C=0,j=0,M=0,H=0,q=0,P=0,F=0,O=0,X=0,Q=0,K=0,Y=0,J=0;e=0|e,t=0|t;var Z=0;do{i[0]=0;var $=(6&this.csr[U])>>1;if(!(63&e)){var Z=S[B]-this.ticks|0;if(Z=Z+(Z<0?4294967295:0)|0,this.ticks=this.ticks+t|0,Z<t&&(S[V]=32|S[V]),Q=S[W]&S[V],K=1&S[U],$<3||3==$&&K){if(8&Q){this.Trap(p,this.pc);continue}if(!this.htif.IsQueueEmpty()){this.Trap(l,this.pc);continue}}if($<1||1==$&&K){if(2&Q){this.Trap(p,this.pc);continue}if(32&Q){this.Trap(f,this.pc);continue}}}if(J=this.TranslateVM(this.pc,d),J!=-1)switch(Y=this.ram.Read32(J),this.pc=this.pc+4|0,127&Y){case 3:switch(D=Y>>20,q=i[Y>>15&31],T=Y>>7&31,Y>>12&7){case 0:if(J=this.TranslateVM(q+D|0,h),J==-1)break;i[T]=this.ram.Read8(J)<<24>>24;break;case 1:if(q+D&1&&(r.Debug("Error in lh: unaligned address"),r.Abort()),J=this.TranslateVM(q+D|0,h),J==-1)break;i[T]=this.ram.Read16(J)<<16>>16;break;case 2:if(q+D&3&&(r.Debug("Error in lw: unaligned address"),r.Abort()),J=this.TranslateVM(q+D|0,h),J==-1)break;i[T]=this.ram.Read32(J);break;case 4:if(J=this.TranslateVM(q+D|0,h),J==-1)break;i[T]=255&this.ram.Read8(J);break;case 5:if(q+D&1&&(r.Debug("Error in lhu: unaligned address"),r.Abort()),J=this.TranslateVM(q+D|0,h),J==-1)break;i[T]=65535&this.ram.Read16(J);break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(Y)+" not found"),r.Abort()}break;case 35:switch(x=Y>>25,E=Y>>7&31,D=x<<5|E,q=i[Y>>15&31],T=Y>>20&31,Y>>12&7){case 0:if(J=this.TranslateVM(q+D|0,u),J==-1)break;this.ram.Write8(J,255&i[T]);break;case 1:if(q+D&1&&(r.Debug("Error in sh: unaligned address"),r.Abort()),J=this.TranslateVM(q+D|0,u),J==-1)break;this.ram.Write16(J,65535&i[T]);break;case 2:if(q+D&3&&(r.Debug("Error in sw: unaligned address"),r.Abort()),J=this.TranslateVM(q+D|0,u),J==-1)break;this.ram.Write32(J,i[T]);break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(Y)+" not found"),r.Abort()}break;case 19:switch(T=Y>>7&31,q=i[Y>>15&31],D=Y>>20,Y>>12&7){case 0:i[T]=q+D;break;case 2:q<D?i[T]=1:i[T]=0;break;case 3:q>>>0<D>>>0?i[T]=1:i[T]=0;break;case 4:i[T]=q^D;break;case 6:i[T]=q|D;break;case 7:i[T]=q&D;break;case 1:i[T]=q<<D;break;case 5:0==(Y>>25&127)?i[T]=q>>>D:32==(Y>>25&127)?i[T]=q>>D:(r.Debug("Error in safecpu: Instruction (sra, srl)"+s.ToHex(Y)+" not found"),r.Abort());break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(Y)+" not found"),r.Abort()}break;case 51:switch(Y>>25&127){case 0:switch(q=i[Y>>15&31],P=i[Y>>20&31],T=Y>>7&31,Y>>12&7){case 0:i[T]=q+P;break;case 2:q<P?i[T]=1:i[T]=0;break;case 3:q>>>0<P>>>0?i[T]=1:i[T]=0;break;case 7:i[T]=q&P;break;case 6:i[T]=q|P;break;case 4:i[T]=q^P;break;case 1:i[T]=q<<(31&P);break;case 5:i[T]=q>>>(31&P)}break;case 32:switch(q=i[Y>>15&31],P=i[Y>>20&31],T=Y>>7&31,Y>>12&7){case 0:i[T]=q-P;break;case 5:i[T]=q>>(31&P);break;default:r.Debug("Error in safecpu: Instruction (sub,sra) "+s.ToHex(Y)+" not found"),r.Abort()}break;case 1:switch(q=i[Y>>15&31],P=i[Y>>20&31],T=Y>>7&31,Y>>12&7){case 0:var ee=this.IMul64(q,P);i[T]=ee[0];break;case 1:var ee=this.IMul64(q,P);i[T]=ee[1];break;case 2:var ee=this.SUMul64(q,P>>>0);i[T]=ee[1];break;case 3:var ee=this.UMul64(q>>>0,P>>>0);i[T]=ee[1];break;case 4:M=0==P?-1:q/P,i[T]=M;break;case 5:M=0==P?4294967295:(q>>>0)/(P>>>0),i[T]=M;break;case 6:H=0==P?q:q%P,i[T]=H;break;case 7:H=0==P?q>>>0:(q>>>0)%(P>>>0),i[T]=H}break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(Y)+" not found"),r.Abort()}break;case 55:T=Y>>7&31,i[T]=4294963200&Y;break;case 23:D=4294963200&Y,T=Y>>7&31,i[T]=this.pc+D-4|0;break;case 111:x=Y>>21&1023,E=(Y>>20&1)<<10,I=(Y>>12&255)<<11,C=Y>>31<<19,D=(x|E|I|C)<<1,T=Y>>7&31,i[T]=this.pc,this.pc=this.pc+D-4|0;break;case 103:D=Y>>20,q=i[Y>>15&31],T=Y>>7&31,i[T]=this.pc,this.pc=q+D&4294967294;break;case 99:switch(x=Y>>31<<11,E=(Y>>25&63)<<4,I=Y>>8&15,C=(Y>>7&1)<<10,D=(x|E|I|C)<<1,q=i[Y>>15&31],P=i[Y>>20&31],Y>>12&7){case 0:q==P&&(this.pc=this.pc+D-4|0);break;case 1:q!=P&&(this.pc=this.pc+D-4|0);break;case 4:q<P&&(this.pc=this.pc+D-4|0);break;case 5:q>=P&&(this.pc=this.pc+D-4|0);break;case 6:q>>>0<P>>>0&&(this.pc=this.pc+D-4|0);break;case 7:q>>>0>=P>>>0&&(this.pc=this.pc+D-4|0);break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(Y)+" not found"),r.Abort()}break;case 115:switch(D=Y>>>20,q=i[Y>>15&31],T=Y>>7&31,Y>>12&7){case 1:i[T]=this.GetCSR(D),this.SetCSR(D,q);break;case 2:i[T]=this.GetCSR(D),this.SetCSR(D,this.GetCSR(D)|q);break;case 3:i[T]=this.GetCSR(D),this.SetCSR(D,this.GetCSR(D)&~q);break;case 5:i[T]=this.GetCSR(D),j=Y>>15&31,0!=j&&this.SetCSR(D,j>>0);break;case 6:i[T]=this.GetCSR(D),j=Y>>15&31,0!=j&&this.SetCSR(D,this.GetCSR(D)|j>>0);break;case 7:i[T]=this.GetCSR(D),j=Y>>15&31,0!=j&&this.SetCSR(D,this.GetCSR(D)&~(j>>0));break;case 0:switch(Y>>20&4095){case 0:switch($){case a:this.Trap(g,this.pc-4|0);break;case n:this.Trap(R,this.pc-4|0);break;case o:this.Trap(y,this.pc-4|0),this.Abort();break;case c:this.Trap(w,this.pc-4|0);break;default:r.Debug("Error in ecall: Don't know how to handle privilege level "+$),r.Abort()}break;case 1:this.Trap(v,this.pc-4|0);break;case 256:var $=(6&S[U])>>1;if($<n){r.Debug("Error in eret: current_privilege_level isn't allowed access"),r.Abort();break}switch(this.PopPrivilegeStack(),$){case n:this.pc=0|S[_];break;case o:this.pc=0|S[L];break;case c:this.pc=0|S[z];break;default:r.Debug("Error in eret: Don't know how to handle privilege level "+$),r.Abort()}break;case 258:break;case 773:if($!=c){r.Debug("Error in mrts: current_privilege_level isn't allowed access"),r.Abort();break}S[U]=S[U]&-7|2,S[ne]=S[N],S[ae]=S[G],S[_]=S[z],this.pc=0|S[A];break;case 257:break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(Y)+" not found"),r.Abort()}break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(Y)+" not found"),r.Abort()}break;case 7:switch(D=Y>>20,q=i[Y>>15&31],T=Y>>7&31,Y>>12&7){case 2:if(q+D&3&&(r.Debug("Error in flw: unaligned address"),r.Abort()),J=this.TranslateVM(q+D|0,h),J==-1)break;i[0]=this.ram.Read32(J),k[T]=m[0];break;case 3:if(q+D&7&&(r.Debug("Error in flw: unaligned address"),r.Abort()),J=this.TranslateVM(q+D|0,h),J==-1)break;b[(T<<1)+0]=this.ram.Read32(J+0),b[(T<<1)+1]=this.ram.Read32(J+4);break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(Y)+" not found"),r.Abort()}break;case 39:switch(x=Y>>25,E=Y>>7&31,D=(x<<5)+E,q=i[Y>>15&31],T=Y>>20&31,Y>>12&7){case 2:if(m[0]=k[T],q+D&3&&(r.Debug("Error in fsw: unaligned address"),r.Abort()),J=this.TranslateVM(q+D|0,u),J==-1)break;this.ram.Write32(J,i[0]);break;case 3:if(q+D&7&&(r.Debug("Error in fsd: unaligned address"),r.Abort()),J=this.TranslateVM(q+D|0,u),J==-1)break;this.ram.Write32(J+0,b[(T<<1)+0]),this.ram.Write32(J+4,b[(T<<1)+1]);break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(Y)+" not found"),r.Abort()}break;case 83:switch(T=Y>>7&31,Y>>25&127){case 0:case 1:F=k[Y>>15&31],O=k[Y>>20&31],k[T]=F+O;break;case 4:case 5:F=k[Y>>15&31],O=k[Y>>20&31],k[T]=F-O;break;case 80:case 81:switch(F=k[Y>>15&31],O=k[Y>>20&31],Y>>12&7){case 0:F<=O?i[T]=1:i[T]=0;break;case 1:F<O?i[T]=1:i[T]=0;break;case 2:F==O?i[T]=1:i[T]=0;break;default:r.Debug("Error in safecpu: Instruction (fcmp) "+s.ToHex(Y)+" not found"),r.Abort()}break;case 32:case 33:F=k[Y>>15&31],k[T]=F;break;case 96:i[T]=k[Y>>15&31];break;case 97:i[T]=k[Y>>15&31];break;case 104:k[T]=i[Y>>15&31];break;case 105:k[T]=i[Y>>15&31];break;case 8:case 9:F=k[Y>>15&31],O=k[Y>>20&31],k[T]=F*O;break;case 16:case 17:switch(F=k[Y>>15&31],O=k[Y>>20&31],Y>>12&7){case 0:k[T]=O<0?-Math.abs(F):Math.abs(F);break;case 1:k[T]=O<0?Math.abs(F):-Math.abs(F);break;case 2:k[T]=O<0&&F<0||O>0&&F>0?Math.abs(F):-Math.abs(F);break;default:r.Debug("Error in safecpu: Instruction (fsgn) "+s.ToHex(Y)+" not found"),r.Abort()}break;case 120:q=i[Y>>15&31],i[0]=q,k[T]=m[0];break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(Y)+" not found"),r.Abort()}break;case 67:F=k[Y>>15&31],O=k[Y>>20&31],X=k[Y>>27&31],T=Y>>7&31,k[T]=F*O+X;break;case 71:F=k[Y>>15&31],O=k[Y>>20&31],X=k[Y>>27&31],T=Y>>7&31,k[T]=F*O-X;break;case 75:F=k[Y>>15&31],O=k[Y>>20&31],X=k[Y>>27&31],T=Y>>7&31,k[T]=-(F*O+X);break;case 79:F=k[Y>>15&31],O=k[Y>>20&31],X=k[Y>>27&31],T=Y>>7&31,k[T]=-(F*O-X);break;case 47:if(q=i[Y>>15&31],P=i[Y>>20&31],T=Y>>7&31,J=this.TranslateVM(0|q,h),J==-1)break;switch(Y>>27&31){case 1:if(i[T]=this.ram.Read32(J),J=this.TranslateVM(0|q,u),J==-1)break;this.ram.Write32(J,P);break;case 0:if(i[T]=this.ram.Read32(J),J=this.TranslateVM(0|q,u),J==-1)break;this.ram.Write32(J,i[T]+P);break;case 4:if(i[T]=this.ram.Read32(J),J=this.TranslateVM(0|q,u),J==-1)break;this.ram.Write32(J,i[T]^P);break;case 12:if(i[T]=this.ram.Read32(J),J=this.TranslateVM(0|q,u),J==-1)break;this.ram.Write32(J,i[T]&P);break;case 8:if(i[T]=this.ram.Read32(J),J=this.TranslateVM(0|q,u),J==-1)break;this.ram.Write32(J,i[T]|P);break;case 16:if(i[T]=this.ram.Read32(J),P>>0>i[T]>>0?i[0]=i[T]:i[0]=P,J=this.TranslateVM(0|q,u),J==-1)break;this.ram.Write32(J,i[0]);break;case 20:if(i[T]=this.ram.Read32(J),P<i[T]?i[0]=i[T]:i[0]=P,J=this.TranslateVM(q,u),J==-1)break;this.ram.Write32(J,i[0]);break;case 24:if(i[T]=this.ram.Read32(J),P>>>0>i[T]>>>0?i[0]=i[T]:i[0]=P,J=this.TranslateVM(q,u),J==-1)break;this.ram.Write32(J,i[0]);break;case 28:if(i[T]=this.ram.Read32(J),P>>>0<i[T]>>>0?i[0]=i[T]:i[0]=P,J=this.TranslateVM(q,u),J==-1)break;this.ram.Write32(J,i[0]);break;case 2:i[T]=this.ram.Read32(J),this.amoaddr=q,this.amovalue=i[T];break;case 3:if(q!=this.amoaddr){i[T]=1;break}if(this.ram.Read32(J)!=this.amovalue){i[T]=1;break}if(i[T]=0,J=this.TranslateVM(q,u),J==-1)break;this.ram.Write32(J,P);break;default:r.Debug("Error in Atomic Memory Instruction "+s.ToHex(Y)+" not found"),r.Abort()}break;case 15:break;default:r.Debug("Error in safecpu: Instruction "+s.ToHex(Y)+" not found at "+s.ToHex(this.pc)),r.Abort()}}while(e=e-1|0);return 0},i.exports=t}()}),define("cjs!jor1k/worker/riscv/fastcpu",["require","exports","module","cjs!../messagehandler","cjs!../utils","cjs!./disassemble"],function(e,t,i){!function(){function t(e,t,i){"use asm";var r=t.DebugMessage;var s=t.abort;var a=t.Read32;var n=t.Write32;var o=t.Read16;var c=t.Write16;var h=t.Read8;var u=t.Write8;var d=t.ReadDEVCMDToHost;var f=t.ReadDEVCMDFromHost;var l=t.WriteDEVCMDToHost;var p=t.WriteDEVCMDFromHost;var b=t.ReadToHost;var v=t.ReadFromHost;var m=t.WriteToHost;var k=t.WriteFromHost;var g=t.imul;var R=e.Math.abs;var y=e.Math.floor;var w=0;var S=1;var T=2;var D=3;var x=4;var E=5;var I=6;var A=7;var C=8;var j=9;var M=10;var _=11;var H=12;var q=0x00;var L=0x01;var U=0x02;var P=0x03;var W=0;var B=1;var F=2;var z=0x80000001;var O=0x80000002;var G=0x80000000;var N=0x01;var V=0x02;var X=0x03;var Q=0x05;var K=0x07;var Y=0x08;var J=0x09;var Z=0x0A;var $=0x0B;var ee=0x3000;var te=0x2400;var ie=0x4;var re=0x8;var se=0xC;var ae=0x400;var ne=0x404;var oe=0x410;var ce=0x484;var he=0x500;var ue=0x504;var de=0x510;var fe=0x600;var le=0x604;var pe=0x904;var be=0xC00;var ve=0xC04;var me=0xC08;var ke=0xC10;var ge=0xC84;var Re=0xD84;var ye=0xD04;var we=0xD00;var Se=0xD08;var Te=0xD0C;var De=0xD10;var xe=0xD14;var Ee=0x1C04;var Ie=0x1D04;var Ae=0x1E08;var Ce=0x1E0C;var je=0x1E00;var Me=0x1E04;var _e=0x1E40;var He=0x1E44;var qe=0x2404;var Le=0x2408;var Ue=0x2600;var Pe=0x2604;var We=0x2608;var Be=0x2804;var Fe=0x3604;var ze=0x2A04;var Oe=0x3404;var Ge=0x3508;var Ne=0x350C;var Ve=0x3C00;var Xe=0x3C04;var Qe=0x3C40;var Ke=0x3200;var Ye=0x3204;var Je=0x3208;var Ze=0x3004;var $e=0x3008;var et=0x300;var tt=0x3300;var it=0x3304;var rt=0x3008;var st=0x330C;var at=0x3310;var nt=0x3314;var ot=0x3318;var ct=0x331C;var ht=0x3320;var ut=0x3324;var dt=0x3328;var ft=0x332C;var lt=0x3330;var pt=0x33334;var bt=0x33338;var vt=0x3333C;var mt=new e.Int32Array(i);var kt=0x00;var gt=new e.Float64Array(i);var Rt=0x80;var yt=new e.Int32Array(i);var wt=0x80;var St=new e.Float32Array(i);var Tt=0x00;var Dt=new e.Int32Array(i);var xt=0x2000;var Et=new e.Int32Array(i);var It=0x100000;var At=new e.Int8Array(i);var Ct=new e.Int16Array(i);var jt=0x200;var Mt=0x200;var _t=1;var Ht=0;var qt=0,Lt=0;var Ut=0x200;var Pt=0x200;var Wt=0x200;var Bt=-0x8000;var Ft=-0x8000;var zt=-1;var Ot=-1;var Gt=-1;var Nt=-1;var Vt=-1;var Xt=-1;var Qt=-1;var Kt=-1;var Yt=-1;var Jt=-1;var Zt=-1;var $t=-1;var ei=-1;var ti=-1;var ii=-1;var ri=-1;var si=-1;var ai=-1;var ni=-1;var oi=-1;var ci=-1;var hi=-1;var ui=-1;var di=-1;var fi=0;function li(){pi()}function pi(){Ht=0;Dt[xt+be>>2]=0x96;Dt[xt+je>>2]=0x780;Dt[xt+Ve>>2]=0x4112D;Dt[xt+Xe>>2]=0x01;Dt[xt+Qe>>2]=0x00;Dt[xt+ve>>2]=0x100;Dt[xt+ke>>2]=0x00;Dt[xt+ye>>2]=0x00;Dt[xt+Se>>2]=0x00;Dt[xt+Te>>2]=0x00;Dt[xt+ae>>2]=0x3010;Dt[xt+ne>>2]=0x00;Dt[xt+oe>>2]=0x00;Dt[xt+Ze>>2]=0x0;Dt[xt+fe>>2]=0x40000;qt=0x00;Lt=0x00}function bi(){jt=Mt+(Pt-Wt)|0;return jt|0}function vi(){var e=0x0;e=(Dt[xt+0xC84>>2]>>>0)-(Ht&0xFFFFFFFF)|0;e=e+((e|0)<0?0xFFFFFFFF:0x0)|0;return e|0}function mi(){return Ht|0}function ki(e){e=e|0;Ht=Ht+e|0}function gi(){}function Ri(){}function yi(e,t){e=e|0;t=t|0;fi=1}function wi(e,t){e=e|0;t=t|0}function Si(e,t){e=e|0;t=t|0;var i=0;var r=0x100;i=(Dt[xt+be>>2]&0x06)>>1;_i();Dt[xt+ye>>2]=t;Dt[xt+Se>>2]=e;jt=r+(i<<6)|0;Ut=Pt;_t=1;Mi()}function Ti(e,t){e=e|0;t=t|0;if((t|0)!=(F|0))jt=Mt+(Pt-Wt)|0;Dt[xt+Te>>2]=e;switch(t|0){case 0:Si(Q,jt-4|0);break;case 1:Si(K,jt-4|0);break;case 2:Si(N,jt);break}}function Di(e,t){e=e|0;t=t|0;var i=0;i=(Dt[xt+be>>2]&0x06)>>1;switch(e|0){case 2:if((t|0)==(W|0))return 1;if((i|0)==(q|0)&(t|0)==(F|0))return 1;return 0;break;case 3:if(!((i|0)==(L|0)&(t|0)==(F|0)))return 1;break;case 4:if((t|0)==(W|0))return 1;return 0;break;case 5:if((t|0)!=(F|0))return 1;break;case 6:if((t|0)!=(B|0))return 1;break;case 7:return 1;break;case 11:if((i|0)==(L|0))return 1;break;case 13:if((i|0)==(L|0)&(t|0)!=(F|0))return 1;break;case 14:if((i|0)==(L|0)&(t|0)!=(B|0))return 1;break;case 15:if((i|0)==(L|0))return 1;break}r(w|0);s();return 0}function xi(e,t){e=e|0;t=t|0;var i=0;var a=0;var n=1;var o=0;var c=0;var h=0;var u=0;var d=0;var f=0;var l=0;var p=0;var b=0;var v=0;var m=0;i=Dt[xt+be>>2]>>17&0x1F;a=(Dt[xt+be>>2]&0x06)>>1;if((i|0)==0|(a|0)==(P|0))return e|0;if((i|0)!=8){r(T|0);s()}o=e&0xFFF;c=e>>>22|0;m=(Dt[xt+fe>>2]|0)+(c<<2)|0;h=Et[It+m>>2]|0;u=h>>1&0xF;d=h&0x01;if((d|0)==0){Ti(e,t);return-1}if((u|0)>=2){if(!(Di(u,t)|0)){r(S|0);s()}return(h>>10|e>>12&0x3FF)<<12|o}o=e&0xFFF;f=(h&0xFFFFFC00)<<2;l=e>>12&0x3FF;m=(f|0)+(l<<2)|0;p=Et[It+m>>2]|0;b=p>>1&0xF;v=p&0x01;n=n-1|0;if((v|0)==0){Ti(e,t);return-1}if(!(Di(b,t)|0)){Ti(e,t);return-1}return p>>10<<12|o|0}function Ei(e,t){e=e|0;t=t|0;var i=0;var a=0;e=e<<2;switch(e|0){case 0xC:Dt[xt+e>>2]=t;break;case 0x1E40:Dt[xt+e>>2]=t;l(t|0);break;case 0x1E44:Dt[xt+e>>2]=t;p(t|0);break;case 0x1E00:Dt[xt+e>>2]=t;m(t|0);break;case 0xD14:a=0x90000000>>0;At[It+a>>0]=t|0;if((t|0)==0xA)At[It+a>>0]=0xD;break;case 0x1E04:Dt[xt+e>>2]=t;k(t|0);break;case 0xC00:Dt[xt+e>>2]=t;Mi();break;case 0x3C00:break;case 0x3C04:Dt[xt+e>>2]=t;break;case 0x3C40:Dt[xt+e>>2]=t;break;case 0xC04:Dt[xt+e>>2]=t;break;case 0xD10:i=0x2|0x08;Dt[xt+e>>2]=Dt[xt+e>>2]&~i|t&i;break;case 0xC10:i=0x2|0x08|0x20;Dt[xt+e>>2]=Dt[xt+e>>2]&~i|t&i;break;case 0x504:case 0xD04:Dt[xt+e>>2]=t;break;case 0xD08:Dt[xt+e>>2]=t;break;case 0x3508:Dt[xt+e>>2]=t;break;case 0xD0C:Dt[xt+e>>2]=t;break;case 0x350C:Dt[xt+e>>2]=t;break;case 0x400:Dt[xt+ae>>2]=t;Dt[xt+be>>2]=Dt[xt+be>>2]&~0x1F039;Dt[xt+be>>2]=Dt[xt+be>>2]|Dt[xt+ae>>2]&0x01;Dt[xt+be>>2]=Dt[xt+be>>2]|Dt[xt+ae>>2]&0x08;Dt[xt+be>>2]=Dt[xt+be>>2]|Dt[xt+ae>>2]&0x10;Dt[xt+be>>2]=Dt[xt+be>>2]|Dt[xt+ae>>2]&0xF000;Dt[xt+be>>2]=Dt[xt+be>>2]|Dt[xt+ae>>2]&0x10000;break;case 0x404:Dt[xt+e>>2]=t;break;case 0x510:i=0x2;Dt[xt+De>>2]=Dt[xt+De>>2]&~i|t&i;break;case 0x410:i=0x2|0x20;Dt[xt+ke>>2]=Dt[xt+ke>>2]&~i|t&i;break;case 0xD00:Dt[xt+e>>2]=t;break;case 0x500:Dt[xt+e>>2]=t;break;case 0x2400:Dt[xt+e>>2]=t;break;case 0x3000:Ht=t;Dt[xt+e>>2]=t;break;case 0x1C04:case 0x3404:case 0x2804:Dt[xt+e>>2]=t;break;case 0x1D04:case 0x3604:case 0x2A04:Dt[xt+e>>2]=t;break;case 0x3004:case 0x2404:Dt[xt+e>>2]=t;break;case 0xC84:case 0x484:Dt[xt+De>>2]=Dt[xt+De>>2]&~32;Dt[xt+e>>2]=t;break;case 0xD84:case 0x600:Dt[xt+e>>2]=t;break;case 0x04:case 0x08:Dt[xt+e>>2]=t;break;default:Dt[xt+e>>2]=t;r(D|0);s();break}}function Ii(e){e=e|0;var t=0;t=(Dt[xt+be>>2]&0x06)>>1;e=e<<2|0;switch(e|0){case 0xC:return 0x0;break;case 0x1E40:return d()|0;break;case 0x1E44:return f()|0;break;case 0x1E00:return b()|0;break;case 0xD14:return 0x0;break;case 0x1E04:return v()|0;break;case 0xC00:return Dt[xt+e>>2]|0;break;case 0x3C00:return Dt[xt+e>>2]|0;break;case 0x3C04:return Dt[xt+e>>2]|0;break;case 0x3C40:return Dt[xt+e>>2]|0;break;case 0xC04:return Dt[xt+e>>2]|0;break;case 0xC10:return Dt[xt+e>>2]|0;break;case 0x504:case 0xD04:return Dt[xt+e>>2]|0;break;case 0xD08:return Dt[xt+e>>2]|0;break;case 0x3508:return Dt[xt+e>>2]|0;break;case 0xD0C:return Dt[xt+e>>2]|0;break;case 0x350C:return Dt[xt+e>>2]|0;break;case 0x400:Dt[xt+ae>>2]=0x00;Dt[xt+ae>>2]=Dt[xt+ae>>2]|Dt[xt+be>>2]&0x01;Dt[xt+ae>>2]=Dt[xt+ae>>2]|Dt[xt+be>>2]&0x08;Dt[xt+ae>>2]=Dt[xt+ae>>2]|Dt[xt+be>>2]&0x10;Dt[xt+ae>>2]=Dt[xt+ae>>2]|Dt[xt+be>>2]&0xF000;Dt[xt+ae>>2]=Dt[xt+ae>>2]|Dt[xt+be>>2]&0x10000;return Dt[xt+ae>>2]|0;break;case 0x404:return Dt[xt+e>>2]|0;break;case 0xD10:return Dt[xt+e>>2]|0;break;case 0x510:return Dt[xt+De>>2]&(0x2|0x20)|0;break;case 0x410:return Dt[xt+ke>>2]&(0x2|0x20)|0;break;case 0xD00:return Dt[xt+e>>2]|0;break;case 0x500:return Dt[xt+e>>2]|0;break;case 0x2400:return Ht|0;break;case 0x3000:return Ht|0;break;case 0x1C04:case 0x3404:case 0x2804:return Ht|0;break;case 0x1D04:case 0x3604:case 0x2A04:return Ht>>32|0;break;case 0x3004:case 0x2404:return Ht|0;break;case 0xC84:case 0x484:return Dt[xt+e>>2]|0;break;case 0xD84:case 0x600:return Dt[xt+e>>2]|0;break;case 0x04:case 0x08:return Dt[xt+e>>2]|0;break;default:r(x|0);s();return Dt[xt+e>>2]|0;break}return 0}function Ai(e,t,i){e=e|0;t=t|0;i=i|0;var r=0,s=0;var a=0,n=0;var o=0,c=0;var h=0;var u=0;var d=0;var f=0;if(e>>>0<32767)if(t>>>0<65536){r=g(e|0,t|0)|0;s=(r|0)<0?-1:0;if((i|0)==0)return r|0;return s|0}a=e&0xFFFF;n=e>>>16;o=t&0xFFFF;c=t>>>16;h=g(a|0,o|0)|0;u=(h>>>16)+(g(n|0,o|0)|0)|0;d=u>>>16;u=(u&0xFFFF)+(g(a|0,c|0)|0)|0;d=d+(u>>>16)|0;f=d>>>16;d=(d&0xFFFF)+(g(n|0,c|0)|0)|0;f=f+(d>>>16)|0;r=(u&0xFFFF)<<16|h&0xFFFF;s=(f&0xFFFF)<<16|d&0xFFFF;if((i|0)==0)return r|0;return s|0}function Ci(e,t,i){e=e|0;t=t|0;i=i|0;var r=0,s=0;var a=0;if((e|0)==0)return 0;if((t|0)==0)return 0;if((e|0)>=-32768)if((e|0)<=32767)if((t|0)>=-32768)if((t|0)<=32767){r=g(e|0,t|0)|0;s=(r|0)<0?-1:0;if((i|0)==0)return r|0;return s|0}a=(e|0)<0^(t|0)<0;e=R(e|0)|0;t=R(t|0)|0;r=Ai(e,t,0)|0;s=Ai(e,t,1)|0;if(a){r=~r;s=~s;r=r+1|0;if((r|0)==0)s=s+1|0}if((i|0)==0)return r|0;return s|0}function ji(e,t,i){e=e|0;t=t|0;i=i|0;var r=0,s=0;var a=0;if((e|0)==0)return 0;if((t|0)==0)return 0;if((e|0)>=-32768)if((e|0)<=32767)if(t>>>0<65536){r=g(e|0,t|0)|0;s=(r|0)<0?-1:0;if((i|0)==0)return r|0;return s|0}a=(e|0)<0;e=R(e|0)|0;r=Ai(e,t,0)|0;s=Ai(e,t,1)|0;if(a){r=~r;s=~s;r=r+1|0;if((r|0)==0)s=s+1|0}if((i|0)==0)return r|0;return s|0}function Mi(){Bt=0xFFFF0000;Ft=-1;zt=0xFFFF0000;Ot=-1;Gt=0xFFFF0000;Nt=-1;Vt=0xFFFF0000;Xt=-1;Qt=0xFFFF0000;Kt=-1;Yt=0xFFFF0000;Jt=-1;Zt=0xFFFF0000;$t=-1;ei=0xFFFF0000;ti=-1;ii=0xFFFF0000;ri=-1;si=0xFFFF0000;ai=-1;ni=0xFFFF0000;oi=-1;ci=0xFFFF0000;hi=-1;ui=0xFFFF0000;di=-1}function _i(){var e=0,t=0,i=0;e=Dt[xt+be>>2]|0;t=e&0xFFF;i=(t<<2|P)<<1&0xFFF;Dt[xt+be>>2]=(e>>12<<12)+i&0xFFFEFFFF}function Hi(){var e=0,t=0,i=0;e=Dt[xt+be>>2]|0;t=e&0xFFF;i=t>>>3|(q<<1|0x1)<<9;Dt[xt+be>>2]=(e>>12<<12)+i;Mi()}function qi(e,t){e=e|0;t=t|0;var i=0x00;var a=0x00;var n=0x00;var o=0x00;var c=0x00;var h=0x00;var u=0x0;var d=0x0;var f=0.0;var l=0.0;var p=0.0;var b=0;var v=0;var m=0;var k=0;var w=0;var S=0;var T=0;var D=64;for(;;){if((Ut|0)!=(Pt|0)){T=Et[Pt>>2]|0;Pt=Pt+4|0;switch(T&0x7F){case 0x03:v=(mt[(T>>13&0x7C)>>2]|0)+(T>>20)|0;switch(T>>12&0x7){case 0x00:if((zt^v)&0xFFFFF000){m=xi(v|0,W)|0;if((m|0)==-1)continue;zt=v|0;Ot=(m^v)&0xFFFFF000}m=Ot^v;mt[(T>>5&0x7C)>>2]=At[It+m>>0]<<24>>24;continue;case 0x01:if((Vt^v)&0xFFFFF000){m=xi(v|0,W)|0;if((m|0)==-1)continue;Vt=v|0;Xt=(m^v)&0xFFFFF000}m=Xt^v;mt[(T>>5&0x7C)>>2]=Ct[It+m>>1]<<16>>16;continue;case 0x02:if(v&3){r(E|0);s()}if((Yt^v)&0xFFFFF000){m=xi(v|0,W)|0;if((m|0)==-1)continue;Yt=v|0;Jt=(m^v)&0xFFFFF000}m=Jt^v;mt[(T>>5&0x7C)>>2]=Et[It+m>>2]|0;continue;case 0x04:if((Gt^v)&0xFFFFF000){m=xi(v|0,W)|0;if((m|0)==-1)continue;Gt=v|0;Nt=(m^v)&0xFFFFF000}m=Nt^v;mt[(T>>5&0x7C)>>2]=At[It+m>>0]&0xFF;continue;case 0x05:if((Qt^v)&0xFFFFF000){m=xi(v|0,W)|0;if((m|0)==-1)continue;Qt=v|0;Kt=(m^v)&0xFFFFF000}m=Kt^v;mt[(T>>5&0x7C)>>2]=Ct[It+m>>1]&0xFFFF;continue;default:r(A|0);s();break}continue;case 0x23:v=(mt[(T>>13&0x7C)>>2]|0)+(T>>25<<5|T>>7&0x1F)|0;switch(T>>12&0x7){case 0x00:if((Zt^v)&0xFFFFF000){m=xi(v|0,B)|0;if((m|0)==-1)continue;
Zt=v|0;$t=(m^v)&0xFFFFF000}m=$t^v;At[It+m>>0]=mt[(T>>18&0x7C)>>2]&0xFF;continue;case 0x01:if((ei^v)&0xFFFFF000){m=xi(v|0,B)|0;if((m|0)==-1)continue;ei=v|0;ti=(m^v)&0xFFFFF000}m=ti^v;Ct[It+m>>1]=mt[(T>>18&0x7C)>>2]&0xFFFF;continue;case 0x02:if(v&3){r(I|0);s()}if((ii^v)&0xFFFFF000){m=xi(v|0,B)|0;if((m|0)==-1)continue;ii=v|0;ri=(m^v)&0xFFFFF000}m=ri^v;Et[It+m>>2]=mt[(T>>18&0x7C)>>2]|0;continue;default:r(A|0);s();break}continue;case 0x13:u=mt[(T>>13&0x7C)>>2]|0;switch(T>>12&0x7){case 0x00:mt[(T>>5&0x7C)>>2]=u+(T>>20)|0;continue;case 0x02:if((u|0)<T>>20)mt[(T>>5&0x7C)>>2]=0x01;else mt[(T>>5&0x7C)>>2]=0x00;continue;case 0x03:if(u>>>0<T>>20>>>0)mt[(T>>5&0x7C)>>2]=0x01;else mt[(T>>5&0x7C)>>2]=0x00;continue;case 0x04:mt[(T>>5&0x7C)>>2]=u^T>>20;continue;case 0x06:mt[(T>>5&0x7C)>>2]=u|T>>20;continue;case 0x07:mt[(T>>5&0x7C)>>2]=u&T>>20;continue;case 0x01:mt[(T>>5&0x7C)>>2]=u<<(T>>20&0x1F);continue;case 0x05:if((T>>25&0x7F)==0x00){mt[(T>>5&0x7C)>>2]=u>>>(T>>20&0x1F)}else if((T>>25&0x7F)==0x20){mt[(T>>5&0x7C)>>2]=u>>(T>>20&0x1F)}continue;default:r(A|0);s();break}continue;case 0x33:switch(T>>25&0x7F){case 0x00:u=mt[(T>>13&0x7C)>>2]|0;d=mt[(T>>18&0x7C)>>2]|0;switch(T>>12&0x7){case 0x00:mt[(T>>5&0x7C)>>2]=u+d;continue;case 0x02:if((u|0)<(d|0))mt[(T>>5&0x7C)>>2]=0x01;else mt[(T>>5&0x7C)>>2]=0x00;continue;case 0x03:if(u>>>0<d>>>0)mt[(T>>5&0x7C)>>2]=0x01;else mt[(T>>5&0x7C)>>2]=0x00;continue;case 0x07:mt[(T>>5&0x7C)>>2]=u&d;continue;case 0x06:mt[(T>>5&0x7C)>>2]=u|d;continue;case 0x04:mt[(T>>5&0x7C)>>2]=u^d;continue;case 0x01:mt[(T>>5&0x7C)>>2]=u<<(d&0x1F);continue;case 0x05:mt[(T>>5&0x7C)>>2]=u>>>(d&0x1F);continue}continue;case 0x20:u=mt[(T>>13&0x7C)>>2]|0;d=mt[(T>>18&0x7C)>>2]|0;switch(T>>12&0x7){case 0x00:mt[(T>>5&0x7C)>>2]=u-d;continue;case 0x05:mt[(T>>5&0x7C)>>2]=u>>(d&0x1F);continue}continue;case 0x01:u=mt[(T>>13&0x7C)>>2]|0;d=mt[(T>>18&0x7C)>>2]|0;switch(T>>12&0x7){case 0x00:h=g(u|0,d|0)|0;mt[(T>>5&0x7C)>>2]=h;continue;case 0x01:h=Ci(u,d,1)|0;mt[(T>>5&0x7C)>>2]=h;continue;case 0x02:h=ji(u,d>>>0,1)|0;mt[(T>>5&0x7C)>>2]=h;continue;case 0x03:h=Ai(u>>>0,d>>>0,1)|0;mt[(T>>5&0x7C)>>2]=h;continue;case 0x04:if((d|0)==0)o=-1;else o=(u|0)/(d|0)|0;mt[(T>>5&0x7C)>>2]=o;continue;case 0x05:if((d|0)==0)o=0xFFFFFFFF;else o=(u>>>0)/(d>>>0)|0;mt[(T>>5&0x7C)>>2]=o;continue;case 0x06:if((d|0)==0)c=u;else c=(u|0)%(d|0)|0;mt[(T>>5&0x7C)>>2]=c;continue;case 0x07:if((d|0)==0)c=u>>>0;else c=(u>>>0)%(d>>>0)|0;mt[(T>>5&0x7C)>>2]=c;continue}continue;default:r(A|0);s();break}continue;case 0x37:mt[(T>>5&0x7C)>>2]=T&0xFFFFF000;continue;case 0x17:jt=Mt+(Pt-Wt)|0;mt[(T>>5&0x7C)>>2]=jt+(T&0xFFFFF000)-4|0;continue;case 0x6F:jt=Mt+(Pt-Wt)|0;mt[(T>>5&0x7C)>>2]=jt;i=(T>>21&0x3FF|(T>>20&0x1)<<10|(T>>12&0xFF)<<11|T>>31<<19)<<1;jt=jt+i-4|0;Ut=Pt;_t=1;mt[0]=0;continue;case 0x67:jt=Mt+(Pt-Wt)|0;u=mt[(T>>13&0x7C)>>2]|0;mt[(T>>5&0x7C)>>2]=jt;jt=u+(T>>20)&0xFFFFFFFE|0;Ut=Pt;_t=1;mt[0]=0;continue;case 0x63:u=mt[(T>>13&0x7C)>>2]|0;d=mt[(T>>18&0x7C)>>2]|0;switch(T>>12&0x7){case 0x00:if((u|0)!=(d|0))continue;Ut=Pt;_t=1;i=(T>>31<<11|(T>>25&0x3F)<<4|T>>8&0x0F|(T>>7&0x01)<<10)<<1;jt=Mt+(Pt-Wt)|0;jt=jt+i-4|0;continue;case 0x01:if((u|0)==(d|0))continue;Ut=Pt;_t=1;i=(T>>31<<11|(T>>25&0x3F)<<4|T>>8&0x0F|(T>>7&0x01)<<10)<<1;jt=Mt+(Pt-Wt)|0;jt=jt+i-4|0;continue;case 0x04:if((u|0)>=(d|0))continue;Ut=Pt;_t=1;i=(T>>31<<11|(T>>25&0x3F)<<4|T>>8&0x0F|(T>>7&0x01)<<10)<<1;jt=Mt+(Pt-Wt)|0;jt=jt+i-4|0;continue;case 0x05:if((u|0)<(d|0))continue;Ut=Pt;_t=1;i=(T>>31<<11|(T>>25&0x3F)<<4|T>>8&0x0F|(T>>7&0x01)<<10)<<1;jt=Mt+(Pt-Wt)|0;jt=jt+i-4|0;continue;case 0x06:if(u>>>0>=d>>>0)continue;Ut=Pt;_t=1;i=(T>>31<<11|(T>>25&0x3F)<<4|T>>8&0x0F|(T>>7&0x01)<<10)<<1;jt=Mt+(Pt-Wt)|0;jt=jt+i-4|0;continue;case 0x07:if(u>>>0<d>>>0)continue;Ut=Pt;_t=1;i=(T>>31<<11|(T>>25&0x3F)<<4|T>>8&0x0F|(T>>7&0x01)<<10)<<1;jt=Mt+(Pt-Wt)|0;jt=jt+i-4|0;continue;default:r(A|0);s();break}continue;case 0x73:i=T>>>20;u=mt[(T>>13&0x7C)>>2]|0;switch(T>>12&0x7){case 0x01:mt[(T>>5&0x7C)>>2]=Ii(i)|0;Ei(i,u);mt[0]=0;continue;case 0x02:mt[(T>>5&0x7C)>>2]=Ii(i)|0;Ei(i,Ii(i)|0|u);mt[0]=0;continue;case 0x03:mt[(T>>5&0x7C)>>2]=Ii(i)|0;Ei(i,(Ii(i)|0)&~u);mt[0]=0;continue;case 0x05:mt[(T>>5&0x7C)>>2]=Ii(i)|0;a=T>>15&0x1F;if((a|0)!=0)Ei(i,a>>0);mt[0]=0;continue;case 0x06:mt[(T>>5&0x7C)>>2]=Ii(i)|0;a=T>>15&0x1F;if((a|0)!=0)Ei(i,Ii(i)|0|a>>0);mt[0]=0;continue;case 0x07:mt[(T>>5&0x7C)>>2]=Ii(i)|0;a=T>>15&0x1F;if((a|0)!=0)Ei(i,(Ii(i)|0)&~(a>>0));mt[0]=0;continue;case 0x00:k=(Dt[xt+be>>2]&0x06)>>1;Ut=Pt;switch(T>>20&0xFFF){case 0x00:jt=Mt+(Pt-Wt)|0;switch(k|0){case 0x00:Si(Y,jt-4|0);break;case 0x01:Si(J,jt-4|0);break;case 0x02:Si(Z,jt-4|0);s();break;case 0x03:Si($,jt-4|0);break;default:r(C|0);s();break}continue;case 0x001:jt=Mt+(Pt-Wt)|0;Si(X,jt-4|0);continue;case 0x100:k=(Dt[xt+be>>2]&0x06)>>1;jt=Mt+(Pt-Wt)|0;if((k|0)<(L|0)){r(M|0);s();break}Hi();switch(k|0){case 0x01:jt=Dt[xt+ue>>2]|0;break;case 0x02:jt=Dt[xt+pe>>2]|0;s();break;case 0x03:jt=Dt[xt+ye>>2]|0;break;default:r(j|0);s();break}_t=1;Mi();continue;case 0x102:w=Dt[xt+ke>>2]&Dt[xt+De>>2];continue;case 0x305:jt=Mt+(Pt-Wt)|0;if((k|0)!=(P|0)){r(_|0);s();break}Dt[xt+be>>2]=Dt[xt+be>>2]&~0x6|0x02;Dt[xt+Ne>>2]=Dt[xt+Te>>2];Dt[xt+Ge>>2]=Dt[xt+Se>>2];Dt[xt+ue>>2]=Dt[xt+ye>>2];jt=Dt[xt+ne>>2]|0;Mi();_t=1;continue;case 0x101:Mi();continue;default:r(A|0);s();break}continue;default:r(A|0);s();break}continue;case 0x07:v=(mt[(T>>13&0x7C)>>2]|0)+(T>>20)|0;switch(T>>12&0x7){case 0x02:if((si^v)&0xFFFFF000){m=xi(v|0,W)|0;if((m|0)==-1)break;si=v|0;ai=(m^v)&0xFFFFF000}m=ai^v;mt[0]=Et[It+m>>2]|0;gt[Rt+((T>>7&0x1F)<<3)>>3]=+St[0];mt[0]=0;continue;case 0x03:if((ni^v)&0xFFFFF000){m=xi(v|0,W)|0;if((m|0)==-1)continue;ni=v|0;oi=(m^v)&0xFFFFF000}m=oi^v;yt[wt+((T>>7&0x1F)<<3)+0>>2]=Et[It+m+0>>2]|0;yt[wt+((T>>7&0x1F)<<3)+4>>2]=Et[It+m+4>>2]|0;continue;default:r(A|0);r(T|0);s();break}continue;case 0x27:v=(mt[(T>>13&0x7C)>>2]|0)+(T>>25<<5|T>>7&0x1F)|0;switch(T>>12&0x7){case 0x02:St[0]=+gt[Rt+((T>>20&0x1F)<<3)>>3];if((ci^v)&0xFFFFF000){m=xi(v|0,W)|0;if((m|0)==-1)continue;ci=v|0;hi=(m^v)&0xFFFFF000}m=hi^v;Et[It+m>>2]=mt[0]|0;mt[0]=0;continue;case 0x03:if((ui^v)&0xFFFFF000){m=xi(v|0,W)|0;if((m|0)==-1)continue;ui=v|0;di=(m^v)&0xFFFFF000}m=di^v;Et[It+m+0>>2]=yt[wt+((T>>20&0x1F)<<3)+0>>2]|0;Et[It+m+4>>2]=yt[wt+((T>>20&0x1F)<<3)+4>>2]|0;continue;default:r(A|0);r(T|0);s();break}continue;case 0x53:switch(T>>25&0x7F){case 0x00:case 0x01:f=+gt[Rt+((T>>15&0x1F)<<3)>>3];l=+gt[Rt+((T>>20&0x1F)<<3)>>3];gt[Rt+((T>>7&0x1F)<<3)>>3]=+f+ +l;continue;case 0x04:case 0x05:f=+gt[Rt+((T>>15&0x1F)<<3)>>3];l=+gt[Rt+((T>>20&0x1F)<<3)>>3];gt[Rt+((T>>7&0x1F)<<3)>>3]=+f-+l;continue;case 0x50:case 0x51:f=+gt[Rt+((T>>15&0x1F)<<3)>>3];l=+gt[Rt+((T>>20&0x1F)<<3)>>3];switch(T>>12&0x7){case 0x0:if(+f<=+l)mt[(T>>5&0x7C)>>2]=1;else mt[(T>>5&0x7C)>>2]=0;continue;case 0x1:if(+f<+l)mt[(T>>5&0x7C)>>2]=1;else mt[(T>>5&0x7C)>>2]=0;continue;case 0x2:if(+f==+l)mt[(T>>5&0x7C)>>2]=1;else mt[(T>>5&0x7C)>>2]=0;continue;default:r(A|0);r(T|0);s();break}continue;case 0x20:case 0x21:gt[Rt+((T>>7&0x1F)<<3)>>3]=+gt[Rt+((T>>15&0x1F)<<3)>>3];continue;case 0x60:mt[(T>>5&0x7C)>>2]=~~y(+gt[Rt+((T>>15&0x1F)<<3)>>3]);continue;case 0x68:case 0x69:gt[Rt+((T>>7&0x1F)<<3)>>3]=+(mt[(T>>13&0x7C)>>2]|0);continue;case 0x08:case 0x09:f=+gt[Rt+((T>>15&0x1F)<<3)>>3];l=+gt[Rt+((T>>20&0x1F)<<3)>>3];gt[Rt+((T>>7&0x1F)<<3)>>3]=+ +f*+l;continue;case 0x10:case 0x11:f=+gt[Rt+((T>>15&0x1F)<<3)>>3];l=+gt[Rt+((T>>20&0x1F)<<3)>>3];switch(T>>12&7){case 0:gt[Rt+((T>>7&0x1F)<<3)>>3]=+l<+0?-+R(+f):+R(+f);continue;case 1:gt[Rt+((T>>7&0x1F)<<3)>>3]=+l<+0?+R(+f):-+R(+f);continue;case 2:if(+f*+l<+0){gt[Rt+((T>>7&0x1F)<<3)>>3]=-+R(+f)}else{gt[Rt+((T>>7&0x1F)<<3)>>3]=+ +R(+f)}continue;default:r(A|0);r(T|0);s()}continue;case 0x61:mt[(T>>5&0x7C)>>2]=~~+gt[Rt+((T>>15&0x1F)<<3)>>3];continue;case 0x78:u=mt[(T>>13&0x7C)>>2]|0;mt[0]=u;gt[Rt+((T>>7&0x1F)<<3)>>3]=+St[0];mt[0]=0;continue;default:r(A|0);r(T|0);s();break}continue;case 0x43:f=+gt[Rt+((T>>15&0x1F)<<3)>>3];l=+gt[Rt+((T>>20&0x1F)<<3)>>3];p=+gt[Rt+((T>>27&0x1F)<<3)>>3];gt[Rt+((T>>7&0x1F)<<3)>>3]=f*l+p;continue;case 0x47:f=+gt[Rt+((T>>15&0x1F)<<3)>>3];l=+gt[Rt+((T>>20&0x1F)<<3)>>3];p=+gt[Rt+((T>>27&0x1F)<<3)>>3];gt[Rt+((T>>7&0x1F)<<3)>>3]=f*l-p;continue;case 0x4B:f=+gt[Rt+((T>>15&0x1F)<<3)>>3];l=+gt[Rt+((T>>20&0x1F)<<3)>>3];p=+gt[Rt+((T>>27&0x1F)<<3)>>3];gt[Rt+((T>>7&0x1F)<<3)>>3]=-(f*l+p);continue;case 0x4F:f=+gt[Rt+((T>>15&0x1F)<<3)>>3];l=+gt[Rt+((T>>20&0x1F)<<3)>>3];p=+gt[Rt+((T>>27&0x1F)<<3)>>3];gt[Rt+((T>>7&0x1F)<<3)>>3]=-(f*l-p);continue;case 0x2F:u=mt[(T>>13&0x7C)>>2]|0;d=mt[(T>>18&0x7C)>>2]|0;m=xi(u|0,W)|0;if((m|0)==-1)continue;switch(T>>27&0x1F){case 0x01:mt[(T>>5&0x7C)>>2]=Et[It+m>>2]|0;Et[It+m>>2]=d|0;m=xi(u|0,B)|0;if((m|0)==-1)continue;mt[0]=0;continue;case 0x00:mt[(T>>5&0x7C)>>2]=Et[It+m>>2]|0;m=xi(u|0,B)|0;if((m|0)==-1)continue;Et[It+m>>2]=(mt[(T>>5&0x7C)>>2]|0)+(d|0)|0;mt[0]=0;continue;case 0x04:mt[(T>>5&0x7C)>>2]=Et[It+m>>2]|0;m=xi(u|0,B)|0;if((m|0)==-1)continue;Et[It+m>>2]=(mt[(T>>5&0x7C)>>2]|0)^(d|0)|0;mt[0]=0;continue;case 0x0C:mt[(T>>5&0x7C)>>2]=Et[It+m>>2]|0;m=xi(u|0,B)|0;if((m|0)==-1)continue;Et[It+m>>2]=(mt[(T>>5&0x7C)>>2]|0)&(d|0)|0;mt[0]=0;continue;case 0x08:mt[(T>>5&0x7C)>>2]=Et[It+m>>2]|0;m=xi(u|0,B)|0;if((m|0)==-1)continue;Et[It+m>>2]=mt[(T>>5&0x7C)>>2]|0|(d|0)|0;mt[0]=0;continue;case 0x10:mt[(T>>5&0x7C)>>2]=Et[It+m>>2]|0;if(d>>0>mt[(T>>5&0x7C)>>2]>>0)mt[0]=mt[(T>>5&0x7C)>>2];else mt[0]=d;m=xi(u|0,B)|0;if((m|0)==-1)continue;Et[It+m>>2]=mt[0]|0;mt[0]=0;continue;case 0x14:mt[(T>>5&0x7C)>>2]=Et[It+m>>2]|0;if(d>>0<mt[(T>>5&0x7C)>>2]>>0)mt[0]=mt[(T>>5&0x7C)>>2];else mt[0]=d;m=xi(u|0,B)|0;if((m|0)==-1)continue;Et[It+m>>2]=mt[0]|0;mt[0]=0;continue;case 0x18:mt[(T>>5&0x7C)>>2]=Et[It+m>>2]|0;if(d>>>0>mt[(T>>5&0x7C)>>2]>>>0)mt[0]=mt[(T>>5&0x7C)>>2];else mt[0]=d;m=xi(u|0,B)|0;if((m|0)==-1)continue;Et[It+m>>2]=mt[0]|0;mt[0]=0;continue;case 0x1C:mt[(T>>5&0x7C)>>2]=Et[It+m>>2]|0;if(d>>>0<mt[(T>>5&0x7C)>>2]>>>0)mt[0]=mt[(T>>5&0x7C)>>2];else mt[0]=d;m=xi(u|0,B)|0;if((m|0)==-1)continue;Et[It+m>>2]=mt[0]|0;mt[0]=0;continue;case 0x02:mt[(T>>5&0x7C)>>2]=Et[It+m>>2]|0;qt=u;Lt=mt[(T>>5&0x7C)>>2]|0;mt[0]=0;continue;case 0x03:if((u|0)!=(qt|0)){mt[(T>>5&0x7C)>>2]=0x01;continue}if((Et[It+m>>2]|0)!=(Lt|0)){mt[(T>>5&0x7C)>>2]=0x01;continue}mt[(T>>5&0x7C)>>2]=0x00;m=xi(u,B)|0;if((m|0)==-1)continue;Et[It+m>>2]=d|0;mt[0]=0;continue;default:r(H|0);s();break}continue;case 0x0F:continue;case 0x0:default:r(A|0);r(T|0);s();break}}else{if(!(_t|0))jt=Mt+(Pt-Wt)|0;D=D-(Pt-Wt>>2)|0;if((D|0)<0){D=D+64|0;e=e-64|0;if((e|0)<0)return 0;b=(Dt[xt+ge>>2]|0)-Ht|0;b=b+((b|0)<0?0xFFFFFFFF:0x0)|0;Ht=Ht+t|0;if((b|0)<(t|0)){Dt[xt+De>>2]=Dt[xt+De>>2]|0x20}k=(Dt[xt+be>>2]&0x06)>>1;w=Dt[xt+ke>>2]&Dt[xt+De>>2];S=Dt[xt+be>>2]&0x01;if((k|0)<3|(k|0)==3&(S|0)){if((w|0)&0x8){Si(G,jt);continue}else if(fi|0){Si(O,jt);fi=0;continue}}if((k|0)<1|(k|0)==1&(S|0)){if((w|0)&0x2){Si(G,jt);continue}else if((w|0)&0x20){Si(z,jt);continue}}}if((Bt^jt)&0xFFFFF000){Pt=xi(jt|0,F)|0;if((Pt|0)==-1){Pt=Ut;continue}Bt=jt;Ft=(Pt^jt)&0xFFFFF000}Pt=It+(Ft^jt)|0;Wt=Pt;Mt=jt;Ut=(Pt>>12)+1<<12;_t=0}}return 0}return{Reset:pi,Init:li,InvalidateTLB:Mi,Step:qi,TranslateVM:xi,GetCSR:Ii,SetCSR:Ei,GetTimeToNextInterrupt:vi,ProgressTime:ki,GetTicks:mi,GetPC:bi,AnalyzeImage:gi,RaiseInterrupt:yi,ClearInterrupt:wi}}e("cjs!../messagehandler"),e("cjs!../utils"),e("cjs!./disassemble");i.exports=t}()}),define("cjs!jor1k/worker/riscv/dynamiccpu",["require","exports","module","cjs!../messagehandler","cjs!../utils","cjs!./disassemble"],function(e,t,i){!function(){function t(e,t,i){"use asm";var r=t.DebugMessage;var s=t.abort;var a=t.Read32;var n=t.Write32;var o=t.Read16;var c=t.Write16;var h=t.Read8;var u=t.Write8;var d=t.ReadDEVCMDToHost;var f=t.ReadDEVCMDFromHost;var l=t.WriteDEVCMDToHost;var p=t.WriteDEVCMDFromHost;var b=t.ReadToHost;var v=t.ReadFromHost;var m=t.WriteToHost;var k=t.WriteFromHost;var g=t.IsQueueEmpty;var R=t.mul;var y=e.Math.abs;var w=0;var S=1;var T=2;var D=3;var x=4;var E=5;var I=6;var A=7;var C=8;var j=9;var M=10;var _=11;var H=12;var q=0x00;var L=0x01;var U=0x02;var P=0x03;var W=0;var B=1;var F=2;var z=0x80000001;var O=0x80000002;var G=0x80000000;var N=0x01;var V=0x02;var X=0x03;var Q=0x05;var K=0x07;var Y=0x08;var J=0x09;var Z=0x0A;var $=0x0B;var ee=0x3000;var te=0x2400;var ie=0x4;var re=0x8;var se=0xC;var ae=0x400;var ne=0x404;var oe=0x410;var ce=0x484;var he=0x500;var ue=0x504;var de=0x510;var fe=0x600;var le=0x604;var pe=0x904;var be=0xC00;var ve=0xC04;var me=0xC08;var ke=0xC10;var ge=0xC84;var Re=0xD84;var ye=0xD04;var we=0xD00;var Se=0xD08;var Te=0xD0C;var De=0xD10;var xe=0xD14;var Ee=0x1C04;var Ie=0x1D04;var Ae=0x1E08;var Ce=0x1E0C;var je=0x1E00;var Me=0x1E04;var _e=0x1E40;var He=0x1E44;var qe=0x2404;var Le=0x2408;var Ue=0x2600;var Pe=0x2604;var We=0x2608;var Be=0x2804;var Fe=0x3604;var ze=0x2A04;var Oe=0x3404;var Ge=0x3508;var Ne=0x350C;var Ve=0x3C00;var Xe=0x3C04;var Qe=0x3C40;var Ke=0x3200;var Ye=0x3204;var Je=0x3208;var Ze=0x3004;var $e=0x3008;var et=0x300;var tt=0x3300;var it=0x3304;var rt=0x3008;var st=0x330C;var at=0x3310;var nt=0x3314;var ot=0x3318;var ct=0x331C;var ht=0x3320;var ut=0x3324;var dt=0x3328;var ft=0x332C;var lt=0x3330;var pt=0x33334;var bt=0x33338;var vt=0x3333C;var mt=new e.Int32Array(i);var kt=0x00;var gt=new e.Float64Array(i);var Rt=0x80;var yt=new e.Int32Array(i);var wt=0x80;var St=new e.Float32Array(i);var Tt=0x00;var Dt=new e.Int32Array(i);var xt=0x2000;var Et=new e.Int32Array(i);var It=0x100000;var At=new e.Int8Array(i);var Ct=new e.Int16Array(i);var jt=0x200;var Mt=0x200;var _t=1;var Ht=0;var qt=0,Lt=0;var Ut=0x200;var Pt=0x200;var Wt=0x200;var Bt=-1;var Ft=-1;var zt=-1;var Ot=-1;var Gt=-1;var Nt=-1;var Vt=-1;var Xt=-1;var Qt=-1;var Kt=-1;var Yt=-1;var Jt=-1;var Zt=-1;var $t=-1;var ei=-1;var ti=-1;var ii=-1;var ri=-1;var si=-1;var ai=-1;var ni=-1;var oi=-1;var ci=-1;var hi=-1;var ui=-1;var di=-1;var fi=0;function li(){pi()}function pi(){Ht=0;Dt[xt+be>>2]=0x96;Dt[xt+je>>2]=0x780;Dt[xt+Ve>>2]=0x4112D;Dt[xt+Xe>>2]=0x01;Dt[xt+Qe>>2]=0x00;Dt[xt+ve>>2]=0x100;Dt[xt+ke>>2]=0x00;Dt[xt+ye>>2]=0x00;Dt[xt+Se>>2]=0x00;Dt[xt+Te>>2]=0x00;Dt[xt+ae>>2]=0x3010;Dt[xt+ne>>2]=0x00;Dt[xt+oe>>2]=0x00;Dt[xt+Ze>>2]=0x0;Dt[xt+fe>>2]=0x40000;qt=0x00;Lt=0x00}function bi(){return 10}function vi(){return Ht|0}function mi(e){e=e|0;Ht=Ht+e|0}function ki(){}function gi(){}function Ri(e,t){e=e|0;t=t|0;fi=1}function yi(e,t){e=e|0;t=t|0}function wi(e,t){e=e|0;t=t|0;var i=0;var r=0x100;i=(Dt[xt+be>>2]&0x06)>>1;Mi();Dt[xt+ye>>2]=t;Dt[xt+Se>>2]=e;jt=r+(i<<6)|0;Ut=Pt;_t=1;ji()}function Si(e,t){e=e|0;t=t|0;if((t|0)!=(F|0))jt=Mt+(Pt-Wt)|0;Dt[xt+Te>>2]=e;switch(t|0){case 0:wi(Q,jt-4|0);break;case 1:wi(K,jt-4|0);break;case 2:wi(N,jt);break}}function Ti(e,t){e=e|0;t=t|0;var i=0;i=(Dt[xt+be>>2]&0x06)>>1;switch(e|0){case 2:if((t|0)==(W|0))return 1;if((i|0)==(q|0)&(t|0)==(F|0))return 1;return 0;break;case 3:if(!((i|0)==(L|0)&(t|0)==(F|0)))return 1;break;case 4:if((t|0)==(W|0))return 1;return 0;break;case 5:if((t|0)!=(F|0))return 1;break;case 6:if((t|0)!=(B|0))return 1;break;case 7:return 1;break;case 13:if((i|0)==(L|0)&(t|0)!=(F|0))return 1;break;case 14:if((i|0)==(L|0)&(t|0)!=(B|0))return 1;break;case 15:if((i|0)==(L|0))return 1;break}r(w|0);s();return 0}function Di(e,t){e=e|0;t=t|0;var i=0;var a=0;var n=1;var o=0;var c=0;var h=0;var u=0;var d=0;var f=0;var l=0;var p=0;var b=0;var v=0;var m=0;i=Dt[xt+be>>2]>>17&0x1F;a=(Dt[xt+be>>2]&0x06)>>1;if((i|0)==0|(a|0)==(P|0))return e|0;if((i|0)!=8){r(T|0);s()}o=e&0xFFF;c=e>>>22|0;m=(Dt[xt+fe>>2]|0)+(c<<2)|0;h=Et[It+m>>2]|0;u=h>>1&0xF;d=h&0x01;if((d|0)==0){Si(e,t);return-1}if((u|0)>=2){if(!(Ti(u,t)|0)){r(S|0);s()}return(h>>10|e>>12&0x3FF)<<12|o}o=e&0xFFF;f=(h&0xFFFFFC00)<<2;l=e>>12&0x3FF;m=(f|0)+(l<<2)|0;p=Et[It+m>>2]|0;b=p>>1&0xF;v=p&0x01;n=n-1|0;if((v|0)==0){Si(e,t);return-1}if(!(Ti(b,t)|0)){Si(e,t);return-1}return p>>10<<12|o|0}function xi(e,t){e=e|0;t=t|0;var i=0;var a=0;e=e<<2;switch(e|0){case 0xC:Dt[xt+e>>2]=t;break;case 0x1E40:Dt[xt+e>>2]=t;l(t|0);break;case 0x1E44:Dt[xt+e>>2]=t;p(t|0);break;case 0x1E00:Dt[xt+e>>2]=t;m(t|0);break;case 0xD14:a=0x90000000>>0;At[It+a>>0]=t|0;if((t|0)==0xA)At[It+a>>0]=0xD;break;case 0x1E04:Dt[xt+e>>2]=t;k(t|0);break;case 0xC00:Dt[xt+e>>2]=t;break;case 0x3C00:break;case 0x3C04:Dt[xt+e>>2]=t;break;case 0x3C40:Dt[xt+e>>2]=t;break;case 0xC04:Dt[xt+e>>2]=t;break;case 0xD10:i=0x2|0x08;Dt[xt+e>>2]=Dt[xt+e>>2]&~i|t&i;break;case 0xC10:i=0x2|0x08|0x20;Dt[xt+e>>2]=Dt[xt+e>>2]&~i|t&i;break;case 0x504:case 0xD04:Dt[xt+e>>2]=t;break;case 0xD08:Dt[xt+e>>2]=t;break;case 0x3508:Dt[xt+e>>2]=t;break;case 0xD0C:Dt[xt+e>>2]=t;break;case 0x350C:Dt[xt+e>>2]=t;break;case 0x400:Dt[xt+ae>>2]=t;Dt[xt+be>>2]=Dt[xt+be>>2]&~0x1F039;Dt[xt+be>>2]=Dt[xt+be>>2]|Dt[xt+ae>>2]&0x01;Dt[xt+be>>2]=Dt[xt+be>>2]|Dt[xt+ae>>2]&0x08;Dt[xt+be>>2]=Dt[xt+be>>2]|Dt[xt+ae>>2]&0x10;Dt[xt+be>>2]=Dt[xt+be>>2]|Dt[xt+ae>>2]&0xF000;Dt[xt+be>>2]=Dt[xt+be>>2]|Dt[xt+ae>>2]&0x10000;break;case 0x404:Dt[xt+e>>2]=t;break;case 0x510:i=0x2;Dt[xt+De>>2]=Dt[xt+De>>2]&~i|t&i;break;case 0x410:i=0x2|0x20;Dt[xt+ke>>2]=Dt[xt+ke>>2]&~i|t&i;break;case 0xD00:Dt[xt+e>>2]=t;break;case 0x500:Dt[xt+e>>2]=t;break;case 0x2400:Dt[xt+e>>2]=t;break;case 0x3000:Ht=t;Dt[xt+e>>2]=t;break;case 0x1C04:case 0x3404:case 0x2804:Dt[xt+e>>2]=t;break;case 0x1D04:case 0x3604:case 0x2A04:Dt[xt+e>>2]=t;break;case 0x3004:case 0x2404:Dt[xt+e>>2]=t;break;case 0xC84:case 0x484:Dt[xt+De>>2]=Dt[xt+De>>2]&~32;Dt[xt+e>>2]=t;break;case 0xD84:case 0x600:Dt[xt+e>>2]=t;break;case 0x04:case 0x08:Dt[xt+e>>2]=t;break;default:Dt[xt+e>>2]=t;r(D|0);s();break}}function Ei(e){e=e|0;var t=0;t=(Dt[xt+be>>2]&0x06)>>1;e=e<<2|0;switch(e|0){case 0xC:return 0x0;break;case 0x1E40:return d()|0;break;case 0x1E44:return f()|0;break;case 0x1E00:return b()|0;break;case 0xD14:return 0x0;break;case 0x1E04:return v()|0;break;case 0xC00:return Dt[xt+e>>2]|0;break;case 0x3C00:return Dt[xt+e>>2]|0;break;case 0x3C04:return Dt[xt+e>>2]|0;break;case 0x3C40:return Dt[xt+e>>2]|0;break;case 0xC04:return Dt[xt+e>>2]|0;break;case 0xC10:return Dt[xt+e>>2]|0;break;case 0x504:case 0xD04:return Dt[xt+e>>2]|0;break;case 0xD08:return Dt[xt+e>>2]|0;break;case 0x3508:return Dt[xt+e>>2]|0;break;case 0xD0C:return Dt[xt+e>>2]|0;break;case 0x350C:return Dt[xt+e>>2]|0;break;case 0x400:Dt[xt+ae>>2]=0x00;Dt[xt+ae>>2]=Dt[xt+ae>>2]|Dt[xt+be>>2]&0x01;Dt[xt+ae>>2]=Dt[xt+ae>>2]|Dt[xt+be>>2]&0x08;Dt[xt+ae>>2]=Dt[xt+ae>>2]|Dt[xt+be>>2]&0x10;Dt[xt+ae>>2]=Dt[xt+ae>>2]|Dt[xt+be>>2]&0xF000;Dt[xt+ae>>2]=Dt[xt+ae>>2]|Dt[xt+be>>2]&0x10000;return Dt[xt+ae>>2]|0;break;case 0x404:return Dt[xt+e>>2]|0;break;case 0xD10:return Dt[xt+e>>2]|0;break;case 0x510:return Dt[xt+De>>2]&(0x2|0x20)|0;break;case 0x410:return Dt[xt+ke>>2]&(0x2|0x20)|0;break;case 0xD00:return Dt[xt+e>>2]|0;break;case 0x500:return Dt[xt+e>>2]|0;break;case 0x2400:return Ht|0;break;case 0x3000:return Ht|0;break;case 0x1C04:case 0x3404:case 0x2804:return Ht|0;break;case 0x1D04:case 0x3604:case 0x2A04:return Ht>>32|0;break;case 0x3004:case 0x2404:return Ht|0;break;case 0xC84:case 0x484:return Dt[xt+e>>2]|0;break;case 0xD84:case 0x600:return Dt[xt+e>>2]|0;break;case 0x04:case 0x08:return Dt[xt+e>>2]|0;break;default:r(x|0);s();return Dt[xt+e>>2]|0;break}return 0}function Ii(e,t,i){e=e|0;t=t|0;i=i|0;var r=0,s=0;var a=0,n=0;var o=0,c=0;var h=0;var u=0;var d=0;var f=0;if(e>>>0<32767&t>>>0<65536){r=R(e|0,t|0)|0;s=(r|0)<0?-1:0;if((i|0)==0)return r|0;else return s|0}a=e&0xFFFF;n=e>>>16;o=t&0xFFFF;c=t>>>16;h=R(a|0,o|0)|0;u=(h>>>16)+(R(n|0,o|0)|0)|0;d=u>>>16;u=(u&0xFFFF)+(R(a|0,c|0)|0)|0;d=d+(u>>>16)|0;f=d>>>16;d=(d&0xFFFF)+(R(n|0,c|0)|0)|0;f=f+(d>>>16)|0;r=(u&0xFFFF)<<16|h&0xFFFF;s=(f&0xFFFF)<<16|d&0xFFFF;if((i|0)==0)return r|0;return s|0}function Ai(e,t,i){e=e|0;t=t|0;i=i|0;var r=0,s=0;var a=0;if((e|0)==0)return 0;if((t|0)==0)return 0;if((e|0)>=-32768&(e|0)<=32767&((t|0)>=-32768&(t|0)<=32767)){r=R(e|0,t|0)|0;s=(r|0)<0?-1:0;if((i|0)==0)return r|0;else return s|0}a=(e|0)<0^(t|0)<0;e=y(e|0)|0;t=y(t|0)|0;r=Ii(e,t,0)|0;s=Ii(e,t,1)|0;if(a){r=~r;s=~s;r=r+1|0;if((r|0)==0)s=s+1|0}if((i|0)==0)return r|0;return s|0}function Ci(e,t,i){e=e|0;t=t|0;i=i|0;var r=0,s=0;var a=0;if((e|0)==0)return 0;if((t|0)==0)return 0;if((e|0)>=-32768&(e|0)<=32767&((t|0)>=-32768&t>>>0<=32767)){r=R(e|0,t|0)|0;s=(r|0)<0?-1:0;if((i|0)==0)return r|0;else return s|0}a=(e|0)<0^(t|0)<0;e=y(e|0)|0;t=y(t|0)|0;r=Ii(e,t,0)|0;s=Ii(e,t,1)|0;if(a){r=~r;s=~s;r=r+1|0;if((r|0)==0)s=s+1|0}if((i|0)==0)return r|0;return s|0}function ji(){zt=-1;Ot=-1;Gt=-1;Nt=-1;Vt=-1;Xt=-1;Qt=-1;Kt=-1;Yt=-1;Jt=-1;Zt=-1;$t=-1;ei=-1;ti=-1;ii=-1;ri=-1;si=-1;ai=-1;ni=-1;oi=-1;ci=-1;hi=-1;ui=-1;di=-1}function Mi(){var e=0,t=0,i=0;e=Dt[xt+be>>2]|0;t=e&0xFFF;i=(t<<2|P)<<1&0xFFF;Dt[xt+be>>2]=(e>>12<<12)+i&0xFFFEFFFF}function _i(){var e=0,t=0,i=0;e=Dt[xt+be>>2]|0;t=e&0xFFF;i=t>>>3|(q<<1|0x1)<<9;Dt[xt+be>>2]=(e>>12<<12)+i}function Hi(e,t){e=e|0;t=t|0;var i=0x00;var a=0x00;var n=0x00;var o=0x00;var c=0x00;var h=0x00;var u=0x0;var d=0x0;var f=0.0;var l=0.0;var p=0.0;var b=0;var v=0;var m=0;var k=0;var g=0;var w=0;var S=64;for(;;){if((Ut|0)!=(Pt|0)){w=Et[Pt>>2]|0;Pt=Pt+4|0;switch(w&0x7F){case 0x03:switch(w>>12&0x7){case 0x00:i=w>>20;u=mt[(w>>15&0x1F)<<2>>2]|0;if(!((zt^(u+i|0))&0xFFFFF000))v=Ot^(u+i|0);else{v=Di(u+i|0,W)|0;if((v|0)==-1)continue;zt=v;Ot=(v^(u+i|0))&0xFFFFF000}mt[(w>>5&0x7C)>>2]=At[It+v>>0]<<24>>24;Et[Pt-4>>2]=w>>7<<7|0x74;continue;case 0x01:i=w>>20;u=mt[(w>>15&0x1F)<<2>>2]|0;if(!((Vt^(u+i|0))&0xFFFFF000))v=Xt^(u+i|0);else{v=Di(u+i|0,W)|0;if((v|0)==-1)continue;Vt=v;Xt=(v^(u+i|0))&0xFFFFF000}mt[(w>>5&0x7C)>>2]=Ct[It+v>>1]<<16>>16;Et[Pt-4>>2]=w>>7<<7|0x75;continue;case 0x02:i=w>>20;u=mt[(w>>15&0x1F)<<2>>2]|0;if(u+i&3){r(E|0);s()}if(!((Yt^(u+i|0))&0xFFFFF000))v=Jt^(u+i|0);else{v=Di(u+i|0,W)|0;if((v|0)==-1)continue;Yt=v;Jt=(v^(u+i|0))&0xFFFFF000}mt[(w>>5&0x7C)>>2]=Et[It+v>>2]|0;Et[Pt-4>>2]=w>>7<<7|0x76;continue;case 0x04:i=w>>20;u=mt[(w>>15&0x1F)<<2>>2]|0;if(!((Gt^(u+i|0))&0xFFFFF000))v=Nt^(u+i|0);else{v=Di(u+i|0,W)|0;if((v|0)==-1)continue;Gt=v;Nt=(v^(u+i|0))&0xFFFFF000}mt[(w>>5&0x7C)>>2]=At[It+v>>0]&0xFF;Et[Pt-4>>2]=w>>7<<7|0x77;continue;case 0x05:i=w>>20;u=mt[(w>>15&0x1F)<<2>>2]|0;if(!((Qt^(u+i|0))&0xFFFFF000))v=Kt^(u+i|0);else{v=Di(u+i|0,W)|0;if((v|0)==-1)continue;Qt=v;Kt=(v^(u+i|0))&0xFFFFF000}mt[(w>>5&0x7C)>>2]=Ct[It+v>>1]&0xFFFF;Et[Pt-4>>2]=w>>7<<7|0x78;continue;default:r(A|0);s();break}continue;case 0x23:i=w>>25<<5|w>>7&0x1F;switch(w>>12&0x7){case 0x00:u=mt[(w>>15&0x1F)<<2>>2]|0;if(!((Zt^(u+i|0))&0xFFFFF000))v=$t^(u+i|0);else{v=Di(u+i|0,B)|0;if((v|0)==-1)continue;Zt=v;$t=(v^(u+i|0))&0xFFFFF000}At[It+v>>0]=mt[(w>>18&0x7C)>>2]&0xFF;Et[Pt-4>>2]=w>>7<<7|0x79;continue;case 0x01:u=mt[(w>>15&0x1F)<<2>>2]|0;if(!((ei^(u+i|0))&0xFFFFF000))v=ti^(u+i|0);else{v=Di(u+i|0,B)|0;if((v|0)==-1)continue;ei=v;ti=(v^(u+i|0))&0xFFFFF000}Ct[It+v>>1]=mt[(w>>18&0x7C)>>2]&0xFFFF;Et[Pt-4>>2]=w>>7<<7|0x7A;continue;case 0x02:u=mt[(w>>15&0x1F)<<2>>2]|0;if(u+i&3){r(I|0);s()}if(!((ii^(u+i|0))&0xFFFFF000))v=ri^(u+i|0);else{v=Di(u+i|0,B)|0;if((v|0)==-1)continue;ii=v;ri=(v^(u+i|0))&0xFFFFF000}Et[It+v>>2]=mt[(w>>18&0x7C)>>2]|0;Et[Pt-4>>2]=w>>7<<7|0x7B;continue;default:r(A|0);s();break}continue;case 0x13:switch(w>>12&0x7){case 0x00:u=mt[(w>>15&0x1F)<<2>>2]|0;mt[(w>>5&0x7C)>>2]=u+(w>>20)|0;continue;case 0x02:u=mt[(w>>15&0x1F)<<2>>2]|0;if((u|0)<w>>20)mt[(w>>5&0x7C)>>2]=0x01;else mt[(w>>5&0x7C)>>2]=0x00;continue;case 0x03:u=mt[(w>>15&0x1F)<<2>>2]|0;if(u>>>0<w>>20>>>0)mt[(w>>5&0x7C)>>2]=0x01;else mt[(w>>5&0x7C)>>2]=0x00;continue;case 0x04:i=w>>20;u=mt[(w>>15&0x1F)<<2>>2]|0;mt[(w>>5&0x7C)>>2]=u^w>>20;continue;case 0x06:u=mt[(w>>15&0x1F)<<2>>2]|0;mt[(w>>5&0x7C)>>2]=u|w>>20;continue;case 0x07:u=mt[(w>>15&0x1F)<<2>>2]|0;mt[(w>>5&0x7C)>>2]=u&w>>20;continue;case 0x01:u=mt[(w>>15&0x1F)<<2>>2]|0;mt[(w>>5&0x7C)>>2]=u<<(w>>20&0x1F);continue;case 0x05:if((w>>25&0x7F)==0x00){u=mt[(w>>15&0x1F)<<2>>2]|0;mt[(w>>5&0x7C)>>2]=u>>>(w>>20&0x1F)}else if((w>>25&0x7F)==0x20){u=mt[(w>>15&0x1F)<<2>>2]|0;mt[(w>>5&0x7C)>>2]=u>>(w>>20&0x1F)}continue;default:r(A|0);s();break}continue;case 0x33:switch(w>>25&0x7F){case 0x00:u=mt[(w>>15&0x1F)<<2>>2]|0;d=mt[(w>>18&0x7C)>>2]|0;switch(w>>12&0x7){case 0x00:mt[(w>>5&0x7C)>>2]=u+d;continue;case 0x02:if((u|0)<(d|0))mt[(w>>5&0x7C)>>2]=0x01;else mt[(w>>5&0x7C)>>2]=0x00;continue;case 0x03:if(u>>>0<d>>>0)mt[(w>>5&0x7C)>>2]=0x01;else mt[(w>>5&0x7C)>>2]=0x00;continue;case 0x07:mt[(w>>5&0x7C)>>2]=u&d;continue;case 0x06:mt[(w>>5&0x7C)>>2]=u|d;continue;case 0x04:mt[(w>>5&0x7C)>>2]=u^d;continue;case 0x01:mt[(w>>5&0x7C)>>2]=u<<(d&0x1F);continue;case 0x05:mt[(w>>5&0x7C)>>2]=u>>>(d&0x1F);continue}continue;case 0x20:u=mt[(w>>15&0x1F)<<2>>2]|0;d=mt[(w>>18&0x7C)>>2]|0;switch(w>>12&0x7){case 0x00:mt[(w>>5&0x7C)>>2]=u-d;continue;case 0x05:mt[(w>>5&0x7C)>>2]=u>>(d&0x1F);continue}continue;case 0x01:u=mt[(w>>15&0x1F)<<2>>2]|0;d=mt[(w>>18&0x7C)>>2]|0;switch(w>>12&0x7){case 0x00:n=R(u|0,d|0)|0;mt[(w>>5&0x7C)>>2]=n&0xFFFFFFFF;continue;case 0x01:h=Ai(u,d,1)|0;mt[(w>>5&0x7C)>>2]=h;continue;case 0x02:h=Ci(u,d>>>0,1)|0;mt[(w>>5&0x7C)>>2]=h;continue;case 0x03:h=Ii(u>>>0,d>>>0,1)|0;mt[(w>>5&0x7C)>>2]=h;continue;case 0x04:if((d|0)==0)o=-1;else o=(u|0)/(d|0)|0;mt[(w>>5&0x7C)>>2]=o;continue;case 0x05:if((d|0)==0)o=0xFFFFFFFF;else o=(u>>>0)/(d>>>0)|0;mt[(w>>5&0x7C)>>2]=o;continue;case 0x06:if((d|0)==0)c=u;else c=(u|0)%(d|0)|0;mt[(w>>5&0x7C)>>2]=c;continue;case 0x07:if((d|0)==0)c=u>>>0;else c=(u>>>0)%(d>>>0)|0;mt[(w>>5&0x7C)>>2]=c;continue}continue;default:r(A|0);s();break}continue;case 0x37:mt[(w>>5&0x7C)>>2]=w&0xFFFFF000;continue;case 0x17:jt=Mt+(Pt-Wt)|0;i=w&0xFFFFF000;mt[(w>>5&0x7C)>>2]=i+jt-4|0;Ut=Pt;_t=1;continue;case 0x6F:jt=Mt+(Pt-Wt)|0;i=(w>>21&0x3FF|(w>>20&0x1)<<10|(w>>12&0xFF)<<11|w>>31<<19)<<1;mt[(w>>5&0x7C)>>2]=jt;jt=jt+i-4|0;Ut=Pt;_t=1;mt[0]=0;continue;case 0x67:jt=Mt+(Pt-Wt)|0;i=w>>20;u=mt[(w>>15&0x1F)<<2>>2]|0;mt[(w>>5&0x7C)>>2]=jt;jt=u+i&0xFFFFFFFE|0;Ut=Pt;_t=1;mt[0]=0;continue;case 0x63:jt=Mt+(Pt-Wt)|0;Ut=Pt;_t=1;u=mt[(w>>15&0x1F)<<2>>2]|0;d=mt[(w>>18&0x7C)>>2]|0;switch(w>>12&0x7){case 0x00:if((u|0)==(d|0)){i=(w>>31<<11|(w>>25&0x3F)<<4|w>>8&0x0F|(w>>7&0x01)<<10)<<1;jt=jt+i-4|0}Et[Pt-4>>2]=w>>7<<7|0x68;continue;case 0x01:if((u|0)!=(d|0)){i=(w>>31<<11|(w>>25&0x3F)<<4|w>>8&0x0F|(w>>7&0x01)<<10)<<1;jt=jt+i-4|0}Et[Pt-4>>2]=w>>7<<7|0x69;continue;case 0x04:if((u|0)<(d|0)){i=(w>>31<<11|(w>>25&0x3F)<<4|w>>8&0x0F|(w>>7&0x01)<<10)<<1;jt=jt+i-4|0}Et[Pt-4>>2]=w>>7<<7|0x6A;continue;case 0x05:if((u|0)>=(d|0)){i=(w>>31<<11|(w>>25&0x3F)<<4|w>>8&0x0F|(w>>7&0x01)<<10)<<1;jt=jt+i-4|0}Et[Pt-4>>2]=w>>7<<7|0x6B;continue;case 0x06:if(u>>>0<d>>>0){i=(w>>31<<11|(w>>25&0x3F)<<4|w>>8&0x0F|(w>>7&0x01)<<10)<<1;jt=jt+i-4|0}Et[Pt-4>>2]=w>>7<<7|0x6C;continue;case 0x07:if(u>>>0>=d>>>0){i=(w>>31<<11|(w>>25&0x3F)<<4|w>>8&0x0F|(w>>7&0x01)<<10)<<1;jt=jt+i-4|0}Et[Pt-4>>2]=w>>7<<7|0x6D;continue;default:r(A|0);s();break}continue;case 0x73:i=w>>>20;u=mt[(w>>15&0x1F)<<2>>2]|0;switch(w>>12&0x7){case 0x01:mt[(w>>5&0x7C)>>2]=Ei(i)|0;xi(i,u);mt[0]=0;continue;case 0x02:mt[(w>>5&0x7C)>>2]=Ei(i)|0;xi(i,Ei(i)|0|u);mt[0]=0;continue;case 0x03:mt[(w>>5&0x7C)>>2]=Ei(i)|0;xi(i,(Ei(i)|0)&~u);mt[0]=0;continue;case 0x05:mt[(w>>5&0x7C)>>2]=Ei(i)|0;a=w>>15&0x1F;if((a|0)!=0)xi(i,a>>0);mt[0]=0;continue;case 0x06:mt[(w>>5&0x7C)>>2]=Ei(i)|0;a=w>>15&0x1F;if((a|0)!=0)xi(i,Ei(i)|0|a>>0);mt[0]=0;continue;case 0x07:mt[(w>>5&0x7C)>>2]=Ei(i)|0;a=w>>15&0x1F;if((a|0)!=0)xi(i,(Ei(i)|0)&~(a>>0));mt[0]=0;continue;case 0x00:m=(Dt[xt+be>>2]&0x06)>>1;Ut=Pt;switch(w>>20&0xFFF){case 0x00:jt=Mt+(Pt-Wt)|0;switch(m|0){case 0x00:wi(Y,jt-4|0);break;case 0x01:wi(J,jt-4|0);break;case 0x02:wi(Z,jt-4|0);s();break;case 0x03:wi($,jt-4|0);break;default:r(C|0);s();break}continue;case 0x001:jt=Mt+(Pt-Wt)|0;wi(X,jt-4|0);continue;case 0x100:m=(Dt[xt+be>>2]&0x06)>>1;jt=Mt+(Pt-Wt)|0;if((m|0)<(L|0)){r(M|0);s();break}_i();switch(m|0){case 0x01:jt=Dt[xt+ue>>2]|0;break;case 0x02:jt=Dt[xt+pe>>2]|0;s();break;case 0x03:jt=Dt[xt+ye>>2]|0;break;default:r(j|0);s();break}_t=1;ji();continue;case 0x102:continue;case 0x305:jt=Mt+(Pt-Wt)|0;if((m|0)!=(P|0)){r(_|0);s();break}Dt[xt+be>>2]=Dt[xt+be>>2]&~0x6|0x02;Dt[xt+Ne>>2]=Dt[xt+Te>>2];Dt[xt+Ge>>2]=Dt[xt+Se>>2];Dt[xt+ue>>2]=Dt[xt+ye>>2];jt=Dt[xt+ne>>2]|0;_t=1;continue;case 0x101:ji();continue;default:r(A|0);s();break}continue;default:r(A|0);s();break}continue;case 0x07:switch(w>>12&0x7){case 0x02:i=w>>20;u=mt[(w>>15&0x1F)<<2>>2]|0;if(!((si^(u+i|0))&0xFFFFF000))v=ai^(u+i|0);else{v=Di(u+i|0,W)|0;if((v|0)==-1)break;si=v;ai=(v^(u+i|0))&0xFFFFF000}mt[0]=Et[It+v>>2]|0;gt[Rt+((w>>7&0x1F)<<3)>>3]=+St[0];mt[0]=0;continue;case 0x03:i=w>>20;u=mt[(w>>15&0x1F)<<2>>2]|0;if(!((ni^(u+i|0))&0xFFFFF000))v=oi^(u+i|0);else{v=Di(u+i|0,W)|0;if((v|0)==-1)continue;ni=v;oi=(v^(u+i|0))&0xFFFFF000}yt[wt+((w>>7&0x1F)+0<<2)>>2]=Et[It+v+0>>2]|0;yt[wt+((w>>7&0x1F)+1<<2)>>2]=Et[It+v+4>>2]|0;continue;default:r(A|0);r(w|0);s();break}continue;case 0x27:switch(w>>12&0x7){case 0x02:i=(w>>25<<5)+(w>>7&0x1F)|0;u=mt[(w>>15&0x1F)<<2>>2]|0;St[0]=gt[Rt+((w>>20&0x1F)<<3)>>3];if(!((ci^(u+i|0))&0xFFFFF000))v=hi^(u+i|0);else{v=Di(u+i|0,W)|0;if((v|0)==-1)continue;ci=v;hi=(v^(u+i|0))&0xFFFFF000}Et[It+v>>2]=mt[0]|0;mt[0]=0;continue;case 0x03:i=(w>>25<<5)+(w>>7&0x1F)|0;u=mt[(w>>15&0x1F)<<2>>2]|0;if(!((ui^(u+i|0))&0xFFFFF000))v=di^(u+i|0);else{v=Di(u+i|0,W)|0;if((v|0)==-1)continue;ui=v;di=(v^(u+i|0))&0xFFFFF000}Et[It+v+0>>2]=yt[wt+((w>>20&0x1F)+0<<2)>>2]|0;Et[It+v+4>>2]=yt[wt+((w>>20&0x1F)+1<<2)>>2]|0;continue;default:r(A|0);r(w|0);s();break}continue;case 0x53:switch(w>>25&0x7F){case 0x00:case 0x01:f=+gt[Rt+((w>>15&0x1F)<<3)>>3];l=+gt[Rt+((w>>20&0x1F)<<3)>>3];gt[Rt+((w>>7&0x1F)<<3)>>3]=f+l;continue;case 0x04:case 0x05:f=+gt[Rt+((w>>15&0x1F)<<3)>>3];l=+gt[Rt+((w>>20&0x1F)<<3)>>3];gt[Rt+((w>>7&0x1F)<<3)>>3]=f-l;continue;case 0x50:case 0x51:f=+gt[Rt+((w>>15&0x1F)<<3)>>3];l=+gt[Rt+((w>>20&0x1F)<<3)>>3];switch(w>>12&0x7){case 0x0:if(+f<=+l)mt[(w>>5&0x7C)>>2]=1;else mt[(w>>5&0x7C)>>2]=0;continue;case 0x1:if(+f<+l)mt[(w>>5&0x7C)>>2]=1;else mt[(w>>5&0x7C)>>2]=0;continue;case 0x2:if(+f==+l)mt[(w>>5&0x7C)>>2]=1;else mt[(w>>5&0x7C)>>2]=0;continue;default:r(A|0);r(w|0);s();break}continue;case 0x60:mt[(w>>5&0x7C)>>2]=~~+gt[Rt+((w>>15&0x1F)<<3)>>3];continue;case 0x68:case 0x69:gt[Rt+((w>>7&0x1F)<<3)>>3]=+~~mt[(w>>15&0x1F)<<2>>2];continue;case 0x08:case 0x09:f=+gt[Rt+((w>>15&0x1F)<<3)>>3];l=+gt[Rt+((w>>20&0x1F)<<3)>>3];gt[Rt+((w>>7&0x1F)<<3)>>3]=+R(f,l);continue;case 0x10:case 0x11:f=+gt[Rt+((w>>15&0x1F)<<3)>>3];l=+gt[Rt+((w>>20&0x1F)<<3)>>3];switch(w>>12&7){case 0:gt[Rt+((w>>7&0x1F)<<3)>>3]=+l<+0?-+y(+f):+y(+f);continue;case 1:gt[Rt+((w>>7&0x1F)<<3)>>3]=+l<+0?+y(+f):-+y(+f);continue;case 3:gt[Rt+((w>>7&0x1F)<<3)>>3]=+l<+0&+f<+0|+l>+0&+f>+0?-+y(+f):+y(+f);continue;default:r(A|0);r(w|0);s()}continue;case 0x61:mt[(w>>5&0x7C)>>2]=~~+gt[Rt+((w>>15&0x1F)<<3)>>3];continue;case 0x78:u=mt[(w>>15&0x1F)<<2>>2]|0;mt[0]=u;gt[Rt+((w>>7&0x1F)<<3)>>3]=+St[0];mt[0]=0;continue;default:r(A|0);r(w|0);s();break}continue;case 0x43:f=+gt[Rt+((w>>15&0x1F)<<3)>>3];l=+gt[Rt+((w>>20&0x1F)<<3)>>3];p=+gt[Rt+((w>>27&0x1F)<<3)>>3];gt[Rt+((w>>7&0x1F)<<3)>>3]=f*l+p;continue;case 0x47:f=+gt[Rt+((w>>15&0x1F)<<3)>>3];l=+gt[Rt+((w>>20&0x1F)<<3)>>3];p=+gt[Rt+((w>>27&0x1F)<<3)>>3];gt[Rt+((w>>7&0x1F)<<3)>>3]=f*l-p;continue;case 0x4B:f=+gt[Rt+((w>>15&0x1F)<<3)>>3];l=+gt[Rt+((w>>20&0x1F)<<3)>>3];p=+gt[Rt+((w>>27&0x1F)<<3)>>3];gt[Rt+((w>>7&0x1F)<<3)>>3]=-(f*l+p);continue;case 0x4F:f=+gt[Rt+((w>>15&0x1F)<<3)>>3];l=+gt[Rt+((w>>20&0x1F)<<3)>>3];p=+gt[Rt+((w>>27&0x1F)<<3)>>3];gt[Rt+((w>>7&0x1F)<<3)>>3]=-(f*l-p);continue;case 0x2F:u=mt[(w>>15&0x1F)<<2>>2]|0;d=mt[(w>>18&0x7C)>>2]|0;switch(w>>27&0x1F){case 0x01:v=Di(u|0,W)|0;if((v|0)==-1)break;mt[(w>>5&0x7C)>>2]=Et[It+v>>2]|0;v=Di(u|0,B)|0;if((v|0)==-1)break;Et[It+v>>2]=d|0;mt[0]=0;continue;case 0x00:v=Di(u|0,W)|0;if((v|0)==-1)break;mt[(w>>5&0x7C)>>2]=Et[It+v>>2]|0;v=Di(u|0,B)|0;if((v|0)==-1)break;Et[It+v>>2]=(mt[(w>>5&0x7C)>>2]|0)+(d|0)|0;mt[0]=0;continue;case 0x04:v=Di(u|0,W)|0;if((v|0)==-1)break;mt[(w>>5&0x7C)>>2]=Et[It+v>>2]|0;v=Di(u|0,B)|0;if((v|0)==-1)break;Et[It+v>>2]=(mt[(w>>5&0x7C)>>2]|0)^(d|0)|0;mt[0]=0;continue;case 0x0C:v=Di(u|0,W)|0;if((v|0)==-1)break;mt[(w>>5&0x7C)>>2]=Et[It+v>>2]|0;v=Di(u|0,B)|0;if((v|0)==-1)break;Et[It+v>>2]=(mt[(w>>5&0x7C)>>2]|0)&(d|0)|0;mt[0]=0;continue;
case 0x08:v=Di(u|0,W)|0;if((v|0)==-1)break;mt[(w>>5&0x7C)>>2]=Et[It+v>>2]|0;v=Di(u|0,B)|0;if((v|0)==-1)break;Et[It+v>>2]=mt[(w>>5&0x7C)>>2]|0|(d|0)|0;mt[0]=0;continue;case 0x10:v=Di(u|0,W)|0;if((v|0)==-1)break;mt[(w>>5&0x7C)>>2]=Et[It+v>>2]|0;if(d>>0>mt[(w>>5&0x7C)>>2]>>0)mt[0]=mt[(w>>5&0x7C)>>2];else mt[0]=d;v=Di(u|0,B)|0;if((v|0)==-1)break;Et[It+v>>2]=mt[0]|0;mt[0]=0;continue;case 0x14:v=Di(u|0,W)|0;if((v|0)==-1)break;mt[(w>>5&0x7C)>>2]=Et[It+v>>2]|0;if(d>>0<mt[(w>>5&0x7C)>>2]>>0)mt[0]=mt[(w>>5&0x7C)>>2];else mt[0]=d;v=Di(u|0,B)|0;if((v|0)==-1)break;Et[It+v>>2]=mt[0]|0;mt[0]=0;continue;case 0x18:v=Di(u|0,W)|0;if((v|0)==-1)break;mt[(w>>5&0x7C)>>2]=Et[It+v>>2]|0;if(d>>>0>mt[(w>>5&0x7C)>>2]>>>0)mt[0]=mt[(w>>5&0x7C)>>2];else mt[0]=d;v=Di(u|0,B)|0;if((v|0)==-1)break;Et[It+v>>2]=mt[0]|0;mt[0]=0;continue;case 0x1C:v=Di(u|0,W)|0;if((v|0)==-1)break;mt[(w>>5&0x7C)>>2]=Et[It+v>>2]|0;if(d>>>0<mt[(w>>5&0x7C)>>2]>>>0)mt[0]=mt[(w>>5&0x7C)>>2];else mt[0]=d;v=Di(u|0,B)|0;if((v|0)==-1)break;Et[It+v>>2]=mt[0]|0;mt[0]=0;continue;case 0x02:u=mt[(w>>15&0x1F)<<2>>2]|0;v=Di(u|0,W)|0;if((v|0)==-1)break;mt[(w>>5&0x7C)>>2]=Et[It+v>>2]|0;qt=u;Lt=mt[(w>>5&0x7C)>>2]|0;mt[0]=0;continue;case 0x03:u=mt[(w>>15&0x1F)<<2>>2]|0;d=mt[(w>>18&0x7C)>>2]|0;if((u|0)!=(qt|0)){mt[(w>>5&0x7C)>>2]=0x01;continue}v=Di(u,W)|0;if((v|0)==-1)break;if((Et[It+v>>2]|0)!=(Lt|0)){mt[(w>>5&0x7C)>>2]=0x01;continue}mt[(w>>5&0x7C)>>2]=0x00;v=Di(u,B)|0;if((v|0)==-1)break;Et[It+v>>2]=d|0;mt[0]=0;continue;default:r(H|0);s();break}continue;case 0x0F:continue;case 0x74:i=w>>20;u=mt[(w>>15&0x1F)<<2>>2]|0;if(!((zt^(u+i|0))&0xFFFFF000))v=Ot^(u+i|0);else{v=Di(u+i|0,W)|0;if((v|0)==-1)continue;zt=v;Ot=(v^(u+i|0))&0xFFFFF000}mt[(w>>5&0x7C)>>2]=At[It+v>>0]<<24>>24;continue;case 0x75:i=w>>20;u=mt[(w>>15&0x1F)<<2>>2]|0;if(!((Vt^(u+i|0))&0xFFFFF000))v=Xt^(u+i|0);else{v=Di(u+i|0,W)|0;if((v|0)==-1)continue;Vt=v;Xt=(v^(u+i|0))&0xFFFFF000}mt[(w>>5&0x7C)>>2]=Ct[It+v>>1]<<16>>16;continue;case 0x76:i=w>>20;u=mt[(w>>15&0x1F)<<2>>2]|0;if(u+i&3){r(E|0);s()}if(!((Yt^(u+i|0))&0xFFFFF000))v=Jt^(u+i|0);else{v=Di(u+i|0,W)|0;if((v|0)==-1)continue;Yt=v;Jt=(v^(u+i|0))&0xFFFFF000}mt[(w>>5&0x7C)>>2]=Et[It+v>>2]|0;continue;case 0x77:i=w>>20;u=mt[(w>>15&0x1F)<<2>>2]|0;if(!((Gt^(u+i|0))&0xFFFFF000))v=Nt^(u+i|0);else{v=Di(u+i|0,W)|0;if((v|0)==-1)continue;Gt=v;Nt=(v^(u+i|0))&0xFFFFF000}mt[(w>>5&0x7C)>>2]=At[It+v>>0]&0xFF;continue;case 0x78:i=w>>20;u=mt[(w>>15&0x1F)<<2>>2]|0;if(!((Qt^(u+i|0))&0xFFFFF000))v=Kt^(u+i|0);else{v=Di(u+i|0,W)|0;if((v|0)==-1)continue;Qt=v;Kt=(v^(u+i|0))&0xFFFFF000}mt[(w>>5&0x7C)>>2]=Ct[It+v>>1]&0xFFFF;continue;case 0x79:i=w>>25<<5|w>>7&0x1F;u=mt[(w>>15&0x1F)<<2>>2]|0;if(!((Zt^(u+i|0))&0xFFFFF000))v=$t^(u+i|0);else{v=Di(u+i|0,B)|0;if((v|0)==-1)continue;Zt=v;$t=(v^(u+i|0))&0xFFFFF000}At[It+v>>0]=mt[(w>>18&0x7C)>>2]&0xFF;continue;case 0x7A:i=w>>25<<5|w>>7&0x1F;u=mt[(w>>15&0x1F)<<2>>2]|0;if(!((ei^(u+i|0))&0xFFFFF000))v=ti^(u+i|0);else{v=Di(u+i|0,B)|0;if((v|0)==-1)continue;ei=v;ti=(v^(u+i|0))&0xFFFFF000}Ct[It+v>>1]=mt[(w>>18&0x7C)>>2]&0xFFFF;continue;case 0x7B:i=w>>25<<5|w>>7&0x1F;u=mt[(w>>15&0x1F)<<2>>2]|0;if(u+i&3){r(I|0);s()}if(!((ii^(u+i|0))&0xFFFFF000))v=ri^(u+i|0);else{v=Di(u+i|0,B)|0;if((v|0)==-1)continue;ii=v;ri=(v^(u+i|0))&0xFFFFF000}Et[It+v>>2]=mt[(w>>18&0x7C)>>2]|0;continue;case 0x68:jt=Mt+(Pt-Wt)|0;Ut=Pt;_t=1;u=mt[(w>>15&0x1F)<<2>>2]|0;d=mt[(w>>18&0x7C)>>2]|0;if((u|0)==(d|0)){i=(w>>31<<11|(w>>25&0x3F)<<4|w>>8&0x0F|(w>>7&0x01)<<10)<<1;jt=jt+i-4|0}continue;case 0x69:jt=Mt+(Pt-Wt)|0;Ut=Pt;_t=1;u=mt[(w>>15&0x1F)<<2>>2]|0;d=mt[(w>>18&0x7C)>>2]|0;if((u|0)!=(d|0)){i=(w>>31<<11|(w>>25&0x3F)<<4|w>>8&0x0F|(w>>7&0x01)<<10)<<1;jt=jt+i-4|0}continue;case 0x6A:jt=Mt+(Pt-Wt)|0;Ut=Pt;_t=1;u=mt[(w>>15&0x1F)<<2>>2]|0;d=mt[(w>>18&0x7C)>>2]|0;if((u|0)<(d|0)){i=(w>>31<<11|(w>>25&0x3F)<<4|w>>8&0x0F|(w>>7&0x01)<<10)<<1;jt=jt+i-4|0}continue;case 0x6B:jt=Mt+(Pt-Wt)|0;Ut=Pt;_t=1;u=mt[(w>>15&0x1F)<<2>>2]|0;d=mt[(w>>18&0x7C)>>2]|0;if((u|0)>=(d|0)){i=(w>>31<<11|(w>>25&0x3F)<<4|w>>8&0x0F|(w>>7&0x01)<<10)<<1;jt=jt+i-4|0}continue;case 0x6C:jt=Mt+(Pt-Wt)|0;Ut=Pt;_t=1;u=mt[(w>>15&0x1F)<<2>>2]|0;d=mt[(w>>18&0x7C)>>2]|0;if(u>>>0<d>>>0){i=(w>>31<<11|(w>>25&0x3F)<<4|w>>8&0x0F|(w>>7&0x01)<<10)<<1;jt=jt+i-4|0}continue;case 0x6D:jt=Mt+(Pt-Wt)|0;Ut=Pt;_t=1;u=mt[(w>>15&0x1F)<<2>>2]|0;d=mt[(w>>18&0x7C)>>2]|0;if(u>>>0>=d>>>0){i=(w>>31<<11|(w>>25&0x3F)<<4|w>>8&0x0F|(w>>7&0x01)<<10)<<1;jt=jt+i-4|0}continue;default:r(A|0);r(w|0);s();break}}else{if(!(_t|0))jt=Mt+(Pt-Wt)|0;S=S-(Pt-Wt>>2)|0;if((S|0)<0){S=S+64|0;e=e-64|0;if((e|0)<0)return 0;b=(Dt[xt+ge>>2]|0)-Ht|0;b=b+((b|0)<0?0xFFFFFFFF:0x0)|0;Ht=Ht+t|0;if((b|0)<(t|0)){Dt[xt+De>>2]=Dt[xt+De>>2]|0x20}m=(Dt[xt+be>>2]&0x06)>>1;k=Dt[xt+ke>>2]&Dt[xt+De>>2];g=Dt[xt+be>>2]&0x01;if((m|0)<3|(m|0)==3&(g|0)){if((k|0)&0x8){wi(G,jt);continue}else if(fi|0){wi(O,jt);fi=0;continue}}if((m|0)<1|(m|0)==1&(g|0)){if((k|0)&0x2){wi(G,jt);continue}else if((k|0)&0x20){wi(z,jt);continue}}}if((Bt^jt)&0xFFFFF000){Pt=Di(jt,F)|0;if((Pt|0)==-1){Pt=Ut;continue}Bt=jt;Ft=(Pt^jt)&0xFFFFF000}Pt=It+(Ft^jt)|0;Wt=Pt;Mt=jt;Ut=(Pt>>12)+1<<12;_t=0}}return 0}return{Reset:pi,Init:li,InvalidateTLB:ji,Step:Hi,TranslateVM:Di,GetCSR:Ei,SetCSR:xi,Trap:wi,MemTrap:Si,PopPrivilegeStack:_i,PushPrivilegeStack:Mi,IMul:Ii,UMul:Ai,SUMul:Ci,CheckVMPrivilege:Ti,GetTimeToNextInterrupt:bi,ProgressTime:mi,GetTicks:vi,AnalyzeImage:ki,CheckForInterrupt:gi,RaiseInterrupt:Ri,ClearInterrupt:yi}}e("cjs!../messagehandler"),e("cjs!../utils"),e("cjs!./disassemble");i.exports=t}()}),define("cjs!jor1k/worker/riscv/index",["require","exports","module","cjs!../messagehandler","cjs!../utils","cjs!../imul","cjs!./safecpu","cjs!./fastcpu","cjs!./dynamiccpu"],function(e,t,i){!function(){function t(e,t,i,r,a){var d=null,f={DebugMessage:s.Debug,abort:s.Abort,imul:Math.imul||n,MathAbs:Math.abs,Read32:t.Read32Little.bind(t),Write32:t.Write32Little.bind(t),Read16:t.Read16Little.bind(t),Write16:t.Write16Little.bind(t),Read8:t.Read8Little.bind(t),Write8:t.Write8Little.bind(t),ReadDEVCMDToHost:i.ReadDEVCMDToHost.bind(i),ReadDEVCMDFromHost:i.ReadDEVCMDFromHost.bind(i),WriteDEVCMDToHost:i.WriteDEVCMDToHost.bind(i),WriteDEVCMDFromHost:i.WriteDEVCMDFromHost.bind(i),ReadToHost:i.ReadToHost.bind(i),ReadFromHost:i.ReadFromHost.bind(i),WriteToHost:i.WriteToHost.bind(i),WriteFromHost:i.WriteFromHost.bind(i)};if("safe"===e)return new o(t,i);if("asm"===e)return d=c(u,f,r),d.Init(),d;if("dynamic"===e)return d=h(u,f,r),d.Init(),d;throw new Error("invalid CPU name:"+e)}function r(e,i,r,s,a){return this.cpu=t(e,i,r,s,a),this.name=e,this.ncores=a,this.ram=i,this.heap=s,this.littleendian=!0,this}var s=e("cjs!../messagehandler"),a=e("cjs!../utils"),n=e("cjs!../imul"),o=e("cjs!./safecpu"),c=e("cjs!./fastcpu"),h=e("cjs!./dynamiccpu"),u={Int32Array:Int32Array,Int8Array:Int8Array,Int16Array:Int16Array,Float32Array:Float32Array,Float64Array:Float64Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array,Math:Math};r.prototype.switchImplementation=function(e){},r.prototype.toString=function(){var e=new Int32Array(this.heap,0),t=new Uint32Array(this.heap,8192),i="";i+="Current state of the machine\n",i+=this.cpu.pc?"PC: "+a.ToHex(this.cpu.pc)+"\n":"PC: "+a.ToHex(this.cpu.GetPC())+"\n";for(var r=0;r<32;r+=4)i+=" r"+(r+0)+": "+a.ToHex(e[r+0])+" r"+(r+1)+": "+a.ToHex(e[r+1])+" r"+(r+2)+": "+a.ToHex(e[r+2])+" r"+(r+3)+": "+a.ToHex(e[r+3])+"\n";return i+="mstatus: "+a.ToBin(t[768])+"\n",i+="mcause: "+a.ToHex(t[834])+" mbadaddress: "+a.ToHex(t[835])+" mepc: "+a.ToHex(t[833])+"\n"};var d=["Reset","Step","RaiseInterrupt","Step","AnalyzeImage","GetTicks","GetTimeToNextInterrupt","ProgressTime","ClearInterrupt"];d.forEach(function(e){r.prototype[e]=function(){return this.cpu[e].apply(this.cpu,arguments)}}),i.exports=r}()}),define("cjs!jor1k/worker/dev/uart",["require","exports","module","cjs!../messagehandler","cjs!../utils"],function(e,t,i){!function(){function t(e,t,i){this.intno=i,this.intdev=t,this.id=e,r.Register("tty"+e,this.ReceiveChar.bind(this)),this.Reset()}var r=e("cjs!../messagehandler"),s=(e("cjs!../utils"),0),a=0,n=0,o=1,c=1,h=2,u=2,d=3,f=4,l=5,p=6,b=1,v=32,m=64,k=8,g=2,R=1,y=0,w=1,S=2,T=12,D=128,x=128,E=32,I=16,A=["DataTerminalReady","RTS","AuxOut1","AuxOut2","Loopback","Autoflow"],C=["FIFO enable","Reset","XMIT-FIFO-Reset","DMA-Mode","Reserved","Reserved","RecrTrig(LSB)","RecrTrig(MSB)"],j=["WordLen","WordLen","StopBits","Parity","EvenParity","StickParity","Break","DivisorLatch"],M=["DeltaCTS","DeltaDataSetReady","DeltaRingIndicator","DeltaCarrierDetect","ClearToSend","DataSetReady","RingIndicator","CarrierDetect"];t.prototype.ToBitDescription=function(e,t){e&=255;for(var i=("00000000"+e.toString(2)).substr(-8)+":",r=0;r<t.length;r++)i+=" "+t[r]+":"+(e>>r&1);return i},t.prototype.Reset=function(){this.LCR=3,this.LSR=m|v,this.MSR=x|E|I,this.ints=0,this.IIR=w,this.IER=0,this.DLL=0,this.DLH=0,this.FCR=0,this.MCR=0,this.rxbuf=new Array,this.txbuf=new Array},t.prototype.Step=function(){0!=this.txbuf.length&&(r.Send("tty"+this.id,this.txbuf),this.txbuf=new Array)},t.prototype.ReceiveChar=function(e){e.forEach(function(e){this.rxbuf.push(255&e)}.bind(this)),this.rxbuf.length>0&&(this.LSR|=b,this.ThrowInterrupt(T))},t.prototype.CheckInterrupt=function(){this.ints&1<<T&&this.IER&R?(this.IIR=T,this.intdev.RaiseInterrupt(this.intno)):this.ints&1<<S&&this.IER&g?(this.IIR=S,this.intdev.RaiseInterrupt(this.intno)):this.ints&1<<y&&this.IER&k?(this.IIR=y,this.intdev.RaiseInterrupt(this.intno)):(this.IIR=w,this.intdev.ClearInterrupt(this.intno))},t.prototype.ThrowInterrupt=function(e){this.ints|=1<<e,this.CheckInterrupt()},t.prototype.ClearInterrupt=function(e){this.ints&=~(1<<e),this.CheckInterrupt()},t.prototype.ReadReg8=function(e){if(this.LCR&D)switch(e){case n:return this.DLL;case o:return this.DLH}switch(e){case s:var t=0;return this.rxbuf.length>0&&(t=this.rxbuf.shift()),0==this.rxbuf.length&&(this.LSR&=~b,this.ClearInterrupt(T)),255&t;case c:return 15&this.IER;case p:var t=this.MSR;return this.MSR&=240,this.verboseuart&&r.Debug("Get UART_MSR "+this.ToBitDescription(t,M)),t;case h:var t=15&this.IIR|192;return this.IIR==S&&this.ClearInterrupt(S),t;case d:return this.LCR;case l:return this.LSR;default:r.Debug("Error in ReadRegister: not supported"),r.Abort()}},t.prototype.WriteReg8=function(e,t){if(t&=255,this.LCR&D)switch(e){case n:return void(this.DLL=t);case o:return void(this.DLH=t)}switch(e){case a:this.LSR&=~m,this.txbuf.push(t),this.LSR|=m|v,this.ThrowInterrupt(S);break;case c:this.IER=15&t,this.CheckInterrupt();break;case u:this.verboseuart&&r.Debug("Set UART_FCR "+this.ToBitDescription(t,C)),this.FCR=201&t,2&this.FCR&&(this.ClearInterrupt(T),this.rxbuf=new Array),4&this.FCR&&(this.txbuf=new Array);break;case d:this.verboseuart&&r.Debug("Set UART_LCR "+this.ToBitDescription(t,j)),3!=(3&this.LCR)&&r.Debug("Warning in UART: Data word length other than 8 bits are not supported"),this.LCR=t;break;case f:this.verboseuart&&r.Debug("Set UART_MCR "+this.ToBitDescription(t,A)),this.MCR=t;break;default:r.Debug("Error in WriteRegister: not supported"),r.Abort()}},i.exports=t}()}),define("cjs!jor1k/worker/dev/irq",["require","exports","module","cjs!../messagehandler","cjs!../utils"],function(e,t,i){!function(){function t(e){this.intdev=e,this.regs=new Uint32Array(64),this.Reset()}var r=e("cjs!../messagehandler"),s=e("cjs!../utils"),a=1<<30;t.prototype.Reset=function(){for(var e=0;e<64;e++)this.regs[e]=0},t.prototype.ReadReg32=function(e){return e>>=2,e>64?(r.Debug("IRQDev: Unknown ReadReg32: "+s.ToHex(e)),0):this.regs[e]},t.prototype.WriteReg32=function(e,t){if(e>>=2,e>64)return void r.Debug("IRQDev: unknown WriteReg32: "+s.ToHex(e)+": "+s.ToHex(t));var i=e>>1;if(1&e)r.Debug("Error in IRQDev: Write STAT of CPU "+i+" : "+s.ToHex(t));else{this.regs[e]=t;var n=65535&t,o=t>>16&16383,c=t>>30&3;if(1&c){if(o==i&&r.Debug("Warning in IRQDev: Try to raise its own IRQ"),this.regs[(o<<1)+1]&a){r.Debug("Warning in IRQDev: CPU "+i+" raised irq on cpu "+o+" without previous acknowledge");var h=new Int32Array(this.intdev.heap);r.Debug("The pc of cpu "+o+" is "+s.ToHex(h[(o<<15)+292>>2])),r.Debug("The IEE flag of cpu "+o+" is "+(4&h[(o<<15)+288>>2])),r.Debug("r9 of cpu "+o+" is "+s.ToHex(h[(o<<15)+36>>2]))}this.regs[(o<<1)+1]=a|(16383&i)<<16|n,this.intdev.RaiseSoftInterrupt(1,o)}2&c&&(this.regs[e+1]&=~a,this.intdev.ClearSoftInterrupt(1,i))}},i.exports=t}()}),define("cjs!jor1k/worker/dev/timer",["require","exports","module","cjs!../messagehandler"],function(e,t,i){!function(){function t(){this.Reset()}var r=e("cjs!../messagehandler");t.prototype.Reset=function(){this.sync=0},t.prototype.ReadReg32=function(e){return this.sync},t.prototype.WriteReg32=function(e,t){r.Debug("Error in Timer: Write reg "+e+" : "+t)},i.exports=t}()}),define("cjs!jor1k/worker/dev/framebuffer",["require","exports","module","cjs!../utils","cjs!../messagehandler"],function(e,t,i){!function(){function t(e){this.ram=e,this.width=640,this.height=400,this.addr=16e6,this.n=this.width*this.height>>1,this.buffer=new Int32Array(this.n),s.Register("GetFB",this.OnGetFB.bind(this))}var r=e("cjs!../utils"),s=e("cjs!../messagehandler");t.prototype.Reset=function(){},t.prototype.ReadReg32=function(e){return 0},t.prototype.WriteReg32=function(e,t){switch(e){case 20:this.addr=r.Swap32(t);break;default:return}},t.prototype.OnGetFB=function(){s.Send("GetFB",this.GetBuffer())},t.prototype.GetBuffer=function(){var e=0,t=this.buffer.length,i=this.buffer,r=this.ram.int32mem,s=this.addr>>2;for(e=0;e<t;++e)i[e]=r[s+e];return this.buffer},i.exports=t}()}),define("cjs!jor1k/worker/dev/ethmac",["require","exports","module","cjs!../messagehandler","cjs!../utils"],function(e,t,i){!function(){function t(e,t,i){this.ram=e,this.intdev=t,this.TransmitCallback=function(e){},this.toTxStat=function(e){return{LEN:e>>>16,RD:e>>>15&1,IRQ:e>>>14&1,WR:e>>>13&1,PAD:e>>>12&1,CRC:e>>>11&1,UR:e>>>8&1,RTRY:e>>>4&15,RL:e>>>3&1,LC:e>>>2&1,DF:e>>>1&1,CS:1&e}},this.fromTxStat=function(e){var t=e.LEN<<16;return t|=(1&e.RD)<<15,t|=(1&e.IRQ)<<14,t|=(1&e.WR)<<13,t|=(1&e.PAD)<<12,t|=(1&e.CRC)<<11,t|=(1&e.UR)<<8,t|=(15&e.RTRY)<<4,t|=(1&e.RL)<<3,t|=(1&e.LC)<<2,t|=(1&e.CDF)<<1,t|=1&e.CS},this.toRxStat=function(e){return{LEN:e>>>16,E:e>>>15&1,IRQ:e>>>14&1,WR:e>>>13&1,CF:e>>>8&1,M:e>>>7&1,OR:e>>>6&1,IS:e>>>5&1,DN:e>>>4&1,TL:e>>>3&1,SF:e>>>2&1,CRC:e>>>1&1,LC:1&e}},this.fromRxStat=function(e){var t=e.LEN<<16;return t|=(1&e.E)<<15,t|=(1&e.IRQ)<<14,t|=(1&e.WR)<<13,t|=(1&e.CF)<<8,t|=(1&e.M)<<7,t|=(1&e.OR)<<6,t|=(1&e.IS)<<5,t|=(1&e.DN)<<4,t|=(1&e.TL)<<3,t|=(1&e.SF)<<2,t|=(1&e.CRC)<<1,t|=1&e.LC},this.makeCRCTable=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t},this.crcTable=this.makeCRCTable(),this.crc32=function(e,t,i){var r=-1,s=4;e instanceof Uint16Array||e instanceof Int16Array?s=2:(e instanceof Uint8Array||e instanceof Int8Array)&&(s=1),i||(i=e.length),t||(t=0);for(var a=0,n=t;n<i;n++)a=255&e[n],r=r>>>8^this.crcTable[255&(r^a)],s>1&&(a=e[n]>>>8&255,r=r>>>8^this.crcTable[255&(r^a)],s>2&&(a=e[n]>>>16&255,r=r>>>8^this.crcTable[255&(r^a)],a=e[n]>>>24&255,r=r>>>8^this.crcTable[255&(r^a)]));return(r^-1)>>>0},this.Reset=function(){this.MODER=40960,this.INT_SOURCE=0,this.INT_MASK=0,this.IPGT=18,this.IPGR1=12,this.IPGR2=18,this.PACKETLEN=4195840,this.COLLCONF=983103,this.TX_BD_NUM=64,this.CTRLMODER=0,this.MIIMODER=100,this.MIICOMMAND=0,this.MIIADDRESS=0,this.MIITX_DATA=0,this.MIIRX_DATA=34,this.MIISTATUS=0,this.MAC_ADDR0|=Math.floor(256*Math.random())<<24,this.MAC_ADDR0|=Math.floor(256*Math.random())<<16,this.MAC_ADDR0|=Math.floor(256*Math.random())<<8,this.MAC_ADDR0|=Math.floor(256*Math.random()),this.MAC_ADDR1|=Math.floor(256*Math.random())<<8&254|2,this.MAC_ADDR1|=Math.floor(256*Math.random()),this.ETH_HASH0_ADR=0,this.ETH_HASH1_ADR=0,this.ETH_TXCTRL=0,this.BD=new Uint32Array(256);for(var e=0;e<256;e++)this.BD[e]=0;this.MIIregs=new Uint16Array(16),this.MIIregs[E]=256,this.MIIregs[I]=30756,this.MIIregs[A]=8192,this.MIIregs[C]=23696,this.MIIregs[j]=481,this.MIIregs[M]=0,this.currRX=this.TX_BD_NUM<<1},this.Receive=function(t){if(0!=(1&this.MODER)){var i=new Uint8Array(t),r=!1,s=!1,a=!1,n=0,o=0;n|=i[2]<<24,n|=i[3]<<16,n|=i[4]<<8,n|=i[5],o|=i[0]<<8,o|=i[1],n==this.MAC_ADDR0&&o==this.MAC_ADDR1?s=!0:32768&o&&(a=!0),32&this.MODER&&(r=!0);var c=this.currRX;if(r||a||s){var h=!1;if(32768&this.BD[c]){var u=this.toRxStat(this.BD[c]);s||a||!r||(u.M=1),u.DN=0,i.length>(65535&this.PACKETLEN)&&16384&this.MODER?u.TL=1:u.TL=0,0==u.DN&&(u.CRC=0);var d=0;if(d|=i[i.length-4]<<24,d|=i[i.length-3]<<16,d|=i[i.length-2]<<8,d|=i[i.length-1],!h){u.LEN=i.length;u.LEN>(65535&this.PACKETLEN)&&(u.LEN=65535&this.PACKETLEN);for(var f=this.BD[c+1],l=0;l<u.LEN;l++)e.Write8(f+l,i[l]);u.LEN+=4,u.E=0}this.BD[c]=this.fromRxStat(u),u.IRQ&&(h&&(this.INT_SOURCE|=8),this.INT_SOURCE|=4,this.INT_MASK&this.INT_SOURCE?this.intdev.RaiseInterrupt(4):this.intdev.ClearInterrupt(4))}else this.INT_SOURCE|=16,this.INT_MASK&this.INT_SOURCE?this.intdev.RaiseInterrupt(4):this.intdev.ClearInterrupt(4);8192&this.BD[this.currRX]||this.currRX+2>=this.BD.length?this.currRX=this.TX_BD_NUM<<1:this.currRX+=2}}},this.Transmit=function(t){if(0!=(2&this.MODER)){var i=this.toTxStat(this.BD[t<<1]),r=this.BD[(t<<1)+1];if(0!=i.RD){var s=i.LEN,a=!1;i.CRC||8192&this.MODER;var n=!1;(i.PAD||32768&this.MODER)&&(n=!0,this.PACKETLEN>>>16>i.LEN&&(s=this.PACKETLEN>>>16));for(var o=new Uint8Array(s),c=0;c<o.length;c++)c<i.LEN?o[c]=e.Read8(r+c):o[c]=0;if(a){var h=0;h=4096&this.MODER?this.crc32(o,4,o.length-4):this.crc32(o,0,o.length-4),o[o.length-1]=h>>24,o[o.length-2]=h>>16&255,o[o.length-3]=h>>8&255,o[o.length-4]=255&h}this.TransmitCallback(o.buffer),i.UR=0,i.RTRY=0,i.RL=0,i.LC=0,i.DF=0,i.CS=0,i.RD=0,this.BD[t<<1]=this.fromTxStat(i),this.INT_SOURCE|=1,this.INT_MASK&this.INT_SOURCE?this.intdev.RaiseInterrupt(4):this.intdev.ClearInterrupt(4)}}},this.ReadReg32=function(e){var t=0;switch(e){case s:t=this.MODER;break;case a:t=this.INT_SOURCE;break;case n:t=this.INT_MASK;break;case o:t=this.IPGT;break;case c:t=this.IPGR1;break;case h:t=this.IPGR2;break;case u:t=this.PACKETLEN;break;case d:t=this.COLLCONF;break;case f:t=this.TX_BD_NUM;break;case l:t=this.CTRLMODER;break;case p:t=this.MIIMODER;break;case b:t=this.MIICOMMAND;break;case v:t=this.MIIADDRESS;break;case m:t=this.MIITX_DATA;break;case k:t=this.MIIRX_DATA;break;case g:t=this.MIISTATUS;break;case R:t=this.MAC_ADDR0;break;case y:t=this.MAC_ADDR1;break;case w:t=this.ETH_HASH0_ADR;break;case S:t=this.ETH_HASH1_ADR;break;case T:t=this.ETH_TXCTRL;break;default:e>=D&&e<=x?t=this.BD[e-D>>>2]:r.Debug("Attempt to access ethmac register beyond 0x800")}return t},this.HandleMIICommand=function(){var e=31&this.MIIADDRESS,t=this.MIIADDRESS>>8&31,i=0;switch(this.MIICOMMAND){case 0:break;case 1:break;case 2:e!=i?this.MIIRX_DATA=65535:this.MIIRX_DATA=this.MIIregs[t];break;case 4:break;default:r.Debug("Error in ethmac: Unknown mii command detected")}},this.WriteReg32=function(e,t){switch(e){case s:this.MODER=t;break;case a:this.INT_SOURCE=this.INT_SOURCE&~t,this.INT_MASK&this.INT_SOURCE?this.intdev.RaiseInterrupt(4):this.intdev.ClearInterrupt(4);break;case n:this.INT_MASK=t,this.INT_MASK&this.INT_SOURCE?this.intdev.RaiseInterrupt(4):this.intdev.ClearInterrupt(4);break;case o:this.IPGT=t;break;case c:this.IPGR1=t;break;case h:this.IPGR2=t;break;case u:this.PACKETLEN=t;break;case d:this.COLLCONF=t;break;case f:this.TX_BD_NUM=t,this.currRX=t<<1;break;case l:this.CTRLMODER=t;break;case p:this.MIIMODER=t;break;case b:this.MIICOMMAND=t,this.HandleMIICommand();break;case v:this.MIIADDRESS=t;break;case m:this.MIITX_DATA=t;break;case k:this.MIIRX_DATA=t;break;case g:this.MIISTATUS=t;break;case R:this.MAC_ADDR0=t;break;case y:this.MAC_ADDR1=t;break;case w:this.ETH_HASH0_ADR=t;break;case S:this.ETH_HASH1_ADR=t;break;case T:this.ETH_TXCTRL=t;break;default:if(e>=D&&e<=x){this.BD[e-D>>>2]=t;var i=e-D>>>3;(i<<3)+D==e&&0!=(32768&t)&&i<this.TX_BD_NUM&&this.Transmit(i)}else r.Debug("Attempt to access ethmac register beyond 0x800")}},this.Reset(),r.Register("ethmac",this.Receive.bind(this))}var r=e("cjs!../messagehandler"),s=(e("cjs!../utils"),0),a=4,n=8,o=12,c=16,h=20,u=24,d=28,f=32,l=36,p=40,b=44,v=48,m=52,k=56,g=60,R=64,y=68,w=72,S=76,T=80,D=1024,x=2047,E=0,I=1,A=2,C=3,j=4,M=25;i.exports=t}()}),define("cjs!jor1k/worker/dev/ata",["require","exports","module","cjs!../utils","cjs!../messagehandler"],function(e,t,i){!function(){function t(e){this.intdev=e;var t=new ArrayBuffer(512);this.identifybuffer=new Uint16Array(t),this.Reset();var t=new ArrayBuffer(65536);this.SetBuffer(t)}var r=e("cjs!../utils"),s=e("cjs!../messagehandler"),a=4,n=8,o=12,c=16,h=20,u=24,d=28,f=a,l=d,p=4,b=2,v=128,m=64,k=16,g=8;t.prototype.Reset=function(){this.DCR=8,this.DR=160,this.SCR=1,this.SNR=1,this.SR=m,this.FR=0,this.ER=1,this.CR=0,this.lcyl=0,this.hcyl=0,this.select=160,this.driveselected=!0,this.readbuffer=this.identifybuffer,this.readbufferindex=0,this.readbuffermax=256},t.prototype.SetBuffer=function(e){this.diskbuffer=new Uint16Array(e),this.heads=16,this.sectors=64,this.cylinders=e.byteLength/(this.heads*this.sectors*512),this.nsectors=this.heads*this.sectors*this.cylinders,this.BuildIdentifyBuffer(this.identifybuffer)},t.prototype.BuildIdentifyBuffer=function(e){for(var t=0;t<256;t++)e[t]=0;e[0]=64,e[1]=this.cylinders,e[3]=this.heads,e[4]=512*this.sectors,e[5]=512,e[6]=this.sectors,e[20]=3,e[21]=512,e[22]=4,e[27]=27247,e[28]=29233,e[29]=27437,e[30]=25705,e[31]=29547;for(var t=32;t<=46;t++)e[t]=8224;e[47]=32896,e[48]=0,e[49]=512,e[51]=512,e[52]=512,e[54]=this.cylinders,e[55]=this.heads,e[56]=this.sectors,e[57]=this.nsectors>>0&65535,e[58]=this.nsectors>>16&65535,e[59]=0,e[60]=this.nsectors>>0&65535,e[61]=this.nsectors>>16&65535,e[80]=6,e[82]=16384,e[83]=16384,e[84]=16384,e[85]=16384,e[86]=0,e[87]=16384},t.prototype.ReadReg8=function(e){if(!this.driveselected)return 255;switch(e){case a:return this.ER;case n:return this.SNR;case o:return this.SCR;case c:return this.lcyl;case h:return this.hcyl;case u:return this.DR;case d:return this.intdev.ClearInterrupt(15),this.SR;case 256:return this.SR;default:s.Debug("ATADev: Error in ReadRegister8: register "+r.ToHex(e)+" not supported"),s.Abort()}return 0},t.prototype.GetSector=function(){return 64&this.DR||(s.Debug("ATADev: CHS mode not supported"),s.Abort()),(15&this.DR)<<24|this.hcyl<<16|this.lcyl<<8|this.SCR},t.prototype.SetSector=function(e){64&this.DR||(s.Debug("ATADev: CHS mode not supported"),s.Abort()),this.SCR=255&e,this.lcyl=e>>8&255,this.hcyl=e>>16&255,this.DR=240&this.DR|e>>24&15},t.prototype.ExecuteCommand=function(){switch(this.CR){case 236:this.readbuffer=this.identifybuffer,this.readbufferindex=0,this.readbuffermax=256,this.SR=m|k|g,this.DCR&b||this.intdev.RaiseInterrupt(15);break;case 145:this.SR=m|k,this.ER=0,this.DCR&b||this.intdev.RaiseInterrupt(15);break;case 32:case 48:var e=this.GetSector();0==this.SNR&&(this.SNR=256),this.readbuffer=this.diskbuffer,this.readbufferindex=256*e,this.readbuffermax=this.readbufferindex+256,this.SR=m|k|g,this.ER=0,32==this.CR&&(this.DCR&b||this.intdev.RaiseInterrupt(15));break;case 196:case 197:var e=this.GetSector();0==this.SNR&&(this.SNR=256),this.readbuffer=this.diskbuffer,this.readbufferindex=256*e,this.readbuffermax=this.readbufferindex+256*this.SNR,this.SR=m|k|g,this.ER=0,196==this.CR&&(this.DCR&b||this.intdev.RaiseInterrupt(15));break;default:s.Debug("ATADev: Command "+r.ToHex(this.CR)+" not supported"),s.Abort()}},t.prototype.WriteReg8=function(e,t){if(e==u)return this.DR=t,void(this.driveselected=!(t>>4&1));if(256==e)return!(t&p)&&this.DCR&p?(this.DR&=240,this.SR=m|k,this.SCR=1,this.SNR=1,this.lcyl=0,this.hcyl=0,this.ER=1,this.CR=0):t&p&&!(this.DCR&p)&&(this.ER=1,this.SR=v|k),void(this.DCR=t);if(this.driveselected)switch(e){case f:this.FR=t;break;case n:this.SNR=t;break;case o:this.SCR=t;break;case c:this.lcyl=t;break;case h:this.hcyl=t;break;case l:this.CR=t,this.ExecuteCommand();break;default:s.Debug("ATADev: Error in WriteRegister8: register "+r.ToHex(e)+" not supported (value: "+r.ToHex(t)+")"),s.Abort()}},t.prototype.ReadReg16=function(e){0!=e&&(s.Debug("ATADev: Error in ReadRegister16: register "+r.ToHex(e)+" not supported"),s.Abort());var t=r.Swap16(this.readbuffer[this.readbufferindex]);return this.readbufferindex++,this.readbufferindex>=this.readbuffermax&&(this.SR=m|k,32==this.CR&&this.SNR>1&&(this.SNR--,this.SetSector(this.GetSector()+1),this.readbuffermax+=256,this.SR=m|k|g,this.DCR&b||this.intdev.RaiseInterrupt(15))),t},t.prototype.WriteReg16=function(e,t){0!=e&&(s.Debug("ATADev: Error in WriteRegister16: register "+r.ToHex(e)+" not supported"),s.Abort()),this.readbuffer[this.readbufferindex]=r.Swap16(t),this.readbufferindex++,this.readbufferindex>=this.readbuffermax&&(this.SR=m|k,this.DCR&b||this.intdev.RaiseInterrupt(15),48==this.CR&&this.SNR>1&&(this.SNR--,this.SetSector(this.GetSector()+1),this.readbuffermax+=256,this.SR=m|k|g))},t.prototype.ReadReg32=function(e){s.Debug("ATADev: Error in ReadRegister32: register "+r.ToHex(e)+" not supported"),this.mesage.Abort()},t.prototype.WriteReg32=function(e,t){s.Debug("ATADev: Error in WriteRegister32: register "+r.ToHex(e)+" not supported"),s.Abort()},i.exports=t}()}),define("cjs!jor1k/worker/dev/rtc",["require","exports","module","cjs!../messagehandler","cjs!../utils"],function(e,t,i){!function(){function t(e){this.intdev=e,this.Reset()}var r=e("cjs!../messagehandler"),s=e("cjs!../utils"),a=0,n=8,o=16,c=20,h=24;t.prototype.Reset=function(){this.ctrl=0},t.prototype.ReadReg32=function(e){switch(e){case a:return Math.floor((new Date).getTime()/1e3);case o:return this.ctrl;case h:return 3049340711;case n:return 0;case c:return 0;default:return r.Debug("RTC: unknown ReadReg32: "+s.ToHex(e)),0}return 0},t.prototype.WriteReg32=function(e,t){switch(e){case o:this.ctrl=t;break;default:return void r.Debug("RTC: unknown WriteReg32: "+s.ToHex(e)+": "+s.ToHex(t))}},i.exports=t}()}),define("cjs!jor1k/worker/dev/touchscreen",["require","exports","module","cjs!../messagehandler","cjs!../utils"],function(e,t,i){!function(){function t(e){this.intdev=e,this.Reset(),r.Register("tsmousedown",this.onmousedown.bind(this)),r.Register("tsmouseup",this.onmouseup.bind(this)),r.Register("tsmousemove",this.onmousemove.bind(this))}var r=e("cjs!../messagehandler"),s=(e("cjs!../utils"),0),a=4,n=8,o=12,c=16,h=20,u=24,d=28,f=32,l=36,p=40,b=44,v=48,m=52,k=56,g=60,R=1,y=128,w=1<<31;t.prototype.Reset=function(){this.control=0,this.status=y,this.ispressed=!1,this.mousemovecount=0,this.fifo=0,this.fifosize=0},t.prototype.onmousedown=function(e){if(this.control&R){var t=e.x,i=e.y;this.status&=~y,this.fifosize=4,this.fifo=0,this.fifo|=(1023-t&1023)<<16,this.fifo|=1023-i&1023,this.ispressed=!0,this.intdev.RaiseInterrupt(9)}},t.prototype.onmousemove=function(e){if(this.control&R&&this.ispressed&&(this.mousemovecount++,!(3&this.mousemovecount))){var t=e.x,i=e.y;this.status&=~y,this.fifosize=4,this.fifo=0,this.fifo|=(1023-t&1023)<<16,this.fifo|=1023-i&1023,this.intdev.RaiseInterrupt(9)}},t.prototype.onmouseup=function(e){if(this.control&R){e.x,e.y;this.status&=~y,this.fifosize=0,this.fifo=w,this.ispressed=!1,this.intdev.RaiseInterrupt(9)}},t.prototype.ReadReg32=function(e){switch(e){case n:return this.control;case s:return this.intdev.ClearInterrupt(9),this.status;case o:return this.fifosize<=0&&(this.status|=y),this.fifosize--,this.fifo}return 0},t.prototype.WriteReg32=function(e,t){switch(e){case n:return void(this.control=t);case a:case l:case p:case b:case v:case m:case k:case g:case h:case c:case d:case f:case u:return}},i.exports=t}()}),define("cjs!jor1k/worker/dev/keyboard",["require","exports","module","cjs!../messagehandler"],function(e,t,i){!function(){function t(e){this.intdev=e,r.Register("keydown",this.OnKeyDown.bind(this)),r.Register("keyup",this.OnKeyUp.bind(this)),this.Reset()}var r=e("cjs!../messagehandler"),s=[0,0,0,0,0,0,0,0,14,15,0,0,0,28,0,0,42,29,56,119,58,0,0,0,0,0,0,1,0,0,0,0,57,104,109,107,102,105,103,106,108,0,0,0,0,110,111,0,11,2,3,4,5,6,7,8,9,10,0,39,,13,0,0,0,30,48,46,32,18,33,34,35,23,36,37,38,50,49,24,25,16,19,31,20,22,47,17,45,21,44,0,0,0,0,0,82,79,80,81,75,76,77,71,72,73,55,77,0,12,83,181,59,60,61,62,63,64,65,66,67,68,87,88,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,69,70,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,12,0,0,0,0,0,0,0,0,0,0,0,0,39,13,51,12,52,53,40,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,26,43,27,40,0,0,0,0,0,0,0];t.prototype.Reset=function(){this.key=0,this.fifo=[]},t.prototype.OnKeyDown=function(e){this.key=0|s[e.keyCode],0!=this.key&&(this.fifo.push(this.key),this.intdev.RaiseInterrupt(5))},t.prototype.OnKeyUp=function(e){this.key=s[e.keyCode],0!=this.key&&(this.key=128|this.key,this.fifo.push(this.key),this.intdev.RaiseInterrupt(5))},t.prototype.ReadReg8=function(e){var t=this.fifo.shift();return 0==this.fifo.length&&this.intdev.ClearInterrupt(5),t},i.exports=t}()}),define("cjs!jor1k/worker/dev/sound",["require","exports","module","cjs!../messagehandler","cjs!../utils"],function(e,t,i){!function(){function t(e,t){r.Debug("Start sound"),this.intdev=e,this.ramdev=t,this.Reset()}var r=e("cjs!../messagehandler"),s=e("cjs!../utils"),a=0,n=4,o=8,c=12,h=16,u=20,d=24,f=28;t.prototype.Reset=function(){this.addr=0,this.status=0,this.periods=0,this.period_size=0,this.rate=22050,this.channels=1,this.offset=0,this.playing=!1,this.nextperiod=0,this.starttime=0,this.lasttotalframe=0},t.prototype.GetTimeToNextInterrupt=function(){return this.playing?1e3*this.nextperiod/this.rate:-1},t.prototype.Progress=function(){},t.prototype.Elapsed=function(){var e=new Int8Array(this.period_size),t=this.periods*this.period_size;if(1==this.format)for(var i=0;i<this.period_size;i++)e[i]=this.ramdev.uint8mem[this.addr+(this.offset++<<0^3)]-128,this.offset==t&&(this.offset=0);else for(var i=0;i<this.period_size;i++)e[i]=this.ramdev.sint8mem[this.addr+1+(this.offset++<<1^3)],this.offset==t&&(this.offset=0);r.Send("sound",e)},t.prototype.ReadReg32=function(e){switch(e){case a:return this.intdev.ClearInterrupt(7),this.Elapsed(),this.playing?1:0;case h:return this.offset;default:return r.Debug("Sound: unknown ReadReg32: "+s.ToHex(e)),0}return 0},t.prototype.WriteReg32=function(e,t){switch(e){case a:this.playing=!!t,this.nextperiod=this.period_size,this.starttime=s.GetMilliseconds(),this.lasttotalframe=0,this.offset=0,r.Send("sound.rate",this.rate),this.Elapsed();break;case n:this.addr=t;break;case o:this.periods=t;break;case c:this.period_size=t;break;case u:this.rate=t;break;case d:this.channels=t;break;case f:this.format=t;break;default:return void r.Debug("sound: unknown WriteReg32: "+s.ToHex(e)+": "+s.ToHex(t))}},i.exports=t}()}),define("cjs!jor1k/worker/dev/virtio",["require","exports","module","cjs!../utils","cjs!./virtio/marshall","cjs!../messagehandler"],function(e,t,i){!function(){function t(e,t,i,r){for(var s=0;s<r;s++)t[s]=e.Read8(i+s)}function r(e,t,i,r){this.dev=r,this.dev.SendReply=this.SendReply.bind(this),this.intdev=e,this.intno=t,this.ramdev=i,this.queuenum=new Uint32Array(16),this.queueready=new Uint32Array(16),this.queuepfn=new Uint32Array(16),this.descaddr=new Uint32Array(16),this.usedaddr=new Uint32Array(16),this.availaddr=new Uint32Array(16),this.lastavailidx=new Uint32Array(16),this.version=2,this.Reset()}var s=e("cjs!../utils"),a=e("cjs!./virtio/marshall"),n=e("cjs!../messagehandler"),o=0,c=4,h=8,u=12,d=16,f=20,l=32,p=36,b=40,v=48,m=52,k=56,g=60,R=64,y=68,w=80,S=96,T=100,D=112,x=128,E=132,I=144,A=148,C=160,j=164,M=252,_=2,H=4;r.prototype.Reset=function(){this.status=0,this.intstatus=0,this.pagesize=8192,this.align=8192,this.availidx=0,this.hostfeaturewordselect=0,this.queuesel=0;for(var e=0;e<16;e++)this.queueready[e]=0,this.queuenum[e]=16,this.queuepfn[e]=0,this.descaddr[e]=0,this.usedaddr[e]=0,this.availaddr[e]=0,this.lastavailidx[e]=0},r.prototype.UpdateAddr=function(){if(1==this.version){var e=this.queuesel;if(this.descaddr[e]=this.queuepfn[e]*this.pagesize,this.availaddr[e]=this.descaddr[e]+16*this.queuenum[e],this.usedaddr[e]=this.availaddr[e]+2+2+2*this.queuenum[e]+2,this.usedaddr[e]&this.align-1){var t=~(this.align-1);
this.usedaddr[e]=(this.usedaddr[e]&t)+this.align}this.lastavailidx[e]=this.ramdev.Read16Little(this.availaddr[e]+2)}},r.prototype.ReadReg8=function(e){return this.dev.configspace[e-256]},r.prototype.ReadReg16=function(e){return"little"==this.ramdev.nativeendian?this.dev.configspace[e-256+1]<<8|this.dev.configspace[e-256]:this.dev.configspace[e-256]<<8|this.dev.configspace[e-256+1]},r.prototype.WriteReg8=function(e,t){this.dev.WriteConfig(e-256,t)},r.prototype.ReadReg32=function(e){var t=0;if(e>=256)return this.dev.configspace[e-256+0]<<24|this.dev.configspace[e-256+1]<<16|this.dev.configspace[e-256+2]<<8|this.dev.configspace[e-256+3]<<0;switch(e){case o:t=1953655158;break;case c:t=this.version;break;case h:t=this.dev.deviceid;break;case u:t=4294967295;break;case d:t=0,0==this.hostfeaturewordselect?t=this.dev.hostfeature:1==this.hostfeaturewordselect&&(t=1);break;case m:t=this.queuenum[this.queuesel];break;case R:t=this.queuepfn[this.queuesel];break;case y:t=this.queueready[this.queuesel];break;case S:t=this.intstatus;break;case D:t=this.status;break;case M:t=0;break;default:n.Debug("Error in VirtIODev: Attempt to read register "+s.ToHex(e)),n.Abort()}return"little"==this.ramdev.nativeendian?t:s.Swap32(t)},r.prototype.GetDescriptor=function(e,i){var r=this.descaddr[e]+16*i,s=new Uint8Array(16);t(this.ramdev,s,r,16);var n=a.Unmarshall(["d","w","h","h"],s,0);return{addr:n[0],len:n[1],flags:n[2],next:n[3]}},r.prototype.ConsumeDescriptor=function(e,t,i){var r=this.usedaddr[e]+2,s=this.ramdev.Read16Little(r);this.ramdev.Write16Little(r,s+1);var a=this.usedaddr[e]+4+8*(s&this.queuenum[e]-1);this.ramdev.Write32Little(a+0,t),this.ramdev.Write32Little(a+4,i)},r.prototype.SendReply=function(e,t){this.ConsumeDescriptor(e,t,this.dev.replybuffersize);this.ramdev.Read16Little(this.availaddr[e]);if(0==this.dev.replybuffersize)return this.intstatus=1,void this.intdev.RaiseInterrupt(this.intno);for(var i=this.GetDescriptor(e,t);0==(i.flags&_);)1&i.flags?i=this.GetDescriptor(e,i.next):(n.Debug("Error in virtiodev: Descriptor is not continuing"),n.Abort());0==(i.flags&_)&&(n.Debug("Error in virtiodev: Descriptor is not allowed to write"),n.Abort());for(var r=0,s=0;s<this.dev.replybuffersize;s++)r>=i.len&&(i=this.GetDescriptor(0,i.next),r=0,0==(i.flags&_)&&(n.Debug("Error in virtiodev: Descriptor is not allowed to write"),n.Abort())),this.ramdev.Write8(i.addr+r,this.dev.replybuffer[s]),r++;this.intstatus=1,this.intdev.RaiseInterrupt(this.intno)},r.prototype.GetDescriptorBufferSize=function(e,t){for(var i=0,r=0,s=this.GetDescriptor(e,t);s.flags&H&&(n.Debug("Error in VirtIO: Indirect descriptors not supported"),n.Abort()),s.flags&_?i+=s.len:r+=s.len,0!=(1&s.flags);)var s=this.GetDescriptor(e,s.next);return{write:i,read:r}},r.prototype.WriteReg32=function(e,t){switch("big"==this.ramdev.nativeendian&&(t=s.Swap32(t)),e){case b:this.pagesize=t,this.UpdateAddr();break;case f:this.hostfeaturewordselect=t;break;case p:break;case l:break;case v:this.queuesel=t;break;case k:this.queuenum[this.queuesel]=t,this.UpdateAddr();break;case g:this.align=t,this.pagesize=t,this.UpdateAddr();break;case R:this.queuepfn[this.queuesel]=t,this.UpdateAddr();break;case w:for(var i=t,r=this.ramdev.Read16Little(this.availaddr[i]+2);this.lastavailidx[i]!=r;){var a=this.lastavailidx[i]&this.queuenum[i]-1,o=this.ramdev.Read16Little(this.availaddr[t]+4+2*a),c=this.GetDescriptorBufferSize(i,o),h=0,u=this.GetDescriptor(i,o),d=function(e,t,i){return function(){t>=i.len&&(t=0,1&i.flags?i=this.GetDescriptor(e,i.next):(n.Debug("Error in virtiodev: Descriptor is not continuing"),n.Abort()));var r=this.ramdev.Read8(i.addr+t);return t++,r}.bind(this)}.bind(this)(i,h,u);this.dev.ReceiveRequest(i,o,d,c),this.lastavailidx[i]++,this.lastavailidx[i]&=65535}break;case y:this.queueready[this.queuesel]=t;break;case T:this.intstatus&=~t,this.intdev.ClearInterrupt(this.intno);break;case D:switch(this.status=t,this.status){case 0:this.intdev.ClearInterrupt(this.intno),this.intstatus=0,this.Reset();break;case 1:break;case 3:break;case 7:break;case 11:break;case 15:break;case 131:n.Debug("Error: virtio device initialization failed with status "+this.status),n.Abort();case 139:n.Debug("Error: virtio device initialization failed with status "+this.status),n.Abort();break;default:n.Debug("Error in virtio status register: Unknown status "+this.status),n.Abort()}break;case x:this.descaddr[this.queuesel]=t;break;case E:break;case I:this.availaddr[this.queuesel]=t,this.lastavailidx[this.queuesel]=this.ramdev.Read16Little(this.availaddr[this.queuesel]+2);break;case A:break;case C:this.usedaddr[this.queuesel]=t;break;case j:break;default:n.Debug("Error in VirtIODev: Attempt to write register "+s.ToHex(e)+":"+s.ToHex(t)),n.Abort()}},i.exports=r}()}),define("cjs!jor1k/worker/dev/virtio/9p",["require","exports","module","cjs!./marshall","cjs!../../messagehandler","cjs!../../utils"],function(e,t,i){!function(){function t(e,t){this.fs=t,this.SendReply=function(){},this.deviceid=9,this.hostfeature=1,this.configspace=[9,0,47,100,101,118,47,114,111,111,116],this.VERSION="9P2000.L",this.BLOCKSIZE=8192,this.msize=8192,this.replybuffer=new Uint8Array(2*this.msize),this.replybuffersize=0,this.Reset()}var r=e("cjs!./marshall"),s=e("cjs!../../messagehandler"),a=(e("cjs!../../utils"),16384),n=2,o=39,c=1,h=2,u=4,d=8,f=16,l=32,p=64,b=128,v=256,m=-1,k=1,g=2;t.prototype.Createfid=function(e,t,i){return{inodeid:e,type:t,uid:i}},t.prototype.Reset=function(){this.fids=[]},t.prototype.BuildReply=function(e,t,i){r.Marshall(["w","b","h"],[i+7,e+1,t],this.replybuffer,0),i+7>=this.replybuffer.length&&s.Debug("Error in 9p: payloadsize exceeds maximum length"),this.replybuffersize=i+7},t.prototype.SendError=function(e,t,i){var s=r.Marshall(["w"],[i],this.replybuffer,7);this.BuildReply(6,e,s)},t.prototype.ReceiveRequest=function(e,t,i){var R=r.Unmarshall2(["w","b","h"],i),y=R[0],w=R[1],S=R[2];switch(w){case 8:var y=this.fs.GetTotalSize(),T=[];T[0]=16914839,T[1]=this.BLOCKSIZE,T[2]=Math.floor(1073741824/T[1]),T[3]=T[2]-Math.floor(y/T[1]),T[4]=T[2]-Math.floor(y/T[1]),T[5]=this.fs.inodes.length,T[6]=1048576,T[7]=0,T[8]=256;var y=r.Marshall(["w","w","d","d","d","d","d","d","w"],T,this.replybuffer,7);this.BuildReply(w,S,y),this.SendReply(0,t);break;case 112:case 12:var T=r.Unmarshall2(["w","w"],i),D=T[0],x=T[1],E=this.fids[D].inodeid,I=this.fs.GetInode(E),A=this.fs.OpenInode(E,x),C=function(e,t,i,s){return function(){var a=this.fs.GetInode(e);T[0]=a.qid,T[1]=this.msize-24,r.Marshall(["Q","w"],T,this.replybuffer,7),this.BuildReply(t,i,17),this.SendReply(0,s)}.bind(this)}.bind(this)(E,w,S,t);this.fs.AddEvent(E,C);break;case 70:var T=r.Unmarshall2(["w","w","s"],i),j=T[0],D=T[1],M=T[2],I=this.fs.CreateInode(),_=this.fs.GetInode(this.fids[D].inodeid);I.mode=_.mode,I.size=_.size,I.symlink=_.symlink,I.data=new Uint8Array(I.size);for(var H=0;H<I.size;H++)I.data[H]=this.fs.ReadByte(_,H);I.name=M,I.parentid=this.fids[j].inodeid,this.fs.PushInode(I),this.BuildReply(w,S,0),this.SendReply(0,t);break;case 16:var T=r.Unmarshall2(["w","s","s","w"],i),D=T[0],M=T[1],q=T[2],L=T[3],E=this.fs.CreateSymlink(M,this.fids[D].inodeid,q),I=this.fs.GetInode(E);I.uid=this.fids[D].uid,I.gid=L,r.Marshall(["Q"],[I.qid],this.replybuffer,7),this.BuildReply(w,S,13),this.SendReply(0,t);break;case 18:var T=r.Unmarshall2(["w","s","w","w","w","w"],i),D=T[0],M=T[1],x=T[2],U=T[3],P=T[4],L=T[5],E=this.fs.CreateNode(M,this.fids[D].inodeid,U,P),I=this.fs.GetInode(E);I.mode=x,I.uid=this.fids[D].uid,I.gid=L,r.Marshall(["Q"],[I.qid],this.replybuffer,7),this.BuildReply(w,S,13),this.SendReply(0,t);break;case 22:var T=r.Unmarshall2(["w"],i),D=T[0],I=this.fs.GetInode(this.fids[D].inodeid),y=r.Marshall(["s"],[I.symlink],this.replybuffer,7);this.BuildReply(w,S,y),this.SendReply(0,t);break;case 72:var T=r.Unmarshall2(["w","s","w","w"],i),D=T[0],M=T[1],x=T[2],L=T[3],E=this.fs.CreateDirectory(M,this.fids[D].inodeid),I=this.fs.GetInode(E);I.mode=x|a,I.uid=this.fids[D].uid,I.gid=L,r.Marshall(["Q"],[I.qid],this.replybuffer,7),this.BuildReply(w,S,13),this.SendReply(0,t);break;case 14:var T=r.Unmarshall2(["w","s","w","w","w"],i),D=T[0],M=T[1],x=(T[2],T[3]),L=T[4],E=this.fs.CreateFile(M,this.fids[D].inodeid);this.fids[D].inodeid=E,this.fids[D].type=k;var I=this.fs.GetInode(E);I.uid=this.fids[D].uid,I.gid=L,I.mode=x,r.Marshall(["Q","w"],[I.qid,this.msize-24],this.replybuffer,7),this.BuildReply(w,S,17),this.SendReply(0,t);break;case 52:r.Marshall(["w"],[0],this.replybuffer,7),this.BuildReply(w,S,1),this.SendReply(0,t);break;case 24:var T=r.Unmarshall2(["w","d"],i),D=T[0],I=this.fs.GetInode(this.fids[D].inodeid);T[0]|=4096,T[0]=T[1],T[1]=I.qid,T[2]=I.mode,T[3]=I.uid,T[4]=I.gid,T[5]=1,T[6]=I.major<<8|I.minor,T[7]=I.size,T[8]=this.BLOCKSIZE,T[9]=Math.floor(I.size/512+1),T[10]=I.atime,T[11]=0,T[12]=I.mtime,T[13]=0,T[14]=I.ctime,T[15]=0,T[16]=0,T[17]=0,T[18]=0,T[19]=0,r.Marshall(["d","Q","w","w","w","d","d","d","d","d","d","d","d","d","d","d","d","d","d","d"],T,this.replybuffer,7),this.BuildReply(w,S,153),this.SendReply(0,t);break;case 26:var T=r.Unmarshall2(["w","w","w","w","w","d","d","d","d","d"],i),D=T[0],I=this.fs.GetInode(this.fids[D].inodeid);T[1]&c&&(I.mode=T[2]),T[1]&h&&(I.uid=T[3]),T[1]&u&&(I.gid=T[4]),T[1]&b&&(I.atime=T[6]),T[1]&v&&(I.atime=T[8]),T[1]&f&&(I.atime=Math.floor((new Date).getTime()/1e3)),T[1]&l&&(I.mtime=Math.floor((new Date).getTime()/1e3)),T[1]&p&&(I.ctime=Math.floor((new Date).getTime()/1e3)),T[1]&d&&this.fs.ChangeSize(this.fids[D].inodeid,T[5]),this.BuildReply(w,S,0),this.SendReply(0,t);break;case 50:var T=r.Unmarshall2(["w","d"],i),D=T[0];this.BuildReply(w,S,0),this.SendReply(0,t);break;case 40:case 116:var T=r.Unmarshall2(["w","d","w"],i),D=T[0],W=T[1],B=T[2],I=this.fs.GetInode(this.fids[D].inodeid);if(this.fids[D].type==g){I.caps.length<W+B&&(B=I.caps.length-W);for(var H=0;H<B;H++)this.replybuffer[11+H]=I.caps[W+H]}else{I.size<W+B&&(B=I.size-W);for(var H=0;H<B;H++)this.replybuffer[11+H]=this.fs.ReadByte(I,W+H)}r.Marshall(["w"],[B],this.replybuffer,7),this.BuildReply(w,S,4+B),this.SendReply(0,t);break;case 118:var T=r.Unmarshall2(["w","d","w"],i),D=T[0],W=T[1],B=T[2];this.fs.Write(this.fids[D].inodeid,W,B,i),r.Marshall(["w"],[B],this.replybuffer,7),this.BuildReply(w,S,4),this.SendReply(0,t);break;case 74:var T=r.Unmarshall2(["w","s","w","s"],i),F=T[0],z=T[1],O=T[2],G=T[3],A=this.fs.Rename(this.fids[F].inodeid,z,this.fids[O].inodeid,G);if(0==A){this.SendError(S,"No such file or directory",n),this.SendReply(0,t);break}this.BuildReply(w,S,0),this.SendReply(0,t);break;case 76:var T=r.Unmarshall2(["w","s","w"],i),N=T[0],M=T[1],w=(T[2],this.fs.Search(this.fids[N].inodeid,M));if(w==-1){this.SendError(S,"No such file or directory",n),this.SendReply(0,t);break}var A=this.fs.Unlink(w);if(!A){this.SendError(S,"Directory not empty",o),this.SendReply(0,t);break}this.BuildReply(w,S,0),this.SendReply(0,t);break;case 100:var V=r.Unmarshall2(["w","s"],i);this.msize=V[0];var y=r.Marshall(["w","s"],[this.msize,this.VERSION],this.replybuffer,7);this.BuildReply(w,S,y),this.SendReply(0,t);break;case 104:var T=r.Unmarshall2(["w","w","s","s","w"],i),D=T[0],X=T[4];this.fids[D]=this.Createfid(0,k,X);var I=this.fs.GetInode(this.fids[D].inodeid);r.Marshall(["Q"],[I.qid],this.replybuffer,7),this.BuildReply(w,S,13),this.SendReply(0,t);break;case 108:var T=r.Unmarshall2(["h"],i);T[0];this.BuildReply(w,S,0),this.SendReply(0,t);break;case 110:var T=r.Unmarshall2(["w","w","h"],i),D=T[0],Q=T[1],K=T[2];if(0==K){this.fids[Q]=this.Createfid(this.fids[D].inodeid,k,this.fids[D].uid),this.fids[Q].inodeid=this.fids[D].inodeid,r.Marshall(["h"],[0],this.replybuffer,7),this.BuildReply(w,S,2),this.SendReply(0,t);break}for(var Y=[],H=0;H<K;H++)Y.push("s");for(var J=r.Unmarshall2(Y,i),E=this.fids[D].inodeid,W=9,Z=0,H=0;H<K&&(E=this.fs.Search(E,J[H]),E!=-1);H++)W+=r.Marshall(["Q"],[this.fs.inodes[E].qid],this.replybuffer,W),Z++,this.fids[Q]=this.Createfid(E,k,this.fids[D].uid);r.Marshall(["h"],[Z],this.replybuffer,7),this.BuildReply(w,S,W-7),this.SendReply(0,t);break;case 120:var T=r.Unmarshall2(["w"],i);this.fids[T[0]]&&this.fids[T[0]].inodeid>=0&&(this.fs.CloseInode(this.fids[T[0]].inodeid),this.fids[T[0]].inodeid=-1,this.fids[T[0]].type=m),this.BuildReply(w,S,0),this.SendReply(0,t);break;case 30:var T=r.Unmarshall2(["w","w","s"],i),D=T[0],$=T[1],M=T[2];this.fids[$]=this.Createfid(this.fids[D].inodeid,m,this.fids[D].uid);var ee=0;"security.capability"==M&&(ee=this.fs.PrepareCAPs(this.fids[D].inodeid),this.fids[$].type=g),r.Marshall(["d"],[ee],this.replybuffer,7),this.BuildReply(w,S,8),this.SendReply(0,t);break;default:s.Debug("Error in Virtio9p: Unknown id "+w+" received"),s.Abort()}},i.exports=t}()}),define("cjs!jor1k/worker/dev/virtio/dummy",["require","exports","module","cjs!../../messagehandler","cjs!../../utils"],function(e,t,i){!function(){function t(e){this.configspace=[0],this.deviceid=0,this.hostfeature=0,this.Reset()}e("cjs!../../messagehandler"),e("cjs!../../utils");t.prototype.Reset=function(){},t.prototype.ReceiveRequest=function(e,t){},i.exports=t}()}),define("cjs!jor1k/worker/dev/virtio/input",["require","exports","module","cjs!../../messagehandler","cjs!../../utils","cjs!./marshall"],function(e,t,i){!function(){function t(e){this.configspace=new Uint8Array(256),this.deviceid=18,this.hostfeature=0,r.Register("virtio.kbd.keydown",this.OnKeyDown.bind(this)),r.Register("virtio.kbd.keyup",this.OnKeyUp.bind(this)),this.replybuffersize=8,this.replybuffer=new Uint8Array(8),this.Reset()}var r=e("cjs!../../messagehandler"),s=(e("cjs!../../utils"),e("cjs!./marshall")),a=0,n=1,o=2,c=3,h=16,u=17,d=18,f=1,l=20;t.prototype.Reset=function(){this.receivebufferdesc=new Array},t.prototype.OnKeyDown=function(e){if(0!=this.receivebufferdesc.length){var t=this.receivebufferdesc[0];this.receivebufferdesc.shift(),this.replybuffersize=8,s.Marshall(["h","h","w"],[f,e.keyCode,1],this.replybuffer,0),this.SendReply(0,t.idx)}},t.prototype.OnKeyUp=function(e){if(0!=this.receivebufferdesc.length){var t=this.receivebufferdesc[0];this.receivebufferdesc.shift(),this.replybuffersize=8,s.Marshall(["h","h","w"],[f,e.keyCode,0],this.replybuffer,0),this.SendReply(0,t.idx)}},t.prototype.WriteConfig=function(e,t){if(this.configspace[e]=t,1==e)switch(this.configspace[0]){case a:break;case n:this.configspace[2]=5,this.configspace[8]=86,this.configspace[9]=75,this.configspace[10]=66,this.configspace[11]=68,this.configspace[12]=0;break;case o:this.configspace[2]=0,this.configspace[8]=0;break;case c:this.configspace[2]=0;break;case h:this.configspace[2]=0;break;case u:switch(this.configspace[1]){case l:this.configspace[2]=0;break;case f:this.configspace[2]=16,this.configspace[8]=255,this.configspace[9]=255,this.configspace[10]=255,this.configspace[11]=255,this.configspace[12]=255,this.configspace[13]=255,this.configspace[14]=255,this.configspace[15]=255,this.configspace[16]=255,this.configspace[17]=255,this.configspace[18]=255,this.configspace[19]=255,this.configspace[20]=255,this.configspace[21]=255,this.configspace[22]=255,this.configspace[22]=255;break;default:this.configspace[2]=0}break;case d:this.configspace[2]=0,r.Debug("Virtioinput: abs_info not implemented"),r.Abort();break;default:r.Debug("Error in virtio input: Unknown config"),r.Abort()}},t.prototype.ReceiveRequest=function(e,t,i,s){if(e>=1&&(r.Debug("Error in Virtio input: Unsupported queue index"),r.Abort()),0==e){for(var a=0;a<this.receivebufferdesc.length;a++)if(this.receivebufferdesc[a].idx==t)return;return void this.receivebufferdesc.push({idx:t,size:s})}},i.exports=t}()}),define("cjs!jor1k/worker/dev/virtio/net",["require","exports","module","cjs!../../messagehandler","cjs!../../utils","cjs!./marshall"],function(e,t,i){!function(){function t(e){this.configspace=[0,0,0,0,0,0],this.deviceid=1,this.hostfeature=32,this.replybuffer=new Uint8Array(65550),this.replybuffersize=0;for(var t=1;t<6;t++)this.configspace[t]=Math.floor(256*Math.random());r.Register("virtio.net.transfer",this.Receive.bind(this)),this.Reset()}var r=e("cjs!../../messagehandler"),s=(e("cjs!../../utils"),e("cjs!./marshall"));t.prototype.Reset=function(){this.receivebufferdesc=new Array,this.receivebuffer=new Array},t.prototype.Receive=function(e){this.receivebuffer.push(e),this.HandleReceive()},t.prototype.HandleReceive=function(){if(0!=this.receivebuffer.length&&0!=this.receivebufferdesc.length){var e=new Uint8Array(this.receivebuffer[0]),t=this.receivebufferdesc[0];e.length>t.size.write&&(r.Debug("Error in VirtioNET: Received packet is larger than the next receive buffer"),r.Abort()),this.receivebuffer.shift(),this.receivebufferdesc.shift(),this.replybuffersize=e.length+12,s.Marshall(["b","b","h","h","h","h","h"],[0,0,0,0,0,0,0],this.replybuffer,0);for(var i=0;i<e.length;i++)this.replybuffer[i+12]=e[i];this.SendReply(0,t.idx)}},t.prototype.ReceiveRequest=function(e,t,i,a){if(e>1&&(r.Debug("Error in VirtioNET: Unsupported ringbuffer"),r.Abort()),0==e){for(var n=0;n<this.receivebufferdesc.length;n++)if(this.receivebufferdesc[n].idx==t)return;return this.receivebufferdesc.push({idx:t,size:a}),void this.HandleReceive()}for(var o=(s.Unmarshall2(["b","b","h","h","h","h","h"],i),new Uint8Array(a.read-12)),n=0;n<a.read-12;n++)o[n]=i();r.Send("ethmac",o.buffer),this.replybuffersize=0,this.SendReply(e,t)},i.exports=t}()}),define("cjs!jor1k/worker/dev/virtio/block",["require","exports","module","cjs!../../messagehandler","cjs!../../utils","cjs!./marshall"],function(e,t,i){!function(){function t(e){this.blocks=100,this.configspace=[this.blocks>>0&255,this.blocks>>8&255,this.blocks>>16&255,0,0,0,0,0],this.deviceid=2,this.hostfeature=0,this.replybuffer=new Uint8Array(65536),this.replybuffersize=0,this.buffer=new Uint8Array(512*this.blocks),this.Reset()}var r=e("cjs!../../messagehandler"),s=(e("cjs!../../utils"),e("cjs!./marshall")),a=0,n=1,o=4,c=5,h=0;t.prototype.Reset=function(){},t.prototype.ReceiveRequest=function(e,t,i,u){var d=s.Unmarshall2(["w","w","d"],i),f=d[0],l=d[2];switch(f){case a:u.write>65536&&(r.Debug("Error in virtioblock: replybuffer too small"),r.Abort());for(var p=0;p<u.write-1;p++)this.replybuffer[p]=this.buffer[512*l+p];this.replybuffersize=u.write,this.replybuffer[u.write-1]=h,this.SendReply(0,t);break;case n:for(var p=0;p<u.read-16;p++)this.buffer[512*l+p]=i();this.replybuffersize=1,this.replybuffer[0]=h,this.SendReply(0,t);break;case o:break;case c:break;default:r.Debug("Error in VirtioBlock: Unknown request type "+f),r.Abort()}},i.exports=t}()}),define("cjs!jor1k/worker/dev/virtio/gpu",["require","exports","module","cjs!../../messagehandler","cjs!../../utils","cjs!./marshall"],function(e,t,i){!function(){function t(e){this.configspace=[0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0],this.deviceid=16,this.hostfeature=0,this.replybuffersize=0,this.replybuffer=new Uint8Array(1024),this.Reset()}var r=e("cjs!../../messagehandler"),s=e("cjs!../../utils"),a=e("cjs!./marshall"),n=256,o=257,c=258,h=259,u=262,d=263,f=4352,l=4353;t.prototype.Reset=function(){this.resource=new Array},t.prototype.ReplyOk=function(e){a.Marshall(["w","w","d","w","w"],[f,0,0,0,0],this.replybuffer,0),this.replybuffersize=24,this.SendReply(0,e)},t.prototype.ReceiveRequest=function(e,t,i,f){r.Debug(""),r.Debug("Virtio GPU request of ringbuffer "+e+" "+t+" "+f.read+" "+f.write),0!=e&&(r.Debug("Error in virtio gpu: queue no. "+e+" unknown"),r.Abort());var p=a.Unmarshall2(["w","w","d","w","w"],i),b=p[0],v=p[3];switch(r.Debug("type: "+b+" flags: "+p[1]+" fence: "+p[2]+" ctx_id: "+v),p[0]){case n:a.Marshall(["w","w","d","w","w"],[l,0,0,0,0],this.replybuffer,0);for(var m=0;m<408;m++)this.replybuffersize[m]=0;a.Marshall(["w","w","w","w","w","w"],[0,0,1024,768,1,0],this.replybuffer,24),r.Debug("get display info"),this.replybuffersize=408,this.SendReply(e,t);break;case o:var p=a.Unmarshall2(["w","w","w","w"],i),k=p[0],g=p[2],R=p[3],y=p[1];0==k&&r.Debug("Error in virtio gpu: resource_id is 0"),this.resource[k]={valid:!0,width:g,height:R,format:y,addr:0,length:0,scanout_id:-1},r.Debug("create 2d: "+g+"x"+R+" format: "+y+" resource_id: "+p[0]),this.ReplyOk(t);break;case c:var p=a.Unmarshall2(["w"],i),k=p[0];this.resource[k].valid=!1,r.Debug("resource unref: resource_id: "+p[0]),this.ReplyOk(t);break;case u:var p=a.Unmarshall2(["w","w"],i),w=p[1],k=p[0];r.Debug("attach backing: resource_id: "+k+" nr_entries:"+p[1]);for(var m=0;m<w;m++){var p=a.Unmarshall2(["d","w","w"],i);r.Debug("attach backing: addr:"+s.ToHex(p[0])+" length: "+p[1]),this.resource[k].addr=p[0],this.resource[k].length=p[1]}this.ReplyOk(t);break;case d:var p=a.Unmarshall2(["w"],i),k=p[0];r.Debug("detach backing: resource_id: "+k),this.resource[k].addr=0,this.resource[k].length=0,this.ReplyOk(t);break;case h:var p=a.Unmarshall2(["w","w","w","w","w","w"],i),S=p[0],T=p[1],g=p[2],R=p[3],D=p[4],k=p[5];r.Debug("set scanout: x: "+S+" y: "+T+" width: "+g+" height: "+R+" scanout_id: "+D+" resource_id: "+k),0!=k&&(this.resource[k].scanout_id=D),this.ReplyOk(t);break;default:r.Debug("Error in virtio gpu: Unknown type "+b),r.Abort()}},i.exports=t}()}),define("cjs!jor1k/worker/dev/virtio/console",["require","exports","module","cjs!../../messagehandler","cjs!../../utils","cjs!./marshall"],function(e,t,i){!function(){function t(e){this.configspace=[80,0,24,0,1,0,0,0],this.deviceid=3,this.hostfeature=0,this.replybuffersize=0,this.replybuffer=new Uint8Array(8),this.Reset()}var r=e("cjs!../../messagehandler"),s=(e("cjs!../../utils"),e("cjs!./marshall")),a=0;t.prototype.Receive=function(e){},t.prototype.Reset=function(){},t.prototype.ReceiveRequest=function(e,t,i,n){if(r.Debug("Virtio console request of ringbuffer "+e+" "+t+" "+n.read+" "+n.write),1==e){for(var o="",c=0;c<n.read;c++)o+=String.fromCharCode(i());r.Debug("Write: "+o),this.replybuffersize=0,this.SendReply(e,t)}if(3==e){var h=s.Unmarshall2(["w","h","h"],i),u=h[0],d=h[1],f=h[2];switch(r.Debug("virtio console: "+u+" "+d+" "+f),d){case a:this.replybuffersize=0,this.SendReply(e,t);break;default:r.Debug("Error in virtio console: Unknown event"),r.Abort()}}},i.exports=t}()}),define("cjs!jor1k/worker/filesystem/tar",["require","exports","module","cjs!../messagehandler"],function(e,t,i){!function(){function t(e){this.fs=e,this.tarbuffer=new Uint8Array(512),this.tarbufferofs=0,this.tarmode=0,this.tarfileoffset=0}function r(e,t,i){for(var r="",s=0;s<i;s++){if(e[t+s]<32)return r;r+=String.fromCharCode(e[t+s])}return r}function s(e,t,i,r){for(var s=Math.min(r,e.length+1),a=0;a<s;a++)t[i+a]=e.charCodeAt(a);t[i+s-1]=0}var a=e("cjs!../messagehandler"),n=61440,o=40960,c=32768,h=16384;t.prototype.Unpack=function(e){if(this.tarbuffer[this.tarbufferofs++]=e,512==this.tarbufferofs){if(this.tarbufferofs=0,1==this.tarmode){for(var t=Math.min(512,this.tarfilebuffer.length-this.tarfileoffset),i=0;i<t;i++)this.tarfilebuffer[this.tarfileoffset++]=this.tarbuffer[i];return void(this.tarfileoffset>=this.tarfilebuffer.length&&(this.tarmode=0))}var s=r(this.tarbuffer,257,5);if("ustar"==s){var a=String.fromCharCode(this.tarbuffer[156]),n=r(this.tarbuffer,0,100),u=n.split("/"),t=u.length;0==u[t-1].length&&u.pop();for(var t=u.length,d=0,f=-1,i=0;i<t-1;i++){if(f=this.fs.Search(d,u[i]),f==-1)throw"Error in untar: Could not find inode.";d=f}if(f=this.fs.Search(d,u[u.length-1]),f==-1&&!(f!=-1&&"5"!=a||f!=-1&&"5"==a)){var l=this.fs.CreateInode();l.name=u[t-1],l.parentid=d,l.mode=parseInt(r(this.tarbuffer,100,8),8),l.uid=parseInt(r(this.tarbuffer,108,8),8),l.gid=parseInt(r(this.tarbuffer,116,8),8),l.atime=parseInt(r(this.tarbuffer,136,12),8),l.ctime=this.atime,l.mtime=this.atime;var p=parseInt(r(this.tarbuffer,124,12),8);switch(a){case"5":l.mode|=h;break;case"0":if(l.mode|=c,l.data=new Uint8Array(p),l.size=p,0==p)break;this.tarmode=1,this.tarfileoffset=0,this.tarfilebuffer=l.data;break;case"1":l.mode|=o,l.symlink="/"+r(this.tarbuffer,157,100);break;case"2":l.mode|=o,l.symlink=r(this.tarbuffer,157,100)}this.fs.PushInode(l)}}}},t.prototype.Pack=function(e){a.Debug("tar: "+e);var t=this.fs.SearchPath(e).id;if(t==-1)return new Uint8Array(0);var i=[];this.fs.GetRecursiveList(t,i);for(var r=0,u=0;u<i.length;u++)switch(this.fs.inodes[i[u]].mode&n){case o:case h:r+=512;break;case c:r+=512,r+=this.fs.inodes[i[u]].size,511&r&&(r&=-512,r+=512)}a.Debug("tar: "+this.fs.GetFullPath(t)+" size: "+r+" files: "+i.length),a.Debug(i);for(var d=new Uint8Array(r),f=0,u=0;u<i.length;u++){var l=this.fs.inodes[i[u]],p=l.mode&n;if(p==o||p==h||p==c){switch(s("ustar ",d,f+257,8),s(this.fs.GetFullPath(i[u]),d,f+0,100),s("00000000000",d,f+124,12),s((4095&l.mode).toString(8),d,f+100,8),s(l.uid.toString(8),d,f+108,8),s(l.gid.toString(8),d,f+116,8),s(l.mtime.toString(8),d,f+136,12),d[f+148+0]=32,d[f+148+1]=32,d[f+148+2]=32,d[f+148+3]=32,d[f+148+4]=32,d[f+148+5]=32,d[f+148+6]=32,d[f+148+7]=32,p){case o:d[f+156]="2".charCodeAt(0),s(l.symlink,d,f+157,100);break;case h:d[f+156]="5".charCodeAt(0);break;case c:d[f+156]="0".charCodeAt(0),s(l.size.toString(8),d,f+124,12)}for(var b=0,v=0;v<512;v++)b+=d[f+v];if(s(b.toString(8),d,f+148,7),f+=512,p==c){for(var v=0;v<l.size;v++)d[f++]=l.data[v];511&f&&(f&=-512,f+=512)}}}return d},i.exports=t}()}),define("cjs!jor1k/worker/filesystem/fsloader",["require","exports","module","cjs!../messagehandler","cjs!../utils"],function(e,t,i){!function(){function t(e){this.fs=e}var r=e("cjs!../messagehandler"),s=e("cjs!../utils"),a=511,n=40960,o=32768,c=16384,h=2;t.prototype.HandleDirContents=function(e,t){for(var i in e){var s=e[i],u=this.fs.Search(t,s.name);if(u!=-1){if(!s.path&&!s.size){s.child&&this.HandleDirContents(s.child,u);continue}r.Debug("Overwriting non-directory!")}var d=this.fs.CreateInode();if(d.name=s.name,d.uid=0|s.uid,d.gid=0|s.gid,d.parentid=t,d.mode=parseInt(s.mode,8),s.path)d.mode=n|a,d.symlink=s.path,this.fs.PushInode(d);else if(s.size){s.lazy&&(d.lazy=s.lazy),d.mode|=o;var f=this.fs.inodes.length;d.status=h,d.compressed=!!s.c,d.size=0|s.size,this.fs.PushInode(d);var l=this.sysrootdir+(s.src?s.src:this.fs.GetFullPath(f));d.url=l,(s.load||this.fs.CheckEarlyload(this.fs.GetFullPath(f)))&&this.fs.LoadFile(f)}else d.mode|=c,d.updatedir=!0,this.fs.PushInode(d),s.child&&this.HandleDirContents(s.child,u!=-1?u:this.fs.inodes.length-1)}},t.prototype.OnJSONLoaded=function(e){var t=JSON.parse(e);this.sysrootdir=t.src,String(this.sysrootdir)!==this.sysrootdir&&r.Debug("No sysroot (src tag)!"),this.sysrootdir+="/",this.HandleDirContents(t.fs,0),r.Debug("processed "+this.fs.inodes.length+" inodes"),this.fs.Check()},t.prototype.LoadJSON=function(e){r.Debug("Load filesystem information from "+e),s.LoadTextResource(e,this.OnJSONLoaded.bind(this),function(e){throw e})},i.exports=t}()}),define("cjs!jor1k/worker/filesystem/lazyUint8Array",["require","exports","module","cjs!../messagehandler"],function(e,t,i){!function(){function t(){return this.lengthKnown||this.CacheLength(),this._length}function r(){return this.lengthKnown||this.CacheLength(),this._chunkSize}function s(e,i){this.fallbackLength=i,this.overlay=[],this.url=e,this.lengthKnown=!1,this.chunks=[],Object.defineProperty(this,"length",{get:t}),Object.defineProperty(this,"chunkSize",{get:r})}var a=e("cjs!../messagehandler");s.prototype.Set=function(e,t){e>this.length-1||e<0||(this.overlay[e]=t)},s.prototype.Get=function(e){if(!(e>this.length-1||e<0)){if("undefined"!=typeof this.overlay[e])return this.overlay[e];var t=e%this.chunkSize,i=e/this.chunkSize|0;return this.GetChunk(i)[t]}},s.prototype.DoXHR=function(e,t){e>t&&a.Error("Invalid range ("+e+", "+t+") or no bytes requested!"),t>this._length-1&&a.Error("Only "+this._length+" bytes available! programmer error!");var i=new XMLHttpRequest;if(i.open("GET",this.url,!1),this._length!==this._chunkSize&&i.setRequestHeader("Range","bytes="+e+"-"+t),i.responseType="arraybuffer",i.send(null),!(i.status>=200&&i.status<300||304===i.status))throw new Error("Couldn't load "+this.url+". Status: "+i.status);return new Uint8Array(i.response||[])},s.prototype.GetChunk=function(e){var t=e*this._chunkSize,i=(e+1)*this._chunkSize-1;return i=Math.min(i,this._length-1),"undefined"==typeof this.chunks[e]&&(this.chunks[e]=this.DoXHR(t,i)),this.chunks[e]},s.prototype.CacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",this.url+"?"+(new Date).getTime(),!1),e.send(null),!(e.status>=200&&e.status<300||304===e.status))throw new Error("Couldn't load "+this.url+". Status: "+e.status);this._length=Number(e.getResponseHeader("Content-length")),0===this._length&&(a.Warning("Server doesn't return Content-length, even though we have a cache defeating URL query-string appended"),this._length=this.fallbackLength),this._chunkSize=1048576;var t,i=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t;i||(this._chunkSize=this._length),this.lengthKnown=!0},i.exports=s}()}),define("cjs!jor1k/worker/filesystem/filesystem",["require","exports","module","cjs!./tar","cjs!./fsloader","cjs!../utils","cjs!../bzip2","cjs!../dev/virtio/marshall","cjs!../../lib/utf8","cjs!../messagehandler","cjs!./lazyUint8Array"],function(e,t,i){!function(){function t(){this.inodes=[],this.events=[],this.qidnumber=0,this.filesinloadingqueue=0,this.OnLoaded=function(){},this.tar=new r(this),this.fsloader=new s(this),this.userinfo=[],this.watchFiles={},this.watchDirectories={},h.Register("LoadFilesystem",this.LoadFilesystem.bind(this)),h.Register("MergeFile",this.MergeFile.bind(this)),h.Register("DeleteNode",this.DeleteNode.bind(this)),h.Register("DeleteDirContents",this.RecursiveDelete.bind(this)),h.Register("CreateDirectory",function(e){var t=this.SearchPath(e);t.id==-1&&t.parentid!=-1&&this.CreateDirectory(t.name,t.parentid)}.bind(this)),h.Register("Rename",function(e){var t=this.SearchPath(e.oldPath),i=this.SearchPath(e.newPath);if(t.id!=-1&&i.parentid!=-1)if(i.id==-1){if((this.inodes[i.parentid].mode&d)!=b)return;this.Rename(this.inodes[t.id].parentid,this.inodes[t.id].name,i.parentid,i.name)}else this.Rename(this.inodes[t.id].parentid,this.inodes[t.id].name,this.inodes[i.id].parentid,this.inodes[i.id].name)}.bind(this)),h.Register("WatchFile",function(e){this.watchFiles[e.name]=!0}.bind(this)),h.Register("WatchDirectory",function(e){this.watchDirectories[e.name]=!0}.bind(this)),h.Register("ReadFile",function(e){h.Send("ReadFile",this.ReadFile.bind(this)(e))}.bind(this)),h.Register("tar",function(e){h.Send("tar",this.tar.Pack(e))}.bind(this)),h.Register("sync",function(e){h.Send("sync",this.tar.Pack(e))}.bind(this)),this.CreateDirectory("",-1)}var r=e("cjs!./tar"),s=e("cjs!./fsloader"),a=e("cjs!../utils"),n=e("cjs!../bzip2"),o=e("cjs!../dev/virtio/marshall"),c=e("cjs!../../lib/utf8"),h=e("cjs!../messagehandler"),u=e("cjs!./lazyUint8Array"),d=61440,f=49152,l=40960,p=32768,b=16384,v=-1,m=0,k=2,g=3,R=4;t.prototype.LoadFilesystem=function(e){this.userinfo=e,this.fsloader.LoadJSON(this.userinfo.basefsURL),this.OnLoaded=function(){this.userinfo.extendedfsURL&&this.fsloader.LoadJSON(this.userinfo.extendedfsURL);for(var e=0;e<this.userinfo.lazyloadimages.length;e++)this.LoadImage(this.userinfo.lazyloadimages[e])}.bind(this)},t.prototype.AddEvent=function(e,t){var i=this.GetInode(e);return i.status==m?void t():void this.events.push({id:e,OnEvent:t})},t.prototype.HandleEvent=function(e){0==this.filesinloadingqueue&&(this.OnLoaded(),this.OnLoaded=function(){});for(var t=[],i=0;i<this.events.length;i++)this.events[i].id==e?this.events[i].OnEvent():t.push(this.events[i]);this.events=t},t.prototype.LoadImage=function(e){e&&a.LoadBinaryResource(e,function(e){var t=new Uint8Array(e);0!=e.byteLength&&n.simple(t,this.tar.Unpack.bind(this.tar))}.bind(this),function(t){h.Debug("Error: Could not load "+e+". Skipping.")}.bind(this))},t.prototype.CheckEarlyload=function(e){for(var t=0;t<this.userinfo.earlyload.length;t++)if(this.userinfo.earlyload[t]==e)return!0;return!1},t.prototype.AppendDateHack=function(e){if("home/user/.profile"==this.GetFullPath(e)){var t=this.inodes[e],i=new Date,r='\ndate -s "'+i.getUTCFullYear()+"-"+(i.getUTCMonth()+1)+"-"+i.getUTCDate()+" "+i.getUTCHours()+":"+i.getUTCMinutes()+":"+i.getUTCSeconds()+'" &>/dev/null\n',s=t.size;this.ChangeSize(e,s+r.length);for(var a=0;a<r.length;a++)t.data[a+s]=r.charCodeAt(a);
}},t.prototype.LoadFile=function(e){var t=this.inodes[e];if(t.status==k){if(t.status=g,this.filesinloadingqueue++,t.compressed){t.data=new Uint8Array(t.size);var i=function(e){return function(t){var i=this.GetInode(e),r=new Uint8Array(t),s=0;n.simple(r,function(e){i.data[s++]=e}.bind(this)),i.status=m,this.filesinloadingqueue--,this.HandleEvent(e)}.bind(this)}.bind(this)(e);return void a.LoadBinaryResource(t.url+".bz2",i,function(e){throw e})}if(t.lazy){h.Debug("Using lazy file for "+t.url),t.data=new u(t.url,t.size);var r=t.size;return t.size=t.data.length,r!=t.size&&h.Warning("Size wrong for lazy loaded file: "+t.name),t.status=m,this.filesinloadingqueue--,void this.HandleEvent(e)}var i=function(e){return function(t){var i=this.GetInode(e);i.data=new Uint8Array(t),i.size!=i.data.length&&h.Warning("Size wrong for uncompressed non-lazily loaded file: "+i.name),i.size=i.data.length,i.status=m,this.filesinloadingqueue--,this.HandleEvent(e)}.bind(this)}.bind(this)(e);a.LoadBinaryResource(t.url,i,function(e){throw e})}},t.prototype.PushInode=function(e){return e.parentid!=-1?(this.inodes.push(e),this.inodes[e.parentid].updatedir=!0,e.nextid=this.inodes[e.parentid].firstid,void(this.inodes[e.parentid].firstid=this.inodes.length-1)):0==this.inodes.length?void this.inodes.push(e):(h.Debug("Error in Filesystem: Pushed inode with name = "+e.name+" has no parent"),void h.Abort())},t.prototype.CreateInode=function(){return this.qidnumber++,{updatedir:!1,parentid:-1,firstid:-1,nextid:-1,status:0,name:"",size:0,uid:0,gid:0,ctime:Math.floor((new Date).getTime()/1e3),atime:Math.floor((new Date).getTime()/1e3),mtime:Math.floor((new Date).getTime()/1e3),major:0,minor:0,data:new Uint8Array(0),symlink:"",mode:493,qid:{type:0,version:0,path:this.qidnumber},url:"",compressed:!1}},t.prototype.CreateDirectory=function(e,t){var i=this.CreateInode();return i.name=e,i.parentid=t,i.mode=511|b,i.updatedir=!0,t>=0&&(i.uid=this.inodes[t].uid,i.gid=this.inodes[t].gid,i.mode=511&this.inodes[t].mode|b),i.qid.type=b>>8,this.PushInode(i),this.NotifyListeners(this.inodes.length-1,"newdir"),this.inodes.length-1},t.prototype.CreateFile=function(e,t){var i=this.CreateInode();return i.name=e,i.parentid=t,i.uid=this.inodes[t].uid,i.gid=this.inodes[t].gid,i.qid.type=p>>8,i.mode=438&this.inodes[t].mode|p,this.PushInode(i),this.NotifyListeners(this.inodes.length-1,"newfile"),this.inodes.length-1},t.prototype.CreateNode=function(e,t,i,r){var s=this.CreateInode();return s.name=e,s.parentid=t,s.major=i,s.minor=r,s.uid=this.inodes[t].uid,s.gid=this.inodes[t].gid,s.qid.type=f>>8,s.mode=438&this.inodes[t].mode,this.PushInode(s),this.inodes.length-1},t.prototype.CreateSymlink=function(e,t,i){var r=this.CreateInode();return r.name=e,r.parentid=t,r.uid=this.inodes[t].uid,r.gid=this.inodes[t].gid,r.qid.type=l>>8,r.symlink=i,r.mode=l,this.PushInode(r),this.inodes.length-1},t.prototype.CreateTextFile=function(e,t,i){var r=this.CreateFile(e,t),s=this.inodes[r];s.data=new Uint8Array(i.length),s.size=i.length;for(var a in i)s.data[a]=i.charCodeAt(a);return r},t.prototype.OpenInode=function(e,t){var i=this.GetInode(e);return(i.mode&d)==b&&this.FillDirectory(e),i.status==k?(this.LoadFile(e),!1):(".profile"==i.name&&this.AppendDateHack(e),!0)},t.prototype.CloseInode=function(e){var t=this.GetInode(e);t.status==R&&(t.status==v,t.data=new Uint8Array(0),t.size=0)},t.prototype.Rename=function(e,t,i,r){if(e==i&&t==r)return!0;var s=this.Search(e,t),a=this.GetFullPath(s);if(s==-1)return!1;var n=this.Search(i,r);n!=-1&&this.Unlink(n);var o=s,c=this.inodes[o];if(this.inodes[c.parentid].firstid==o)this.inodes[c.parentid].firstid=c.nextid;else{var u=this.FindPreviousID(o);u==-1&&(h.Debug("Error in Filesystem: Cannot find previous id of inode"),h.Abort()),this.inodes[u].nextid=c.nextid}return c.parentid=i,c.name=r,c.qid.version++,c.nextid=this.inodes[c.parentid].firstid,this.inodes[c.parentid].firstid=o,this.inodes[e].updatedir=!0,this.inodes[i].updatedir=!0,this.NotifyListeners(o,"rename",{oldpath:a}),!0},t.prototype.Write=function(e,t,i,r){this.NotifyListeners(e,"write");var s=this.inodes[e];if(s.data.length<t+i?(this.ChangeSize(e,Math.floor(3*(t+i)/2)),s.size=t+i):s.size<t+i&&(s.size=t+i),s.data instanceof Uint8Array)for(var a=0;a<i;a++)s.data[t+a]=r();else for(var a=0;a<i;a++)s.data.Set(t+a,r())},t.prototype.Search=function(e,t){for(var i=this.inodes[e].firstid;i!=-1;){if(this.inodes[i].parentid!=e&&h.Debug("Error in Filesystem: Found inode with wrong parent id"),this.inodes[i].name==t)return i;i=this.inodes[i].nextid}return-1},t.prototype.GetTotalSize=function(){for(var e=0,t=0;t<this.inodes.length;t++)e+=this.inodes[t].data.length;return e},t.prototype.GetFullPath=function(e){for(var t="";0!=e;)t="/"+this.inodes[e].name+t,e=this.inodes[e].parentid;return t.substring(1)},t.prototype.FindPreviousID=function(e){for(var t=this.GetInode(e),i=this.inodes[t.parentid].firstid;i!=-1;){if(this.inodes[i].nextid==e)return i;i=this.inodes[i].nextid}return i},t.prototype.Unlink=function(e){if(this.NotifyListeners(e,"delete"),0==e)return!1;var t=this.GetInode(e);if((t.mode&d)==b&&t.firstid!=-1)return!1;if(this.inodes[t.parentid].firstid==e)this.inodes[t.parentid].firstid=t.nextid;else{var i=this.FindPreviousID(e);i==-1&&(h.Debug("Error in Filesystem: Cannot find previous id of inode"),h.Abort()),this.inodes[i].nextid=t.nextid}return this.inodes[t.parentid].updatedir=!0,t.status=R,t.nextid=-1,t.firstid=-1,t.parentid=-1,!0},t.prototype.GetInode=function(e){return isNaN(e)?(h.Debug("Error in filesystem: id is not a number "),0):e<0||e>this.inodes.length?(h.Debug("Error in filesystem: Attempt to get inode with id "+e),0):this.inodes[e]},t.prototype.ChangeSize=function(e,t){var i=this.GetInode(e);if(t!=i.size){var r=new Uint8Array(t);i.size=t;for(var s=Math.min(i.data.length,i.size),a=0;a<s;a++)r[a]=this.ReadByte(i,a);i.data=r}},t.prototype.ReadByte=function(e,t){return e.data instanceof Uint8Array?e.data[t]:e.data.Get(t)},t.prototype.SearchPath=function(e){e=e.replace("//","/");var t=e.split("/"),i=t.length;0==t[i-1].length&&t.pop(),0==t[0].length&&t.shift();for(var i=t.length,r=0,s=-1,a=0;a<i;a++){if(s=this.Search(r,t[a]),s==-1)return a<i-1?{id:-1,parentid:-1,name:t[a]}:{id:-1,parentid:r,name:t[a]};r=s}return{id:s,parentid:r,name:t[a]}},t.prototype.GetRecursiveList=function(e,t){for(var i=this.inodes[e].firstid;i!=-1;)t.push(i),(this.inodes[i].mode&d)==b&&this.GetRecursiveList(i,t),i=this.inodes[i].nextid},t.prototype.ReadFile=function(e){var t=this.SearchPath(e.name);if(t.parentid!=-1)return t.id==-1?null:(e.data=this.inodes[t.id].data,e.size=this.inodes[t.id].size,e)},t.prototype.MergeFile=function(e){h.Debug("Merge path:"+e.name);var t=this.SearchPath(e.name);t.parentid!=-1&&(t.id==-1&&(t.id=this.CreateFile(t.name,t.parentid)),this.inodes[t.id].data=e.data,this.inodes[t.id].size=e.data.length)},t.prototype.RecursiveDelete=function(e){var t=[],i=this.SearchPath(e);if(i.parentid!=-1&&i.id!=-1){this.GetRecursiveList(i.id,t);for(var r=t.length-1;r>=0;r--)this.Unlink(t[r])}},t.prototype.DeleteNode=function(e){var t=this.SearchPath(e);if(t.parentid!=-1&&t.id!=-1){if((this.inodes[t.id].mode&d)==p)return void this.Unlink(t.id);if((this.inodes[t.id].mode&d)==b){var i=[];this.GetRecursiveList(t.id,i);for(var r=i.length-1;r>=0;r--)this.Unlink(i[r]);return void this.Unlink(t.id)}}},t.prototype.NotifyListeners=function(e,t,i){void 0==i&&(i={});var r=this.GetFullPath(e);1==this.watchFiles[r]&&"write"==t&&h.Send("WatchFileEvent",r);for(var s in this.watchDirectories)if(this.watchDirectories.hasOwnProperty(s)){var a=r.indexOf(s);0!=a&&1!=a||h.Send("WatchDirectoryEvent",{path:r,event:t,info:i})}},t.prototype.Check=function(){for(var e=1;e<this.inodes.length;e++)if(this.inodes[e].status!=v){this.inodes[e].nextid==e&&(h.Debug("Error in filesystem: file points to itself"),h.Abort());var t=this.GetInode(e);t.parentid<0&&h.Debug("Error in filesystem: negative parent id "+e);var i=t.name.length;0==i&&h.Debug("Error in filesystem: inode with no name and id "+e);for(var r in t.name){var s=t.name.charCodeAt(r);s<32&&h.Debug("Error in filesystem: Unallowed char in filename")}}},t.prototype.FillDirectory=function(e){var t=this.GetInode(e);if(t.updatedir){var i=t.parentid;i==-1&&(i=0);for(var r=0,s=this.inodes[e].firstid;s!=-1;)r+=24+c.UTF8Length(this.inodes[s].name),s=this.inodes[s].nextid;r+=25,r+=26,t.data=new Uint8Array(r),t.size=r;var a=0;a+=o.Marshall(["Q","d","b","s"],[this.inodes[e].qid,a+13+8+1+2+1,this.inodes[e].mode>>12,"."],t.data,a),a+=o.Marshall(["Q","d","b","s"],[this.inodes[i].qid,a+13+8+1+2+2,this.inodes[i].mode>>12,".."],t.data,a);for(var s=this.inodes[e].firstid;s!=-1;)a+=o.Marshall(["Q","d","b","s"],[this.inodes[s].qid,a+13+8+1+2+c.UTF8Length(this.inodes[s].name),this.inodes[s].mode>>12,this.inodes[s].name],t.data,a),s=this.inodes[s].nextid;t.updatedir=!1}},t.prototype.PrepareCAPs=function(e){var t=this.GetInode(e);return t.caps?t.caps.length:(t.caps=new Uint8Array(12),t.caps[0]=0,t.caps[1]=0,t.caps[2]=0,t.caps[3]=1,t.caps[4]=255,t.caps[5]=255,t.caps[6]=255,t.caps[7]=255,t.caps[8]=255,t.caps[9]=255,t.caps[10]=255,t.caps[11]=255,t.caps.length)},i.exports=t}()}),define("cjs!jor1k/worker/system",["require","exports","module","cjs!./messagehandler","cjs!./utils","cjs!./ram","cjs!./bzip2","cjs!./elf","cjs!./timer","cjs!./riscv/htif","cjs!./or1k","cjs!./riscv","cjs!./dev/uart","cjs!./dev/irq","cjs!./dev/timer","cjs!./dev/framebuffer","cjs!./dev/ethmac","cjs!./dev/ata","cjs!./dev/rtc","cjs!./dev/touchscreen","cjs!./dev/keyboard","cjs!./dev/sound","cjs!./dev/virtio","cjs!./dev/virtio/9p","cjs!./dev/virtio/dummy","cjs!./dev/virtio/input","cjs!./dev/virtio/net","cjs!./dev/virtio/block","cjs!./dev/virtio/gpu","cjs!./dev/virtio/console","cjs!./filesystem/filesystem"],function(e,t,i){!function(){function t(){r.Register("LoadAndStart",this.LoadImageAndStart.bind(this)),r.Register("execute",this.MainLoop.bind(this)),r.Register("Init",this.Init.bind(this)),r.Register("Reset",this.Reset.bind(this)),r.Register("ChangeCore",this.ChangeCPU.bind(this)),r.Register("PrintOnAbort",this.PrintState.bind(this)),r.Register("GetIPS",function(e){r.Send("GetIPS",this.ips),this.ips=0}.bind(this))}var r=e("cjs!./messagehandler"),s=e("cjs!./utils"),a=e("cjs!./ram"),n=e("cjs!./bzip2"),o=e("cjs!./elf"),c=e("cjs!./timer"),h=e("cjs!./riscv/htif"),u=e("cjs!./or1k"),d=e("cjs!./riscv"),f=e("cjs!./dev/uart"),l=e("cjs!./dev/irq"),p=e("cjs!./dev/timer"),b=e("cjs!./dev/framebuffer"),v=e("cjs!./dev/ethmac"),m=e("cjs!./dev/ata"),k=e("cjs!./dev/rtc"),g=e("cjs!./dev/touchscreen"),R=e("cjs!./dev/keyboard"),y=e("cjs!./dev/sound"),w=e("cjs!./dev/virtio"),S=e("cjs!./dev/virtio/9p"),T=e("cjs!./dev/virtio/dummy"),D=e("cjs!./dev/virtio/input"),x=e("cjs!./dev/virtio/net"),E=e("cjs!./dev/virtio/block"),I=e("cjs!./dev/virtio/gpu"),A=e("cjs!./dev/virtio/console"),C=e("cjs!./filesystem/filesystem"),j=1,M=2,_=3;t.prototype.CreateCPU=function(e,t){try{if("or1k"==t)this.cpu=new u(e,this.ram,this.heap,this.ncores);else{if("riscv"!=t)throw"Architecture "+t+" not supported";this.cpu=new d(e,this.ram,this.htif,this.heap,this.ncores)}}catch(i){r.Debug("Error: failed to create CPU:"+i)}},t.prototype.ChangeCPU=function(e){this.cpu.switchImplementation(e)},t.prototype.Reset=function(){this.status=M;for(var e=0;e<this.devices.length;e++)this.devices[e].Reset();this.ips=0},t.prototype.Init=function(e){this.status=M,this.memorysize=e.memorysize,this.ncores=e.ncores,e.ncores||(e.ncores=1);var t=1048576;this.heap=new ArrayBuffer(1048576*this.memorysize),this.memorysize--,this.ram=new a(this.heap,t),"riscv"==e.arch&&(this.htif=new h(this.ram,this)),this.CreateCPU(e.cpu,e.arch),this.devices=[],this.devices.push(this.cpu),"or1k"==e.arch?(this.irqdev=new l(this),this.timerdev=new p,this.uartdev0=new f(0,this,2),this.uartdev1=new f(1,this,3),this.ethdev=new v(this.ram,this),this.ethdev.TransmitCallback=function(e){r.Send("ethmac",e)},this.fbdev=new b(this.ram),this.atadev=new m(this),this.tsdev=new g(this),this.kbddev=new R(this),this.snddev=new y(this,this.ram),this.rtcdev=new k(this),this.filesystem=new C,this.virtio9pdev=new S(this.ram,this.filesystem),this.virtiodev1=new w(this,6,this.ram,this.virtio9pdev),this.virtioinputdev=new D(this.ram),this.virtionetdev=new x(this.ram),this.virtioblockdev=new E(this.ram),this.virtiodummydev=new T(this.ram),this.virtiogpudev=new I(this.ram),this.virtioconsoledev=new A(this.ram),this.virtiodev2=new w(this,11,this.ram,this.virtiodummydev),this.virtiodev3=new w(this,12,this.ram,this.virtiodummydev),this.devices.push(this.irqdev),this.devices.push(this.timerdev),this.devices.push(this.uartdev0),this.devices.push(this.uartdev1),this.devices.push(this.ethdev),this.devices.push(this.fbdev),this.devices.push(this.atadev),this.devices.push(this.tsdev),this.devices.push(this.kbddev),this.devices.push(this.snddev),this.devices.push(this.rtcdev),this.devices.push(this.virtio9pdev),this.devices.push(this.virtiodev1),this.devices.push(this.virtiodev2),this.devices.push(this.virtiodev3),this.devices.push(this.virtioinputdev),this.devices.push(this.virtionetdev),this.devices.push(this.virtioblockdev),this.devices.push(this.virtiodummydev),this.devices.push(this.virtiogpudev),this.devices.push(this.virtioconsoledev),this.ram.AddDevice(this.uartdev0,2415919104,7),this.ram.AddDevice(this.fbdev,2432696320,4096),this.ram.AddDevice(this.ethdev,2449473536,4096),this.ram.AddDevice(this.tsdev,2466250752,4096),this.ram.AddDevice(this.kbddev,2483027968,256),this.ram.AddDevice(this.uartdev1,2516582400,7),this.ram.AddDevice(this.virtiodev1,2533359616,4096),this.ram.AddDevice(this.snddev,2550136832,1024),this.ram.AddDevice(this.rtcdev,2566914048,4096),this.ram.AddDevice(this.irqdev,2583691264,4096),this.ram.AddDevice(this.timerdev,2600468480,4096),this.ram.AddDevice(this.virtiodev2,2617245696,4096),this.ram.AddDevice(this.virtiodev3,2634022912,4096),this.ram.AddDevice(this.atadev,2650800128,4096)):"riscv"==e.arch&&(this.uartdev0=new f(0,this,2),this.devices.push(this.uartdev0),this.ram.AddDevice(this.uartdev0,2415919104,7)),this.ips=0,this.idletime=0,this.idlemaxwait=0,this.ticksperms=2e4,this.loopspersecond=100,this.timer=new c(this.ticksperms,this.loopspersecond)},t.prototype.RaiseInterrupt=function(e){if(this.cpu.RaiseInterrupt(e,-1),this.status==_){this.status=j,clearTimeout(this.idletimeouthandle);var t=(s.GetMilliseconds()-this.idletime)*this.ticksperms;t>this.idlemaxwait&&(t=this.idlemaxwait),this.cpu.ProgressTime(t),this.MainLoop()}},t.prototype.ClearInterrupt=function(e){this.cpu.ClearInterrupt(e,-1)},t.prototype.RaiseSoftInterrupt=function(e,t){this.cpu.RaiseInterrupt(e,t)},t.prototype.ClearSoftInterrupt=function(e,t){this.cpu.ClearInterrupt(e,t)},t.prototype.PrintState=function(){this.uartdev0&&this.uartdev0.Step(),this.uartdev1&&this.uartdev1.Step(),r.Debug(this.cpu.toString())},t.prototype.SendStringToTerminal=function(e){for(var t=[],i=0;i<e.length;i++)t.push(e.charCodeAt(i));r.Send("tty0",t)},t.prototype.LoadImageAndStart=function(e){this.SendStringToTerminal("\r================================================================================"),"string"==typeof e?(this.SendStringToTerminal("\r\nLoading kernel and hard and basic file system from web server. Please wait ...\r\n"),s.LoadBinaryResource(e,this.OnKernelLoaded.bind(this),function(e){throw e})):this.OnKernelLoaded(e)},t.prototype.PatchKernel=function(e){for(var t=this.ram.uint8mem,i=0;i<e;i++)109===t[i+0]&&101===t[i+1]&&109===t[i+2]&&111===t[i+3]&&114===t[i+4]&&121===t[i+5]&&0===t[i+6]&&1===t[i+24]&&240===t[i+25]&&0===t[i+26]&&0===t[i+27]&&(t[i+24]=1048576*this.memorysize>>24,t[i+25]=1048576*this.memorysize>>16,t[i+26]=0,t[i+27]=0)},t.prototype.OnKernelLoaded=function(e){this.SendStringToTerminal("Decompressing kernel...\r\n");var t=new Uint8Array(e),i=0;if(o.IsELF(t))o.Extract(t,this.ram.uint8mem);else if(n.IsBZIP2(t)){if(n.simple(t,function(e){this.ram.uint8mem[i++]=e}.bind(this)),o.IsELF(this.ram.uint8mem)){for(var s=new Uint8Array(i),a=0;a<i;a++)s[a]=this.ram.uint8mem[a];o.Extract(s,this.ram.uint8mem)}}else{i=t.length;for(var a=0;a<i;a++)this.ram.uint8mem[a]=t[a]}this.PatchKernel(i),0==this.cpu.littleendian&&this.ram.Little2Big(i),r.Debug("Kernel loaded: "+i+" bytes"),this.SendStringToTerminal("Booting\r\n"),this.SendStringToTerminal("================================================================================"),this.cpu.Reset(),this.cpu.AnalyzeImage(),r.Debug("Starting emulation"),this.status=j,r.Send("execute",0)},t.prototype.HandleHalt=function(){var e=this.cpu.GetTimeToNextInterrupt();if(e!=-1){this.idlemaxwait=e;var t=Math.floor(e/this.ticksperms/this.timer.correction+.5);t<=1||(t>1e3&&r.Debug("Warning: idle for "+t+"ms"),this.idletime=s.GetMilliseconds(),this.status=_,this.idletimeouthandle=setTimeout(function(){this.status==_&&(this.status=j,this.cpu.ProgressTime(e),this.MainLoop())}.bind(this),t))}},t.prototype.MainLoop=function(){if(this.status==j){r.Send("execute",0);var e=this.cpu.Step(this.timer.instructionsperloop,this.timer.timercyclesperinstruction),t=this.timer.instructionsperloop-e;t++,this.ips+=t,this.uartdev0&&this.uartdev0.Step(),this.uartdev1&&this.uartdev1.Step();var i=!!e;this.timer.Update(t,this.cpu.GetTicks(),i),i&&this.HandleHalt()}},i.exports=t}()}),define("cjs!jor1k/worker/worker",["require","exports","module","cjs!./messagehandler","cjs!./system"],function(e,t,i){!function(){var t=e("cjs!./messagehandler"),i=e("cjs!./system");new i,t.Send("WorkerReady",0)}()}),require.config({baseUrl:".",paths:{text:"bower_modules/requirejs-text/text",cjs:"bower_modules/cjs/cjs","amd-loader":"bower_modules/amd-loader/amd-loader",bootstrap:"bower_modules/bootstrap-sass/assets/javascripts/bootstrap.min",modernizr:"bower_modules/modernizr/modernizr",crossroads:"bower_modules/crossroads/dist/crossroads.min",hasher:"bower_modules/hasher/dist/js/hasher.min",jquery:"bower_modules/jquery/dist/jquery",knockout:"bower_modules/knockout/dist/knockout","knockout-projections":"bower_modules/knockout-projections/dist/knockout-projections",signals:"bower_modules/js-signals/dist/signals.min",marked:"bower_modules/marked/marked.min",videojs:"bower_modules/videojs/dist/video.min","jquery-ui":"bower_modules/jquery-ui/jquery-ui.min","jquery-ui-layout":"bower_modules/jquery-ui-layout/source/stable/jquery.layout_and_plugins.min","jquery-fullscreen":"bower_modules/jquery-fullscreen/jquery.fullscreen-min","jquery-notific8":"bower_modules/jquery-notific8/dist/jquery.notific8.min",ace:"bower_modules/ace/lib/ace","typeahead-jquery":"bower_modules/typeahead.js/dist/typeahead.jquery.min",bloodhound:"bower_modules/typeahead.js/dist/bloodhound.min",FileSaver:"bower_modules/FileSaver/FileSaver.min",Blob:"bower_modules/Blob/Blob","bootstrap-contextmenu":"bower_modules/bootstrap-contextmenu/bootstrap-contextmenu",bootbox:"bower_modules/bootbox.js/bootbox","github-api":"bower_modules/github-api/github",jszip:"bower_modules/jszip/dist/jszip.min","app/config":"app/config/config.dev","js-base64":"app/github-int/github-base64",xmlhttprequest:"app/github-int/github-xmlhttpreq"},shim:{"github-api":{},bootstrap:{deps:["jquery"]},"jquery-ui":{deps:["jquery"]},"jquery-ui-layout":{deps:["jquery","jquery-ui"]},"jquery-fullscreen":{deps:["jquery"]},"typeahead-jquery":{deps:["jquery"]},bootbox:{deps:["jquery"]},"bootstrap-contextmenu":{deps:["bootstrap"]}},packages:[{name:"jor1k",location:"bower_modules/jor1k/js"}],map:{"jor1k/worker/system":{"jor1k/worker/or1k":"jor1k/worker/or1k/index","jor1k/worker/or1k/index":"jor1k/worker/or1k/index","jor1k/worker/riscv":"jor1k/worker/riscv/index","jor1k/worker/riscv/index":"jor1k/worker/riscv/index","jor1k/worker/riscv/htif":"jor1k/worker/riscv/htif"}}}),define("app/require.config",function(){}),require(["cjs!jor1k/worker/worker"]),require.config({bundles:{}});