8bitworkshop/gen/arm32-IVL2WI33.js

10 lines
65 KiB
JavaScript

import{H as lr,q as Cr}from"./chunk-ULPRULB6.js";import{E as Fr,J as hr,T as Z,W as I,X as fr,Z as mr,a as z,aa as tr,g as _}from"./chunk-RXF2JDJ3.js";import{a as nr,b as or}from"./chunk-WAARL7ET.js";var d;(function(o){o[o.MODE_ARM=0]="MODE_ARM",o[o.MODE_THUMB=1]="MODE_THUMB",o[o.MODE_USER=16]="MODE_USER",o[o.MODE_FIQ=17]="MODE_FIQ",o[o.MODE_IRQ=18]="MODE_IRQ",o[o.MODE_SUPERVISOR=19]="MODE_SUPERVISOR",o[o.MODE_ABORT=23]="MODE_ABORT",o[o.MODE_UNDEFINED=27]="MODE_UNDEFINED",o[o.MODE_SYSTEM=31]="MODE_SYSTEM"})(d||(d={}));var u;(function(s){s[s.SP=13]="SP",s[s.LR=14]="LR",s[s.PC=15]="PC"})(u||(u={}));var k;(function(x){x[x.BANK_NONE=0]="BANK_NONE",x[x.BANK_FIQ=1]="BANK_FIQ",x[x.BANK_IRQ=2]="BANK_IRQ",x[x.BANK_SUPERVISOR=3]="BANK_SUPERVISOR",x[x.BANK_ABORT=4]="BANK_ABORT",x[x.BANK_UNDEFINED=5]="BANK_UNDEFINED",x[x.WORD_SIZE_ARM=4]="WORD_SIZE_ARM",x[x.WORD_SIZE_THUMB=2]="WORD_SIZE_THUMB",x[x.BASE_RESET=0]="BASE_RESET",x[x.BASE_UNDEF=4]="BASE_UNDEF",x[x.BASE_SWI=8]="BASE_SWI",x[x.BASE_PABT=12]="BASE_PABT",x[x.BASE_DABT=16]="BASE_DABT",x[x.BASE_IRQ=24]="BASE_IRQ",x[x.BASE_FIQ=28]="BASE_FIQ"})(k||(k={}));var vr=4026531840,xr=223,Er=32;function F(t){this.cpu=t,this.addressingMode23Immediate=[function(r,i,s){var e=t.gprs,a=function(){var c=e[r];return(!s||s())&&(e[r]-=i),c};return a.writesPC=r==15,a},null,null,null,function(r,i,s){var e=t.gprs,a=function(){var c=e[r];return(!s||s())&&(e[r]+=i),c};return a.writesPC=r==15,a},null,null,null,function(r,i,s){var e=t.gprs,a=function(){return e[r]-i};return a.writesPC=!1,a},function(r,i,s){var e=t.gprs,a=function(){var c=e[r]-i;return(!s||s())&&(e[r]=c),c};return a.writesPC=r==15,a},null,null,function(r,i,s){var e=t.gprs,a=function(){return e[r]+i};return a.writesPC=!1,a},function(r,i,s){var e=t.gprs,a=function(){var c=e[r]+i;return(!s||s())&&(e[r]=c),c};return a.writesPC=r==15,a},null,null],this.addressingMode23Register=[function(r,i,s){var e=t.gprs,a=function(){var c=e[r];return(!s||s())&&(e[r]-=e[i]),c};return a.writesPC=r==15,a},null,null,null,function(r,i,s){var e=t.gprs,a=function(){var c=e[r];return(!s||s())&&(e[r]+=e[i]),c};return a.writesPC=r==15,a},null,null,null,function(r,i,s){var e=t.gprs,a=function(){return e[r]-e[i]};return a.writesPC=!1,a},function(r,i,s){var e=t.gprs,a=function(){var c=e[r]-e[i];return(!s||s())&&(e[r]=c),c};return a.writesPC=r==15,a},null,null,function(r,i,s){var e=t.gprs,a=function(){var c=e[r]+e[i];return c};return a.writesPC=!1,a},function(r,i,s){var e=t.gprs,a=function(){var c=e[r]+e[i];return(!s||s())&&(e[r]=c),c};return a.writesPC=r==15,a},null,null],this.addressingMode2RegisterShifted=[function(r,i,s){var e=t.gprs,a=function(){var c=e[r];return(!s||s())&&(i(),e[r]-=t.shifterOperand),c};return a.writesPC=r==15,a},null,null,null,function(r,i,s){var e=t.gprs,a=function(){var c=e[r];return(!s||s())&&(i(),e[r]+=t.shifterOperand),c};return a.writesPC=r==15,a},null,null,null,function(r,i,s){var e=t.gprs,a=function(){return i(),e[r]-t.shifterOperand};return a.writesPC=!1,a},function(r,i,s){var e=t.gprs,a=function(){i();var c=e[r]-t.shifterOperand;return(!s||s())&&(e[r]=c),c};return a.writesPC=r==15,a},null,null,function(r,i,s){var e=t.gprs,a=function(){return i(),e[r]+t.shifterOperand};return a.writesPC=!1,a},function(r,i,s){var e=t.gprs,a=function(){i();var c=e[r]+t.shifterOperand;return(!s||s())&&(e[r]=c),c};return a.writesPC=r==15,a},null,null]}F.prototype.constructAddressingMode1ASR=function(t,r){var i=this.cpu,s=i.gprs;return function(){++i.cycles;var e=s[t];t==15&&(e+=4),e&=255;var a=s[r];r==15&&(a+=4),e==0?(i.shifterOperand=a,i.shifterCarryOut=i.cpsrC):e<32?(i.shifterOperand=a>>e,i.shifterCarryOut=a&1<<e-1):s[r]>>31?(i.shifterOperand=4294967295,i.shifterCarryOut=2147483648):(i.shifterOperand=0,i.shifterCarryOut=0)}};F.prototype.constructAddressingMode1Immediate=function(t){var r=this.cpu;return function(){r.shifterOperand=t,r.shifterCarryOut=r.cpsrC}};F.prototype.constructAddressingMode1ImmediateRotate=function(t,r){var i=this.cpu;return function(){i.shifterOperand=t>>>r|t<<32-r,i.shifterCarryOut=i.shifterOperand>>31}};F.prototype.constructAddressingMode1LSL=function(t,r){var i=this.cpu,s=i.gprs;return function(){++i.cycles;var e=s[t];t==15&&(e+=4),e&=255;var a=s[r];r==15&&(a+=4),e==0?(i.shifterOperand=a,i.shifterCarryOut=i.cpsrC):e<32?(i.shifterOperand=a<<e,i.shifterCarryOut=a&1<<32-e):e==32?(i.shifterOperand=0,i.shifterCarryOut=a&1):(i.shifterOperand=0,i.shifterCarryOut=0)}};F.prototype.constructAddressingMode1LSR=function(t,r){var i=this.cpu,s=i.gprs;return function(){++i.cycles;var e=s[t];t==15&&(e+=4),e&=255;var a=s[r];r==15&&(a+=4),e==0?(i.shifterOperand=a,i.shifterCarryOut=i.cpsrC):e<32?(i.shifterOperand=a>>>e,i.shifterCarryOut=a&1<<e-1):e==32?(i.shifterOperand=0,i.shifterCarryOut=a>>31):(i.shifterOperand=0,i.shifterCarryOut=0)}};F.prototype.constructAddressingMode1ROR=function(t,r){var i=this.cpu,s=i.gprs;return function(){++i.cycles;var e=s[t];t==15&&(e+=4),e&=255;var a=s[r];r==15&&(a+=4);var c=e&31;e==0?(i.shifterOperand=a,i.shifterCarryOut=i.cpsrC):c?(i.shifterOperand=s[r]>>>c|s[r]<<32-c,i.shifterCarryOut=a&1<<c-1):(i.shifterOperand=a,i.shifterCarryOut=a>>31)}};F.prototype.constructAddressingMode23Immediate=function(t,r,i){var s=(t&983040)>>16;return this.addressingMode23Immediate[(t&27262976)>>21](s,r,i)};F.prototype.constructAddressingMode23Register=function(t,r,i){var s=(t&983040)>>16;return this.addressingMode23Register[(t&27262976)>>21](s,r,i)};F.prototype.constructAddressingMode2RegisterShifted=function(t,r,i){var s=(t&983040)>>16;return this.addressingMode2RegisterShifted[(t&27262976)>>21](s,r,i)};F.prototype.constructAddressingMode4=function(t,r){var i=this.cpu,s=i.gprs;return function(){var e=s[r]+t;return e}};F.prototype.constructAddressingMode4Writeback=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(c){var p=a[i]+t;return c&&s&&e.mmu.store32(a[i]+t-4,a[i]),a[i]+=r,p}};F.prototype.constructNOP=function(){return this.writesPC=!1,function(){}};F.prototype.constructADC=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){if(e.mmu.waitPrefetch32(a[15]),!(s&&!s())){i();var c=(e.shifterOperand>>>0)+(e.cpsrC?1:0);a[t]=(a[r]>>>0)+c}}};F.prototype.constructADCS=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){if(e.mmu.waitPrefetch32(a[15]),!(s&&!s())){i();var c=(e.shifterOperand>>>0)+(e.cpsrC?1:0),p=(a[r]>>>0)+c;t==15&&e.hasSPSR()?e.unpackCPSR(e.spsr):(e.cpsrN=p>>31,e.cpsrZ=!(p&4294967295),e.cpsrC=p>4294967295,e.cpsrV=a[r]>>31==c>>31&&a[r]>>31!=p>>31&&c>>31!=p>>31),a[t]=p}}};F.prototype.constructADD=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){e.mmu.waitPrefetch32(a[15]),!(s&&!s())&&(i(),a[t]=(a[r]>>>0)+(e.shifterOperand>>>0))}};F.prototype.constructADDS=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){if(e.mmu.waitPrefetch32(a[15]),!(s&&!s())){i();var c=(a[r]>>>0)+(e.shifterOperand>>>0);t==15&&e.hasSPSR()?e.unpackCPSR(e.spsr):(e.cpsrN=c>>31,e.cpsrZ=!(c&4294967295),e.cpsrC=c>4294967295,e.cpsrV=a[r]>>31==e.shifterOperand>>31&&a[r]>>31!=c>>31&&e.shifterOperand>>31!=c>>31),a[t]=c}}};F.prototype.constructAND=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){e.mmu.waitPrefetch32(a[15]),!(s&&!s())&&(i(),a[t]=a[r]&e.shifterOperand)}};F.prototype.constructANDS=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){e.mmu.waitPrefetch32(a[15]),!(s&&!s())&&(i(),a[t]=a[r]&e.shifterOperand,t==15&&e.hasSPSR()?e.unpackCPSR(e.spsr):(e.cpsrN=a[t]>>31,e.cpsrZ=!(a[t]&4294967295),e.cpsrC=e.shifterCarryOut))}};F.prototype.constructB=function(t,r){var i=this.cpu,s=i.gprs;return function(){if(r&&!r()){i.mmu.waitPrefetch32(s[15]);return}i.mmu.waitPrefetch32(s[15]),s[15]+=t}};F.prototype.constructBIC=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){e.mmu.waitPrefetch32(a[15]),!(s&&!s())&&(i(),a[t]=a[r]&~e.shifterOperand)}};F.prototype.constructBICS=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){e.mmu.waitPrefetch32(a[15]),!(s&&!s())&&(i(),a[t]=a[r]&~e.shifterOperand,t==15&&e.hasSPSR()?e.unpackCPSR(e.spsr):(e.cpsrN=a[t]>>31,e.cpsrZ=!(a[t]&4294967295),e.cpsrC=e.shifterCarryOut))}};F.prototype.constructBL=function(t,r){var i=this.cpu,s=i.gprs;return function(){if(r&&!r()){i.mmu.waitPrefetch32(s[15]);return}i.mmu.waitPrefetch32(s[15]),s[14]=s[15]-4,s[15]+=t}};F.prototype.constructBX=function(t,r){var i=this.cpu,s=i.gprs;return function(){if(r&&!r()){i.mmu.waitPrefetch32(s[15]);return}i.mmu.waitPrefetch32(s[15]),i.switchExecMode(s[t]&1),s[15]=s[t]&4294967294}};F.prototype.constructCMN=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){if(e.mmu.waitPrefetch32(a[15]),!(s&&!s())){i();var c=(a[r]>>>0)+(e.shifterOperand>>>0);e.cpsrN=c>>31,e.cpsrZ=!(c&4294967295),e.cpsrC=c>4294967295,e.cpsrV=a[r]>>31==e.shifterOperand>>31&&a[r]>>31!=c>>31&&e.shifterOperand>>31!=c>>31}}};F.prototype.constructCMP=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){if(e.mmu.waitPrefetch32(a[15]),!(s&&!s())){i();var c=a[r]-e.shifterOperand;e.cpsrN=c>>31,e.cpsrZ=!(c&4294967295),e.cpsrC=a[r]>>>0>=e.shifterOperand>>>0,e.cpsrV=a[r]>>31!=e.shifterOperand>>31&&a[r]>>31!=c>>31}}};F.prototype.constructEOR=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){e.mmu.waitPrefetch32(a[15]),!(s&&!s())&&(i(),a[t]=a[r]^e.shifterOperand)}};F.prototype.constructEORS=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){e.mmu.waitPrefetch32(a[15]),!(s&&!s())&&(i(),a[t]=a[r]^e.shifterOperand,t==15&&e.hasSPSR()?e.unpackCPSR(e.spsr):(e.cpsrN=a[t]>>31,e.cpsrZ=!(a[t]&4294967295),e.cpsrC=e.shifterCarryOut))}};F.prototype.constructLDM=function(t,r,i){var s=this.cpu,e=s.gprs,a=s.mmu;return function(){if(a.waitPrefetch32(e[15]),!(i&&!i())){var c=r(!1),p=0,n,o;for(n=t,o=0;n;n>>=1,++o)n&1&&(e[o]=a.load32(c&4294967292),c+=4,++p);a.waitMulti32(c,p),++s.cycles}}};F.prototype.constructLDMS=function(t,r,i){var s=this.cpu,e=s.gprs,a=s.mmu;return function(){if(a.waitPrefetch32(e[15]),!(i&&!i())){var c=r(!1),p=0,n=s.mode;s.switchMode(31);var o,l;for(o=t,l=0;o;o>>=1,++l)o&1&&(e[l]=a.load32(c&4294967292),c+=4,++p);s.switchMode(n),a.waitMulti32(c,p),++s.cycles}}};F.prototype.constructLDR=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){if(s.mmu.waitPrefetch32(e[15]),!(i&&!i())){var a=r();e[t]=s.mmu.load32(a),s.mmu.wait32(a),++s.cycles}}};F.prototype.constructLDRB=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){if(s.mmu.waitPrefetch32(e[15]),!(i&&!i())){var a=r();e[t]=s.mmu.loadU8(a),s.mmu.wait(a),++s.cycles}}};F.prototype.constructLDRH=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){if(s.mmu.waitPrefetch32(e[15]),!(i&&!i())){var a=r();e[t]=s.mmu.loadU16(a),s.mmu.wait(a),++s.cycles}}};F.prototype.constructLDRSB=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){if(s.mmu.waitPrefetch32(e[15]),!(i&&!i())){var a=r();e[t]=s.mmu.load8(a),s.mmu.wait(a),++s.cycles}}};F.prototype.constructLDRSH=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){if(s.mmu.waitPrefetch32(e[15]),!(i&&!i())){var a=r();e[t]=s.mmu.load16(a),s.mmu.wait(a),++s.cycles}}};F.prototype.constructMLA=function(t,r,i,s,e){var a=this.cpu,c=a.gprs;return function(){if(a.mmu.waitPrefetch32(c[15]),!(e&&!e()))if(++a.cycles,a.mmu.waitMul(i),c[s]&4294901760&&c[i]&4294901760){var p=(c[s]&4294901760)*c[i]&4294967295,n=(c[s]&65535)*c[i]&4294967295;c[t]=p+n+c[r]&4294967295}else c[t]=c[s]*c[i]+c[r]}};F.prototype.constructMLAS=function(t,r,i,s,e){var a=this.cpu,c=a.gprs;return function(){if(a.mmu.waitPrefetch32(c[15]),!(e&&!e())){if(++a.cycles,a.mmu.waitMul(i),c[s]&4294901760&&c[i]&4294901760){var p=(c[s]&4294901760)*c[i]&4294967295,n=(c[s]&65535)*c[i]&4294967295;c[t]=p+n+c[r]&4294967295}else c[t]=c[s]*c[i]+c[r];a.cpsrN=c[t]>>31,a.cpsrZ=!(c[t]&4294967295)}}};F.prototype.constructMOV=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){e.mmu.waitPrefetch32(a[15]),!(s&&!s())&&(i(),a[t]=e.shifterOperand)}};F.prototype.constructMOVS=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){e.mmu.waitPrefetch32(a[15]),!(s&&!s())&&(i(),a[t]=e.shifterOperand,t==15&&e.hasSPSR()?e.unpackCPSR(e.spsr):(e.cpsrN=a[t]>>31,e.cpsrZ=!(a[t]&4294967295),e.cpsrC=e.shifterCarryOut))}};F.prototype.constructMRS=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){s.mmu.waitPrefetch32(e[15]),!(i&&!i())&&(r?e[t]=s.spsr:e[t]=s.packCPSR())}};F.prototype.constructMSR=function(t,r,i,s,e){var a=this.cpu,c=a.gprs,p=i&65536,n=i&524288;return function(){if(a.mmu.waitPrefetch32(c[15]),!(e&&!e())){var o;i&33554432?o=s:o=c[t];var l=(p?255:0)|(n?4278190080:0);r?(l&=vr|xr|Er,a.spsr=a.spsr&~l|o&l):(l&vr&&(a.cpsrN=o>>31,a.cpsrZ=o&1073741824,a.cpsrC=o&536870912,a.cpsrV=o&268435456),a.mode!=16&&l&xr&&(a.switchMode(o&15|16),a.cpsrI=o&128,a.cpsrF=o&64))}}};F.prototype.constructMUL=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){if(e.mmu.waitPrefetch32(a[15]),!(s&&!s()))if(e.mmu.waitMul(a[r]),a[i]&4294901760&&a[r]&4294901760){var c=(a[i]&4294901760)*a[r]|0,p=(a[i]&65535)*a[r]|0;a[t]=c+p}else a[t]=a[i]*a[r]}};F.prototype.constructMULS=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){if(e.mmu.waitPrefetch32(a[15]),!(s&&!s())){if(e.mmu.waitMul(a[r]),a[i]&4294901760&&a[r]&4294901760){var c=(a[i]&4294901760)*a[r]|0,p=(a[i]&65535)*a[r]|0;a[t]=c+p}else a[t]=a[i]*a[r];e.cpsrN=a[t]>>31,e.cpsrZ=!(a[t]&4294967295)}}};F.prototype.constructMVN=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){e.mmu.waitPrefetch32(a[15]),!(s&&!s())&&(i(),a[t]=~e.shifterOperand)}};F.prototype.constructMVNS=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){e.mmu.waitPrefetch32(a[15]),!(s&&!s())&&(i(),a[t]=~e.shifterOperand,t==15&&e.hasSPSR()?e.unpackCPSR(e.spsr):(e.cpsrN=a[t]>>31,e.cpsrZ=!(a[t]&4294967295),e.cpsrC=e.shifterCarryOut))}};F.prototype.constructORR=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){e.mmu.waitPrefetch32(a[15]),!(s&&!s())&&(i(),a[t]=a[r]|e.shifterOperand)}};F.prototype.constructORRS=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){e.mmu.waitPrefetch32(a[15]),!(s&&!s())&&(i(),a[t]=a[r]|e.shifterOperand,t==15&&e.hasSPSR()?e.unpackCPSR(e.spsr):(e.cpsrN=a[t]>>31,e.cpsrZ=!(a[t]&4294967295),e.cpsrC=e.shifterCarryOut))}};F.prototype.constructRSB=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){e.mmu.waitPrefetch32(a[15]),!(s&&!s())&&(i(),a[t]=e.shifterOperand-a[r])}};F.prototype.constructRSBS=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){if(e.mmu.waitPrefetch32(a[15]),!(s&&!s())){i();var c=e.shifterOperand-a[r];t==15&&e.hasSPSR()?e.unpackCPSR(e.spsr):(e.cpsrN=c>>31,e.cpsrZ=!(c&4294967295),e.cpsrC=e.shifterOperand>>>0>=a[r]>>>0,e.cpsrV=e.shifterOperand>>31!=a[r]>>31&&e.shifterOperand>>31!=c>>31),a[t]=c}}};F.prototype.constructRSC=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){if(e.mmu.waitPrefetch32(a[15]),!(s&&!s())){i();var c=(a[r]>>>0)+(e.cpsrC?0:1);a[t]=(e.shifterOperand>>>0)-c}}};F.prototype.constructRSCS=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){if(e.mmu.waitPrefetch32(a[15]),!(s&&!s())){i();var c=(a[r]>>>0)+(e.cpsrC?0:1),p=(e.shifterOperand>>>0)-c;t==15&&e.hasSPSR()?e.unpackCPSR(e.spsr):(e.cpsrN=p>>31,e.cpsrZ=!(p&4294967295),e.cpsrC=e.shifterOperand>>>0>=p>>>0,e.cpsrV=e.shifterOperand>>31!=c>>31&&e.shifterOperand>>31!=p>>31),a[t]=p}}};F.prototype.constructSBC=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){if(e.mmu.waitPrefetch32(a[15]),!(s&&!s())){i();var c=(e.shifterOperand>>>0)+(e.cpsrC?0:1);a[t]=(a[r]>>>0)-c}}};F.prototype.constructSBCS=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){if(e.mmu.waitPrefetch32(a[15]),!(s&&!s())){i();var c=(e.shifterOperand>>>0)+(e.cpsrC?0:1),p=(a[r]>>>0)-c;t==15&&e.hasSPSR()?e.unpackCPSR(e.spsr):(e.cpsrN=p>>31,e.cpsrZ=!(p&4294967295),e.cpsrC=a[r]>>>0>=p>>>0,e.cpsrV=a[r]>>31!=c>>31&&a[r]>>31!=p>>31),a[t]=p}}};F.prototype.constructSMLAL=function(t,r,i,s,e){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(e&&!e())){a.cycles+=2,a.mmu.waitMul(i);var n=(p[s]&4294901760)*p[i],o=(p[s]&65535)*p[i],l=(p[r]>>>0)+n+o;p[r]=l,p[t]+=Math.floor(l*c)}}};F.prototype.constructSMLALS=function(t,r,i,s,e){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(e&&!e())){a.cycles+=2,a.mmu.waitMul(i);var n=(p[s]&4294901760)*p[i],o=(p[s]&65535)*p[i],l=(p[r]>>>0)+n+o;p[r]=l,p[t]+=Math.floor(l*c),a.cpsrN=p[t]>>31,a.cpsrZ=!(p[t]&4294967295||p[r]&4294967295)}}};F.prototype.constructSMULL=function(t,r,i,s,e){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(e&&!e())){++a.cycles,a.mmu.waitMul(p[i]);var n=((p[s]&4294901760)>>0)*(p[i]>>0),o=((p[s]&65535)>>0)*(p[i]>>0);p[r]=(n&4294967295)+(o&4294967295)&4294967295,p[t]=Math.floor(n*c+o*c)}}};F.prototype.constructSMULLS=function(t,r,i,s,e){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(e&&!e())){++a.cycles,a.mmu.waitMul(p[i]);var n=((p[s]&4294901760)>>0)*(p[i]>>0),o=((p[s]&65535)>>0)*(p[i]>>0);p[r]=(n&4294967295)+(o&4294967295)&4294967295,p[t]=Math.floor(n*c+o*c),a.cpsrN=p[t]>>31,a.cpsrZ=!(p[t]&4294967295||p[r]&4294967295)}}};F.prototype.constructSTM=function(t,r,i){var s=this.cpu,e=s.gprs,a=s.mmu;return function(){if(i&&!i()){a.waitPrefetch32(e[15]);return}a.wait32(e[15]);var c=r(!0),p=0,n,o;for(n=t,o=0;n;n>>=1,++o)n&1&&(a.store32(c,e[o]),c+=4,++p);a.waitMulti32(c,p)}};F.prototype.constructSTMS=function(t,r,i){var s=this.cpu,e=s.gprs,a=s.mmu;return function(){if(i&&!i()){a.waitPrefetch32(e[15]);return}a.wait32(e[15]);var c=s.mode,p=r(!0),n=0,o,l;for(s.switchMode(31),o=t,l=0;o;o>>=1,++l)o&1&&(a.store32(p,e[l]),p+=4,++n);s.switchMode(c),a.waitMulti32(p,n)}};F.prototype.constructSTR=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){if(i&&!i()){s.mmu.waitPrefetch32(e[15]);return}var a=r();s.mmu.store32(a,e[t]),s.mmu.wait32(a),s.mmu.wait32(e[15])}};F.prototype.constructSTRB=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){if(i&&!i()){s.mmu.waitPrefetch32(e[15]);return}var a=r();s.mmu.store8(a,e[t]),s.mmu.wait(a),s.mmu.wait32(e[15])}};F.prototype.constructSTRH=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){if(i&&!i()){s.mmu.waitPrefetch32(e[15]);return}var a=r();s.mmu.store16(a,e[t]),s.mmu.wait(a),s.mmu.wait32(e[15])}};F.prototype.constructSUB=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){e.mmu.waitPrefetch32(a[15]),!(s&&!s())&&(i(),a[t]=a[r]-e.shifterOperand)}};F.prototype.constructSUBS=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){if(e.mmu.waitPrefetch32(a[15]),!(s&&!s())){i();var c=a[r]-e.shifterOperand;t==15&&e.hasSPSR()?e.unpackCPSR(e.spsr):(e.cpsrN=c>>31,e.cpsrZ=!(c&4294967295),e.cpsrC=a[r]>>>0>=e.shifterOperand>>>0,e.cpsrV=a[r]>>31!=e.shifterOperand>>31&&a[r]>>31!=c>>31),a[t]=c}}};F.prototype.constructSWI=function(t,r){var i=this.cpu,s=i.gprs;return function(){if(r&&!r()){i.mmu.waitPrefetch32(s[15]);return}i.irq.swi32(t),i.mmu.waitPrefetch32(s[15])}};F.prototype.constructSWP=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){if(e.mmu.waitPrefetch32(a[15]),!(s&&!s())){e.mmu.wait32(a[r]),e.mmu.wait32(a[r]);var c=e.mmu.load32(a[r]);e.mmu.store32(a[r],a[i]),a[t]=c,++e.cycles}}};F.prototype.constructSWPB=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){if(e.mmu.waitPrefetch32(a[15]),!(s&&!s())){e.mmu.wait(a[r]),e.mmu.wait(a[r]);var c=e.mmu.loadU8(a[r]);e.mmu.store8(a[r],a[i]),a[t]=c,++e.cycles}}};F.prototype.constructTEQ=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){if(e.mmu.waitPrefetch32(a[15]),!(s&&!s())){i();var c=a[r]^e.shifterOperand;e.cpsrN=c>>31,e.cpsrZ=!(c&4294967295),e.cpsrC=e.shifterCarryOut}}};F.prototype.constructTST=function(t,r,i,s){var e=this.cpu,a=e.gprs;return function(){if(e.mmu.waitPrefetch32(a[15]),!(s&&!s())){i();var c=a[r]&e.shifterOperand;e.cpsrN=c>>31,e.cpsrZ=!(c&4294967295),e.cpsrC=e.shifterCarryOut}}};F.prototype.constructUMLAL=function(t,r,i,s,e){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(e&&!e())){a.cycles+=2,a.mmu.waitMul(i);var n=((p[s]&4294901760)>>>0)*(p[i]>>>0),o=(p[s]&65535)*(p[i]>>>0),l=(p[r]>>>0)+n+o;p[r]=l,p[t]+=l*c}}};F.prototype.constructUMLALS=function(t,r,i,s,e){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(e&&!e())){a.cycles+=2,a.mmu.waitMul(i);var n=((p[s]&4294901760)>>>0)*(p[i]>>>0),o=(p[s]&65535)*(p[i]>>>0),l=(p[r]>>>0)+n+o;p[r]=l,p[t]+=l*c,a.cpsrN=p[t]>>31,a.cpsrZ=!(p[t]&4294967295||p[r]&4294967295)}}};F.prototype.constructUMULL=function(t,r,i,s,e){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(e&&!e())){++a.cycles,a.mmu.waitMul(p[i]);var n=((p[s]&4294901760)>>>0)*(p[i]>>>0),o=((p[s]&65535)>>>0)*(p[i]>>>0);p[r]=(n&4294967295)+(o&4294967295)&4294967295,p[t]=n*c+o*c>>>0}}};F.prototype.constructUMULLS=function(t,r,i,s,e){var a=this.cpu,c=1/4294967296,p=a.gprs;return function(){if(a.mmu.waitPrefetch32(p[15]),!(e&&!e())){++a.cycles,a.mmu.waitMul(p[i]);var n=((p[s]&4294901760)>>>0)*(p[i]>>>0),o=((p[s]&65535)>>>0)*(p[i]>>>0);p[r]=(n&4294967295)+(o&4294967295)&4294967295,p[t]=n*c+o*c>>>0,a.cpsrN=p[t]>>31,a.cpsrZ=!(p[t]&4294967295||p[r]&4294967295)}}};F.prototype.constructVFP3Register=function(t,r,i,s,e,a,c){var p=this.cpu,n=e?p.dfprs:p.sfprs;return function(){if(p.mmu.waitPrefetch32(p.gprs[15]),!(t&&!t())){switch(r){case 2:switch(a){case 0:n[s]=n[i]*n[c];return}break;case 3:switch(a){case 0:n[s]=n[i]+n[c];return;case 2:n[s]=n[i]-n[c];return}break;case 8:switch(a){case 0:n[s]=n[i]/n[c];return}break}console.log("Unsupported instruction: "+_(r)+" "+_(a))}}};F.prototype.constructVCVT=function(t,r,i,s,e,a,c,p){var n=this.cpu,o=n.sfprs,l=n.dfprs,m=n.ifprs;return function(){if(n.mmu.waitPrefetch32(n.gprs[15]),!(t&&!t())){var A,h;s&&e?A=l[i]:s?A=o[i]:A=m[i],s?h=c?Math.floor(A):Math.round(A):h=A,s?m[r]=h:e?l[r]=h:o[r]=h}}};F.prototype.constructVCVTF=function(t,r,i,s){var e=this.cpu,a=e.sfprs,c=e.dfprs;return function(){if(e.mmu.waitPrefetch32(e.gprs[15]),!(t&&!t())){var p=s?c[i]:a[i];s?a[r]=p:c[r]=p}}};F.prototype.constructVLDR=function(t,r,i,s){var e=this.cpu,a=e.ifprs;return function(){if(e.mmu.waitPrefetch32(e.gprs[15]),t&&!t())return;let c=i();s?a[r]=e.mmu.load32(c):(a[r]=e.mmu.load32(c),a[r+1]=e.mmu.load32(c+4)),e.mmu.wait32(c),e.mmu.wait32(e.gprs[15])}};F.prototype.constructVSTR=function(t,r,i,s){var e=this.cpu,a=e.ifprs;return function(){if(e.mmu.waitPrefetch32(e.gprs[15]),t&&!t())return;let c=i();s?e.mmu.store32(c,a[r]):(e.mmu.store32(c,a[r]),e.mmu.store32(c+4,a[r+1])),e.mmu.wait32(c),e.mmu.wait32(e.gprs[15])}};F.prototype.constructVPUSH=function(t,r,i,s){var e=this.cpu,a=e.ifprs;return function(){if(e.mmu.waitPrefetch32(e.gprs[15]),t&&!t())return;let c=e.gprs[13]-i*4;e.gprs[13]=c;for(let p=0;p<i;++p)e.mmu.store32(c,a[r+p]),c+=4}};F.prototype.constructVPOP=function(t,r,i,s){var e=this.cpu,a=e.ifprs;return function(){if(e.mmu.waitPrefetch32(e.gprs[15]),t&&!t())return;let c=e.gprs[13];e.gprs[13]+=i*4;for(let p=0;p<i;++p)a[r+p]=e.mmu.load32(c),c+=4}};function gr(t,r){return isNaN(t)||isNaN(r)?3:t==r?6:t<r?8:2}F.prototype.constructVCMP=function(t,r,i,s,e,a,c){var p=this.cpu,n=p.sfprs,o=p.dfprs;return function(){if(p.mmu.waitPrefetch32(p.gprs[15]),t&&!t())return;let l,m;s?(l=o[r],m=o[a]):(l=n[r],m=n[a]);let A=gr(l,m);p.cpsrN=(A&8)!=0,p.cpsrZ=(A&4)!=0,p.cpsrC=(A&2)!=0,p.cpsrV=(A&1)!=0}};F.prototype.constructVCMP0=function(t,r,i,s,e){var a=this.cpu,c=a.sfprs,p=a.dfprs;return function(){if(a.mmu.waitPrefetch32(a.gprs[15]),t&&!t())return;let n,o=0;s?n=p[r]:n=c[r];let l=gr(n,o);a.cpsrN=(l&8)!=0,a.cpsrZ=(l&4)!=0,a.cpsrC=(l&2)!=0,a.cpsrV=(l&1)!=0}};F.prototype.constructVMOV=function(t,r,i,s){var e=this.cpu;return function(){e.mmu.waitPrefetch32(e.gprs[15]),!(t&&!t())&&(r?e.gprs[s]=e.ifprs[i]:e.ifprs[i]=e.gprs[s])}};function f(t){this.cpu=t}f.prototype.constructADC=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]);var e=(s[r]>>>0)+(i.cpsrC?1:0),a=s[t],c=(a>>>0)+e,p=a>>31,n=c>>31,o=e>>31;i.cpsrN=n,i.cpsrZ=!(c&4294967295),i.cpsrC=c>4294967295,i.cpsrV=p==o&&p!=n&&o!=n,s[t]=c}};f.prototype.constructADD1=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){s.mmu.waitPrefetch(e[15]);var a=(e[r]>>>0)+i;s.cpsrN=a>>31,s.cpsrZ=!(a&4294967295),s.cpsrC=a>4294967295,s.cpsrV=!(e[r]>>31)&&(e[r]>>31^a)>>31&&a>>31,e[t]=a}};f.prototype.constructADD2=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]);var e=(s[t]>>>0)+r;i.cpsrN=e>>31,i.cpsrZ=!(e&4294967295),i.cpsrC=e>4294967295,i.cpsrV=!(s[t]>>31)&&(s[t]^e)>>31&&(r^e)>>31,s[t]=e}};f.prototype.constructADD3=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){s.mmu.waitPrefetch(e[15]);var a=(e[r]>>>0)+(e[i]>>>0);s.cpsrN=a>>31,s.cpsrZ=!(a&4294967295),s.cpsrC=a>4294967295,s.cpsrV=!((e[r]^e[i])>>31)&&(e[r]^a)>>31&&(e[i]^a)>>31,e[t]=a}};f.prototype.constructADD4=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]),s[t]+=s[r]}};f.prototype.constructADD5=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]),s[t]=(s[15]&4294967292)+r}};f.prototype.constructADD6=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]),s[t]=s[13]+r}};f.prototype.constructADD7=function(t){var r=this.cpu,i=r.gprs;return function(){r.mmu.waitPrefetch(i[15]),i[13]+=t}};f.prototype.constructAND=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]),s[t]=s[t]&s[r],i.cpsrN=s[t]>>31,i.cpsrZ=!(s[t]&4294967295)}};f.prototype.constructASR1=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){s.mmu.waitPrefetch(e[15]),i==0?(s.cpsrC=e[r]>>31,s.cpsrC?e[t]=4294967295:e[t]=0):(s.cpsrC=e[r]&1<<i-1,e[t]=e[r]>>i),s.cpsrN=e[t]>>31,s.cpsrZ=!(e[t]&4294967295)}};f.prototype.constructASR2=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]);var e=s[r]&255;e&&(e<32?(i.cpsrC=s[t]&1<<e-1,s[t]>>=e):(i.cpsrC=s[t]>>31,i.cpsrC?s[t]=4294967295:s[t]=0)),i.cpsrN=s[t]>>31,i.cpsrZ=!(s[t]&4294967295)}};f.prototype.constructB1=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]),r()&&(s[15]+=t)}};f.prototype.constructB2=function(t){var r=this.cpu,i=r.gprs;return function(){r.mmu.waitPrefetch(i[15]),i[15]+=t}};f.prototype.constructBIC=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]),s[t]=s[t]&~s[r],i.cpsrN=s[t]>>31,i.cpsrZ=!(s[t]&4294967295)}};f.prototype.constructBL1=function(t){var r=this.cpu,i=r.gprs;return function(){r.mmu.waitPrefetch(i[15]),i[14]=i[15]+t}};f.prototype.constructBL2=function(t){var r=this.cpu,i=r.gprs;return function(){r.mmu.waitPrefetch(i[15]);var s=i[15];i[15]=i[14]+(t<<1),i[14]=s-1}};f.prototype.constructBX=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]),i.switchExecMode(s[r]&1);var e=0;r==15&&(e=s[r]&2),s[15]=s[r]&4294967294-e}};f.prototype.constructCMN=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]);var e=(s[t]>>>0)+(s[r]>>>0);i.cpsrN=e>>31,i.cpsrZ=!(e&4294967295),i.cpsrC=e>4294967295,i.cpsrV=s[t]>>31==s[r]>>31&&s[t]>>31!=e>>31&&s[r]>>31!=e>>31}};f.prototype.constructCMP1=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]);var e=s[t]-r;i.cpsrN=e>>31,i.cpsrZ=!(e&4294967295),i.cpsrC=s[t]>>>0>=r,i.cpsrV=s[t]>>31&&(s[t]^e)>>31}};f.prototype.constructCMP2=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]);var e=s[t],a=s[r],c=e-a,p=c>>31,n=e>>31;i.cpsrN=p,i.cpsrZ=!(c&4294967295),i.cpsrC=e>>>0>=a>>>0,i.cpsrV=n!=a>>31&&n!=p}};f.prototype.constructCMP3=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]);var e=s[t]-s[r];i.cpsrN=e>>31,i.cpsrZ=!(e&4294967295),i.cpsrC=s[t]>>>0>=s[r]>>>0,i.cpsrV=(s[t]^s[r])>>31&&(s[t]^e)>>31}};f.prototype.constructEOR=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]),s[t]=s[t]^s[r],i.cpsrN=s[t]>>31,i.cpsrZ=!(s[t]&4294967295)}};f.prototype.constructLDMIA=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]);var e=s[t],a=0,c,p;for(c=1,p=0;p<8;c<<=1,++p)r&c&&(s[p]=i.mmu.load32(e),e+=4,++a);i.mmu.waitMulti32(e,a),1<<t&r||(s[t]=e)}};f.prototype.constructLDR1=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){s.mmu.waitPrefetch(e[15]);var a=e[r]+i;e[t]=s.mmu.load32(a),s.mmu.wait32(a),++s.cycles}};f.prototype.constructLDR2=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){s.mmu.waitPrefetch(e[15]),e[t]=s.mmu.load32(e[r]+e[i]),s.mmu.wait32(e[r]+e[i]),++s.cycles}};f.prototype.constructLDR3=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]),s[t]=i.mmu.load32((s[15]&4294967292)+r),i.mmu.wait32(s[15]),++i.cycles}};f.prototype.constructLDR4=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]),s[t]=i.mmu.load32(s[13]+r),i.mmu.wait32(s[13]+r),++i.cycles}};f.prototype.constructLDRB1=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){var a=e[r]+i;s.mmu.waitPrefetch(e[15]),e[t]=s.mmu.loadU8(a),s.mmu.wait(a),++s.cycles}};f.prototype.constructLDRB2=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){s.mmu.waitPrefetch(e[15]),e[t]=s.mmu.loadU8(e[r]+e[i]),s.mmu.wait(e[r]+e[i]),++s.cycles}};f.prototype.constructLDRH1=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){var a=e[r]+i;s.mmu.waitPrefetch(e[15]),e[t]=s.mmu.loadU16(a),s.mmu.wait(a),++s.cycles}};f.prototype.constructLDRH2=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){s.mmu.waitPrefetch(e[15]),e[t]=s.mmu.loadU16(e[r]+e[i]),s.mmu.wait(e[r]+e[i]),++s.cycles}};f.prototype.constructLDRSB=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){s.mmu.waitPrefetch(e[15]),e[t]=s.mmu.load8(e[r]+e[i]),s.mmu.wait(e[r]+e[i]),++s.cycles}};f.prototype.constructLDRSH=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){s.mmu.waitPrefetch(e[15]),e[t]=s.mmu.load16(e[r]+e[i]),s.mmu.wait(e[r]+e[i]),++s.cycles}};f.prototype.constructLSL1=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){s.mmu.waitPrefetch(e[15]),i==0?e[t]=e[r]:(s.cpsrC=e[r]&1<<32-i,e[t]=e[r]<<i),s.cpsrN=e[t]>>31,s.cpsrZ=!(e[t]&4294967295)}};f.prototype.constructLSL2=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]);var e=s[r]&255;e&&(e<32?(i.cpsrC=s[t]&1<<32-e,s[t]<<=e):(e>32?i.cpsrC=0:i.cpsrC=s[t]&1,s[t]=0)),i.cpsrN=s[t]>>31,i.cpsrZ=!(s[t]&4294967295)}};f.prototype.constructLSR1=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){s.mmu.waitPrefetch(e[15]),i==0?(s.cpsrC=e[r]>>31,e[t]=0):(s.cpsrC=e[r]&1<<i-1,e[t]=e[r]>>>i),s.cpsrN=0,s.cpsrZ=!(e[t]&4294967295)}};f.prototype.constructLSR2=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]);var e=s[r]&255;e&&(e<32?(i.cpsrC=s[t]&1<<e-1,s[t]>>>=e):(e>32?i.cpsrC=0:i.cpsrC=s[t]>>31,s[t]=0)),i.cpsrN=s[t]>>31,i.cpsrZ=!(s[t]&4294967295)}};f.prototype.constructMOV1=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]),s[t]=r,i.cpsrN=r>>31,i.cpsrZ=!(r&4294967295)}};f.prototype.constructMOV2=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){s.mmu.waitPrefetch(e[15]);var a=e[r];s.cpsrN=a>>31,s.cpsrZ=!(a&4294967295),s.cpsrC=0,s.cpsrV=0,e[t]=a}};f.prototype.constructMOV3=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]),s[t]=s[r]}};f.prototype.constructMUL=function(t,r){var i=this.cpu,s=i.gprs;return function(){if(i.mmu.waitPrefetch(s[15]),i.mmu.waitMul(s[r]),s[r]&4294901760&&s[t]&4294901760){var e=(s[t]&4294901760)*s[r]&4294967295,a=(s[t]&65535)*s[r]&4294967295;s[t]=e+a&4294967295}else s[t]*=s[r];i.cpsrN=s[t]>>31,i.cpsrZ=!(s[t]&4294967295)}};f.prototype.constructMVN=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]),s[t]=~s[r],i.cpsrN=s[t]>>31,i.cpsrZ=!(s[t]&4294967295)}};f.prototype.constructNEG=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]);var e=-s[r];i.cpsrN=e>>31,i.cpsrZ=!(e&4294967295),i.cpsrC=0>=e>>>0,i.cpsrV=s[r]>>31&&e>>31,s[t]=e}};f.prototype.constructORR=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]),s[t]=s[t]|s[r],i.cpsrN=s[t]>>31,i.cpsrZ=!(s[t]&4294967295)}};f.prototype.constructPOP=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]),++i.cycles;var e=s[13],a=0,c,p;for(c=1,p=0;p<8;c<<=1,++p)t&c&&(i.mmu.waitSeq32(e),s[p]=i.mmu.load32(e),e+=4,++a);r&&(s[15]=i.mmu.load32(e)&4294967294,e+=4,++a),i.mmu.waitMulti32(e,a),s[13]=e}};f.prototype.constructPUSH=function(t,r){var i=this.cpu,s=i.gprs;return function(){var e=s[13]-4,a=0;i.mmu.waitPrefetch(s[15]),r&&(i.mmu.store32(e,s[14]),e-=4,++a);var c,p;for(c=128,p=7;c;c>>=1,--p)if(t&c){i.mmu.store32(e,s[p]),e-=4,++a;break}for(c>>=1,--p;c;c>>=1,--p)t&c&&(i.mmu.store32(e,s[p]),e-=4,++a);i.mmu.waitMulti32(e,a),s[13]=e+4}};f.prototype.constructROR=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]);var e=s[r]&255;if(e){var a=e&31;a>0?(i.cpsrC=s[t]&1<<a-1,s[t]=s[t]>>>a|s[t]<<32-a):i.cpsrC=s[t]>>31}i.cpsrN=s[t]>>31,i.cpsrZ=!(s[t]&4294967295)}};f.prototype.constructSBC=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]);var e=(s[r]>>>0)+(i.cpsrC?0:1),a=(s[t]>>>0)-e;i.cpsrN=a>>31,i.cpsrZ=!(a&4294967295),i.cpsrC=s[t]>>>0>=a>>>0,i.cpsrV=(s[t]^e)>>31&&(s[t]^a)>>31,s[t]=a}};f.prototype.constructSTMIA=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.wait(s[15]);var e=s[t],a=0,c,p;for(c=1,p=0;p<8;c<<=1,++p)if(r&c){i.mmu.store32(e,s[p]),e+=4,++a;break}for(c<<=1,++p;p<8;c<<=1,++p)r&c&&(i.mmu.store32(e,s[p]),e+=4,++a);i.mmu.waitMulti32(e,a),s[t]=e}};f.prototype.constructSTR1=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){var a=e[r]+i;s.mmu.store32(a,e[t]),s.mmu.wait(e[15]),s.mmu.wait32(a)}};f.prototype.constructSTR2=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){s.mmu.store32(e[r]+e[i],e[t]),s.mmu.wait(e[15]),s.mmu.wait32(e[r]+e[i])}};f.prototype.constructSTR3=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.store32(s[13]+r,s[t]),i.mmu.wait(s[15]),i.mmu.wait32(s[13]+r)}};f.prototype.constructSTRB1=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){var a=e[r]+i;s.mmu.store8(a,e[t]),s.mmu.wait(e[15]),s.mmu.wait(a)}};f.prototype.constructSTRB2=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){s.mmu.store8(e[r]+e[i],e[t]),s.mmu.wait(e[15]),s.mmu.wait(e[r]+e[i])}};f.prototype.constructSTRH1=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){var a=e[r]+i;s.mmu.store16(a,e[t]),s.mmu.wait(e[15]),s.mmu.wait(a)}};f.prototype.constructSTRH2=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){s.mmu.store16(e[r]+e[i],e[t]),s.mmu.wait(e[15]),s.mmu.wait(e[r]+e[i])}};f.prototype.constructSUB1=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){s.mmu.waitPrefetch(e[15]);var a=e[r]-i;s.cpsrN=a>>31,s.cpsrZ=!(a&4294967295),s.cpsrC=e[r]>>>0>=i,s.cpsrV=e[r]>>31&&(e[r]^a)>>31,e[t]=a}};f.prototype.constructSUB2=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]);var e=s[t]-r;i.cpsrN=e>>31,i.cpsrZ=!(e&4294967295),i.cpsrC=s[t]>>>0>=r,i.cpsrV=s[t]>>31&&(s[t]^e)>>31,s[t]=e}};f.prototype.constructSUB3=function(t,r,i){var s=this.cpu,e=s.gprs;return function(){s.mmu.waitPrefetch(e[15]);var a=e[r]-e[i];s.cpsrN=a>>31,s.cpsrZ=!(a&4294967295),s.cpsrC=e[r]>>>0>=e[i]>>>0,s.cpsrV=e[r]>>31!=e[i]>>31&&e[r]>>31!=a>>31,e[t]=a}};f.prototype.constructSWI=function(t){var r=this.cpu,i=r.gprs;return function(){r.irq.swi(t),r.mmu.waitPrefetch(i[15])}};f.prototype.constructTST=function(t,r){var i=this.cpu,s=i.gprs;return function(){i.mmu.waitPrefetch(s[15]);var e=s[t]&s[r];i.cpsrN=e>>31,i.cpsrZ=!(e&4294967295)}};function y(){this.SP=13,this.LR=14,this.PC=15,this.MODE_ARM=0,this.MODE_THUMB=1,this.MODE_USER=16,this.MODE_FIQ=17,this.MODE_IRQ=18,this.MODE_SUPERVISOR=19,this.MODE_ABORT=23,this.MODE_UNDEFINED=27,this.MODE_SYSTEM=31,this.BANK_NONE=0,this.BANK_FIQ=1,this.BANK_IRQ=2,this.BANK_SUPERVISOR=3,this.BANK_ABORT=4,this.BANK_UNDEFINED=5,this.WORD_SIZE_ARM=4,this.WORD_SIZE_THUMB=2,this.BASE_RESET=0,this.BASE_UNDEF=4,this.BASE_SWI=8,this.BASE_PABT=12,this.BASE_DABT=16,this.BASE_IRQ=24,this.BASE_FIQ=28,this.armCompiler=new F(this),this.thumbCompiler=new f(this),this.generateConds(),this.gprs=new Int32Array(16),this.dfprs=new Float64Array(16),this.sfprs=new Float32Array(this.dfprs.buffer),this.ifprs=new Int32Array(this.dfprs.buffer)}y.prototype.resetCPU=function(t){for(var r=0;r<15;++r)this.gprs[r]=0;this.gprs[15]=t+4,this.dfprs.set(0),this.loadInstruction=this.loadInstructionArm,this.execMode=0,this.instructionWidth=4,this.mode=31,this.cpsrI=!1,this.cpsrF=!1,this.cpsrV=!1,this.cpsrC=!1,this.cpsrZ=!1,this.cpsrN=!1,this.bankedRegisters=[new Int32Array(7),new Int32Array(7),new Int32Array(2),new Int32Array(2),new Int32Array(2),new Int32Array(2)],this.spsr=0,this.bankedSPSRs=new Int32Array(6),this.cycles=0,this.shifterOperand=0,this.shifterCarryOut=0,this.page=null,this.pageId=0,this.pageRegion=-1,this.instruction=null,this.irq.clear();var i=this.gprs,s=this.mmu;this.step=function(){var e=this.instruction||(this.instruction=this.loadInstruction(i[15]-this.instructionWidth));if(i[15]+=this.instructionWidth,this.conditionPassed=!0,e(),!e.writesPC)this.instruction!=null&&((e.next==null||e.next.page.invalid)&&(e.next=this.loadInstruction(i[15]-this.instructionWidth)),this.instruction=e.next);else if(this.conditionPassed){var a=i[15]&=4294967294;this.execMode==0?(s.wait32(a),s.waitPrefetch32(a)):(s.wait(a),s.waitPrefetch(a)),i[15]+=this.instructionWidth,e.fixedJump?this.instruction!=null&&((e.next==null||e.next.page.invalid)&&(e.next=this.loadInstruction(i[15]-this.instructionWidth)),this.instruction=e.next):this.instruction=null}else this.instruction=null;this.irq.updateTimers()}};y.prototype.freeze=function(){return{PC:this.gprs[15]-this.instructionWidth,SP:this.gprs[13],gprs:[this.gprs[0],this.gprs[1],this.gprs[2],this.gprs[3],this.gprs[4],this.gprs[5],this.gprs[6],this.gprs[7],this.gprs[8],this.gprs[9],this.gprs[10],this.gprs[11],this.gprs[12],this.gprs[13],this.gprs[14],this.gprs[15]],sfprs:this.sfprs.slice(),dfprs:this.dfprs.slice(),ifprs:this.ifprs.slice(),mode:this.mode,cpsrI:this.cpsrI,cpsrF:this.cpsrF,cpsrV:this.cpsrV,cpsrC:this.cpsrC,cpsrZ:this.cpsrZ,cpsrN:this.cpsrN,bankedRegisters:[[this.bankedRegisters[0][0],this.bankedRegisters[0][1],this.bankedRegisters[0][2],this.bankedRegisters[0][3],this.bankedRegisters[0][4],this.bankedRegisters[0][5],this.bankedRegisters[0][6]],[this.bankedRegisters[1][0],this.bankedRegisters[1][1],this.bankedRegisters[1][2],this.bankedRegisters[1][3],this.bankedRegisters[1][4],this.bankedRegisters[1][5],this.bankedRegisters[1][6]],[this.bankedRegisters[2][0],this.bankedRegisters[2][1]],[this.bankedRegisters[3][0],this.bankedRegisters[3][1]],[this.bankedRegisters[4][0],this.bankedRegisters[4][1]],[this.bankedRegisters[5][0],this.bankedRegisters[5][1]]],spsr:this.spsr,bankedSPSRs:[this.bankedSPSRs[0],this.bankedSPSRs[1],this.bankedSPSRs[2],this.bankedSPSRs[3],this.bankedSPSRs[4],this.bankedSPSRs[5]],cycles:this.cycles,instructionWidth:this.instructionWidth}};y.prototype.defrost=function(t){this.instruction=null,this.page=null,this.pageId=0,this.pageRegion=-1,this.gprs[0]=t.gprs[0],this.gprs[1]=t.gprs[1],this.gprs[2]=t.gprs[2],this.gprs[3]=t.gprs[3],this.gprs[4]=t.gprs[4],this.gprs[5]=t.gprs[5],this.gprs[6]=t.gprs[6],this.gprs[7]=t.gprs[7],this.gprs[8]=t.gprs[8],this.gprs[9]=t.gprs[9],this.gprs[10]=t.gprs[10],this.gprs[11]=t.gprs[11],this.gprs[12]=t.gprs[12],this.gprs[13]=t.gprs[13],this.gprs[14]=t.gprs[14],this.gprs[15]=t.gprs[15],this.ifprs.set(t.ifprs),this.mode=t.mode,this.cpsrI=t.cpsrI,this.cpsrF=t.cpsrF,this.cpsrV=t.cpsrV,this.cpsrC=t.cpsrC,this.cpsrZ=t.cpsrZ,this.cpsrN=t.cpsrN,this.bankedRegisters[0][0]=t.bankedRegisters[0][0],this.bankedRegisters[0][1]=t.bankedRegisters[0][1],this.bankedRegisters[0][2]=t.bankedRegisters[0][2],this.bankedRegisters[0][3]=t.bankedRegisters[0][3],this.bankedRegisters[0][4]=t.bankedRegisters[0][4],this.bankedRegisters[0][5]=t.bankedRegisters[0][5],this.bankedRegisters[0][6]=t.bankedRegisters[0][6],this.bankedRegisters[1][0]=t.bankedRegisters[1][0],this.bankedRegisters[1][1]=t.bankedRegisters[1][1],this.bankedRegisters[1][2]=t.bankedRegisters[1][2],this.bankedRegisters[1][3]=t.bankedRegisters[1][3],this.bankedRegisters[1][4]=t.bankedRegisters[1][4],this.bankedRegisters[1][5]=t.bankedRegisters[1][5],this.bankedRegisters[1][6]=t.bankedRegisters[1][6],this.bankedRegisters[2][0]=t.bankedRegisters[2][0],this.bankedRegisters[2][1]=t.bankedRegisters[2][1],this.bankedRegisters[3][0]=t.bankedRegisters[3][0],this.bankedRegisters[3][1]=t.bankedRegisters[3][1],this.bankedRegisters[4][0]=t.bankedRegisters[4][0],this.bankedRegisters[4][1]=t.bankedRegisters[4][1],this.bankedRegisters[5][0]=t.bankedRegisters[5][0],this.bankedRegisters[5][1]=t.bankedRegisters[5][1],this.spsr=t.spsr,this.bankedSPSRs[0]=t.bankedSPSRs[0],this.bankedSPSRs[1]=t.bankedSPSRs[1],this.bankedSPSRs[2]=t.bankedSPSRs[2],this.bankedSPSRs[3]=t.bankedSPSRs[3],this.bankedSPSRs[4]=t.bankedSPSRs[4],this.bankedSPSRs[5]=t.bankedSPSRs[5],this.cycles=t.cycles,this.instructionWidth=t.instructionWidth,this.loadInstruction=t.instructionWidth==2?this.loadInstructionThumb:this.loadInstructionArm,this.execMode=t.instructionWidth==2?1:0};y.prototype.fetchPage=function(t){var r=this.mmu,i=t>>>r.BASE_OFFSET,s=r.addressToPage(i,t&r.OFFSET_MASK);if(i==this.pageRegion){if(s==this.pageId&&!this.page.invalid)return;this.pageId=s}else this.pageMask=r.memory[i].PAGE_MASK,this.pageRegion=i,this.pageId=s;this.page=r.accessPage(i,s)};y.prototype.loadInstructionArm=function(t){var r=null;this.fetchPage(t);var i=(t&this.pageMask)>>2;if(r=this.page.arm[i],r)return r;var s=this.mmu.load32(t)>>>0;return r=this.compileArm(s),r.next=null,r.page=this.page,r.address=t,r.opcode=s,this.page.arm[i]=r,r};y.prototype.loadInstructionThumb=function(t){var r=null;this.fetchPage(t);var i=(t&this.pageMask)>>1;if(r=this.page.thumb[i],r)return r;var s=this.mmu.load16(t);return r=this.compileThumb(s),r.next=null,r.page=this.page,r.address=t,r.opcode=s,this.page.thumb[i]=r,r};y.prototype.selectBank=function(t){switch(t){case 16:case 31:return 0;case 17:return 1;case 18:return 2;case 19:return 3;case 23:return 4;case 27:return 5;default:throw new Z("Invalid user mode "+t+" passed to selectBank")}};y.prototype.switchExecMode=function(t){this.execMode!=t&&(this.execMode=t,t==0?(this.instructionWidth=4,this.loadInstruction=this.loadInstructionArm):(this.instructionWidth=2,this.loadInstruction=this.loadInstructionThumb))};y.prototype.switchMode=function(t){if(t!=this.mode){if(t!=16||t!=31){var r=this.selectBank(t),i=this.selectBank(this.mode);if(r!=i){if(t==17||this.mode==17){var s=i==1?1:0,e=r==1?1:0;this.bankedRegisters[s][2]=this.gprs[8],this.bankedRegisters[s][3]=this.gprs[9],this.bankedRegisters[s][4]=this.gprs[10],this.bankedRegisters[s][5]=this.gprs[11],this.bankedRegisters[s][6]=this.gprs[12],this.gprs[8]=this.bankedRegisters[e][2],this.gprs[9]=this.bankedRegisters[e][3],this.gprs[10]=this.bankedRegisters[e][4],this.gprs[11]=this.bankedRegisters[e][5],this.gprs[12]=this.bankedRegisters[e][6]}this.bankedRegisters[i][0]=this.gprs[13],this.bankedRegisters[i][1]=this.gprs[14],this.gprs[13]=this.bankedRegisters[r][0],this.gprs[14]=this.bankedRegisters[r][1],this.bankedSPSRs[i]=this.spsr,this.spsr=this.bankedSPSRs[r]}}this.mode=t}};y.prototype.packCPSR=function(){return this.mode|this.execMode<<5|this.cpsrF<<6|this.cpsrI<<7|this.cpsrN<<31|this.cpsrZ<<30|this.cpsrC<<29|this.cpsrV<<28};y.prototype.unpackCPSR=function(t){this.switchMode(t&31),this.switchExecMode(!!(t&32)),this.cpsrF=t&64,this.cpsrI=t&128,this.cpsrN=t&2147483648,this.cpsrZ=t&1073741824,this.cpsrC=t&536870912,this.cpsrV=t&268435456,this.irq.testIRQ()};y.prototype.hasSPSR=function(){return this.mode!=31&&this.mode!=16};y.prototype.raiseIRQ=function(){if(!this.cpsrI){var t=this.packCPSR(),r=this.instructionWidth;this.switchMode(18),this.spsr=t,this.gprs[14]=this.gprs[15]-r+4,this.gprs[15]=this.BASE_IRQ+4,this.instruction=null,this.switchExecMode(0),this.cpsrI=!0}};y.prototype.raiseTrap=function(){var t=this.packCPSR(),r=this.instructionWidth;this.switchMode(19),this.spsr=t,this.gprs[14]=this.gprs[15]-r,this.gprs[15]=this.BASE_SWI+4,this.instruction=null,this.switchExecMode(0),this.cpsrI=!0};y.prototype.badOp=function(t){var r=function(){throw new Z("Illegal instruction: 0x"+t.toString(16))};return r.writesPC=!0,r.fixedJump=!1,r};y.prototype.generateConds=function(){var t=this;this.conds=[function(){return t.conditionPassed=t.cpsrZ},function(){return t.conditionPassed=!t.cpsrZ},function(){return t.conditionPassed=t.cpsrC},function(){return t.conditionPassed=!t.cpsrC},function(){return t.conditionPassed=t.cpsrN},function(){return t.conditionPassed=!t.cpsrN},function(){return t.conditionPassed=t.cpsrV},function(){return t.conditionPassed=!t.cpsrV},function(){return t.conditionPassed=t.cpsrC&&!t.cpsrZ},function(){return t.conditionPassed=!t.cpsrC||t.cpsrZ},function(){return t.conditionPassed=!t.cpsrN==!t.cpsrV},function(){return t.conditionPassed=!t.cpsrN!=!t.cpsrV},function(){return t.conditionPassed=!t.cpsrZ&&!t.cpsrN==!t.cpsrV},function(){return t.conditionPassed=t.cpsrZ||!t.cpsrN!=!t.cpsrV},null,null]};y.prototype.barrelShiftImmediate=function(t,r,i){var s=this,e=this.gprs,a=this.badOp;switch(t){case 0:r?a=function(){s.shifterOperand=e[i]<<r,s.shifterCarryOut=e[i]&1<<32-r}:a=function(){s.shifterOperand=e[i],s.shifterCarryOut=s.cpsrC};break;case 32:r?a=function(){s.shifterOperand=e[i]>>>r,s.shifterCarryOut=e[i]&1<<r-1}:a=function(){s.shifterOperand=0,s.shifterCarryOut=e[i]&2147483648};break;case 64:r?a=function(){s.shifterOperand=e[i]>>r,s.shifterCarryOut=e[i]&1<<r-1}:a=function(){s.shifterCarryOut=e[i]&2147483648,s.shifterCarryOut?s.shifterOperand=4294967295:s.shifterOperand=0};break;case 96:r?a=function(){s.shifterOperand=e[i]>>>r|e[i]<<32-r,s.shifterCarryOut=e[i]&1<<r-1}:a=function(){s.shifterOperand=(s.cpsrC?1:0)<<31|e[i]>>>1,s.shifterCarryOut=e[i]&1};break}return a};y.prototype.compileArm=function(t){var r=this.badOp(t),i=t&234881024,s=this,e=this.gprs,a=this.conds[(t&4026531840)>>>28];if((t&268435440)==19922704){var c=t&15;r=this.armCompiler.constructBX(c,a),r.writesPC=!0,r.fixedJump=!1}else if(!(t&201326592)&&(i==33554432||(t&144)!=144)){var p=t&31457280,n=t&1048576,o=!1;if((p&25165824)==16777216&&!n){var l=t&4194304;if((t&11595776)==2158592){var c=t&15,m=t&255,A=(t&3840)>>7;m=m>>>A|m<<32-A,r=this.armCompiler.constructMSR(c,l,t,m,a),r.writesPC=!1}else if((t&12517376)==983040){var h=(t&61440)>>12;r=this.armCompiler.constructMRS(h,l,a),r.writesPC=h==15}}else{var C=(t&983040)>>16,h=(t&61440)>>12,x=t&96,c=t&15,v=function(){throw new Z("BUG: invalid barrel shifter")};if(t&33554432){var m=t&255,ar=(t&3840)>>7;ar?v=this.armCompiler.constructAddressingMode1ImmediateRotate(m,ar):v=this.armCompiler.constructAddressingMode1Immediate(m)}else if(t&16){var P=(t&3840)>>8;switch(o=!0,x){case 0:v=this.armCompiler.constructAddressingMode1LSL(P,c);break;case 32:v=this.armCompiler.constructAddressingMode1LSR(P,c);break;case 64:v=this.armCompiler.constructAddressingMode1ASR(P,c);break;case 96:v=this.armCompiler.constructAddressingMode1ROR(P,c);break}}else{var m=(t&3968)>>7;v=this.barrelShiftImmediate(x,m,c)}switch(p){case 0:n?r=this.armCompiler.constructANDS(h,C,v,a):r=this.armCompiler.constructAND(h,C,v,a);break;case 2097152:n?r=this.armCompiler.constructEORS(h,C,v,a):r=this.armCompiler.constructEOR(h,C,v,a);break;case 4194304:n?r=this.armCompiler.constructSUBS(h,C,v,a):r=this.armCompiler.constructSUB(h,C,v,a);break;case 6291456:n?r=this.armCompiler.constructRSBS(h,C,v,a):r=this.armCompiler.constructRSB(h,C,v,a);break;case 8388608:n?r=this.armCompiler.constructADDS(h,C,v,a):r=this.armCompiler.constructADD(h,C,v,a);break;case 10485760:n?r=this.armCompiler.constructADCS(h,C,v,a):r=this.armCompiler.constructADC(h,C,v,a);break;case 12582912:n?r=this.armCompiler.constructSBCS(h,C,v,a):r=this.armCompiler.constructSBC(h,C,v,a);break;case 14680064:n?r=this.armCompiler.constructRSCS(h,C,v,a):r=this.armCompiler.constructRSC(h,C,v,a);break;case 16777216:r=this.armCompiler.constructTST(h,C,v,a);break;case 18874368:r=this.armCompiler.constructTEQ(h,C,v,a);break;case 20971520:r=this.armCompiler.constructCMP(h,C,v,a);break;case 23068672:r=this.armCompiler.constructCMN(h,C,v,a);break;case 25165824:n?r=this.armCompiler.constructORRS(h,C,v,a):r=this.armCompiler.constructORR(h,C,v,a);break;case 27262976:n?r=this.armCompiler.constructMOVS(h,C,v,a):r=this.armCompiler.constructMOV(h,C,v,a);break;case 29360128:n?r=this.armCompiler.constructBICS(h,C,v,a):r=this.armCompiler.constructBIC(h,C,v,a);break;case 31457280:n?r=this.armCompiler.constructMVNS(h,C,v,a):r=this.armCompiler.constructMVN(h,C,v,a);break}r.writesPC=h==15}}else if((t&263196656)==16777360){var c=t&15,h=t>>12&15,C=t>>16&15;t&4194304?r=this.armCompiler.constructSWPB(h,C,c,a):r=this.armCompiler.constructSWP(h,C,c,a),r.writesPC=h==15}else switch(i){case 0:if((t&16777456)==144){var h=(t&983040)>>16,C=(t&61440)>>12,P=(t&3840)>>8,c=t&15;switch(t&15728640){case 0:r=this.armCompiler.constructMUL(h,P,c,a);break;case 1048576:r=this.armCompiler.constructMULS(h,P,c,a);break;case 2097152:r=this.armCompiler.constructMLA(h,C,P,c,a);break;case 3145728:r=this.armCompiler.constructMLAS(h,C,P,c,a);break;case 8388608:r=this.armCompiler.constructUMULL(h,C,P,c,a);break;case 9437184:r=this.armCompiler.constructUMULLS(h,C,P,c,a);break;case 10485760:r=this.armCompiler.constructUMLAL(h,C,P,c,a);break;case 11534336:r=this.armCompiler.constructUMLALS(h,C,P,c,a);break;case 12582912:r=this.armCompiler.constructSMULL(h,C,P,c,a);break;case 13631488:r=this.armCompiler.constructSMULLS(h,C,P,c,a);break;case 14680064:r=this.armCompiler.constructSMLAL(h,C,P,c,a);break;case 15728640:r=this.armCompiler.constructSMLALS(h,C,P,c,a);break}r.writesPC=h==15}else{var L=t&1048576,h=(t&61440)>>12,Sr=(t&3840)>>4,Mr=c=t&15,cr=t&32,n=t&64,W=t&2097152,i=t&4194304,g;if(i){var m=Mr|Sr;g=this.armCompiler.constructAddressingMode23Immediate(t,m,a)}else g=this.armCompiler.constructAddressingMode23Register(t,c,a);g.writesPC=!!W&&C==15,(t&144)==144&&(L?cr?n?r=this.armCompiler.constructLDRSH(h,g,a):r=this.armCompiler.constructLDRH(h,g,a):n&&(r=this.armCompiler.constructLDRSB(h,g,a)):!n&&cr&&(r=this.armCompiler.constructSTRH(h,g,a))),r.writesPC=h==15||g.writesPC}break;case 67108864:case 100663296:var h=(t&61440)>>12,L=t&1048576,ur=t&4194304,i=t&33554432;if((t&4293918960)==(3891265776|0)){var m=t&15;throw new Z("Program exited ("+m+")")}var g=function(){throw new Z("Unimplemented memory access: 0x"+t.toString(16))};if(~t&16777216&&(t&=4292870143),i){var c=t&15,x=t&96,pr=(t&3968)>>7;x||pr?(v=this.barrelShiftImmediate(x,pr,c),g=this.armCompiler.constructAddressingMode2RegisterShifted(t,v,a)):g=this.armCompiler.constructAddressingMode23Register(t,c,a)}else{var U=t&4095;g=this.armCompiler.constructAddressingMode23Immediate(t,U,a)}L?ur?r=this.armCompiler.constructLDRB(h,g,a):r=this.armCompiler.constructLDR(h,g,a):ur?r=this.armCompiler.constructSTRB(h,g,a):r=this.armCompiler.constructSTR(h,g,a),r.writesPC=L&&(h==15||g.writesPC);break;case 134217728:var L=t&1048576,W=t&2097152,V=t&4194304,q=t&8388608,$=t&16777216,P=t&65535,C=(t&983040)>>16,g,m=0,U=0,Q=!1;if(q){$&&(m=4);for(var K=1,i=0;i<16;K<<=1,++i)P&K&&(W&&i==C&&!U&&(P&=~K,m+=4,Q=!0),U+=4)}else{$||(m=4);for(var K=1,i=0;i<16;K<<=1,++i)P&K&&(W&&i==C&&!U&&(P&=~K,m+=4,Q=!0),m-=4,U-=4)}W?g=this.armCompiler.constructAddressingMode4Writeback(m,U,C,Q):g=this.armCompiler.constructAddressingMode4(m,C),L?(V?r=this.armCompiler.constructLDMS(P,g,a):r=this.armCompiler.constructLDM(P,g,a),r.writesPC=!!(P&1<<15)):(V?r=this.armCompiler.constructSTMS(P,g,a):r=this.armCompiler.constructSTM(P,g,a),r.writesPC=!1);break;case 167772160:var m=t&16777215;m&8388608&&(m|=4278190080),m<<=2;var Ar=t&16777216;Ar?r=this.armCompiler.constructBL(m,a):r=this.armCompiler.constructB(m,a),r.writesPC=!0,r.fixedJump=!0;break;case 201326592:var L=t&1048576,W=t&2097152,V=t&4194304,q=t&8388608,$=t&16777216,C=(t&983040)>>16,G=(t&61440)>>12,Br=(t&3840)>>8,m=t&255,wr=t>>28&15,a=this.conds[wr];if((t&264179456)==221055488)r=this.armCompiler.constructVPUSH(a,G<<1|(V?1:0),m,!0);else if((t&264179456)==221055744)r=this.armCompiler.constructVPUSH(a,((V?16:0)|G)*2,m,!1);else if((t&264179456)==213715456)r=this.armCompiler.constructVPOP(a,G<<1|(V?1:0),m,!0);else if((t&264179456)==213715712)r=this.armCompiler.constructVPOP(a,((V?16:0)|G)*2,m,!1);else if((t&253759232)==218106368){m*=4,q||(m=-m);var Q=!1,J=G<<1|(V?1:0),g;W?g=this.armCompiler.constructAddressingMode4Writeback(m,U,C,Q):g=this.armCompiler.constructAddressingMode4(m,C),L?r=this.armCompiler.constructVLDR(a,J,g,!0):r=this.armCompiler.constructVSTR(a,J,g,!0)}else if((t&253759232)==218106624){m*=4,q||(m=-m);var Q=!1,J=((V?16:0)|G)*2,g;W?g=this.armCompiler.constructAddressingMode4Writeback(m,U,C,Q):g=this.armCompiler.constructAddressingMode4(m,C),L?r=this.armCompiler.constructVLDR(a,J,g,!1):r=this.armCompiler.constructVSTR(a,J,g,!1)}break;case 234881024:if((t&251658240)==251658240){var m=t&16777215;r=this.armCompiler.constructSWI(m,a),r.writesPC=!1}else if((t&263720528)==246942272){let O=t>>28&15,S=t>>22&1,b=t>>16&7,R=t>>12&15,M=t>>8&1,T=t>>7&1,w=t>>5&1,E=t&15,D=b&4,H=M!=0,Y=D?b&1:0,rr=T!=0,er=!1,Tr=M?(S?16:0)|R:R<<1|(S?1:0),kr=M?(w?16:0)|E:E<<1|(w?1:0);r=this.armCompiler.constructVCVT(a,Tr,kr,D,H,Y,rr,er),r.writesPC=!1}else if((t&264179408)==246876864){let O=t>>28&15,S=t>>22&1,b=t>>12&15,R=t>>8&1,M=t>>5&1,T=t&15,w=R!=0,E=R?(S?16:0)|b:b<<1|(S?1:0),D=R?(M?16:0)|T:T<<1|(M?1:0);r=this.armCompiler.constructVCVTF(a,E,D,w),r.writesPC=!1}else if((t&262147600)==236980736){let O=t>>28&15,S=t>>22&1,b=t>>7&1,R=t>>5&1,M=(t&15728640)>>20,T=(t&983040)>>16,w=(t&61440)>>12,E=(t&224)>>5,D=t&15,H=t>>8&1,Y=H?(S?16:0)|w:w<<1|(S?1:0),rr=H?(R?16:0)|D:D<<1|(R?1:0),er=H?(b?16:0)|T:T<<1|(b?1:0);var a=this.conds[O];r=this.armCompiler.constructVFP3Register(a,M,er,Y,H,E,rr),r.writesPC=!1}else if((t&263195728)==243271680){let O=t>>28&15,S=t>>22&1,b=t>>16&15,R=t>>12&15,M=t>>8&3,T=t>>7&1,w=t>>5&1,E=t&15,D=M==3?(S?16:0)|R:R<<1|(S?1:0),H=M==3?(w?16:0)|E:E<<1|(w?1:0),Y=M==3?(T?16:0)|b:b<<1|(T?1:0);r=this.armCompiler.constructVFP3Register(a,8,Y,D,M==3,0,H),r.writesPC=!1}else if((t&264179280)==246680128){let O=t>>28&15,S=t>>22&1,b=t>>12&15,R=t>>8&1,M=t>>7&1,T=t>>5&1,w=t&15,E=R?(S?16:0)|b:b<<1|(S?1:0),D=R?(T?16:0)|w:w<<1|(T?1:0);var a=this.conds[O];r=this.armCompiler.constructVCMP(a,E,b,R,M,D,w),r.writesPC=!1}else if((t&264179455)==246745664){let O=t>>28&15,S=t>>22&1,b=t>>12&15,R=t>>8&1,M=t>>7&1,T=t>>5&1,w=t&15,E=R?(S?16:0)|b:b<<1|(S?1:0),D=R?(T?16:0)|w:w<<1|(T?1:0);var a=this.conds[O];r=this.armCompiler.constructVCMP0(a,E,b,R,M,D,w),r.writesPC=!1}else if(t==4008835600)r=this.armCompiler.constructNOP();else if((t&266342160)==234883600){let O=t>>28&15,S=t>>20&1,b=t>>16&15,R=t>>12&15,M=t>>7&1;var a=this.conds[O];r=this.armCompiler.constructVMOV(a,S,b<<1|(M?1:0),R)}else t==3992980240?r=this.armCompiler.constructVMOV(a,!1,0,0):t==3995081488&&(r=this.armCompiler.constructVMOV(a,!1,1,1));break;default:throw new Z("Bad opcode: 0x"+t.toString(16))}return r.execMode=0,r.fixedJump=r.fixedJump||!1,r};y.prototype.compileThumb=function(t){var r=this.badOp(t&65535),i=this,s=this.gprs;if((t&64512)==16384){var e=(t&56)>>3,a=t&7;switch(t&960){case 0:r=this.thumbCompiler.constructAND(a,e);break;case 64:r=this.thumbCompiler.constructEOR(a,e);break;case 128:r=this.thumbCompiler.constructLSL2(a,e);break;case 192:r=this.thumbCompiler.constructLSR2(a,e);break;case 256:r=this.thumbCompiler.constructASR2(a,e);break;case 320:r=this.thumbCompiler.constructADC(a,e);break;case 384:r=this.thumbCompiler.constructSBC(a,e);break;case 448:r=this.thumbCompiler.constructROR(a,e);break;case 512:r=this.thumbCompiler.constructTST(a,e);break;case 576:r=this.thumbCompiler.constructNEG(a,e);break;case 640:r=this.thumbCompiler.constructCMP2(a,e);break;case 704:r=this.thumbCompiler.constructCMN(a,e);break;case 768:r=this.thumbCompiler.constructORR(a,e);break;case 832:r=this.thumbCompiler.constructMUL(a,e);break;case 896:r=this.thumbCompiler.constructBIC(a,e);break;case 960:r=this.thumbCompiler.constructMVN(a,e);break}r.writesPC=!1}else if((t&64512)==17408){var e=(t&120)>>3,c=t&7,p=t&128,a=c|p>>4;switch(t&768){case 0:r=this.thumbCompiler.constructADD4(a,e),r.writesPC=a==15;break;case 256:r=this.thumbCompiler.constructCMP3(a,e),r.writesPC=!1;break;case 512:r=this.thumbCompiler.constructMOV3(a,e),r.writesPC=a==15;break;case 768:r=this.thumbCompiler.constructBX(a,e),r.writesPC=!0,r.fixedJump=!1;break}}else if((t&63488)==6144){var e=(t&448)>>6,c=(t&56)>>3,a=t&7;switch(t&1536){case 0:r=this.thumbCompiler.constructADD3(a,c,e);break;case 512:r=this.thumbCompiler.constructSUB3(a,c,e);break;case 1024:var n=(t&448)>>6;n?r=this.thumbCompiler.constructADD1(a,c,n):r=this.thumbCompiler.constructMOV2(a,c,e);break;case 1536:var n=(t&448)>>6;r=this.thumbCompiler.constructSUB1(a,c,n);break}r.writesPC=!1}else if(t&57344)if((t&57344)==8192){var n=t&255,c=(t&1792)>>8;switch(t&6144){case 0:r=this.thumbCompiler.constructMOV1(c,n);break;case 2048:r=this.thumbCompiler.constructCMP1(c,n);break;case 4096:r=this.thumbCompiler.constructADD2(c,n);break;case 6144:r=this.thumbCompiler.constructSUB2(c,n);break}r.writesPC=!1}else if((t&63488)==18432){var a=(t&1792)>>8,n=(t&255)<<2;r=this.thumbCompiler.constructLDR3(a,n),r.writesPC=!1}else if((t&61440)==20480){var a=t&7,c=(t&56)>>3,e=(t&448)>>6,o=t&3584;switch(o){case 0:r=this.thumbCompiler.constructSTR2(a,c,e);break;case 512:r=this.thumbCompiler.constructSTRH2(a,c,e);break;case 1024:r=this.thumbCompiler.constructSTRB2(a,c,e);break;case 1536:r=this.thumbCompiler.constructLDRSB(a,c,e);break;case 2048:r=this.thumbCompiler.constructLDR2(a,c,e);break;case 2560:r=this.thumbCompiler.constructLDRH2(a,c,e);break;case 3072:r=this.thumbCompiler.constructLDRB2(a,c,e);break;case 3584:r=this.thumbCompiler.constructLDRSH(a,c,e);break}r.writesPC=!1}else if((t&57344)==24576){var a=t&7,c=(t&56)>>3,n=(t&1984)>>4,l=t&4096;l&&(n>>=2);var m=t&2048;m?l?r=this.thumbCompiler.constructLDRB1(a,c,n):r=this.thumbCompiler.constructLDR1(a,c,n):l?r=this.thumbCompiler.constructSTRB1(a,c,n):r=this.thumbCompiler.constructSTR1(a,c,n),r.writesPC=!1}else if((t&62976)==46080){var A=!!(t&256),h=t&255;t&2048?(r=this.thumbCompiler.constructPOP(h,A),r.writesPC=A,r.fixedJump=!1):(r=this.thumbCompiler.constructPUSH(h,A),r.writesPC=!1)}else if(t&32768)switch(t&28672){case 0:var a=t&7,c=(t&56)>>3,n=(t&1984)>>5;t&2048?r=this.thumbCompiler.constructLDRH1(a,c,n):r=this.thumbCompiler.constructSTRH1(a,c,n),r.writesPC=!1;break;case 4096:var a=(t&1792)>>8,n=(t&255)<<2,m=t&2048;m?r=this.thumbCompiler.constructLDR4(a,n):r=this.thumbCompiler.constructSTR3(a,n),r.writesPC=!1;break;case 8192:var a=(t&1792)>>8,n=(t&255)<<2;t&2048?r=this.thumbCompiler.constructADD6(a,n):r=this.thumbCompiler.constructADD5(a,n),r.writesPC=!1;break;case 12288:if(!(t&3840)){var l=t&128,n=(t&127)<<2;l&&(n=-n),r=this.thumbCompiler.constructADD7(n),r.writesPC=!1}break;case 16384:var c=(t&1792)>>8,h=t&255;t&2048?r=this.thumbCompiler.constructLDMIA(c,h):r=this.thumbCompiler.constructSTMIA(c,h),r.writesPC=!1;break;case 20480:var C=(t&3840)>>8,n=t&255;if(C==15)r=this.thumbCompiler.constructSWI(n),r.writesPC=!1;else{t&128&&(n|=4294967040),n<<=1;var x=this.conds[C];r=this.thumbCompiler.constructB1(n,x),r.writesPC=!0,r.fixedJump=!0}break;case 24576:case 28672:var n=t&2047,v=t&6144;switch(v){case 0:n&1024&&(n|=4294965248),n<<=1,r=this.thumbCompiler.constructB2(n),r.writesPC=!0,r.fixedJump=!0;break;case 2048:break;case 4096:n&1024&&(n|=4294966272),n<<=12,r=this.thumbCompiler.constructBL1(n),r.writesPC=!1;break;case 6144:r=this.thumbCompiler.constructBL2(n),r.writesPC=!0,r.fixedJump=!1;break}break;default:throw new Z("Undefined instruction: 0x"+t.toString(16))}else throw new Z("Bad opcode: 0x"+t.toString(16));else{var a=t&7,e=(t&56)>>3,n=(t&1984)>>6;switch(t&6144){case 0:r=this.thumbCompiler.constructLSL1(a,e,n);break;case 2048:r=this.thumbCompiler.constructLSR1(a,e,n);break;case 4096:r=this.thumbCompiler.constructASR1(a,e,n);break;case 6144:break}r.writesPC=!1}return r.execMode=1,r.fixedJump=r.fixedJump||!1,r};var sr=class{constructor(){this.f64arr=new Float64Array(1);this.f32arr=new Float32Array(this.f64arr.buffer);this.i32arr=new Int32Array(this.f64arr.buffer);this.BASE_OFFSET=24;this.OFFSET_MASK=16777215;this.core=new y,this.core.irq=this,this.core.mmu=this,this.resetMemory()}resetMemory(){this.memory=[];for(var r=0;r<256;r++){let i=10;this.memory[r]={PAGE_MASK:(2<<i)-1,ICACHE_PAGE_BITS:i,icache:new Array}}}advanceInsn(){var r=this.core.cycles;return this.core.step(),r-=this.core.cycles,r>0?r:1}getPC(){return this.core.gprs[15]-this.core.instructionWidth}getSP(){return this.core.gprs[13]}isStable(){return!0}connectMemoryBus(r){this.bus=r}reset(){this.resetMemory();let r=this.load32(0);this.core.resetCPU(r)}saveState(){return this.core.freeze()}loadState(r){this.core.defrost(r)}load8(r){return this.bus.read(r)<<24>>24}loadU8(r){return this.bus.read(r)&255}load16(r){return this.loadU16(r)<<16>>16}loadU16(r){return this.bus.read(r)|this.bus.read(r+1)<<8}load32(r){var i=this.bus.read32(r);return i}store8(r,i){this.bus.write(r,i&255)}store16(r,i){this.bus.write(r,i&255),this.bus.write(r+1,i>>8&255)}store32(r,i){this.bus.write32(r,i)}wait(r){++this.core.cycles}wait32(r){++this.core.cycles}waitSeq32(r){++this.core.cycles}waitMul(r){(r&4294967040)==4294967040||!(r&4294967040)?this.core.cycles+=1:(r&4294901760)==4294901760||!(r&4294901760)?this.core.cycles+=2:(r&4278190080)==4278190080||!(r&4278190080)?this.core.cycles+=3:this.core.cycles+=4}waitMulti32(r,i){this.core.cycles+=2}waitPrefetch(r){++this.core.cycles}waitPrefetch32(r){++this.core.cycles}addressToPage(r,i){return i>>this.memory[r].ICACHE_PAGE_BITS}accessPage(r,i){var s=this.memory[r],e=s.icache[i];return(!e||e.invalid)&&(e={thumb:new Array(1<<s.ICACHE_PAGE_BITS),arm:new Array(1<<s.ICACHE_PAGE_BITS-1),invalid:!1},s.icache[i]=e),e}swi(r){this.core.raiseTrap()}swi32(r){this.swi(r>>16)}clear(){}updateTimers(){}testIRQ(){}isThumb(){return this.core.instructionWidth==2}getDebugTree(){return{state:this.saveState(),mmu:this.core.mmu}}};var Dr=mr([[I.A,0,1],[I.B,0,2],[I.GP_A,0,1],[I.GP_B,0,2],[I.SELECT,0,4],[I.START,0,8],[I.RIGHT,0,16],[I.LEFT,0,32],[I.UP,0,64],[I.DOWN,0,128]]),B=0,N=1048576,dr=0,j=67108864,X=256,Ir=1e6,Pr=4e6,Rr=3991793133,ir=class extends Cr{constructor(){super();this.cpuFrequency=Pr;this.canvasWidth=160;this.numTotalScanlines=256;this.numVisibleScanlines=128;this.cpuCyclesPerLine=Math.floor(Pr/(256*60));this.defaultROMSize=N-dr;this.sampleRate=1;this.cpu=new sr;this.ram=new Uint8Array(N);this.ram16=new Uint16Array(this.ram.buffer);this.ram32=new Uint32Array(this.ram.buffer);this.rombase=dr;this.brightness=255;this.ioregs=new Uint8Array(X);this.ioregs32=new Uint32Array(this.ioregs.buffer);this.read=tr([[B,B+N-1,N-1,r=>this.ram[r]],[j,j+X-1,X-1,(r,i)=>this.readIO(r)]],{defaultval:Rr&255});this.write=tr([[B,B+N-1,N-1,(r,i)=>{this.ram[r]=i}],[j,j+X-1,X-1,(r,i)=>{this.writeIO(r,i)}]]);this.read32=r=>r>=B&&r<N&&(r&3)==0?this.ram32[r>>2]:this.read(r)|this.read(r+1)<<8|this.read(r+2)<<16|this.read(r+3)<<24;this.write32=(r,i)=>{r>=B&&r<N&&(r&3)==0?this.ram32[r>>2]=i:(this.write(r,i&255),this.write(r+1,i>>8&255),this.write(r+2,i>>16&255),this.write(r+3,i>>24&255))};this.connectCPUMemoryBus(this),this.handler=fr(this.inputs,Dr)}connectVideo(r){super.connectVideo(r),this.pixels32=r,this.pixels8=new Uint8Array(r.buffer)}connectSerialIO(r){this.serial=r}loadROM(r){super.loadROM(r)}reset(){this.ram.fill(0),this.rom&&this.ram.set(this.rom,this.rombase),super.reset(),this.serialOut=[],this.serialIn=[]}readAddress(r){return r>=B&&r<B+N?this.read(r):Rr}readIO(r){switch(r){case 0:return this.inputs[0];case 32:return this.getRasterY()&255;case 33:return this.getRasterY()>>8;case 36:return this.getRasterX();case 37:return this.getRasterX()>>8;case 64:return(this.serial.byteAvailable()?128:0)|(this.serial.clearToSend()?64:0);case 68:let i=this.serialIn.shift();return i!=null?(this.serialOut.push(i),i.value):0;default:return 0}}writeIO(r,i){switch(this.ioregs[r]=i,r){case 72:this.serialOut.length<Ir&&this.serialOut.push({op:"write",value:i,nbits:8});break}}startScanline(){}drawScanline(){}postFrame(){for(var r=this.pixels32,s=this.ioregs32[128>>2]>>1&1048575,e=this.brightness<<24,a=0;a<r.length;a++){var c=this.ram16[a+s];r[a]=e|(c&31)<<3|(c>>5&31)<<11|(c>>10&31)<<19}}getDebugCategories(){return["CPU","Stack","FPU"]}getDebugInfo(r,i){switch(r){case"Stack":for(var s="",e=i.c,a=e.gprs[13],c=e.gprs[11],p=0;p<16&&(s+=_(a,8)+" "+_(this.ram32[a-B>>2],8),a==c&&(s+=" FP"),s+=`
`,a+=4,!(a>=B+N));p++);return s;case"CPU":var s="",e=i.c;let n={2:"Thumb",4:"ARM"},o={15:"PC",14:"LR",13:"SP",12:"IP",11:"FP",9:"SB"};for(var p=0;p<8;p++){let m=p+8;s+=z("r"+p,5)+" "+_(e.gprs[p],8)+" ",s+=z("r"+m,5)+" "+_(e.gprs[m],8)+z(o[m]||"",3)+`
`}return s+="Flags ",s+=e.cpsrN?" N":" -",s+=e.cpsrV?" V":" -",s+=e.cpsrF?" F":" -",s+=e.cpsrZ?" Z":" -",s+=e.cpsrC?" C":" -",s+=e.cpsrI?" I":" -",s+=`
`,s+="MODE "+n[e.instructionWidth]+" "+Or[e.mode]+`
`,s+="SPSR "+_(e.spsr,8)+`
`,s+="cycl "+e.cycles+`
`,s;case"FPU":for(var s="",e=i.c,p=0;p<16;p++)s+=z("s"+p,5)+" "+_(e.ifprs[p],8)+" "+e.sfprs[p].toPrecision(6),p&1&&(s+=z("d"+(p>>1),5)+" "+e.dfprs[p>>1].toPrecision(12)),s+=`
`;return s}}saveState(){var r=super.saveState();return r.serial={sin:this.serialIn.slice(0),sout:this.serialOut.slice(0)},r}loadState(r){super.loadState(r),this.serialIn=r.serial.sin,this.serialOut=r.serial.sout}},Or={16:"USER",17:"FIQ",18:"IRQ",19:"SUPERVISOR",23:"ABORT",27:"UNDEFINED",31:"SYSTEM"};var _r=[{id:"vidfill.c",name:"Video Memory Fill"}],br=class extends lr{getToolForFilename(r){return r=r.toLowerCase(),r.endsWith(".vasm")?"vasmarm":r.endsWith(".armips")?"armips":(r.endsWith(".c")||r.endsWith(".s"),"armtcc")}getPresets(){return _r}getDefaultExtension(){return".c"}},yr=class extends br{constructor(){super(...arguments);this.getMemoryMap=function(){return{main:[{name:"ROM",start:0,size:1048576,type:"ram"},{name:"I/O",start:67108864,size:256,type:"io"}]}}}async start(){super.start(),console.log("Loading Capstone"),await Fr("./lib/capstone-arm.min.js"),this.capstone_arm=new cs.Capstone(cs.ARCH_ARM,cs.MODE_ARM),this.capstone_thumb=new cs.Capstone(cs.ARCH_ARM,cs.MODE_THUMB)}newMachine(){return new ir}readAddress(r){return this.machine.read(r)}getPlatformName(){return"ARM7"}getDebugTree(){return or(nr({},this.machine.cpu.getDebugTree()),{dwarf:this.debugSymbols.debuginfo})}disassemble(r,i){for(var s=this.machine.cpu.isThumb(),e=s?this.capstone_thumb:this.capstone_arm,a=[],c=0;c<4;c++)a[c]=i(r+c);var p=e.disasm(a,r,4),n=p&&p[0];return n?{nbytes:n.size,line:n.mnemonic+" "+n.op_str,isaddr:n.address>0}:{nbytes:4,line:"???",isaddr:!1}}};hr.arm32=yr;export{br as BaseARMMachinePlatform};
//# sourceMappingURL=arm32-IVL2WI33.js.map