| 'use strict';function Virtio9p(a){this.fs=a;this.SendReply=function(){};this.configspace=[6,0,104,111,115,116,57,112];this.msize=this.BLOCKSIZE=8192;this.replybuffer=new Uint8Array(2*this.msize);this.replybuffersize=0;this.fid2inode=[];this.fidtype=[];this._state_skip=["fs","SendReply"]}Virtio9p.prototype.BuildReply=function(a,b,c){Marshall(["w","b","h"],[c+7,a+1,b],this.replybuffer,0);this.replybuffersize=c+7}; |
| Virtio9p.prototype.SendError=function(a,b){var c=Marshall(["w"],[b],this.replybuffer,7);this.BuildReply(6,a,c)}; |
| Virtio9p.prototype.ReceiveRequest=function(a,b){var c=Unmarshall2(["w","b","h"],b),d=c[1],e=c[2];switch(d){case 8:var c=1234567,f=[16914839];f[1]=this.BLOCKSIZE;f[2]=Math.floor(1073741824/f[1]);f[3]=f[2]-Math.floor(c/f[1]);f[4]=f[2]-Math.floor(c/f[1]);f[5]=this.fs.inodes.length;f[6]=1048576;f[7]=0;f[8]=256;c=Marshall("wwddddddw".split(""),f,this.replybuffer,7);this.BuildReply(d,e,c);this.SendReply(a);break;case 112:case 12:var f=Unmarshall2(["w","w"],b),g=f[0],l=f[1],k=this.fs.GetInode(this.fid2inode[g]); |
| f[0]=k.qid;f[1]=this.msize-24;Marshall(["Q","w"],f,this.replybuffer,7);this.BuildReply(d,e,17);c=this.fs.OpenInode(this.fid2inode[g]);this.fs.AddEvent(this.fid2inode[g],function(){f[0]=k.qid;f[1]=this.msize-24;Marshall(["Q","w"],f,this.replybuffer,7);this.BuildReply(d,e,17);this.SendReply(a)}.bind(this));break;case 70:var f=Unmarshall2(["w","w","s"],b),l=f[0],g=f[1],c=f[2],k=this.fs.CreateInode(),m=this.fs.GetInode(this.fid2inode[g]),n=this.fs.inodedata[this.fid2inode[g]];k.mode=m.mode;k.size=m.size; |
| k.symlink=m.symlink;for(var p=this.fs.inodedata[this.fs.inodes.length]=new Uint8Array(k.size),m=0;m<k.size;m++)p[m]=n[m];k.name=c;k.parentid=this.fid2inode[l];this.fs.PushInode(k);this.BuildReply(d,e,0);this.SendReply(a);break;case 16:f=Unmarshall2(["w","s","s","w"],b);g=f[0];c=f[1];m=f[3];c=this.fs.CreateSymlink(c,this.fid2inode[g],f[2]);k=this.fs.GetInode(c);k.uid=m;k.gid=m;Marshall(["Q"],[k.qid],this.replybuffer,7);this.BuildReply(d,e,13);this.SendReply(a);break;case 18:f=Unmarshall2("wswwww".split(""), |
| b);g=f[0];c=f[1];l=f[2];c=this.fs.CreateNode(c,this.fid2inode[g],f[3],f[4]);k=this.fs.GetInode(c);k.mode=l;k.uid=m;k.gid=m;Marshall(["Q"],[k.qid],this.replybuffer,7);this.BuildReply(d,e,13);this.SendReply(a);break;case 22:f=Unmarshall2(["w"],b);g=f[0];k=this.fs.GetInode(this.fid2inode[g]);c=Marshall(["s"],[k.symlink],this.replybuffer,7);this.BuildReply(d,e,c);this.SendReply(a);break;case 72:f=Unmarshall2(["w","s","w","w"],b);g=f[0];c=f[1];l=f[2];m=f[3];c=this.fs.CreateDirectory(c,this.fid2inode[g]); |
| k=this.fs.GetInode(c);k.mode=l|S_IFDIR;k.uid=m;k.gid=m;Marshall(["Q"],[k.qid],this.replybuffer,7);this.BuildReply(d,e,13);this.SendReply(a);break;case 14:f=Unmarshall2(["w","s","w","w","w"],b);g=f[0];c=f[1];l=f[3];m=f[4];c=this.fs.CreateFile(c,this.fid2inode[g]);this.fid2inode[g]=c;this.fidtype[g]=1;k=this.fs.GetInode(c);k.uid=m;k.gid=m;k.mode=l;Marshall(["Q","w"],[k.qid,this.msize-24],this.replybuffer,7);this.BuildReply(d,e,17);this.SendReply(a);break;case 52:Marshall(["w"],[0],this.replybuffer, |
| 7);this.BuildReply(d,e,1);this.SendReply(a);break;case 24:f=Unmarshall2(["w","d"],b);g=f[0];k=this.fs.GetInode(this.fid2inode[g]);f[0]|=4096;f[0]=f[1];f[1]=k.qid;f[2]=k.mode;f[3]=k.uid;f[4]=k.gid;f[5]=1;f[6]=k.major<<8|k.minor;f[7]=k.size;f[8]=k.size;f[9]=Math.floor(k.size/this.BLOCKSIZE+1);f[10]=k.atime;f[11]=0;f[12]=k.mtime;f[13]=0;f[14]=k.ctime;f[15]=0;f[16]=0;f[17]=0;f[18]=0;f[19]=0;Marshall("dQwwwddddddddddddddd".split(""),f,this.replybuffer,7);this.BuildReply(d,e,153);this.SendReply(a);break; |
| case 26:f=Unmarshall2("wwwwwddddd".split(""),b);g=f[0];k=this.fs.GetInode(this.fid2inode[g]);f[1]&1&&(k.mode=f[2]);f[1]&2&&(k.uid=f[3]);f[1]&4&&(k.gid=f[4]);f[1]&128&&(k.atime=f[6]);f[1]&256&&(k.atime=f[8]);f[1]&16&&(k.atime=Math.floor((new Date).getTime()/1E3));f[1]&32&&(k.mtime=Math.floor((new Date).getTime()/1E3));f[1]&64&&(k.ctime=Math.floor((new Date).getTime()/1E3));f[1]&8&&this.fs.ChangeSize(this.fid2inode[g],f[5]);this.BuildReply(d,e,0);this.SendReply(a);break;case 50:f=Unmarshall2(["w","d"], |
| b);g=f[0];this.BuildReply(d,e,0);this.SendReply(a);break;case 40:case 116:var f=Unmarshall2(["w","d","w"],b),g=f[0],r=f[1],s=f[2],k=this.fs.GetInode(this.fid2inode[g]);if(2==this.fidtype[g]){k.caps.length<r+s&&(s=k.caps.length-r);for(m=0;m<s;m++)this.replybuffer[11+m]=k.caps[r+m];Marshall(["w"],[s],this.replybuffer,7);this.BuildReply(d,e,4+s);this.SendReply(a)}else this.fs.OpenInode(this.fid2inode[g]),this.fs.AddEvent(this.fid2inode[g],function(){k.size<r+s&&(s=k.size-r);var b=this.fs.inodedata[this.fid2inode[g]]; |
| if(b)for(var c=0;c<s;c++)this.replybuffer[11+c]=b[r+c];Marshall(["w"],[s],this.replybuffer,7);this.BuildReply(d,e,4+s);this.SendReply(a)}.bind(this));break;case 118:f=Unmarshall2(["w","d","w"],b);g=f[0];r=f[1];s=f[2];this.fs.Write(this.fid2inode[g],r,s,b);Marshall(["w"],[s],this.replybuffer,7);this.BuildReply(d,e,4);this.SendReply(a);break;case 74:f=Unmarshall2(["w","s","w","s"],b);c=this.fs.Rename(this.fid2inode[f[0]],f[1],this.fid2inode[f[2]],f[3]);if(0==c){this.SendError(e,2);this.SendReply(a); |
| break}this.BuildReply(d,e,0);this.SendReply(a);break;case 76:f=Unmarshall2(["w","s","w"],b);m=f[0];c=f[1];g=this.fs.Search(this.fid2inode[m],c);if(-1==g){this.SendError(e,2);this.SendReply(a);break}c=this.fs.Unlink(g);if(!c){this.SendError(e,39);this.SendReply(a);break}this.BuildReply(g,e,0);this.SendReply(a);break;case 100:this.msize=Unmarshall2(["w","s"],b)[0];c=Marshall(["w","s"],[this.msize,"9P2000.L"],this.replybuffer,7);this.BuildReply(d,e,c);this.SendReply(a);break;case 104:f=Unmarshall2(["w", |
| "w","s","s"],b);g=f[0];this.fid2inode[g]=0;this.fidtype[g]=1;k=this.fs.GetInode(this.fid2inode[g]);Marshall(["Q"],[k.qid],this.replybuffer,7);this.BuildReply(d,e,13);this.SendReply(a);break;case 108:f=Unmarshall2(["h"],b);this.BuildReply(d,e,0);this.SendReply(a);break;case 110:f=Unmarshall2(["w","w","h"],b);g=f[0];l=f[1];n=f[2];if(0==n){this.fid2inode[l]=this.fid2inode[g];Marshall(["h"],[0],this.replybuffer,7);this.BuildReply(d,e,2);this.SendReply(a);break}c=[];for(m=0;m<n;m++)c.push("s");for(var p= |
| Unmarshall2(c,b),c=this.fid2inode[g],r=9,q=0,m=0;m<n;m++){c=this.fs.Search(c,p[m]);if(-1==c)break;r+=Marshall(["Q"],[this.fs.inodes[c].qid],this.replybuffer,r);q++;this.fid2inode[l]=c;this.fidtype[l]=1}Marshall(["h"],[q],this.replybuffer,7);this.BuildReply(d,e,r-7);this.SendReply(a);break;case 120:f=Unmarshall2(["w"],b);0<=this.fid2inode[f[0]]&&(this.fs.CloseInode(this.fid2inode[f[0]]),this.fid2inode[f[0]]=-1,this.fidtype[f[0]]=-1);this.BuildReply(d,e,0);this.SendReply(a);break;case 32:this.SendError(e, |
| 524);this.SendReply(a);break;case 30:f=Unmarshall2(["w","w","s"],b),g=f[0],m=f[1],c=f[2],this.fid2inode[m]=this.fid2inode[g],this.fidtype[m]=-1,l=0,"security.capability"==c&&(l=this.fs.PrepareCAPs(this.fid2inode[g]),this.fidtype[m]=2),Marshall(["d"],[l],this.replybuffer,7),this.BuildReply(d,e,8),this.SendReply(a)}};window.requestAnimationFrame||(window.requestAnimationFrame=window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame); |
| function ScreenAdapter(a,b){function c(a){a=a.toString(16);return"#"+Array(7-a.length).join("0")+a}function d(){for(var a=0;a<z;a++)y[a]&&(G.text_update_row(a),y[a]=0);this.timer()}function e(){u<t&&(l.putImageData(n,0,0,0,u/C>>2,C,((t-u)/C>>2)+1),u=1E7,t=0);this.timer()}function f(a,b,c){b=""+(1===b?"":" scaleX("+b+")")+(1===c?"":" scaleY("+c+")");a.style.webkitTransform=a.style.MozTransform=b}console.assert(a,"1st argument must be a DOM container");for(var g=a.getElementsByTagName("canvas")[0], |
| l=g.getContext("2d"),k=g.nextElementSibling||g.previousElementSibling,m=document.createElement("div"),n,p,r,s,q,w=1,B=1,C,u=0,t=0,y,D=!1,v,x,z,G=this,H=new Uint16Array([199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197,201,230,198,244,246,242,251,249,255,214,220,162,163,165,8359,402,225,237,243,250,241,209,170,186,191,8976,172,189,188,161,171,187,9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488,9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574, |
| 9568,9552,9580,9575,9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600,945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745,8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160]),I=new Uint16Array([32,9786,9787,9829,9830,9827,9824,8226,9688,9675,9689,9794,9792,9834,9835,9788,9658,9668,8597,8252,182,167,9644,8616,8593,8595,8594,8592,8735,8596,9650,9660]),F=[],E,A=0;256>A;A++)127<A?E=H[A-128]:32>A?E=I[A]:E=A,F[A]=String.fromCharCode(E); |
| l.imageSmoothingEnabled=!1;l.mozImageSmoothingEnabled=!1;l.webkitImageSmoothingEnabled=!1;m.style.position="absolute";m.style.backgroundColor="#ccc";m.style.width="7px";m.style.display="inline-block";k.style.display="block";g.style.display="none";this.bus=b;b.register("screen-set-mode",function(a){this.set_mode(a)},this);b.register("screen-put-pixel-linear",function(a){this.put_pixel_linear(a[0],a[1])},this);b.register("screen-put-pixel-linear32",function(a){this.put_pixel_linear32(a[0],a[1])},this); |
| b.register("screen-put-char",function(a){this.put_char(a[0],a[1],a[2],a[3],a[4])},this);b.register("screen-update-cursor",function(a){this.update_cursor(a[0],a[1])},this);b.register("screen-update-cursor-scanline",function(a){this.update_cursor_scanline(a[0],a[1])},this);b.register("screen-set-size-text",function(a){this.set_size_text(a[0],a[1])},this);b.register("screen-set-size-graphical",function(a){this.set_size_graphical(a[0],a[1])},this);this.init=function(){this.set_size_text(80,25);this.timer()}; |
| this.make_screenshot=function(){try{window.open(g.toDataURL())}catch(a){}};this.put_char=function(a,b,c,e,d){a<z&&b<x&&(b=3*(a*x+b),v[b]=c,v[b+1]=e,v[b+2]=d,y[a]=1)};this.timer=function(){requestAnimationFrame(D?e:d)};d=d.bind(this);e=e.bind(this);this.put_pixel_linear=function(a,b){a>=p.length||(u=a<u?a:u,t=a>t?a:t,p[a+1^3]=b)};this.put_pixel_linear32=function(a,b){u=a<u?a:u;t=a>t?a:t;r[a>>2]=4278190080|b>>16&255|b<<16|b&65280};this.destroy=function(){};this.set_mode=function(a){(D=a)?(k.style.display= |
| "none",g.style.display="block"):(k.style.display="block",g.style.display="none")};this.set_size_text=function(a,b){if(a!==x&&b!==z){y=new Int8Array(b);v=new Int32Array(a*b*3);x=a;for(z=b;k.childNodes.length>b;)k.removeChild(k.firstChild);for(;k.childNodes.length<b;)k.appendChild(document.createElement("div"));for(var c=0;c<b;c++)this.text_update_row(c)}};this.set_size_graphical=function(a,b){g.style.display="block";g.width=a;g.height=b;n=l.createImageData(a,b);p=new Uint8Array(n.data.buffer);r=new Int32Array(n.data.buffer); |
| for(var c=3;c<p.length;c+=4)p[c]=255;C=a};this.set_scale=function(a,b){w=a;B=b;f(g,w,B);f(k,w,B)};this.set_scale(w,B);this.update_cursor_scanline=function(a,b){a&32?m.style.display="none":(m.style.display="inline",m.style.height=Math.min(15,b-a)+"px",m.style.marginTop=Math.min(15,a)+"px")};this.update_cursor=function(a,b){if(a!==s||b!==q)y[a]=1,y[s]=1,s=a,q=b};this.text_update_row=function(a){var b=3*a*x,e,d,f,g,l,n;e=k.childNodes[a];for(f=document.createDocumentFragment();e.firstChild;)e.removeChild(e.firstChild); |
| for(var p=0;p<x;){d=document.createElement("span");g=v[b+1];l=v[b+2];d.style.backgroundColor=c(g);d.style.color=c(l);for(n="";p<x&&v[b+1]===g&&v[b+2]===l;)if(n+=F[v[b]],p++,b+=3,a===s)if(p===q)break;else if(p===q+1){f.appendChild(m);break}d.textContent=n;f.appendChild(d)}e.appendChild(f)};this.init()};function CPU(){this.memory_size=0;this.segment_is_null=[];this.segment_offsets=[];this.segment_limits=[];this.tlb_data=new Int32Array(1048576);this.tlb_info=new Uint8Array(1048576);this.tlb_info_global=new Uint8Array(1048576);this.protected_mode=!1;this.gdtr_offset=this.gdtr_size=this.idtr_offset=this.idtr_size=0;this.page_fault=!1;this.page_size_extensions=this.cpl=this.cr4=this.cr3=this.cr2=this.cr0=0;this.in_hlt=this.address_size_32=this.stack_size_32=this.operand_size_32=this.is_32=!1;this.devices= |
| {vga:{timer:function(){},destroy:function(){}},ps2:{timer:function(){},destroy:function(){}}};this.tsc_offset=this.last_result=this.last_add_result=this.last_op_size=this.last_op2=this.last_op1=this.flags_changed=this.flags=this.repeat_string_prefix=this.sysenter_eip=this.sysenter_esp=this.sysenter_cs=this.eip_phys=this.last_virt_eip=0;this.regv=this.reg16;this.reg_vdi=this.reg_vsi=this.reg_vcx=0;this.table=[];this.table0F=[];this.paging=!1;this.previous_ip=this.instruction_pointer=0;this.bios={main:null, |
| vga:null};this.timestamp_counter=0;this.reg32s=new Int32Array(8);this.reg32=new Uint32Array(this.reg32s.buffer);this.reg16s=new Int16Array(this.reg32s.buffer);this.reg16=new Uint16Array(this.reg32s.buffer);this.reg8s=new Int8Array(this.reg32s.buffer);this.reg8=new Uint8Array(this.reg32s.buffer);this.sreg=new Uint16Array(8);this.dreg=new Int32Array(8);this.stack_reg=this.reg16;this.reg_vbp=this.reg_vsp=0;this.memory=null;this.segment_prefix=-1;this.last_instr_jump=!1;this.fpu=this.io=void 0;"use strict"; |
| (function(a){var b={};a.debug=b;b.step_mode=!1;b.ops=void 0;b.all_ops=[];b.trace_all=!1;b.show=function(a){if("undefined"!==typeof document){var b=document.getElementById("log");if(b){b.textContent+=a+"\n";b.style.display="block";b.scrollTop=1E9;return}}console.log(b)};b.init=function(){};b.dump_regs=function(){};b.dump_instructions=function(){};b.get_instructions=function(){};b.dump_regs_short=function(){};b.dump_stack=function(){};b.dump_page_directory=function(){};b.dump_gdt_ldt=function(){};b.dump_idt= |
| function(){};b.get_memory_dump=function(){};b.memory_hex_dump=function(){};b.used_memory_dump=function(){};b.step=function(){};b.run_until=function(){};b.debugger=function(){};b.unimpl=function(a){a="Unimplemented"+(a?": "+a:"");b.show(a);b.show("Execution stopped");return a};b.logop=function(){}})(this);this._state_restore()} |
| CPU.prototype._state_restore=function(){this.reg32=new Uint32Array(this.reg32s.buffer);this.reg16s=new Int16Array(this.reg32s.buffer);this.reg16=new Uint16Array(this.reg32s.buffer);this.reg8s=new Int8Array(this.reg32s.buffer);this.reg8=new Uint8Array(this.reg32s.buffer);this.update_address_size();this.update_operand_size();this.stack_size_32?this.stack_reg=this.reg32s:this.stack_reg=this.reg16;this.full_clear_tlb();this.timestamp_counter=0;this.tsc_offset=v86.microtick();this._state_skip=[this.bios, |
| this.debug,this.table16,this.table32,this.table0F_16,this.table0F_32,this.tlb_data,this.tlb_info,this.tlb_info_global]};"use strict"; |
| (function(){CPU.prototype.modrm_table16=Array(192);CPU.prototype.modrm_table32=Array(192);CPU.prototype.sib_table=Array(256);CPU.prototype.modrm_table16[0]=function(a){return a.get_seg_prefix_ds()+(a.reg16[6]+a.reg16[12]&65535)|0};CPU.prototype.modrm_table16[64]=function(a){return a.get_seg_prefix_ds()+(a.reg16[6]+a.reg16[12]+a.read_imm8s()&65535)|0};CPU.prototype.modrm_table16[128]=function(a){return a.get_seg_prefix_ds()+(a.reg16[6]+a.reg16[12]+a.read_imm16()&65535)|0};CPU.prototype.modrm_table16[1]= |
| function(a){return a.get_seg_prefix_ds()+(a.reg16[6]+a.reg16[14]&65535)|0};CPU.prototype.modrm_table16[65]=function(a){return a.get_seg_prefix_ds()+(a.reg16[6]+a.reg16[14]+a.read_imm8s()&65535)|0};CPU.prototype.modrm_table16[129]=function(a){return a.get_seg_prefix_ds()+(a.reg16[6]+a.reg16[14]+a.read_imm16()&65535)|0};CPU.prototype.modrm_table16[2]=function(a){return a.get_seg_prefix_ss()+(a.reg16[10]+a.reg16[12]&65535)|0};CPU.prototype.modrm_table16[66]=function(a){return a.get_seg_prefix_ss()+(a.reg16[10]+ |
| a.reg16[12]+a.read_imm8s()&65535)|0};CPU.prototype.modrm_table16[130]=function(a){return a.get_seg_prefix_ss()+(a.reg16[10]+a.reg16[12]+a.read_imm16()&65535)|0};CPU.prototype.modrm_table16[3]=function(a){return a.get_seg_prefix_ss()+(a.reg16[10]+a.reg16[14]&65535)|0};CPU.prototype.modrm_table16[67]=function(a){return a.get_seg_prefix_ss()+(a.reg16[10]+a.reg16[14]+a.read_imm8s()&65535)|0};CPU.prototype.modrm_table16[131]=function(a){return a.get_seg_prefix_ss()+(a.reg16[10]+a.reg16[14]+a.read_imm16()& |
| 65535)|0};CPU.prototype.modrm_table16[4]=function(a){return a.get_seg_prefix_ds()+(a.reg16[12]&65535)|0};CPU.prototype.modrm_table16[68]=function(a){return a.get_seg_prefix_ds()+(a.reg16[12]+a.read_imm8s()&65535)|0};CPU.prototype.modrm_table16[132]=function(a){return a.get_seg_prefix_ds()+(a.reg16[12]+a.read_imm16()&65535)|0};CPU.prototype.modrm_table16[5]=function(a){return a.get_seg_prefix_ds()+(a.reg16[14]&65535)|0};CPU.prototype.modrm_table16[69]=function(a){return a.get_seg_prefix_ds()+(a.reg16[14]+ |
| a.read_imm8s()&65535)|0};CPU.prototype.modrm_table16[133]=function(a){return a.get_seg_prefix_ds()+(a.reg16[14]+a.read_imm16()&65535)|0};CPU.prototype.modrm_table16[6]=function(a){return a.get_seg_prefix_ss()+(a.reg16[10]&65535)|0};CPU.prototype.modrm_table16[70]=function(a){return a.get_seg_prefix_ss()+(a.reg16[10]+a.read_imm8s()&65535)|0};CPU.prototype.modrm_table16[134]=function(a){return a.get_seg_prefix_ss()+(a.reg16[10]+a.read_imm16()&65535)|0};CPU.prototype.modrm_table16[7]=function(a){return a.get_seg_prefix_ds()+ |
| (a.reg16[6]&65535)|0};CPU.prototype.modrm_table16[71]=function(a){return a.get_seg_prefix_ds()+(a.reg16[6]+a.read_imm8s()&65535)|0};CPU.prototype.modrm_table16[135]=function(a){return a.get_seg_prefix_ds()+(a.reg16[6]+a.read_imm16()&65535)|0};CPU.prototype.modrm_table32[0]=function(a){return a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.modrm_table32[64]=function(a){return a.get_seg_prefix_ds()+a.reg32s[0]+a.read_imm8s()|0};CPU.prototype.modrm_table32[128]=function(a){return a.get_seg_prefix_ds()+ |
| a.reg32s[0]+a.read_imm32s()|0};CPU.prototype.modrm_table32[1]=function(a){return a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.modrm_table32[65]=function(a){return a.get_seg_prefix_ds()+a.reg32s[1]+a.read_imm8s()|0};CPU.prototype.modrm_table32[129]=function(a){return a.get_seg_prefix_ds()+a.reg32s[1]+a.read_imm32s()|0};CPU.prototype.modrm_table32[2]=function(a){return a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.modrm_table32[66]=function(a){return a.get_seg_prefix_ds()+a.reg32s[2]+a.read_imm8s()| |
| 0};CPU.prototype.modrm_table32[130]=function(a){return a.get_seg_prefix_ds()+a.reg32s[2]+a.read_imm32s()|0};CPU.prototype.modrm_table32[3]=function(a){return a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.modrm_table32[67]=function(a){return a.get_seg_prefix_ds()+a.reg32s[3]+a.read_imm8s()|0};CPU.prototype.modrm_table32[131]=function(a){return a.get_seg_prefix_ds()+a.reg32s[3]+a.read_imm32s()|0};CPU.prototype.modrm_table32[4]=function(a){return a.sib_table[a.read_imm8()](a,!1)|0};CPU.prototype.modrm_table32[68]= |
| function(a){return a.sib_table[a.read_imm8()](a,!1)+a.read_imm8s()|0};CPU.prototype.modrm_table32[132]=function(a){return a.sib_table[a.read_imm8()](a,!1)+a.read_imm32s()|0};CPU.prototype.modrm_table32[5]=function(a){return a.get_seg_prefix_ss()+a.reg32s[5]|0};CPU.prototype.modrm_table32[69]=function(a){return a.get_seg_prefix_ss()+a.reg32s[5]+a.read_imm8s()|0};CPU.prototype.modrm_table32[133]=function(a){return a.get_seg_prefix_ss()+a.reg32s[5]+a.read_imm32s()|0};CPU.prototype.modrm_table32[6]=function(a){return a.get_seg_prefix_ds()+ |
| a.reg32s[6]|0};CPU.prototype.modrm_table32[70]=function(a){return a.get_seg_prefix_ds()+a.reg32s[6]+a.read_imm8s()|0};CPU.prototype.modrm_table32[134]=function(a){return a.get_seg_prefix_ds()+a.reg32s[6]+a.read_imm32s()|0};CPU.prototype.modrm_table32[7]=function(a){return a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.modrm_table32[71]=function(a){return a.get_seg_prefix_ds()+a.reg32s[7]+a.read_imm8s()|0};CPU.prototype.modrm_table32[135]=function(a){return a.get_seg_prefix_ds()+a.reg32s[7]+a.read_imm32s()| |
| 0};CPU.prototype.modrm_table16[6]=function(a){return a.get_seg_prefix_ds()+a.read_imm16()|0};CPU.prototype.modrm_table32[5]=function(a){return a.get_seg_prefix_ds()+a.read_imm32s()|0};CPU.prototype.modrm_table32[4]=function(a){return a.sib_table[a.read_imm8()](a,!1)|0};CPU.prototype.modrm_table32[68]=function(a){return a.sib_table[a.read_imm8()](a,!0)+a.read_imm8s()|0};CPU.prototype.modrm_table32[132]=function(a){return a.sib_table[a.read_imm8()](a,!0)+a.read_imm32s()|0};for(var a=0;8>a;a++)for(var b= |
| 0;3>b;b++)for(var c=a|b<<6,d=1;8>d;d++)CPU.prototype.modrm_table32[c|d<<3]=CPU.prototype.modrm_table32[c],CPU.prototype.modrm_table16[c|d<<3]=CPU.prototype.modrm_table16[c];CPU.prototype.sib_table[0]=function(a){return a.reg32s[0]+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[1]=function(a){return a.reg32s[0]+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[2]=function(a){return a.reg32s[0]+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[3]=function(a){return a.reg32s[0]+ |
| a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[4]=function(a){return a.reg32s[0]+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[5]=function(a,b){return a.reg32s[0]+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[6]=function(a){return a.reg32s[0]+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[7]=function(a){return a.reg32s[0]+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[64]=function(a){return(a.reg32s[0]<< |
| 1)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[65]=function(a){return(a.reg32s[0]<<1)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[66]=function(a){return(a.reg32s[0]<<1)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[67]=function(a){return(a.reg32s[0]<<1)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[68]=function(a){return(a.reg32s[0]<<1)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[69]=function(a,b){return(a.reg32s[0]<< |
| 1)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[70]=function(a){return(a.reg32s[0]<<1)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[71]=function(a){return(a.reg32s[0]<<1)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[128]=function(a){return(a.reg32s[0]<<2)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[129]=function(a){return(a.reg32s[0]<<2)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[130]= |
| function(a){return(a.reg32s[0]<<2)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[131]=function(a){return(a.reg32s[0]<<2)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[132]=function(a){return(a.reg32s[0]<<2)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[133]=function(a,b){return(a.reg32s[0]<<2)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[134]=function(a){return(a.reg32s[0]<<2)+a.get_seg_prefix_ds()+ |
| a.reg32s[6]|0};CPU.prototype.sib_table[135]=function(a){return(a.reg32s[0]<<2)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[192]=function(a){return(a.reg32s[0]<<3)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[193]=function(a){return(a.reg32s[0]<<3)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[194]=function(a){return(a.reg32s[0]<<3)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[195]=function(a){return(a.reg32s[0]<<3)+a.get_seg_prefix_ds()+ |
| a.reg32s[3]|0};CPU.prototype.sib_table[196]=function(a){return(a.reg32s[0]<<3)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[197]=function(a,b){return(a.reg32s[0]<<3)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[198]=function(a){return(a.reg32s[0]<<3)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[199]=function(a){return(a.reg32s[0]<<3)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[8]=function(a){return a.reg32s[1]+ |
| a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[9]=function(a){return a.reg32s[1]+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[10]=function(a){return a.reg32s[1]+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[11]=function(a){return a.reg32s[1]+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[12]=function(a){return a.reg32s[1]+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[13]=function(a,b){return a.reg32s[1]+(b?a.get_seg_prefix_ss()+ |
| a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[14]=function(a){return a.reg32s[1]+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[15]=function(a){return a.reg32s[1]+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[72]=function(a){return(a.reg32s[1]<<1)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[73]=function(a){return(a.reg32s[1]<<1)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[74]=function(a){return(a.reg32s[1]<< |
| 1)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[75]=function(a){return(a.reg32s[1]<<1)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[76]=function(a){return(a.reg32s[1]<<1)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[77]=function(a,b){return(a.reg32s[1]<<1)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[78]=function(a){return(a.reg32s[1]<<1)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[79]= |
| function(a){return(a.reg32s[1]<<1)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[136]=function(a){return(a.reg32s[1]<<2)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[137]=function(a){return(a.reg32s[1]<<2)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[138]=function(a){return(a.reg32s[1]<<2)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[139]=function(a){return(a.reg32s[1]<<2)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[140]= |
| function(a){return(a.reg32s[1]<<2)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[141]=function(a,b){return(a.reg32s[1]<<2)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[142]=function(a){return(a.reg32s[1]<<2)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[143]=function(a){return(a.reg32s[1]<<2)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[200]=function(a){return(a.reg32s[1]<<3)+a.get_seg_prefix_ds()+ |
| a.reg32s[0]|0};CPU.prototype.sib_table[201]=function(a){return(a.reg32s[1]<<3)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[202]=function(a){return(a.reg32s[1]<<3)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[203]=function(a){return(a.reg32s[1]<<3)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[204]=function(a){return(a.reg32s[1]<<3)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[205]=function(a,b){return(a.reg32s[1]<<3)+(b?a.get_seg_prefix_ss()+ |
| a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[206]=function(a){return(a.reg32s[1]<<3)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[207]=function(a){return(a.reg32s[1]<<3)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[16]=function(a){return a.reg32s[2]+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[17]=function(a){return a.reg32s[2]+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[18]=function(a){return a.reg32s[2]+ |
| a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[19]=function(a){return a.reg32s[2]+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[20]=function(a){return a.reg32s[2]+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[21]=function(a,b){return a.reg32s[2]+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[22]=function(a){return a.reg32s[2]+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[23]=function(a){return a.reg32s[2]+ |
| a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[80]=function(a){return(a.reg32s[2]<<1)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[81]=function(a){return(a.reg32s[2]<<1)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[82]=function(a){return(a.reg32s[2]<<1)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[83]=function(a){return(a.reg32s[2]<<1)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[84]=function(a){return(a.reg32s[2]<<1)+a.get_seg_prefix_ss()+ |
| a.reg32s[4]|0};CPU.prototype.sib_table[85]=function(a,b){return(a.reg32s[2]<<1)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[86]=function(a){return(a.reg32s[2]<<1)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[87]=function(a){return(a.reg32s[2]<<1)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[144]=function(a){return(a.reg32s[2]<<2)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[145]=function(a){return(a.reg32s[2]<< |
| 2)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[146]=function(a){return(a.reg32s[2]<<2)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[147]=function(a){return(a.reg32s[2]<<2)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[148]=function(a){return(a.reg32s[2]<<2)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[149]=function(a,b){return(a.reg32s[2]<<2)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[150]= |
| function(a){return(a.reg32s[2]<<2)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[151]=function(a){return(a.reg32s[2]<<2)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[208]=function(a){return(a.reg32s[2]<<3)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[209]=function(a){return(a.reg32s[2]<<3)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[210]=function(a){return(a.reg32s[2]<<3)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[211]= |
| function(a){return(a.reg32s[2]<<3)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[212]=function(a){return(a.reg32s[2]<<3)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[213]=function(a,b){return(a.reg32s[2]<<3)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[214]=function(a){return(a.reg32s[2]<<3)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[215]=function(a){return(a.reg32s[2]<<3)+a.get_seg_prefix_ds()+ |
| a.reg32s[7]|0};CPU.prototype.sib_table[24]=function(a){return a.reg32s[3]+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[25]=function(a){return a.reg32s[3]+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[26]=function(a){return a.reg32s[3]+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[27]=function(a){return a.reg32s[3]+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[28]=function(a){return a.reg32s[3]+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[29]= |
| function(a,b){return a.reg32s[3]+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[30]=function(a){return a.reg32s[3]+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[31]=function(a){return a.reg32s[3]+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[88]=function(a){return(a.reg32s[3]<<1)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[89]=function(a){return(a.reg32s[3]<<1)+a.get_seg_prefix_ds()+a.reg32s[1]| |
| 0};CPU.prototype.sib_table[90]=function(a){return(a.reg32s[3]<<1)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[91]=function(a){return(a.reg32s[3]<<1)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[92]=function(a){return(a.reg32s[3]<<1)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[93]=function(a,b){return(a.reg32s[3]<<1)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[94]=function(a){return(a.reg32s[3]<< |
| 1)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[95]=function(a){return(a.reg32s[3]<<1)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[152]=function(a){return(a.reg32s[3]<<2)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[153]=function(a){return(a.reg32s[3]<<2)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[154]=function(a){return(a.reg32s[3]<<2)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[155]=function(a){return(a.reg32s[3]<< |
| 2)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[156]=function(a){return(a.reg32s[3]<<2)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[157]=function(a,b){return(a.reg32s[3]<<2)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[158]=function(a){return(a.reg32s[3]<<2)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[159]=function(a){return(a.reg32s[3]<<2)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[216]= |
| function(a){return(a.reg32s[3]<<3)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[217]=function(a){return(a.reg32s[3]<<3)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[218]=function(a){return(a.reg32s[3]<<3)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[219]=function(a){return(a.reg32s[3]<<3)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[220]=function(a){return(a.reg32s[3]<<3)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[221]= |
| function(a,b){return(a.reg32s[3]<<3)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[222]=function(a){return(a.reg32s[3]<<3)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[223]=function(a){return(a.reg32s[3]<<3)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[32]=function(a){return a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[33]=function(a){return a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[34]= |
| function(a){return a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[35]=function(a){return a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[36]=function(a){return a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[37]=function(a,b){return(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[38]=function(a){return a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[39]=function(a){return a.get_seg_prefix_ds()+ |
| a.reg32s[7]|0};CPU.prototype.sib_table[96]=function(a){return a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[97]=function(a){return a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[98]=function(a){return a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[99]=function(a){return a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[100]=function(a){return a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[101]=function(a,b){return(b?a.get_seg_prefix_ss()+ |
| a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[102]=function(a){return a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[103]=function(a){return a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[160]=function(a){return a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[161]=function(a){return a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[162]=function(a){return a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[163]= |
| function(a){return a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[164]=function(a){return a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[165]=function(a,b){return(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[166]=function(a){return a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[167]=function(a){return a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[224]=function(a){return a.get_seg_prefix_ds()+ |
| a.reg32s[0]|0};CPU.prototype.sib_table[225]=function(a){return a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[226]=function(a){return a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[227]=function(a){return a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[228]=function(a){return a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[229]=function(a,b){return(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[230]= |
| function(a){return a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[231]=function(a){return a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[40]=function(a){return a.reg32s[5]+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[41]=function(a){return a.reg32s[5]+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[42]=function(a){return a.reg32s[5]+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[43]=function(a){return a.reg32s[5]+a.get_seg_prefix_ds()+ |
| a.reg32s[3]|0};CPU.prototype.sib_table[44]=function(a){return a.reg32s[5]+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[45]=function(a,b){return a.reg32s[5]+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[46]=function(a){return a.reg32s[5]+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[47]=function(a){return a.reg32s[5]+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[104]=function(a){return(a.reg32s[5]<< |
| 1)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[105]=function(a){return(a.reg32s[5]<<1)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[106]=function(a){return(a.reg32s[5]<<1)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[107]=function(a){return(a.reg32s[5]<<1)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[108]=function(a){return(a.reg32s[5]<<1)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[109]=function(a,b){return(a.reg32s[5]<< |
| 1)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[110]=function(a){return(a.reg32s[5]<<1)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[111]=function(a){return(a.reg32s[5]<<1)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[168]=function(a){return(a.reg32s[5]<<2)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[169]=function(a){return(a.reg32s[5]<<2)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[170]= |
| function(a){return(a.reg32s[5]<<2)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[171]=function(a){return(a.reg32s[5]<<2)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[172]=function(a){return(a.reg32s[5]<<2)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[173]=function(a,b){return(a.reg32s[5]<<2)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[174]=function(a){return(a.reg32s[5]<<2)+a.get_seg_prefix_ds()+ |
| a.reg32s[6]|0};CPU.prototype.sib_table[175]=function(a){return(a.reg32s[5]<<2)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[232]=function(a){return(a.reg32s[5]<<3)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[233]=function(a){return(a.reg32s[5]<<3)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[234]=function(a){return(a.reg32s[5]<<3)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[235]=function(a){return(a.reg32s[5]<<3)+a.get_seg_prefix_ds()+ |
| a.reg32s[3]|0};CPU.prototype.sib_table[236]=function(a){return(a.reg32s[5]<<3)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[237]=function(a,b){return(a.reg32s[5]<<3)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[238]=function(a){return(a.reg32s[5]<<3)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[239]=function(a){return(a.reg32s[5]<<3)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[48]=function(a){return a.reg32s[6]+ |
| a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[49]=function(a){return a.reg32s[6]+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[50]=function(a){return a.reg32s[6]+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[51]=function(a){return a.reg32s[6]+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[52]=function(a){return a.reg32s[6]+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[53]=function(a,b){return a.reg32s[6]+(b?a.get_seg_prefix_ss()+ |
| a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[54]=function(a){return a.reg32s[6]+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[55]=function(a){return a.reg32s[6]+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[112]=function(a){return(a.reg32s[6]<<1)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[113]=function(a){return(a.reg32s[6]<<1)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[114]=function(a){return(a.reg32s[6]<< |
| 1)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[115]=function(a){return(a.reg32s[6]<<1)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[116]=function(a){return(a.reg32s[6]<<1)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[117]=function(a,b){return(a.reg32s[6]<<1)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[118]=function(a){return(a.reg32s[6]<<1)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[119]= |
| function(a){return(a.reg32s[6]<<1)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[176]=function(a){return(a.reg32s[6]<<2)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[177]=function(a){return(a.reg32s[6]<<2)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[178]=function(a){return(a.reg32s[6]<<2)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[179]=function(a){return(a.reg32s[6]<<2)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[180]= |
| function(a){return(a.reg32s[6]<<2)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[181]=function(a,b){return(a.reg32s[6]<<2)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[182]=function(a){return(a.reg32s[6]<<2)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[183]=function(a){return(a.reg32s[6]<<2)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[240]=function(a){return(a.reg32s[6]<<3)+a.get_seg_prefix_ds()+ |
| a.reg32s[0]|0};CPU.prototype.sib_table[241]=function(a){return(a.reg32s[6]<<3)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[242]=function(a){return(a.reg32s[6]<<3)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[243]=function(a){return(a.reg32s[6]<<3)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[244]=function(a){return(a.reg32s[6]<<3)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[245]=function(a,b){return(a.reg32s[6]<<3)+(b?a.get_seg_prefix_ss()+ |
| a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[246]=function(a){return(a.reg32s[6]<<3)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[247]=function(a){return(a.reg32s[6]<<3)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[56]=function(a){return a.reg32s[7]+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[57]=function(a){return a.reg32s[7]+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[58]=function(a){return a.reg32s[7]+ |
| a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[59]=function(a){return a.reg32s[7]+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[60]=function(a){return a.reg32s[7]+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[61]=function(a,b){return a.reg32s[7]+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[62]=function(a){return a.reg32s[7]+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[63]=function(a){return a.reg32s[7]+ |
| a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[120]=function(a){return(a.reg32s[7]<<1)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[121]=function(a){return(a.reg32s[7]<<1)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[122]=function(a){return(a.reg32s[7]<<1)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[123]=function(a){return(a.reg32s[7]<<1)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[124]=function(a){return(a.reg32s[7]<< |
| 1)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[125]=function(a,b){return(a.reg32s[7]<<1)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[126]=function(a){return(a.reg32s[7]<<1)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[127]=function(a){return(a.reg32s[7]<<1)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[184]=function(a){return(a.reg32s[7]<<2)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[185]= |
| function(a){return(a.reg32s[7]<<2)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[186]=function(a){return(a.reg32s[7]<<2)+a.get_seg_prefix_ds()+a.reg32s[2]|0};CPU.prototype.sib_table[187]=function(a){return(a.reg32s[7]<<2)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[188]=function(a){return(a.reg32s[7]<<2)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[189]=function(a,b){return(a.reg32s[7]<<2)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())| |
| 0};CPU.prototype.sib_table[190]=function(a){return(a.reg32s[7]<<2)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[191]=function(a){return(a.reg32s[7]<<2)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.sib_table[248]=function(a){return(a.reg32s[7]<<3)+a.get_seg_prefix_ds()+a.reg32s[0]|0};CPU.prototype.sib_table[249]=function(a){return(a.reg32s[7]<<3)+a.get_seg_prefix_ds()+a.reg32s[1]|0};CPU.prototype.sib_table[250]=function(a){return(a.reg32s[7]<<3)+a.get_seg_prefix_ds()+a.reg32s[2]| |
| 0};CPU.prototype.sib_table[251]=function(a){return(a.reg32s[7]<<3)+a.get_seg_prefix_ds()+a.reg32s[3]|0};CPU.prototype.sib_table[252]=function(a){return(a.reg32s[7]<<3)+a.get_seg_prefix_ss()+a.reg32s[4]|0};CPU.prototype.sib_table[253]=function(a,b){return(a.reg32s[7]<<3)+(b?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};CPU.prototype.sib_table[254]=function(a){return(a.reg32s[7]<<3)+a.get_seg_prefix_ds()+a.reg32s[6]|0};CPU.prototype.sib_table[255]=function(a){return(a.reg32s[7]<< |
| 3)+a.get_seg_prefix_ds()+a.reg32s[7]|0};CPU.prototype.modrm_resolve=function(a){return(this.address_size_32?this.modrm_table32:this.modrm_table16)[a](this)}})();"use strict";CPU.prototype.add=function(a,b,c){this.last_op1=a;this.last_op2=b;this.last_add_result=this.last_result=a+b|0;this.last_op_size=c;this.flags_changed=2261;return this.last_result}; |
| CPU.prototype.adc=function(a,b,c){var d=this.getcf();this.last_op1=a;this.last_op2=b;this.last_add_result=this.last_result=(a+b|0)+d|0;this.last_op_size=c;this.flags_changed=2261;return this.last_result};CPU.prototype.sub=function(a,b,c){this.last_add_result=a;this.last_op2=b;this.last_op1=this.last_result=a-b|0;this.last_op_size=c;this.flags_changed=2261;return this.last_result}; |
| CPU.prototype.sbb=function(a,b,c){var d=this.getcf();this.last_add_result=a;this.last_op2=b;this.last_op1=this.last_result=a-b-d|0;this.last_op_size=c;this.flags_changed=2261;return this.last_result};CPU.prototype.inc=function(a,b){this.flags=this.flags&-2|this.getcf();this.last_op1=a;this.last_op2=1;this.last_add_result=this.last_result=a+1|0;this.last_op_size=b;this.flags_changed=2260;return this.last_result}; |
| CPU.prototype.dec=function(a,b){this.flags=this.flags&-2|this.getcf();this.last_add_result=a;this.last_op2=1;this.last_op1=this.last_result=a-1|0;this.last_op_size=b;this.flags_changed=2260;return this.last_result};CPU.prototype.neg=function(a,b){this.last_op1=this.last_result=-a|0;this.flags_changed=2261;this.last_add_result=0;this.last_op2=a;this.last_op_size=b;return this.last_result}; |
| CPU.prototype.mul8=function(a){a=a*this.reg8[0];this.reg16[0]=a;this.flags=256>a?this.flags&-2050:this.flags|2049;this.flags_changed=0};CPU.prototype.imul8=function(a){a=a*this.reg8s[0];this.reg16[0]=a;this.flags=127<a||-128>a?this.flags|2049:this.flags&-2050;this.flags_changed=0};CPU.prototype.mul16=function(a){a=a*this.reg16[0];var b=a>>>16;this.reg16[0]=a;this.reg16[4]=b;this.flags=0===b?this.flags&-2050:this.flags|2049;this.flags_changed=0}; |
| CPU.prototype.imul16=function(a){a=a*this.reg16s[0];this.reg16[0]=a;this.reg16[4]=a>>16;this.flags=32767<a||-32768>a?this.flags|2049:this.flags&-2050;this.flags_changed=0};CPU.prototype.imul_reg16=function(a,b){var c=a*b;this.flags=32767<c||-32768>c?this.flags|2049:this.flags&-2050;this.flags_changed=0;return c}; |
| CPU.prototype.mul32=function(a){var b=this.reg32s[0],c=b&65535,b=b>>>16,d=a&65535;a=a>>>16;var e=c*d,d=(e>>>16)+(b*d|0)|0,f=d>>>16,d=(d&65535)+(c*a|0)|0,f=((d>>>16)+(b*a|0)|0)+f|0;this.reg32s[0]=d<<16|e&65535;this.reg32s[2]=f;this.flags=0===f?this.flags&-2050:this.flags|2049;this.flags_changed=0}; |
| CPU.prototype.imul32=function(a){var b=this.reg32s[0],c=!1;0>b&&(c=!0,b=-b|0);0>a&&(c=!c,a=-a|0);var d=b&65535,b=b>>>16,e=a&65535;a=a>>>16;var f=d*e,e=(f>>>16)+(b*e|0)|0,g=e>>>16,e=(e&65535)+(d*a|0)|0,f=e<<16|f&65535,g=((e>>>16)+(b*a|0)|0)+g|0;c&&(f=-f|0,g=~g+!f|0);this.reg32s[0]=f;this.reg32s[2]=g;this.flags=g===f>>31?this.flags&-2050:this.flags|2049;this.flags_changed=0}; |
| CPU.prototype.imul_reg32=function(a,b){var c=!1;0>a&&(c=!0,a=-a|0);0>b&&(c=!c,b=-b|0);var d=a&65535,e=a>>>16,f=b&65535,g=b>>>16,l=d*f,f=(l>>>16)+(e*f|0)|0,k=f>>>16,f=(f&65535)+(d*g|0)|0,l=f<<16|l&65535,k=((f>>>16)+(e*g|0)|0)+k|0;c&&(l=-l|0,k=~k+!l|0);this.flags=k===l>>31?this.flags&-2050:this.flags|2049;this.flags_changed=0;return l};CPU.prototype.div8=function(a){var b=this.reg16[0],c=b/a|0;256<=c||0===a?this.trigger_de():(this.reg8[0]=c,this.reg8[1]=b%a)}; |
| CPU.prototype.idiv8=function(a){var b=this.reg16s[0],c=b/a|0;128<=c||-129>=c||0===a?this.trigger_de():(this.reg8[0]=c,this.reg8[1]=b%a)};CPU.prototype.div16=function(a){var b=(this.reg16[0]|this.reg16[4]<<16)>>>0,c=b/a|0;65536<=c||0>c||0===a?this.trigger_de():(this.reg16[0]=c,this.reg16[4]=b%a)};CPU.prototype.idiv16=function(a){var b=this.reg16[0]|this.reg16[4]<<16,c=b/a|0;32768<=c||-32769>=c||0===a?this.trigger_de():(this.reg16[0]=c,this.reg16[4]=b%a)}; |
| CPU.prototype.div32=function(a){var b=this.reg32[0],c=this.reg32[2];(c>=a||!a)&&this.trigger_de();var d=0;if(1048576<c){for(var e=32,f=a;f>c;)f>>>=1,e--;for(;1048576<c;){if(c>=f){var c=c-f,g=a<<e>>>0;g>b&&c--;b=b-g>>>0;d|=1<<e}e--;f>>=1}d>>>=0}b+=4294967296*c;c=b%a;d+=b/a|0;4294967296<=d||0===a?this.trigger_de():(this.reg32s[0]=d,this.reg32s[2]=c)}; |
| CPU.prototype.idiv32=function(a){var b=this.reg32[0],c=this.reg32s[2],d=!1,e=!1;0>a&&(e=!0,a=-a);0>c&&(d=!0,e=!e,b=-b|0,c=~c+!b);(c>=a||!a)&&this.trigger_de();var f=0;if(1048576<c){for(var g=32,l=a;l>c;)l>>>=1,g--;for(;1048576<c;){if(c>=l){var c=c-l,k=a<<g>>>0;k>b&&c--;b=b-k>>>0;f|=1<<g}g--;l>>=1}f>>>=0}b+=4294967296*c;c=b%a;f+=b/a|0;e&&(f=-f|0);d&&(c=-c|0);2147483648<=f||-2147483649>=f||0===a?this.trigger_de():(this.reg32s[0]=f,this.reg32s[2]=c)}; |
| CPU.prototype.xadd8=function(a,b){var c=this.reg8[b];this.reg8[b]=a;return this.add(a,c,7)};CPU.prototype.xadd16=function(a,b){var c=this.reg16[b];this.reg16[b]=a;return this.add(a,c,15)};CPU.prototype.xadd32=function(a,b){var c=this.reg32s[b];this.reg32s[b]=a;return this.add(a,c,31)}; |
| CPU.prototype.bcd_daa=function(){var a=this.reg8[0],b=this.getcf(),c=this.getaf();this.flags&=-18;if(9<(a&15)||c)this.reg8[0]+=6,this.flags|=16;if(153<a||b)this.reg8[0]+=96,this.flags|=1;this.last_result=this.reg8[0];this.last_op_size=7;this.last_op1=this.last_op2=0;this.flags_changed=196}; |
| CPU.prototype.bcd_das=function(){var a=this.reg8[0],b=this.getcf();this.flags&=-2;9<(a&15)||this.getaf()?(this.reg8[0]-=6,this.flags|=16,this.flags=this.flags&-2|b|this.reg8[0]>>7):this.flags&=-17;if(153<a||b)this.reg8[0]-=96,this.flags|=1;this.last_result=this.reg8[0];this.last_op_size=7;this.last_op1=this.last_op2=0;this.flags_changed=196}; |
| CPU.prototype.bcd_aam=function(){var a=this.read_imm8();if(0===a)this.trigger_de();else{var b=this.reg8[0];this.reg8[1]=b/a;this.reg8[0]=b%a;this.last_result=this.reg8[0];this.flags_changed=196;this.flags&=-2066}};CPU.prototype.bcd_aad=function(){var a=this.read_imm8();this.last_result=this.reg8[0]+this.reg8[1]*a;this.reg16[0]=this.last_result&255;this.last_op_size=7;this.flags_changed=196;this.flags&=-2066}; |
| CPU.prototype.bcd_aaa=function(){9<(this.reg8[0]&15)||this.getaf()?(this.reg16[0]+=6,this.reg8[1]+=1,this.flags|=17):this.flags&=-18;this.reg8[0]&=15;this.flags_changed&=-18};CPU.prototype.bcd_aas=function(){9<(this.reg8[0]&15)||this.getaf()?(this.reg16[0]-=6,--this.reg8[1],this.flags|=17):this.flags&=-18;this.reg8[0]&=15;this.flags_changed&=-18};CPU.prototype.and=function(a,b,c){this.last_result=a&b;this.last_op_size=c;this.flags&=-2066;this.flags_changed=196;return this.last_result}; |
| CPU.prototype.or=function(a,b,c){this.last_result=a|b;this.last_op_size=c;this.flags&=-2066;this.flags_changed=196;return this.last_result};CPU.prototype.xor=function(a,b,c){this.last_result=a^b;this.last_op_size=c;this.flags&=-2066;this.flags_changed=196;return this.last_result};CPU.prototype.rol8=function(a,b){if(!b)return a;b&=7;var c=a<<b|a>>8-b;this.flags_changed&=-2050;this.flags=this.flags&-2050|c&1|(c<<11^c<<4)&2048;return c}; |
| CPU.prototype.rol16=function(a,b){if(!b)return a;b&=15;var c=a<<b|a>>16-b;this.flags_changed&=-2050;this.flags=this.flags&-2050|c&1|(c<<11^c>>4)&2048;return c};CPU.prototype.rol32=function(a,b){if(!b)return a;var c=a<<b|a>>>32-b;this.flags_changed&=-2050;this.flags=this.flags&-2050|c&1|(c<<11^c>>20)&2048;return c};CPU.prototype.rcl8=function(a,b){b%=9;if(!b)return a;var c=a<<b|this.getcf()<<b-1|a>>9-b;this.flags_changed&=-2050;this.flags=this.flags&-2050|c>>8&1|(c<<3^c<<4)&2048;return c}; |
| CPU.prototype.rcl16=function(a,b){b%=17;if(!b)return a;var c=a<<b|this.getcf()<<b-1|a>>17-b;this.flags_changed&=-2050;this.flags=this.flags&-2050|c>>16&1|(c>>5^c>>4)&2048;return c};CPU.prototype.rcl32=function(a,b){if(!b)return a;var c=a<<b|this.getcf()<<b-1;1<b&&(c|=a>>>33-b);this.flags_changed&=-2050;this.flags=this.flags&-2050|a>>>32-b&1;this.flags|=(this.flags<<11^c>>20)&2048;return c}; |
| CPU.prototype.ror8=function(a,b){b&=7;if(!b)return a;var c=a>>b|a<<8-b;this.flags_changed&=-2050;this.flags=this.flags&-2050|c>>7&1|(c<<4^c<<5)&2048;return c};CPU.prototype.ror16=function(a,b){b&=15;if(!b)return a;var c=a>>b|a<<16-b;this.flags_changed&=-2050;this.flags=this.flags&-2050|c>>15&1|(c>>4^c>>3)&2048;return c};CPU.prototype.ror32=function(a,b){if(!b)return a;var c=a>>>b|a<<32-b;this.flags_changed&=-2050;this.flags=this.flags&-2050|c>>31&1|(c>>20^c>>19)&2048;return c}; |
| CPU.prototype.rcr8=function(a,b){b%=9;if(!b)return a;var c=a>>b|this.getcf()<<8-b|a<<9-b;this.flags_changed&=-2050;this.flags=this.flags&-2050|c>>8&1|(c<<4^c<<5)&2048;return c};CPU.prototype.rcr16=function(a,b){b%=17;if(!b)return a;var c=a>>b|this.getcf()<<16-b|a<<17-b;this.flags_changed&=-2050;this.flags=this.flags&-2050|c>>16&1|(c>>4^c>>3)&2048;return c}; |
| CPU.prototype.rcr32=function(a,b){if(!b)return a;var c=a>>>b|this.getcf()<<32-b;1<b&&(c|=a<<33-b);this.flags_changed&=-2050;this.flags=this.flags&-2050|a>>b-1&1|(c>>20^c>>19)&2048;return c};CPU.prototype.shl8=function(a,b){if(0===b)return a;this.last_result=a<<b;this.last_op_size=7;this.flags_changed=212;this.flags=this.flags&-2050|this.last_result>>8&1|(this.last_result<<3^this.last_result<<4)&2048;return this.last_result}; |
| CPU.prototype.shl16=function(a,b){if(0===b)return a;this.last_result=a<<b;this.last_op_size=15;this.flags_changed=212;this.flags=this.flags&-2050|this.last_result>>16&1|(this.last_result>>5^this.last_result>>4)&2048;return this.last_result};CPU.prototype.shl32=function(a,b){if(0===b)return a;this.last_result=a<<b;this.last_op_size=31;this.flags_changed=212;this.flags=this.flags&-2050|a>>>32-b&1;this.flags|=(this.flags&1^this.last_result>>31&1)<<11&2048;return this.last_result}; |
| CPU.prototype.shr8=function(a,b){if(0===b)return a;this.last_result=a>>b;this.last_op_size=7;this.flags_changed=212;this.flags=this.flags&-2050|a>>b-1&1|(a>>7&1)<<11&2048;return this.last_result};CPU.prototype.shr16=function(a,b){if(0===b)return a;this.last_result=a>>b;this.last_op_size=15;this.flags_changed=212;this.flags=this.flags&-2050|a>>b-1&1|a>>4&2048;return this.last_result}; |
| CPU.prototype.shr32=function(a,b){if(0===b)return a;this.last_result=a>>>b;this.last_op_size=31;this.flags_changed=212;this.flags=this.flags&-2050|a>>>b-1&1|a>>20&2048;return this.last_result};CPU.prototype.sar8=function(a,b){if(0===b)return a;this.last_result=a>>b;this.last_op_size=7;this.flags_changed=212;this.flags=this.flags&-2050|a>>b-1&1;return this.last_result}; |
| CPU.prototype.sar16=function(a,b){if(0===b)return a;this.last_result=a>>b;this.last_op_size=15;this.flags_changed=212;this.flags=this.flags&-2050|a>>b-1&1;return this.last_result};CPU.prototype.sar32=function(a,b){if(0===b)return a;this.last_result=a>>b;this.last_op_size=31;this.flags_changed=212;this.flags=this.flags&-2050|a>>>b-1&1;return this.last_result}; |
| CPU.prototype.shrd16=function(a,b,c){if(0===c)return a;16>=c?(this.last_result=a>>c|b<<16-c,this.flags=this.flags&-2|a>>c-1&1):(this.last_result=a<<32-c|b>>c-16,this.flags=this.flags&-2|b>>c-17&1);this.last_op_size=15;this.flags_changed=212;this.flags=this.flags&-2049|(this.last_result^a)>>4&2048;return this.last_result}; |
| CPU.prototype.shrd32=function(a,b,c){if(0===c)return a;this.last_result=a>>>c|b<<32-c;this.last_op_size=31;this.flags_changed=212;this.flags=this.flags&-2|a>>>c-1&1;this.flags=this.flags&-2049|(this.last_result^a)>>20&2048;return this.last_result}; |
| CPU.prototype.shld16=function(a,b,c){if(0===c)return a;16>=c?(this.last_result=a<<c|b>>>16-c,this.flags=this.flags&-2|a>>>16-c&1):(this.last_result=a>>32-c|b<<c-16,this.flags=this.flags&-2|b>>>32-c&1);this.last_op_size=15;this.flags_changed=212;this.flags=this.flags&-2049|(this.flags&1^this.last_result>>15&1)<<11;return this.last_result}; |
| CPU.prototype.shld32=function(a,b,c){if(0===c)return a;this.last_result=a<<c|b>>>32-c;this.last_op_size=31;this.flags_changed=212;this.flags=this.flags&-2|a>>>32-c&1;this.flags=this.flags&-2049|(this.flags&1^this.last_result>>31&1)<<11;return this.last_result};CPU.prototype.bt_reg=function(a,b){this.flags=this.flags&-2|a>>b&1;this.flags_changed&=-2};CPU.prototype.btc_reg=function(a,b){this.flags=this.flags&-2|a>>b&1;this.flags_changed&=-2;return a^1<<b}; |
| CPU.prototype.bts_reg=function(a,b){this.flags=this.flags&-2|a>>b&1;this.flags_changed&=-2;return a|1<<b};CPU.prototype.btr_reg=function(a,b){this.flags=this.flags&-2|a>>b&1;this.flags_changed&=-2;return a&~(1<<b)};CPU.prototype.bt_mem=function(a,b){var c=this.safe_read8(a+(b>>3));this.flags=this.flags&-2|c>>(b&7)&1;this.flags_changed&=-2}; |
| CPU.prototype.btc_mem=function(a,b){var c=this.translate_address_write(a+(b>>3)),d=this.memory.read8(c);b&=7;this.flags=this.flags&-2|d>>b&1;this.flags_changed&=-2;this.memory.write8(c,d^1<<b)};CPU.prototype.btr_mem=function(a,b){var c=this.translate_address_write(a+(b>>3)),d=this.memory.read8(c);b&=7;this.flags=this.flags&-2|d>>b&1;this.flags_changed&=-2;this.memory.write8(c,d&~(1<<b))}; |
| CPU.prototype.bts_mem=function(a,b){var c=this.translate_address_write(a+(b>>3)),d=this.memory.read8(c);b&=7;this.flags=this.flags&-2|d>>b&1;this.flags_changed&=-2;this.memory.write8(c,d|1<<b)};CPU.prototype.bsf16=function(a,b){this.flags_changed=0;if(0===b)return this.flags|=64,a;this.flags&=-65;return v86util.int_log2(-b&b)};CPU.prototype.bsf32=function(a,b){this.flags_changed=0;if(0===b)return this.flags|=64,a;this.flags&=-65;return v86util.int_log2((-b&b)>>>0)}; |
| CPU.prototype.bsr16=function(a,b){this.flags_changed=0;if(0===b)return this.flags|=64,a;this.flags&=-65;return v86util.int_log2(b)};CPU.prototype.bsr32=function(a,b){this.flags_changed=0;if(0===b)return this.flags|=64,a;this.flags&=-65;return v86util.int_log2(b>>>0)};CPU.prototype.popcnt=function(a){this.flags_changed=0;this.flags&=-2262;if(a)return a=a-(a>>1&1431655765),a=(a&858993459)+(a>>2&858993459),16843009*(a+(a>>4)&252645135)>>24;this.flags|=64;return 0};"use strict";var data_dest,data_src; |
| CPU.prototype.string_instruction=function(a,b,c,d,e,f){var g,l,k,m,n=this.flags&1024?-(a>>3):a>>3,p=!1;b&&!c&&(data_src=32===a?this.reg32s[0]:16===a?this.reg16[0]:this.reg8[0]);d&&(l=this.get_seg(0)+this.regv[this.reg_vdi]|0);c&&(g=this.get_seg_prefix(3)+this.regv[this.reg_vsi]|0);if(0!==this.repeat_string_prefix){var r=this.regv[this.reg_vcx]>>>0,s=r;if(0===r)return;var q=16384;if(8!==a&&(d&&l&(a>>3)-1||c&&g&(a>>3)-1)){do e(this,g,l),d&&(l+=n,this.regv[this.reg_vdi]+=n),c&&(g+=n,this.regv[this.reg_vsi]+= |
| n),p=0!==--this.regv[this.reg_vcx]&&(!b||data_src===data_dest===(2===this.repeat_string_prefix));while(p&&q--)}else{e=n>>31|1;this.paging?(c&&(q=(e>>1^~g)&4095,m=this.translate_address_read(g)),d&&(q=Math.min(q,(e>>1^~l)&4095),k=b?this.translate_address_read(l):this.translate_address_write(l)),32===a?q>>=2:16===a&&(q>>=1)):(d&&(k=l),c&&(m=g));32===a?(d&&(k>>>=2),c&&(m>>>=2)):16===a&&(d&&(k>>>=1),c&&(m>>>=1));do f(this,m,k),d&&(k+=e),c&&(m+=e),p=0!==--r&&(!b||data_src===data_dest===(2===this.repeat_string_prefix)); |
| while(p&&q--);f=n*(s-r)|0;d&&(this.regv[this.reg_vdi]+=f);c&&(this.regv[this.reg_vsi]+=f);this.regv[this.reg_vcx]=r;this.timestamp_counter+=s-r}}else 8===a?(c&&(m=this.translate_address_read(g)),d&&(k=b?this.translate_address_read(l):this.translate_address_write(l)),f(this,m,k)):e(this,g,l),d&&(this.regv[this.reg_vdi]+=n),c&&(this.regv[this.reg_vsi]+=n);b&&(32===a?this.sub(data_src,data_dest,31):16===a?this.sub(data_src,data_dest,15):this.sub(data_src,data_dest,7));p&&(this.instruction_pointer=this.previous_ip)}; |
| function movsb(a){a.string_instruction(8,!1,!0,!0,function(){},function(a,c,d){a.memory.write8(d,a.memory.read8(c))})}function movsw(a){a.string_instruction(16,!1,!0,!0,function(a,c,d){a.safe_write16(d,a.safe_read16(c))},function(a,c,d){a.memory.write_aligned16(d,a.memory.read_aligned16(c))})} |
| function movsd(a){if(0!==a.repeat_string_prefix){var b=a.get_seg_prefix(3)+a.regv[a.reg_vsi],c=a.get_seg(0)+a.regv[a.reg_vdi],d=a.regv[a.reg_vcx]>>>0;if(!d)return;var e=a.paging?4095:3;if(0===(c&e)&&0===(b&e)&&0===(a.flags&1024)&&(e=!1,a.paging&&(b=a.translate_address_read(b),c=a.translate_address_write(c),1024<d&&(d=1024,e=!0)),!a.io.in_mmap_range(b,d)&&!a.io.in_mmap_range(c,d))){var f=d<<2;a.regv[a.reg_vcx]-=d;a.regv[a.reg_vdi]+=f;a.regv[a.reg_vsi]+=f;b>>=2;a.memory.mem32s.set(a.memory.mem32s.subarray(b, |
| b+d),c>>2);e&&(a.instruction_pointer=a.previous_ip);return}}a.string_instruction(32,!1,!0,!0,function(a,b,c){a.safe_write32(c,a.safe_read32s(b))},function(a,b,c){a.memory.write_aligned32(c,a.memory.read_aligned32(b))})}function cmpsb(a){a.string_instruction(8,!0,!0,!0,function(){},function(a,c,d){data_dest=a.memory.read8(d);data_src=a.memory.read8(c)})} |
| function cmpsw(a){a.string_instruction(16,!0,!0,!0,function(a,c,d){data_dest=a.safe_read16(d);data_src=a.safe_read16(c)},function(a,c,d){data_dest=a.memory.read_aligned16(d);data_src=a.memory.read_aligned16(c)})}function cmpsd(a){a.string_instruction(32,!0,!0,!0,function(a,c,d){data_dest=a.safe_read32s(d);data_src=a.safe_read32s(c)},function(a,c,d){data_dest=a.memory.read_aligned32(d);data_src=a.memory.read_aligned32(c)})} |
| function stosb(a){var b=a.reg8[0];a.string_instruction(8,!1,!1,!0,function(){},function(a,d,e){a.memory.write8(e,b)})}function stosw(a){var b=a.reg16[0];a.string_instruction(16,!1,!1,!0,function(a,d,e){a.safe_write16(e,b)},function(a,d,e){a.memory.write_aligned16(e,b)})}function stosd(a){var b=a.reg32s[0];a.string_instruction(32,!1,!1,!0,function(a,d,e){a.safe_write32(e,b)},function(a,d,e){a.memory.write_aligned32(e,b)})} |
| function lodsb(a){a.string_instruction(8,!1,!0,!1,function(){},function(a,c){a.reg8[0]=a.memory.read8(c)})}function lodsw(a){a.string_instruction(16,!1,!0,!1,function(a,c){a.reg16[0]=a.safe_read16(c)},function(a,c){a.reg16[0]=a.memory.read_aligned16(c)})}function lodsd(a){a.string_instruction(32,!1,!0,!1,function(a,c){a.reg32s[0]=a.safe_read32s(c)},function(a,c){a.reg32s[0]=a.memory.read_aligned32(c)})} |
| function scasb(a){a.string_instruction(8,!0,!1,!0,function(){},function(a,c,d){data_dest=a.memory.read8(d)})}function scasw(a){a.string_instruction(16,!0,!1,!0,function(a,c,d){data_dest=a.safe_read16(d)},function(a,c,d){data_dest=a.memory.read_aligned16(d)})}function scasd(a){a.string_instruction(32,!0,!1,!0,function(a,c,d){data_dest=a.safe_read32s(d)},function(a,c,d){data_dest=a.memory.read_aligned32(d)})} |
| function insb(a){var b=a.reg16[4];a.test_privileges_for_io(b,1);a.string_instruction(8,!1,!1,!0,function(){},function(a,d,e){a.memory.write8(e,a.io.port_read8(b))})}function insw(a){var b=a.reg16[4];a.test_privileges_for_io(b,2);a.string_instruction(16,!1,!1,!0,function(a,d,e){a.safe_write16(e,a.io.port_read16(b))},function(a,d,e){a.memory.write_aligned16(e,a.io.port_read16(b))})} |
| function insd(a){var b=a.reg16[4];a.test_privileges_for_io(b,4);a.string_instruction(32,!1,!1,!0,function(a,d,e){a.safe_write32(e,a.io.port_read32(b))},function(a,d,e){a.memory.write_aligned32(e,a.io.port_read32(b))})}function outsb(a){var b=a.reg16[4];a.test_privileges_for_io(b,1);a.string_instruction(8,!1,!0,!1,function(){},function(a,d){a.io.port_write8(b,a.memory.read8(d))})} |
| function outsw(a){var b=a.reg16[4];a.test_privileges_for_io(b,2);a.string_instruction(16,!1,!0,!1,function(a,d){a.io.port_write16(b,a.safe_read16(d))},function(a,d){a.io.port_write16(b,a.memory.read_aligned16(d))})}function outsd(a){var b=a.reg16[4];a.test_privileges_for_io(b,4);a.string_instruction(32,!1,!0,!1,function(a,d){a.io.port_write32(b,a.safe_read32s(d))},function(a,d){a.io.port_write32(b,a.memory.read_aligned32(d))})}"use strict";var table16=[],table32=[],table0F_16=[],table0F_32=[]; |
| CPU.prototype.table16=table16;CPU.prototype.table32=table32;CPU.prototype.table0F_16=table0F_16;CPU.prototype.table0F_32=table0F_32;table16[0]=table32[0]=function(a){var b=a.read_imm8(),c,d;192>b?(d=a.translate_address_write(a.modrm_resolve(b)),c=a.memory.read8(d)):c=a.reg8[b<<2&12|b>>2&1];c=a.add(c,a.reg8[b>>1&12|b>>5&1],7);192>b?a.memory.write8(d,c):a.reg8[b<<2&12|b>>2&1]=c}; |
| table16[1]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c=a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];c=a.add(c,a.reg16[b>>2&14],15);192>b?e?a.virt_boundary_write16(d,e,c):a.memory.write16(d,c):a.reg16[b<<1&14]=c}; |
| table32[1]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(e=a.translate_address_write(c+3),c=a.virt_boundary_read32s(d,e)):c=a.memory.read32s(d)):c=a.reg32s[b&7];c=a.add(c,a.reg32s[b>>3&7],31);192>b?e?a.virt_boundary_write32(d,e,c):a.memory.write32(d,c):a.reg32s[b&7]=c}; |
| table16[2]=table32[2]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read8(a.modrm_resolve(b)):a.reg8[b<<2&12|b>>2&1];a.reg8[b>>1&12|b>>5&1]=a.add(a.reg8[b>>1&12|b>>5&1],c,7)};table16[3]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.reg16[b>>2&14]=a.add(a.reg16[b>>2&14],c,15)};table32[3]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.reg32s[b>>3&7]=a.add(a.reg32s[b>>3&7],c,31)}; |
| table16[4]=table32[4]=function(a){a.reg8[0]=a.add(a.reg8[0],a.read_imm8(),7)};table16[5]=function(a){a.reg16[0]=a.add(a.reg16[0],a.read_imm16(),15)};table32[5]=function(a){a.reg32s[0]=a.add(a.reg32s[0],a.read_imm32s(),31)};table16[6]=function(a){a.push16(a.sreg[0])};table32[6]=function(a){a.push32(a.sreg[0])};table16[7]=function(a){a.switch_seg(0,a.safe_read16(a.get_stack_pointer(0)));a.stack_reg[a.reg_vsp]+=2}; |
| table32[7]=function(a){a.switch_seg(0,a.safe_read16(a.get_stack_pointer(0)));a.stack_reg[a.reg_vsp]+=4};table16[8]=table32[8]=function(a){var b=a.read_imm8(),c,d;192>b?(d=a.translate_address_write(a.modrm_resolve(b)),c=a.memory.read8(d)):c=a.reg8[b<<2&12|b>>2&1];c=a.or(c,a.reg8[b>>1&12|b>>5&1],7);192>b?a.memory.write8(d,c):a.reg8[b<<2&12|b>>2&1]=c}; |
| table16[9]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c=a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];c=a.or(c,a.reg16[b>>2&14],15);192>b?e?a.virt_boundary_write16(d,e,c):a.memory.write16(d,c):a.reg16[b<<1&14]=c}; |
| table32[9]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(e=a.translate_address_write(c+3),c=a.virt_boundary_read32s(d,e)):c=a.memory.read32s(d)):c=a.reg32s[b&7];c=a.or(c,a.reg32s[b>>3&7],31);192>b?e?a.virt_boundary_write32(d,e,c):a.memory.write32(d,c):a.reg32s[b&7]=c}; |
| table16[10]=table32[10]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read8(a.modrm_resolve(b)):a.reg8[b<<2&12|b>>2&1];a.reg8[b>>1&12|b>>5&1]=a.or(a.reg8[b>>1&12|b>>5&1],c,7)};table16[11]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.reg16[b>>2&14]=a.or(a.reg16[b>>2&14],c,15)};table32[11]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.reg32s[b>>3&7]=a.or(a.reg32s[b>>3&7],c,31)}; |
| table16[12]=table32[12]=function(a){a.reg8[0]=a.or(a.reg8[0],a.read_imm8(),7)};table16[13]=function(a){a.reg16[0]=a.or(a.reg16[0],a.read_imm16(),15)};table32[13]=function(a){a.reg32s[0]=a.or(a.reg32s[0],a.read_imm32s(),31)};table16[14]=function(a){a.push16(a.sreg[1])};table32[14]=function(a){a.push32(a.sreg[1])};table16[15]=table32[15]=function(a){a.table0F[a.read_imm8()](a)}; |
| table16[16]=table32[16]=function(a){var b=a.read_imm8(),c,d;192>b?(d=a.translate_address_write(a.modrm_resolve(b)),c=a.memory.read8(d)):c=a.reg8[b<<2&12|b>>2&1];c=a.adc(c,a.reg8[b>>1&12|b>>5&1],7);192>b?a.memory.write8(d,c):a.reg8[b<<2&12|b>>2&1]=c}; |
| table16[17]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c=a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];c=a.adc(c,a.reg16[b>>2&14],15);192>b?e?a.virt_boundary_write16(d,e,c):a.memory.write16(d,c):a.reg16[b<<1&14]=c}; |
| table32[17]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(e=a.translate_address_write(c+3),c=a.virt_boundary_read32s(d,e)):c=a.memory.read32s(d)):c=a.reg32s[b&7];c=a.adc(c,a.reg32s[b>>3&7],31);192>b?e?a.virt_boundary_write32(d,e,c):a.memory.write32(d,c):a.reg32s[b&7]=c}; |
| table16[18]=table32[18]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read8(a.modrm_resolve(b)):a.reg8[b<<2&12|b>>2&1];a.reg8[b>>1&12|b>>5&1]=a.adc(a.reg8[b>>1&12|b>>5&1],c,7)};table16[19]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.reg16[b>>2&14]=a.adc(a.reg16[b>>2&14],c,15)};table32[19]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.reg32s[b>>3&7]=a.adc(a.reg32s[b>>3&7],c,31)}; |
| table16[20]=table32[20]=function(a){a.reg8[0]=a.adc(a.reg8[0],a.read_imm8(),7)};table16[21]=function(a){a.reg16[0]=a.adc(a.reg16[0],a.read_imm16(),15)};table32[21]=function(a){a.reg32s[0]=a.adc(a.reg32s[0],a.read_imm32s(),31)};table16[22]=function(a){a.push16(a.sreg[2])};table32[22]=function(a){a.push32(a.sreg[2])};table16[23]=function(a){a.switch_seg(2,a.safe_read16(a.get_stack_pointer(0)));a.stack_reg[a.reg_vsp]+=2}; |
| table32[23]=function(a){a.switch_seg(2,a.safe_read16(a.get_stack_pointer(0)));a.stack_reg[a.reg_vsp]+=4};table16[24]=table32[24]=function(a){var b=a.read_imm8(),c,d;192>b?(d=a.translate_address_write(a.modrm_resolve(b)),c=a.memory.read8(d)):c=a.reg8[b<<2&12|b>>2&1];c=a.sbb(c,a.reg8[b>>1&12|b>>5&1],7);192>b?a.memory.write8(d,c):a.reg8[b<<2&12|b>>2&1]=c}; |
| table16[25]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c=a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];c=a.sbb(c,a.reg16[b>>2&14],15);192>b?e?a.virt_boundary_write16(d,e,c):a.memory.write16(d,c):a.reg16[b<<1&14]=c}; |
| table32[25]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(e=a.translate_address_write(c+3),c=a.virt_boundary_read32s(d,e)):c=a.memory.read32s(d)):c=a.reg32s[b&7];c=a.sbb(c,a.reg32s[b>>3&7],31);192>b?e?a.virt_boundary_write32(d,e,c):a.memory.write32(d,c):a.reg32s[b&7]=c}; |
| table16[26]=table32[26]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read8(a.modrm_resolve(b)):a.reg8[b<<2&12|b>>2&1];a.reg8[b>>1&12|b>>5&1]=a.sbb(a.reg8[b>>1&12|b>>5&1],c,7)};table16[27]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.reg16[b>>2&14]=a.sbb(a.reg16[b>>2&14],c,15)};table32[27]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.reg32s[b>>3&7]=a.sbb(a.reg32s[b>>3&7],c,31)}; |
| table16[28]=table32[28]=function(a){a.reg8[0]=a.sbb(a.reg8[0],a.read_imm8(),7)};table16[29]=function(a){a.reg16[0]=a.sbb(a.reg16[0],a.read_imm16(),15)};table32[29]=function(a){a.reg32s[0]=a.sbb(a.reg32s[0],a.read_imm32s(),31)};table16[30]=function(a){a.push16(a.sreg[3])};table32[30]=function(a){a.push32(a.sreg[3])};table16[31]=function(a){a.switch_seg(3,a.safe_read16(a.get_stack_pointer(0)));a.stack_reg[a.reg_vsp]+=2}; |
| table32[31]=function(a){a.switch_seg(3,a.safe_read16(a.get_stack_pointer(0)));a.stack_reg[a.reg_vsp]+=4};table16[32]=table32[32]=function(a){var b=a.read_imm8(),c,d;192>b?(d=a.translate_address_write(a.modrm_resolve(b)),c=a.memory.read8(d)):c=a.reg8[b<<2&12|b>>2&1];c=a.and(c,a.reg8[b>>1&12|b>>5&1],7);192>b?a.memory.write8(d,c):a.reg8[b<<2&12|b>>2&1]=c}; |
| table16[33]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c=a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];c=a.and(c,a.reg16[b>>2&14],15);192>b?e?a.virt_boundary_write16(d,e,c):a.memory.write16(d,c):a.reg16[b<<1&14]=c}; |
| table32[33]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(e=a.translate_address_write(c+3),c=a.virt_boundary_read32s(d,e)):c=a.memory.read32s(d)):c=a.reg32s[b&7];c=a.and(c,a.reg32s[b>>3&7],31);192>b?e?a.virt_boundary_write32(d,e,c):a.memory.write32(d,c):a.reg32s[b&7]=c}; |
| table16[34]=table32[34]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read8(a.modrm_resolve(b)):a.reg8[b<<2&12|b>>2&1];a.reg8[b>>1&12|b>>5&1]=a.and(a.reg8[b>>1&12|b>>5&1],c,7)};table16[35]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.reg16[b>>2&14]=a.and(a.reg16[b>>2&14],c,15)};table32[35]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.reg32s[b>>3&7]=a.and(a.reg32s[b>>3&7],c,31)}; |
| table16[36]=table32[36]=function(a){a.reg8[0]=a.and(a.reg8[0],a.read_imm8(),7)};table16[37]=function(a){a.reg16[0]=a.and(a.reg16[0],a.read_imm16(),15)};table32[37]=function(a){a.reg32s[0]=a.and(a.reg32s[0],a.read_imm32s(),31)};table16[38]=table32[38]=function(a){a.seg_prefix(0)};table16[39]=table32[39]=function(a){a.bcd_daa()}; |
| table16[40]=table32[40]=function(a){var b=a.read_imm8(),c,d;192>b?(d=a.translate_address_write(a.modrm_resolve(b)),c=a.memory.read8(d)):c=a.reg8[b<<2&12|b>>2&1];c=a.sub(c,a.reg8[b>>1&12|b>>5&1],7);192>b?a.memory.write8(d,c):a.reg8[b<<2&12|b>>2&1]=c}; |
| table16[41]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c=a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];c=a.sub(c,a.reg16[b>>2&14],15);192>b?e?a.virt_boundary_write16(d,e,c):a.memory.write16(d,c):a.reg16[b<<1&14]=c}; |
| table32[41]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(e=a.translate_address_write(c+3),c=a.virt_boundary_read32s(d,e)):c=a.memory.read32s(d)):c=a.reg32s[b&7];c=a.sub(c,a.reg32s[b>>3&7],31);192>b?e?a.virt_boundary_write32(d,e,c):a.memory.write32(d,c):a.reg32s[b&7]=c}; |
| table16[42]=table32[42]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read8(a.modrm_resolve(b)):a.reg8[b<<2&12|b>>2&1];a.reg8[b>>1&12|b>>5&1]=a.sub(a.reg8[b>>1&12|b>>5&1],c,7)};table16[43]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.reg16[b>>2&14]=a.sub(a.reg16[b>>2&14],c,15)};table32[43]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.reg32s[b>>3&7]=a.sub(a.reg32s[b>>3&7],c,31)}; |
| table16[44]=table32[44]=function(a){a.reg8[0]=a.sub(a.reg8[0],a.read_imm8(),7)};table16[45]=function(a){a.reg16[0]=a.sub(a.reg16[0],a.read_imm16(),15)};table32[45]=function(a){a.reg32s[0]=a.sub(a.reg32s[0],a.read_imm32s(),31)};table16[46]=table32[46]=function(a){a.seg_prefix(1)};table16[47]=table32[47]=function(a){a.bcd_das()}; |
| table16[48]=table32[48]=function(a){var b=a.read_imm8(),c,d;192>b?(d=a.translate_address_write(a.modrm_resolve(b)),c=a.memory.read8(d)):c=a.reg8[b<<2&12|b>>2&1];c=a.xor(c,a.reg8[b>>1&12|b>>5&1],7);192>b?a.memory.write8(d,c):a.reg8[b<<2&12|b>>2&1]=c}; |
| table16[49]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c=a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];c=a.xor(c,a.reg16[b>>2&14],15);192>b?e?a.virt_boundary_write16(d,e,c):a.memory.write16(d,c):a.reg16[b<<1&14]=c}; |
| table32[49]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(e=a.translate_address_write(c+3),c=a.virt_boundary_read32s(d,e)):c=a.memory.read32s(d)):c=a.reg32s[b&7];c=a.xor(c,a.reg32s[b>>3&7],31);192>b?e?a.virt_boundary_write32(d,e,c):a.memory.write32(d,c):a.reg32s[b&7]=c}; |
| table16[50]=table32[50]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read8(a.modrm_resolve(b)):a.reg8[b<<2&12|b>>2&1];a.reg8[b>>1&12|b>>5&1]=a.xor(a.reg8[b>>1&12|b>>5&1],c,7)};table16[51]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.reg16[b>>2&14]=a.xor(a.reg16[b>>2&14],c,15)};table32[51]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.reg32s[b>>3&7]=a.xor(a.reg32s[b>>3&7],c,31)}; |
| table16[52]=table32[52]=function(a){a.reg8[0]=a.xor(a.reg8[0],a.read_imm8(),7)};table16[53]=function(a){a.reg16[0]=a.xor(a.reg16[0],a.read_imm16(),15)};table32[53]=function(a){a.reg32s[0]=a.xor(a.reg32s[0],a.read_imm32s(),31)};table16[54]=table32[54]=function(a){a.seg_prefix(2)};table16[55]=table32[55]=function(a){a.bcd_aaa()};table16[56]=table32[56]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read8(a.modrm_resolve(b)):a.reg8[b<<2&12|b>>2&1];a.sub(c,a.reg8[b>>1&12|b>>5&1],7)}; |
| table16[57]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.sub(c,a.reg16[b>>2&14],15)};table32[57]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.sub(c,a.reg32s[b>>3&7],31)};table16[58]=table32[58]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read8(a.modrm_resolve(b)):a.reg8[b<<2&12|b>>2&1];a.sub(a.reg8[b>>1&12|b>>5&1],c,7)}; |
| table16[59]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.sub(a.reg16[b>>2&14],c,15)};table32[59]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.sub(a.reg32s[b>>3&7],c,31)};table16[60]=table32[60]=function(a){a.sub(a.reg8[0],a.read_imm8(),7)};table16[61]=function(a){a.sub(a.reg16[0],a.read_imm16(),15)};table32[61]=function(a){a.sub(a.reg32s[0],a.read_imm32s(),31)};table16[62]=table32[62]=function(a){a.seg_prefix(3)}; |
| table16[63]=table32[63]=function(a){a.bcd_aas()};table16[64]=function(a){a.reg16[0]=a.inc(a.reg16[0],15)};table32[64]=function(a){a.reg32s[0]=a.inc(a.reg32s[0],31)};table16[65]=function(a){a.reg16[2]=a.inc(a.reg16[2],15)};table32[65]=function(a){a.reg32s[1]=a.inc(a.reg32s[1],31)};table16[66]=function(a){a.reg16[4]=a.inc(a.reg16[4],15)};table32[66]=function(a){a.reg32s[2]=a.inc(a.reg32s[2],31)};table16[67]=function(a){a.reg16[6]=a.inc(a.reg16[6],15)}; |
| table32[67]=function(a){a.reg32s[3]=a.inc(a.reg32s[3],31)};table16[68]=function(a){a.reg16[8]=a.inc(a.reg16[8],15)};table32[68]=function(a){a.reg32s[4]=a.inc(a.reg32s[4],31)};table16[69]=function(a){a.reg16[10]=a.inc(a.reg16[10],15)};table32[69]=function(a){a.reg32s[5]=a.inc(a.reg32s[5],31)};table16[70]=function(a){a.reg16[12]=a.inc(a.reg16[12],15)};table32[70]=function(a){a.reg32s[6]=a.inc(a.reg32s[6],31)};table16[71]=function(a){a.reg16[14]=a.inc(a.reg16[14],15)}; |
| table32[71]=function(a){a.reg32s[7]=a.inc(a.reg32s[7],31)};table16[72]=function(a){a.reg16[0]=a.dec(a.reg16[0],15)};table32[72]=function(a){a.reg32s[0]=a.dec(a.reg32s[0],31)};table16[73]=function(a){a.reg16[2]=a.dec(a.reg16[2],15)};table32[73]=function(a){a.reg32s[1]=a.dec(a.reg32s[1],31)};table16[74]=function(a){a.reg16[4]=a.dec(a.reg16[4],15)};table32[74]=function(a){a.reg32s[2]=a.dec(a.reg32s[2],31)};table16[75]=function(a){a.reg16[6]=a.dec(a.reg16[6],15)}; |
| table32[75]=function(a){a.reg32s[3]=a.dec(a.reg32s[3],31)};table16[76]=function(a){a.reg16[8]=a.dec(a.reg16[8],15)};table32[76]=function(a){a.reg32s[4]=a.dec(a.reg32s[4],31)};table16[77]=function(a){a.reg16[10]=a.dec(a.reg16[10],15)};table32[77]=function(a){a.reg32s[5]=a.dec(a.reg32s[5],31)};table16[78]=function(a){a.reg16[12]=a.dec(a.reg16[12],15)};table32[78]=function(a){a.reg32s[6]=a.dec(a.reg32s[6],31)};table16[79]=function(a){a.reg16[14]=a.dec(a.reg16[14],15)}; |
| table32[79]=function(a){a.reg32s[7]=a.dec(a.reg32s[7],31)};table16[80]=function(a){a.push16(a.reg16[0])};table32[80]=function(a){a.push32(a.reg32s[0])};table16[81]=function(a){a.push16(a.reg16[2])};table32[81]=function(a){a.push32(a.reg32s[1])};table16[82]=function(a){a.push16(a.reg16[4])};table32[82]=function(a){a.push32(a.reg32s[2])};table16[83]=function(a){a.push16(a.reg16[6])};table32[83]=function(a){a.push32(a.reg32s[3])};table16[84]=function(a){a.push16(a.reg16[8])};table32[84]=function(a){a.push32(a.reg32s[4])}; |
| table16[85]=function(a){a.push16(a.reg16[10])};table32[85]=function(a){a.push32(a.reg32s[5])};table16[86]=function(a){a.push16(a.reg16[12])};table32[86]=function(a){a.push32(a.reg32s[6])};table16[87]=function(a){a.push16(a.reg16[14])};table32[87]=function(a){a.push32(a.reg32s[7])};table16[88]=function(a){a.reg16[0]=a.pop16()};table32[88]=function(a){a.reg32s[0]=a.pop32s()};table16[89]=function(a){a.reg16[2]=a.pop16()};table32[89]=function(a){a.reg32s[1]=a.pop32s()}; |
| table16[90]=function(a){a.reg16[4]=a.pop16()};table32[90]=function(a){a.reg32s[2]=a.pop32s()};table16[91]=function(a){a.reg16[6]=a.pop16()};table32[91]=function(a){a.reg32s[3]=a.pop32s()};table16[92]=function(a){a.reg16[8]=a.pop16()};table32[92]=function(a){a.reg32s[4]=a.pop32s()};table16[93]=function(a){a.reg16[10]=a.pop16()};table32[93]=function(a){a.reg32s[5]=a.pop32s()};table16[94]=function(a){a.reg16[12]=a.pop16()};table32[94]=function(a){a.reg32s[6]=a.pop32s()}; |
| table16[95]=function(a){a.reg16[14]=a.pop16()};table32[95]=function(a){a.reg32s[7]=a.pop32s()};table16[96]=function(a){a.pusha16()};table32[96]=function(a){a.pusha32()};table16[97]=function(a){a.popa16()};table32[97]=function(a){a.popa32()};table16[98]=table32[98]=function(){}; |
| table16[99]=table32[99]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c=a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];c=a.arpl(c,b>>2&14);192>b?e?a.virt_boundary_write16(d,e,c):a.memory.write16(d,c):a.reg16[b<<1&14]=c};table16[100]=table32[100]=function(a){a.seg_prefix(4)};table16[101]=table32[101]=function(a){a.seg_prefix(5)}; |
| table16[102]=table32[102]=function(a){a.operand_size_32=!a.is_32;a.update_operand_size();a.do_op();a.operand_size_32=a.is_32;a.update_operand_size()};table16[103]=table32[103]=function(a){a.address_size_32=!a.is_32;a.update_address_size();a.do_op();a.address_size_32=a.is_32;a.update_address_size()};table16[104]=function(a){a.push16(a.read_imm16())};table32[104]=function(a){a.push32(a.read_imm32s())}; |
| table16[105]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b))<<16>>16:a.reg16s[b<<1&14];a.reg16[b>>2&14]=a.imul_reg16(a.read_imm16s(),c)};table32[105]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.reg32s[b>>3&7]=a.imul_reg32(a.read_imm32s(),c)};table16[106]=function(a){a.push16(a.read_imm8s())};table32[106]=function(a){a.push32(a.read_imm8s())}; |
| table16[107]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b))<<16>>16:a.reg16s[b<<1&14];a.reg16[b>>2&14]=a.imul_reg16(a.read_imm8s(),c)};table32[107]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.reg32s[b>>3&7]=a.imul_reg32(a.read_imm8s(),c)};table16[108]=table32[108]=function(a){insb(a)};table16[109]=function(a){insw(a)};table32[109]=function(a){insd(a)};table16[110]=table32[110]=function(a){outsb(a)};table16[111]=function(a){outsw(a)}; |
| table32[111]=function(a){outsd(a)};table16[112]=table32[112]=function(a){a.test_o()&&(a.instruction_pointer=a.instruction_pointer+a.read_imm8s()|0);a.instruction_pointer++;a.last_instr_jump=!0};table16[113]=table32[113]=function(a){a.test_o()||(a.instruction_pointer=a.instruction_pointer+a.read_imm8s()|0);a.instruction_pointer++;a.last_instr_jump=!0}; |
| table16[114]=table32[114]=function(a){a.test_b()&&(a.instruction_pointer=a.instruction_pointer+a.read_imm8s()|0);a.instruction_pointer++;a.last_instr_jump=!0};table16[115]=table32[115]=function(a){a.test_b()||(a.instruction_pointer=a.instruction_pointer+a.read_imm8s()|0);a.instruction_pointer++;a.last_instr_jump=!0};table16[116]=table32[116]=function(a){a.test_z()&&(a.instruction_pointer=a.instruction_pointer+a.read_imm8s()|0);a.instruction_pointer++;a.last_instr_jump=!0}; |
| table16[117]=table32[117]=function(a){a.test_z()||(a.instruction_pointer=a.instruction_pointer+a.read_imm8s()|0);a.instruction_pointer++;a.last_instr_jump=!0};table16[118]=table32[118]=function(a){a.test_be()&&(a.instruction_pointer=a.instruction_pointer+a.read_imm8s()|0);a.instruction_pointer++;a.last_instr_jump=!0};table16[119]=table32[119]=function(a){a.test_be()||(a.instruction_pointer=a.instruction_pointer+a.read_imm8s()|0);a.instruction_pointer++;a.last_instr_jump=!0}; |
| table16[120]=table32[120]=function(a){a.test_s()&&(a.instruction_pointer=a.instruction_pointer+a.read_imm8s()|0);a.instruction_pointer++;a.last_instr_jump=!0};table16[121]=table32[121]=function(a){a.test_s()||(a.instruction_pointer=a.instruction_pointer+a.read_imm8s()|0);a.instruction_pointer++;a.last_instr_jump=!0};table16[122]=table32[122]=function(a){a.test_p()&&(a.instruction_pointer=a.instruction_pointer+a.read_imm8s()|0);a.instruction_pointer++;a.last_instr_jump=!0}; |
| table16[123]=table32[123]=function(a){a.test_p()||(a.instruction_pointer=a.instruction_pointer+a.read_imm8s()|0);a.instruction_pointer++;a.last_instr_jump=!0};table16[124]=table32[124]=function(a){a.test_l()&&(a.instruction_pointer=a.instruction_pointer+a.read_imm8s()|0);a.instruction_pointer++;a.last_instr_jump=!0};table16[125]=table32[125]=function(a){a.test_l()||(a.instruction_pointer=a.instruction_pointer+a.read_imm8s()|0);a.instruction_pointer++;a.last_instr_jump=!0}; |
| table16[126]=table32[126]=function(a){a.test_le()&&(a.instruction_pointer=a.instruction_pointer+a.read_imm8s()|0);a.instruction_pointer++;a.last_instr_jump=!0};table16[127]=table32[127]=function(a){a.test_le()||(a.instruction_pointer=a.instruction_pointer+a.read_imm8s()|0);a.instruction_pointer++;a.last_instr_jump=!0}; |
| table16[128]=table32[128]=function(a){var b=a.read_imm8();if(56===(b&56)){var c=192>b?a.safe_read8(a.modrm_resolve(b)):a.reg8[b<<2&12|b>>2&1];a.sub(c,a.read_imm8(),7)}else{var d,e,f;192>b?(e=a.translate_address_write(a.modrm_resolve(b)),c=a.memory.read8(e)):c=a.reg8[b<<2&12|b>>2&1];f=0;d=a.read_imm8();switch(b>>3&7){case 0:f=a.add(c,d,7);break;case 1:f=a.or(c,d,7);break;case 2:f=a.adc(c,d,7);break;case 3:f=a.sbb(c,d,7);break;case 4:f=a.and(c,d,7);break;case 5:f=a.sub(c,d,7);break;case 6:f=a.xor(c, |
| d,7);break;case 7:f=dbg_assert.bind(this,0)(c,d)}192>b?a.memory.write8(e,f):a.reg8[b<<2&12|b>>2&1]=f}}; |
| table16[129]=function(a){var b=a.read_imm8();if(56===(b&56)){var c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.sub(c,a.read_imm16(),15)}else{var d,e,f=0,g;192>b?(c=a.modrm_resolve(b),e=a.translate_address_write(c),a.paging&&4095===(c&4095)?(f=a.translate_address_write(c+1),c=a.virt_boundary_read16(e,f)):c=a.memory.read16(e)):c=a.reg16[b<<1&14];g=0;d=a.read_imm16();switch(b>>3&7){case 0:g=a.add(c,d,15);break;case 1:g=a.or(c,d,15);break;case 2:g=a.adc(c,d,15);break;case 3:g=a.sbb(c,d, |
| 15);break;case 4:g=a.and(c,d,15);break;case 5:g=a.sub(c,d,15);break;case 6:g=a.xor(c,d,15);break;case 7:g=dbg_assert.bind(this,0)(c,d)}192>b?f?a.virt_boundary_write16(e,f,g):a.memory.write16(e,g):a.reg16[b<<1&14]=g}}; |
| table32[129]=function(a){var b=a.read_imm8();if(56===(b&56)){var c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.sub(c,a.read_imm32s(),31)}else{var d,e,f=0,g;192>b?(c=a.modrm_resolve(b),e=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(f=a.translate_address_write(c+3),c=a.virt_boundary_read32s(e,f)):c=a.memory.read32s(e)):c=a.reg32s[b&7];g=0;d=a.read_imm32s();switch(b>>3&7){case 0:g=a.add(c,d,31);break;case 1:g=a.or(c,d,31);break;case 2:g=a.adc(c,d,31);break;case 3:g=a.sbb(c,d,31); |
| break;case 4:g=a.and(c,d,31);break;case 5:g=a.sub(c,d,31);break;case 6:g=a.xor(c,d,31);break;case 7:g=dbg_assert.bind(this,0)(c,d)}192>b?f?a.virt_boundary_write32(e,f,g):a.memory.write32(e,g):a.reg32s[b&7]=g}};table16[130]=table32[130]=function(a){a.table[128](a)}; |
| table16[131]=function(a){var b=a.read_imm8();if(56===(b&56)){var c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.sub(c,a.read_imm8s(),15)}else{var d,e,f=0,g;192>b?(c=a.modrm_resolve(b),e=a.translate_address_write(c),a.paging&&4095===(c&4095)?(f=a.translate_address_write(c+1),c=a.virt_boundary_read16(e,f)):c=a.memory.read16(e)):c=a.reg16[b<<1&14];g=0;d=a.read_imm8s();switch(b>>3&7){case 0:g=a.add(c,d,15);break;case 1:g=a.or(c,d,15);break;case 2:g=a.adc(c,d,15);break;case 3:g=a.sbb(c,d, |
| 15);break;case 4:g=a.and(c,d,15);break;case 5:g=a.sub(c,d,15);break;case 6:g=a.xor(c,d,15);break;case 7:g=dbg_assert.bind(this,0)(c,d)}192>b?f?a.virt_boundary_write16(e,f,g):a.memory.write16(e,g):a.reg16[b<<1&14]=g}}; |
| table32[131]=function(a){var b=a.read_imm8();if(56===(b&56)){var c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.sub(c,a.read_imm8s(),31)}else{var d,e,f=0,g;192>b?(c=a.modrm_resolve(b),e=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(f=a.translate_address_write(c+3),c=a.virt_boundary_read32s(e,f)):c=a.memory.read32s(e)):c=a.reg32s[b&7];g=0;d=a.read_imm8s();switch(b>>3&7){case 0:g=a.add(c,d,31);break;case 1:g=a.or(c,d,31);break;case 2:g=a.adc(c,d,31);break;case 3:g=a.sbb(c,d,31); |
| break;case 4:g=a.and(c,d,31);break;case 5:g=a.sub(c,d,31);break;case 6:g=a.xor(c,d,31);break;case 7:g=dbg_assert.bind(this,0)(c,d)}192>b?f?a.virt_boundary_write32(e,f,g):a.memory.write32(e,g):a.reg32s[b&7]=g}};table16[132]=table32[132]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read8(a.modrm_resolve(b)):a.reg8[b<<2&12|b>>2&1];a.and(c,a.reg8[b>>1&12|b>>5&1],7)};table16[133]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.and(c,a.reg16[b>>2&14],15)}; |
| table32[133]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.and(c,a.reg32s[b>>3&7],31)};table16[134]=table32[134]=function(a){var b=a.read_imm8(),c,d;192>b?(d=a.translate_address_write(a.modrm_resolve(b)),c=a.memory.read8(d)):c=a.reg8[b<<2&12|b>>2&1];c=a.xchg8(c,b);192>b?a.memory.write8(d,c):a.reg8[b<<2&12|b>>2&1]=c}; |
| table16[135]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c=a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];c=a.xchg16(c,b);192>b?e?a.virt_boundary_write16(d,e,c):a.memory.write16(d,c):a.reg16[b<<1&14]=c}; |
| table32[135]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(e=a.translate_address_write(c+3),c=a.virt_boundary_read32s(d,e)):c=a.memory.read32s(d)):c=a.reg32s[b&7];c=a.xchg32(c,b);192>b?e?a.virt_boundary_write32(d,e,c):a.memory.write32(d,c):a.reg32s[b&7]=c}; |
| table16[136]=table32[136]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=a.reg8[b>>1&12|b>>5&1];192>b?a.safe_write8(c,d):a.reg8[b<<2&12|b>>2&1]=d};table16[137]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=a.reg16[b>>2&14];192>b?a.safe_write16(c,d):a.reg16[b<<1&14]=d};table32[137]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=a.reg32s[b>>3&7];192>b?a.safe_write32(c,d):a.reg32[b&7]=d}; |
| table16[138]=table32[138]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read8(a.modrm_resolve(b)):a.reg8[b<<2&12|b>>2&1];a.reg8[b>>1&12|b>>5&1]=c};table16[139]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.reg16[b>>2&14]=c};table32[139]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.reg32s[b>>3&7]=c}; |
| table16[140]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=a.sreg[b>>3&7];192>b?a.safe_write16(c,d):a.reg16[b<<1&14]=d};table32[140]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=a.sreg[b>>3&7];192>b?a.safe_write32(c,d):a.reg32[b&7]=d};table16[141]=function(a){var b=a.read_imm8();192<=b&&a.trigger_ud();a.segment_prefix=9;a.reg16[(b>>3&7)<<1]=a.modrm_resolve(b);a.segment_prefix=-1}; |
| table32[141]=function(a){var b=a.read_imm8();192<=b&&a.trigger_ud();a.segment_prefix=9;a.reg32s[b>>3&7]=a.modrm_resolve(b);a.segment_prefix=-1};table16[142]=table32[142]=function(a){var b=a.read_imm8(),c=b>>3&7,b=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.switch_seg(c,b)}; |
| table16[143]=function(a){var b=a.read_imm8(),c=a.safe_read16(a.get_stack_pointer(0));a.stack_reg[a.reg_vsp]+=2;192>b?(b=a.modrm_resolve(b),a.stack_reg[a.reg_vsp]-=2,a.safe_write16(b,c),a.stack_reg[a.reg_vsp]+=2):a.reg16[b<<1&14]=c};table32[143]=function(a){var b=a.read_imm8(),c=a.safe_read32s(a.get_stack_pointer(0));a.stack_reg[a.reg_vsp]+=4;192>b?(b=a.modrm_resolve(b),a.stack_reg[a.reg_vsp]-=4,a.safe_write32(b,c),a.stack_reg[a.reg_vsp]+=4):a.reg32s[b&7]=c};table16[144]=table32[144]=function(){}; |
| table16[145]=function(a){a.xchg16r(2)};table32[145]=function(a){a.xchg32r(1)};table16[146]=function(a){a.xchg16r(4)};table32[146]=function(a){a.xchg32r(2)};table16[147]=function(a){a.xchg16r(6)};table32[147]=function(a){a.xchg32r(3)};table16[148]=function(a){a.xchg16r(8)};table32[148]=function(a){a.xchg32r(4)};table16[149]=function(a){a.xchg16r(10)};table32[149]=function(a){a.xchg32r(5)};table16[150]=function(a){a.xchg16r(12)};table32[150]=function(a){a.xchg32r(6)};table16[151]=function(a){a.xchg16r(14)}; |
| table32[151]=function(a){a.xchg32r(7)};table16[152]=function(a){a.reg16[0]=a.reg8s[0]};table32[152]=function(a){a.reg32s[0]=a.reg16s[0]};table16[153]=function(a){a.reg16[4]=a.reg16s[0]>>15};table32[153]=function(a){a.reg32s[2]=a.reg32s[0]>>31};table16[154]=function(a){var b=a.read_imm16(),c=a.read_imm16();a.writable_or_pagefault(a.get_stack_pointer(-4),4);a.push16(a.sreg[1]);a.push16(a.get_real_eip());a.switch_seg(1,c);a.instruction_pointer=a.get_seg(1)+b|0;a.last_instr_jump=!0}; |
| table32[154]=function(a){var b=a.read_imm32s(),c=a.read_imm16();a.writable_or_pagefault(a.get_stack_pointer(-8),8);a.push32(a.sreg[1]);a.push32(a.get_real_eip());a.switch_seg(1,c);a.instruction_pointer=a.get_seg(1)+b|0;a.last_instr_jump=!0};table16[155]=table32[155]=function(a){10===(a.cr0&10)&&a.trigger_nm()};table16[156]=function(a){a.flags&131072&&3>a.getiopl()?a.trigger_gp(0):(a.load_eflags(),a.push16(a.flags))}; |
| table32[156]=function(a){a.flags&131072&&3>a.getiopl()?a.trigger_gp(0):(a.load_eflags(),a.push32(a.flags&-196609))};table16[157]=function(a){a.flags&131072&&3>a.getiopl()&&a.trigger_gp(0);a.update_eflags(a.flags&-65536|a.pop16());a.handle_irqs()};table32[157]=function(a){a.flags&131072&&3>a.getiopl()&&a.trigger_gp(0);a.update_eflags(a.pop32s());a.handle_irqs()};table16[158]=table32[158]=function(a){a.flags=a.flags&-256|a.reg8[1];a.flags=a.flags&4161493|2;a.flags_changed=0}; |
| table16[159]=table32[159]=function(a){a.load_eflags();a.reg8[1]=a.flags};table16[160]=table32[160]=function(a){var b=a.safe_read8(a.read_moffs());a.reg8[0]=b};table16[161]=function(a){var b=a.safe_read16(a.read_moffs());a.reg16[0]=b};table32[161]=function(a){var b=a.safe_read32s(a.read_moffs());a.reg32s[0]=b};table16[162]=table32[162]=function(a){a.safe_write8(a.read_moffs(),a.reg8[0])};table16[163]=function(a){a.safe_write16(a.read_moffs(),a.reg16[0])}; |
| table32[163]=function(a){a.safe_write32(a.read_moffs(),a.reg32s[0])};table16[164]=table32[164]=function(a){movsb(a)};table16[165]=function(a){movsw(a)};table32[165]=function(a){movsd(a)};table16[166]=table32[166]=function(a){cmpsb(a)};table16[167]=function(a){cmpsw(a)};table32[167]=function(a){cmpsd(a)};table16[168]=table32[168]=function(a){a.and(a.reg8[0],a.read_imm8(),7)};table16[169]=function(a){a.and(a.reg16[0],a.read_imm16(),15)};table32[169]=function(a){a.and(a.reg32s[0],a.read_imm32s(),31)}; |
| table16[170]=table32[170]=function(a){stosb(a)};table16[171]=function(a){stosw(a)};table32[171]=function(a){stosd(a)};table16[172]=table32[172]=function(a){lodsb(a)};table16[173]=function(a){lodsw(a)};table32[173]=function(a){lodsd(a)};table16[174]=table32[174]=function(a){scasb(a)};table16[175]=function(a){scasw(a)};table32[175]=function(a){scasd(a)};table16[176]=table32[176]=function(a){a.reg8[0]=a.read_imm8()};table16[177]=table32[177]=function(a){a.reg8[4]=a.read_imm8()}; |
| table16[178]=table32[178]=function(a){a.reg8[8]=a.read_imm8()};table16[179]=table32[179]=function(a){a.reg8[12]=a.read_imm8()};table16[180]=table32[180]=function(a){a.reg8[1]=a.read_imm8()};table16[181]=table32[181]=function(a){a.reg8[5]=a.read_imm8()};table16[182]=table32[182]=function(a){a.reg8[9]=a.read_imm8()};table16[183]=table32[183]=function(a){a.reg8[13]=a.read_imm8()};table16[184]=function(a){a.reg16[0]=a.read_imm16()};table32[184]=function(a){a.reg32s[0]=a.read_imm32s()}; |
| table16[185]=function(a){a.reg16[2]=a.read_imm16()};table32[185]=function(a){a.reg32s[1]=a.read_imm32s()};table16[186]=function(a){a.reg16[4]=a.read_imm16()};table32[186]=function(a){a.reg32s[2]=a.read_imm32s()};table16[187]=function(a){a.reg16[6]=a.read_imm16()};table32[187]=function(a){a.reg32s[3]=a.read_imm32s()};table16[188]=function(a){a.reg16[8]=a.read_imm16()};table32[188]=function(a){a.reg32s[4]=a.read_imm32s()};table16[189]=function(a){a.reg16[10]=a.read_imm16()}; |
| table32[189]=function(a){a.reg32s[5]=a.read_imm32s()};table16[190]=function(a){a.reg16[12]=a.read_imm16()};table32[190]=function(a){a.reg32s[6]=a.read_imm32s()};table16[191]=function(a){a.reg16[14]=a.read_imm16()};table32[191]=function(a){a.reg32s[7]=a.read_imm32s()}; |
| table16[192]=table32[192]=function(a){var b=a.read_imm8(),c,d,e,f;192>b?(e=a.translate_address_write(a.modrm_resolve(b)),d=a.memory.read8(e)):d=a.reg8[b<<2&12|b>>2&1];f=0;c=a.read_imm8()&31;switch(b>>3&7){case 0:f=a.rol8(d,c);break;case 1:f=a.ror8(d,c);break;case 2:f=a.rcl8(d,c);break;case 3:f=a.rcr8(d,c);break;case 4:f=a.shl8(d,c);break;case 5:f=a.shr8(d,c);break;case 6:f=a.shl8(d,c);break;case 7:f=a.sar8(d,c)}192>b?a.memory.write8(e,f):a.reg8[b<<2&12|b>>2&1]=f}; |
| table16[193]=function(a){var b=a.read_imm8(),c,d,e,f=0,g;192>b?(c=a.modrm_resolve(b),e=a.translate_address_write(c),a.paging&&4095===(c&4095)?(f=a.translate_address_write(c+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[b<<1&14];g=0;c=a.read_imm8()&31;switch(b>>3&7){case 0:g=a.rol16(d,c);break;case 1:g=a.ror16(d,c);break;case 2:g=a.rcl16(d,c);break;case 3:g=a.rcr16(d,c);break;case 4:g=a.shl16(d,c);break;case 5:g=a.shr16(d,c);break;case 6:g=a.shl16(d,c);break;case 7:g=a.sar16(d, |
| c)}192>b?f?a.virt_boundary_write16(e,f,g):a.memory.write16(e,g):a.reg16[b<<1&14]=g}; |
| table32[193]=function(a){var b=a.read_imm8(),c,d,e,f=0,g;192>b?(c=a.modrm_resolve(b),e=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(f=a.translate_address_write(c+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[b&7];g=0;c=a.read_imm8()&31;switch(b>>3&7){case 0:g=a.rol32(d,c);break;case 1:g=a.ror32(d,c);break;case 2:g=a.rcl32(d,c);break;case 3:g=a.rcr32(d,c);break;case 4:g=a.shl32(d,c);break;case 5:g=a.shr32(d,c);break;case 6:g=a.shl32(d,c);break;case 7:g=a.sar32(d,c)}192> |
| b?f?a.virt_boundary_write32(e,f,g):a.memory.write32(e,g):a.reg32s[b&7]=g};table16[194]=function(a){var b=a.read_imm16();a.instruction_pointer=a.get_seg(1)+a.pop16()|0;a.stack_reg[a.reg_vsp]+=b;a.last_instr_jump=!0};table32[194]=function(a){var b=a.read_imm16();a.instruction_pointer=a.get_seg(1)+a.pop32s()|0;a.stack_reg[a.reg_vsp]+=b;a.last_instr_jump=!0};table16[195]=function(a){a.instruction_pointer=a.get_seg(1)+a.pop16()|0;a.last_instr_jump=!0}; |
| table32[195]=function(a){a.instruction_pointer=a.get_seg(1)+a.pop32s()|0;a.last_instr_jump=!0};table16[196]=function(a){var b=a.read_imm8();192<=b&&a.trigger_ud();a.lss16(0,a.modrm_resolve(b),b>>2&14)};table32[196]=function(a){var b=a.read_imm8();192<=b&&a.trigger_ud();a.lss32(0,a.modrm_resolve(b),b>>3&7)};table16[197]=function(a){var b=a.read_imm8();192<=b&&a.trigger_ud();a.lss16(3,a.modrm_resolve(b),b>>2&14)}; |
| table32[197]=function(a){var b=a.read_imm8();192<=b&&a.trigger_ud();a.lss32(3,a.modrm_resolve(b),b>>3&7)};table16[198]=table32[198]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=a.read_imm8();192>b?a.safe_write8(c,d):a.reg8[b<<2&12|b>>2&1]=d};table16[199]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=a.read_imm16();192>b?a.safe_write16(c,d):a.reg16[b<<1&14]=d}; |
| table32[199]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=a.read_imm32s();192>b?a.safe_write32(c,d):a.reg32[b&7]=d};table16[200]=function(a){a.enter16()};table32[200]=function(a){a.enter32()};table16[201]=function(a){a.stack_reg[a.reg_vsp]=a.stack_reg[a.reg_vbp];a.reg16[10]=a.pop16()};table32[201]=function(a){a.stack_reg[a.reg_vsp]=a.stack_reg[a.reg_vbp];a.reg32s[5]=a.pop32s()}; |
| table16[202]=function(a){a.translate_address_read(a.get_seg(2)+a.stack_reg[a.reg_vsp]+4);var b=a.read_imm16(),c=a.pop16();a.switch_seg(1,a.pop16());a.instruction_pointer=a.get_seg(1)+c|0;a.stack_reg[a.reg_vsp]+=b;a.last_instr_jump=!0};table32[202]=function(a){a.translate_address_read(a.get_seg(2)+a.stack_reg[a.reg_vsp]+8);var b=a.read_imm16(),c=a.pop32s();a.switch_seg(1,a.pop32s()&65535);a.instruction_pointer=a.get_seg(1)+c|0;a.stack_reg[a.reg_vsp]+=b;a.last_instr_jump=!0}; |
| table16[203]=function(a){a.translate_address_read(a.get_seg(2)+a.stack_reg[a.reg_vsp]+4);var b=a.pop16();a.switch_seg(1,a.pop16());a.instruction_pointer=a.get_seg(1)+b|0;a.last_instr_jump=!0};table32[203]=function(a){a.translate_address_read(a.get_seg(2)+a.stack_reg[a.reg_vsp]+8);var b=a.pop32s();a.switch_seg(1,a.pop32s()&65535);a.instruction_pointer=a.get_seg(1)+b|0;a.last_instr_jump=!0};table16[204]=table32[204]=function(a){a.call_interrupt_vector(3,!0,!1)}; |
| table16[205]=table32[205]=function(a){var b=a.read_imm8();a.call_interrupt_vector(b,!0,!1)};table16[206]=table32[206]=function(a){a.getof()&&a.call_interrupt_vector(4,!0,!1)};table16[207]=function(a){a.iret16()};table32[207]=function(a){a.iret32()}; |
| table16[208]=table32[208]=function(a){var b=a.read_imm8(),c,d,e;192>b?(d=a.translate_address_write(a.modrm_resolve(b)),c=a.memory.read8(d)):c=a.reg8[b<<2&12|b>>2&1];e=0;switch(b>>3&7){case 0:e=a.rol8(c,1);break;case 1:e=a.ror8(c,1);break;case 2:e=a.rcl8(c,1);break;case 3:e=a.rcr8(c,1);break;case 4:e=a.shl8(c,1);break;case 5:e=a.shr8(c,1);break;case 6:e=a.shl8(c,1);break;case 7:e=a.sar8(c,1)}192>b?a.memory.write8(d,e):a.reg8[b<<2&12|b>>2&1]=e}; |
| table16[209]=function(a){var b=a.read_imm8(),c,d,e=0,f;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c=a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];f=0;switch(b>>3&7){case 0:f=a.rol16(c,1);break;case 1:f=a.ror16(c,1);break;case 2:f=a.rcl16(c,1);break;case 3:f=a.rcr16(c,1);break;case 4:f=a.shl16(c,1);break;case 5:f=a.shr16(c,1);break;case 6:f=a.shl16(c,1);break;case 7:f=a.sar16(c,1)}192>b?e?a.virt_boundary_write16(d, |
| e,f):a.memory.write16(d,f):a.reg16[b<<1&14]=f}; |
| table32[209]=function(a){var b=a.read_imm8(),c,d,e=0,f;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(e=a.translate_address_write(c+3),c=a.virt_boundary_read32s(d,e)):c=a.memory.read32s(d)):c=a.reg32s[b&7];f=0;switch(b>>3&7){case 0:f=a.rol32(c,1);break;case 1:f=a.ror32(c,1);break;case 2:f=a.rcl32(c,1);break;case 3:f=a.rcr32(c,1);break;case 4:f=a.shl32(c,1);break;case 5:f=a.shr32(c,1);break;case 6:f=a.shl32(c,1);break;case 7:f=a.sar32(c,1)}192>b?e?a.virt_boundary_write32(d, |
| e,f):a.memory.write32(d,f):a.reg32s[b&7]=f}; |
| table16[210]=table32[210]=function(a){var b=a.read_imm8(),c,d,e,f;192>b?(e=a.translate_address_write(a.modrm_resolve(b)),d=a.memory.read8(e)):d=a.reg8[b<<2&12|b>>2&1];f=0;c=a.reg8[4]&31;switch(b>>3&7){case 0:f=a.rol8(d,c);break;case 1:f=a.ror8(d,c);break;case 2:f=a.rcl8(d,c);break;case 3:f=a.rcr8(d,c);break;case 4:f=a.shl8(d,c);break;case 5:f=a.shr8(d,c);break;case 6:f=a.shl8(d,c);break;case 7:f=a.sar8(d,c)}192>b?a.memory.write8(e,f):a.reg8[b<<2&12|b>>2&1]=f}; |
| table16[211]=function(a){var b=a.read_imm8(),c,d,e,f=0,g;192>b?(c=a.modrm_resolve(b),e=a.translate_address_write(c),a.paging&&4095===(c&4095)?(f=a.translate_address_write(c+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[b<<1&14];g=0;c=a.reg8[4]&31;switch(b>>3&7){case 0:g=a.rol16(d,c);break;case 1:g=a.ror16(d,c);break;case 2:g=a.rcl16(d,c);break;case 3:g=a.rcr16(d,c);break;case 4:g=a.shl16(d,c);break;case 5:g=a.shr16(d,c);break;case 6:g=a.shl16(d,c);break;case 7:g=a.sar16(d,c)}192> |
| b?f?a.virt_boundary_write16(e,f,g):a.memory.write16(e,g):a.reg16[b<<1&14]=g}; |
| table32[211]=function(a){var b=a.read_imm8(),c,d,e,f=0,g;192>b?(c=a.modrm_resolve(b),e=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(f=a.translate_address_write(c+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[b&7];g=0;c=a.reg8[4]&31;switch(b>>3&7){case 0:g=a.rol32(d,c);break;case 1:g=a.ror32(d,c);break;case 2:g=a.rcl32(d,c);break;case 3:g=a.rcr32(d,c);break;case 4:g=a.shl32(d,c);break;case 5:g=a.shr32(d,c);break;case 6:g=a.shl32(d,c);break;case 7:g=a.sar32(d,c)}192> |
| b?f?a.virt_boundary_write32(e,f,g):a.memory.write32(e,g):a.reg32s[b&7]=g};table16[212]=table32[212]=function(a){a.bcd_aam()};table16[213]=table32[213]=function(a){a.bcd_aad()};table16[214]=table32[214]=function(a){a.reg8[0]=-a.getcf()};table16[215]=table32[215]=function(a){a.reg8[0]=a.address_size_32?a.safe_read8(a.get_seg_prefix(3)+a.reg32s[3]+a.reg8[0]):a.safe_read8(a.get_seg_prefix(3)+a.reg16[6]+a.reg8[0])}; |
| table16[216]=table32[216]=function(a){var b=a.read_imm8();a.cr0&12&&a.trigger_nm();192>b?a.fpu.op_D8_mem(b,a.modrm_resolve(b)):a.fpu.op_D8_reg(b)};table16[217]=table32[217]=function(a){var b=a.read_imm8();a.cr0&12&&a.trigger_nm();192>b?a.fpu.op_D9_mem(b,a.modrm_resolve(b)):a.fpu.op_D9_reg(b)};table16[218]=table32[218]=function(a){var b=a.read_imm8();a.cr0&12&&a.trigger_nm();192>b?a.fpu.op_DA_mem(b,a.modrm_resolve(b)):a.fpu.op_DA_reg(b)}; |
| table16[219]=table32[219]=function(a){var b=a.read_imm8();a.cr0&12&&a.trigger_nm();192>b?a.fpu.op_DB_mem(b,a.modrm_resolve(b)):a.fpu.op_DB_reg(b)};table16[220]=table32[220]=function(a){var b=a.read_imm8();a.cr0&12&&a.trigger_nm();192>b?a.fpu.op_DC_mem(b,a.modrm_resolve(b)):a.fpu.op_DC_reg(b)};table16[221]=table32[221]=function(a){var b=a.read_imm8();a.cr0&12&&a.trigger_nm();192>b?a.fpu.op_DD_mem(b,a.modrm_resolve(b)):a.fpu.op_DD_reg(b)}; |
| table16[222]=table32[222]=function(a){var b=a.read_imm8();a.cr0&12&&a.trigger_nm();192>b?a.fpu.op_DE_mem(b,a.modrm_resolve(b)):a.fpu.op_DE_reg(b)};table16[223]=table32[223]=function(a){var b=a.read_imm8();a.cr0&12&&a.trigger_nm();192>b?a.fpu.op_DF_mem(b,a.modrm_resolve(b)):a.fpu.op_DF_reg(b)};table16[224]=table32[224]=function(a){a.loopne()};table16[225]=table32[225]=function(a){a.loope()};table16[226]=table32[226]=function(a){a.loop()};table16[227]=table32[227]=function(a){a.jcxz()}; |
| table16[228]=table32[228]=function(a){var b=a.read_imm8();a.test_privileges_for_io(b,1);a.reg8[0]=a.io.port_read8(b)};table16[229]=function(a){var b=a.read_imm8();a.test_privileges_for_io(b,2);a.reg16[0]=a.io.port_read16(b)};table32[229]=function(a){var b=a.read_imm8();a.test_privileges_for_io(b,4);a.reg32s[0]=a.io.port_read32(b)};table16[230]=table32[230]=function(a){var b=a.read_imm8();a.test_privileges_for_io(b,1);a.io.port_write8(b,a.reg8[0])}; |
| table16[231]=function(a){var b=a.read_imm8();a.test_privileges_for_io(b,2);a.io.port_write16(b,a.reg16[0])};table32[231]=function(a){var b=a.read_imm8();a.test_privileges_for_io(b,4);a.io.port_write32(b,a.reg32s[0])};table16[232]=function(a){var b=a.read_imm16s();a.push16(a.get_real_eip());a.jmp_rel16(b);a.last_instr_jump=!0};table32[232]=function(a){var b=a.read_imm32s();a.push32(a.get_real_eip());a.instruction_pointer=a.instruction_pointer+b|0;a.last_instr_jump=!0}; |
| table16[233]=function(a){var b=a.read_imm16s();a.jmp_rel16(b);a.last_instr_jump=!0};table32[233]=function(a){var b=a.read_imm32s();a.instruction_pointer=a.instruction_pointer+b|0;a.last_instr_jump=!0};table16[234]=function(a){var b=a.read_imm16();a.switch_seg(1,a.read_imm16());a.instruction_pointer=b+a.get_seg(1)|0;a.last_instr_jump=!0};table32[234]=function(a){var b=a.read_imm32s();a.switch_seg(1,a.read_imm16());a.instruction_pointer=b+a.get_seg(1)|0;a.last_instr_jump=!0}; |
| table16[235]=table32[235]=function(a){var b=a.read_imm8s();a.instruction_pointer=a.instruction_pointer+b|0;a.last_instr_jump=!0};table16[236]=table32[236]=function(a){var b=a.reg16[4];a.test_privileges_for_io(b,1);a.reg8[0]=a.io.port_read8(b)};table16[237]=function(a){var b=a.reg16[4];a.test_privileges_for_io(b,2);a.reg16[0]=a.io.port_read16(b)};table32[237]=function(a){var b=a.reg16[4];a.test_privileges_for_io(b,4);a.reg32s[0]=a.io.port_read32(b)}; |
| table16[238]=table32[238]=function(a){var b=a.reg16[4];a.test_privileges_for_io(b,1);a.io.port_write8(b,a.reg8[0])};table16[239]=function(a){var b=a.reg16[4];a.test_privileges_for_io(b,2);a.io.port_write16(b,a.reg16[0])};table32[239]=function(a){var b=a.reg16[4];a.test_privileges_for_io(b,4);a.io.port_write32(b,a.reg32s[0])};table16[240]=table32[240]=function(a){a.do_op()};table16[241]=table32[241]=function(a){throw a.debug.unimpl("int1 instruction");}; |
| table16[242]=table32[242]=function(a){a.repeat_string_prefix=1;a.do_op();a.repeat_string_prefix=0};table16[243]=table32[243]=function(a){a.repeat_string_prefix=2;a.do_op();a.repeat_string_prefix=0};table16[244]=table32[244]=function(a){a.hlt_op()};table16[245]=table32[245]=function(a){a.flags=(a.flags|1)^a.getcf();a.flags_changed&=-2}; |
| table16[246]=table32[246]=function(a){var b=a.read_imm8();switch(b>>3&7){case 0:var c=192>b?a.safe_read8(a.modrm_resolve(b)):a.reg8[b<<2&12|b>>2&1];a.and(c,a.read_imm8(),7);break;case 1:c=192>b?a.safe_read8(a.modrm_resolve(b)):a.reg8[b<<2&12|b>>2&1];a.and(c,a.read_imm8(),7);break;case 2:var d;192>b?(d=a.translate_address_write(a.modrm_resolve(b)),c=a.memory.read8(d)):c=a.reg8[b<<2&12|b>>2&1];c=~c;192>b?a.memory.write8(d,c):a.reg8[b<<2&12|b>>2&1]=c;break;case 3:192>b?(d=a.translate_address_write(a.modrm_resolve(b)), |
| c=a.memory.read8(d)):c=a.reg8[b<<2&12|b>>2&1];c=a.neg(c,7);192>b?a.memory.write8(d,c):a.reg8[b<<2&12|b>>2&1]=c;break;case 4:c=192>b?a.safe_read8(a.modrm_resolve(b)):a.reg8[b<<2&12|b>>2&1];a.mul8(c);break;case 5:192>b?c=a.safe_read8(a.modrm_resolve(b))<<24>>24:c=a.reg8s[b<<2&12|b>>2&1];a.imul8(c);break;case 6:c=192>b?a.safe_read8(a.modrm_resolve(b)):a.reg8[b<<2&12|b>>2&1];a.div8(c);break;case 7:192>b?c=a.safe_read8(a.modrm_resolve(b))<<24>>24:c=a.reg8s[b<<2&12|b>>2&1],a.idiv8(c)}}; |
| table16[247]=function(a){var b=a.read_imm8();switch(b>>3&7){case 0:var c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.and(c,a.read_imm16(),15);break;case 1:c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.and(c,a.read_imm16(),15);break;case 2:var d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c=a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];c=~c;192>b?e?a.virt_boundary_write16(d, |
| e,c):a.memory.write16(d,c):a.reg16[b<<1&14]=c;break;case 3:e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c=a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];c=a.neg(c,15);192>b?e?a.virt_boundary_write16(d,e,c):a.memory.write16(d,c):a.reg16[b<<1&14]=c;break;case 4:c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.mul16(c);break;case 5:192>b?c=a.safe_read16(a.modrm_resolve(b))<<16>>16:c=a.reg16s[b<< |
| 1&14];a.imul16(c);break;case 6:c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.div16(c);break;case 7:192>b?c=a.safe_read16(a.modrm_resolve(b))<<16>>16:c=a.reg16s[b<<1&14],a.idiv16(c)}}; |
| table32[247]=function(a){var b=a.read_imm8();switch(b>>3&7){case 0:var c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.and(c,a.read_imm32s(),31);break;case 1:c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.and(c,a.read_imm32s(),31);break;case 2:var d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(e=a.translate_address_write(c+3),c=a.virt_boundary_read32s(d,e)):c=a.memory.read32s(d)):c=a.reg32s[b&7];c=~c;192>b?e?a.virt_boundary_write32(d, |
| e,c):a.memory.write32(d,c):a.reg32s[b&7]=c;break;case 3:e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(e=a.translate_address_write(c+3),c=a.virt_boundary_read32s(d,e)):c=a.memory.read32s(d)):c=a.reg32s[b&7];c=a.neg(c,31);192>b?e?a.virt_boundary_write32(d,e,c):a.memory.write32(d,c):a.reg32s[b&7]=c;break;case 4:192>b?c=a.safe_read32s(a.modrm_resolve(b))>>>0:c=a.reg32[b&7];a.mul32(c);break;case 5:c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.imul32(c); |
| break;case 6:192>b?c=a.safe_read32s(a.modrm_resolve(b))>>>0:c=a.reg32[b&7];a.div32(c);break;case 7:c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7],a.idiv32(c)}};table16[248]=table32[248]=function(a){a.flags&=-2;a.flags_changed&=-2};table16[249]=table32[249]=function(a){a.flags|=1;a.flags_changed&=-2}; |
| table16[250]=table32[250]=function(a){!a.protected_mode||(a.flags&131072?3===a.getiopl():a.getiopl()>=a.cpl)?a.flags&=-513:3>a.getiopl()&&(a.flags&131072?a.cr4&1:3===a.cpl&&a.cr4&2)?a.flags&=-524289:a.trigger_gp(0)};table16[251]=table32[251]=function(a){!a.protected_mode||(a.flags&131072?3===a.getiopl():a.getiopl()>=a.cpl)?(a.flags|=512,a.cycle(),a.handle_irqs()):3>a.getiopl()&&0===(a.flags&1048576)&&(a.flags&131072?a.cr4&1:3===a.cpl&&a.cr4&2)?a.flags|=524288:a.trigger_gp(0)}; |
| table16[252]=table32[252]=function(a){a.flags&=-1025};table16[253]=table32[253]=function(a){a.flags|=1024}; |
| table16[254]=table32[254]=function(a){var b=a.read_imm8(),c=b&56;if(0===c){var d;192>b?(d=a.translate_address_write(a.modrm_resolve(b)),c=a.memory.read8(d)):c=a.reg8[b<<2&12|b>>2&1];c=a.inc(c,7);192>b?a.memory.write8(d,c):a.reg8[b<<2&12|b>>2&1]=c}else 8===c?(192>b?(d=a.translate_address_write(a.modrm_resolve(b)),c=a.memory.read8(d)):c=a.reg8[b<<2&12|b>>2&1],c=a.dec(c,7),192>b?a.memory.write8(d,c):a.reg8[b<<2&12|b>>2&1]=c):a.trigger_ud()}; |
| table16[255]=function(a){var b=a.read_imm8();switch(b>>3&7){case 0:var c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c=a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];c=a.inc(c,15);192>b?e?a.virt_boundary_write16(d,e,c):a.memory.write16(d,c):a.reg16[b<<1&14]=c;break;case 1:e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c= |
| a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];c=a.dec(c,15);192>b?e?a.virt_boundary_write16(d,e,c):a.memory.write16(d,c):a.reg16[b<<1&14]=c;break;case 2:c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.push16(a.get_real_eip());a.instruction_pointer=a.get_seg(1)+c|0;a.last_instr_jump=!0;break;case 3:192<=b&&a.trigger_ud();c=a.modrm_resolve(b);b=a.safe_read16(c+2);d=a.safe_read16(c);a.writable_or_pagefault(a.get_stack_pointer(-4),4);a.push16(a.sreg[1]);a.push16(a.get_real_eip()); |
| a.switch_seg(1,b);a.instruction_pointer=a.get_seg(1)+d|0;a.last_instr_jump=!0;break;case 4:c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.instruction_pointer=a.get_seg(1)+c|0;a.last_instr_jump=!0;break;case 5:192<=b&&a.trigger_ud();c=a.modrm_resolve(b);b=a.safe_read16(c+2);d=a.safe_read16(c);a.switch_seg(1,b);a.instruction_pointer=a.get_seg(1)+d|0;a.last_instr_jump=!0;break;case 6:c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.push16(c);break;case 7:a.trigger_ud()}}; |
| table32[255]=function(a){var b=a.read_imm8();switch(b>>3&7){case 0:var c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(e=a.translate_address_write(c+3),c=a.virt_boundary_read32s(d,e)):c=a.memory.read32s(d)):c=a.reg32s[b&7];c=a.inc(c,31);192>b?e?a.virt_boundary_write32(d,e,c):a.memory.write32(d,c):a.reg32s[b&7]=c;break;case 1:e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(e=a.translate_address_write(c+3),c=a.virt_boundary_read32s(d, |
| e)):c=a.memory.read32s(d)):c=a.reg32s[b&7];c=a.dec(c,31);192>b?e?a.virt_boundary_write32(d,e,c):a.memory.write32(d,c):a.reg32s[b&7]=c;break;case 2:c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.push32(a.get_real_eip());a.instruction_pointer=a.get_seg(1)+c|0;a.last_instr_jump=!0;break;case 3:192<=b&&a.trigger_ud();c=a.modrm_resolve(b);b=a.safe_read16(c+4);d=a.safe_read32s(c);a.writable_or_pagefault(a.get_stack_pointer(-8),8);a.push32(a.sreg[1]);a.push32(a.get_real_eip());a.switch_seg(1, |
| b);a.instruction_pointer=a.get_seg(1)+d|0;a.last_instr_jump=!0;break;case 4:c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.instruction_pointer=a.get_seg(1)+c|0;a.last_instr_jump=!0;break;case 5:192<=b&&a.trigger_ud();c=a.modrm_resolve(b);b=a.safe_read16(c+4);d=a.safe_read32s(c);a.switch_seg(1,b);a.instruction_pointer=a.get_seg(1)+d|0;a.last_instr_jump=!0;break;case 6:c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.push32(c);break;case 7:a.trigger_ud()}}; |
| table0F_16[0]=table0F_32[0]=function(a){var b=a.read_imm8();a.protected_mode||a.trigger_ud();a.cpl&&a.trigger_gp(0);switch(b>>3&7){case 0:if(192>b)var c=a.modrm_resolve(b);var d=a.sreg[7];192>b?a.safe_write16(c,d):a.reg16[b<<1&14]=d;break;case 1:192>b&&(c=a.modrm_resolve(b));d=a.sreg[6];192>b?a.safe_write16(c,d):a.reg16[b<<1&14]=d;break;case 2:d=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.load_ldt(d);break;case 3:d=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.load_tr(d); |
| break;default:a.trigger_ud()}}; |
| table0F_16[1]=table0F_32[1]=function(a){var b=a.read_imm8();a.cpl&&a.trigger_gp(0);var c=b>>3&7;if(4===c){if(192>b)var d=a.modrm_resolve(b);c=a.cr0;192>b?a.safe_write16(d,c):a.reg16[b<<1&14]=c}else if(6===c)c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14],a.cr0=a.cr0&-16|c&15,a.protected_mode&&(a.cr0|=1),a.cr0_changed();else switch(192<=b&&a.trigger_ud(),2!==c&&3!==c||!a.protected_mode||(a.segment_prefix=9),d=a.modrm_resolve(b),a.segment_prefix=-1,c){case 0:a.writable_or_pagefault(d,6); |
| a.safe_write16(d,a.gdtr_size);a.safe_write32(d+2,a.gdtr_offset);break;case 1:a.writable_or_pagefault(d,6);a.safe_write16(d,a.idtr_size);a.safe_write32(d+2,a.idtr_offset);break;case 2:b=a.safe_read16(d);d=a.safe_read32s(d+2);a.gdtr_size=b;a.gdtr_offset=d;a.operand_size_32||(a.gdtr_offset&=16777215);break;case 3:b=a.safe_read16(d);d=a.safe_read32s(d+2);a.idtr_size=b;a.idtr_offset=d;a.operand_size_32||(a.idtr_offset&=16777215);break;case 7:a.invlpg(d);break;default:a.trigger_ud()}}; |
| table0F_16[2]=table0F_32[2]=function(a){a.read_imm8();a.trigger_ud()};table0F_16[3]=table0F_32[3]=function(a){a.read_imm8();a.trigger_ud()};table0F_16[4]=table0F_32[4]=function(a){a.trigger_ud()};table0F_16[5]=table0F_32[5]=function(a){a.trigger_ud()};table0F_16[6]=table0F_32[6]=function(a){a.cpl?a.trigger_gp(0):a.cr0&=-9};table0F_16[7]=table0F_32[7]=function(a){a.trigger_ud()};table0F_16[8]=table0F_32[8]=function(a){a.trigger_ud()};table0F_16[9]=table0F_32[9]=function(a){a.cpl&&a.trigger_gp(0)}; |
| table0F_16[10]=table0F_32[10]=function(a){a.trigger_ud()};table0F_16[11]=table0F_32[11]=function(a){a.trigger_ud()};table0F_16[12]=table0F_32[12]=function(a){a.trigger_ud()};table0F_16[13]=table0F_32[13]=function(a){a.trigger_ud()};table0F_16[14]=table0F_32[14]=function(a){a.trigger_ud()};table0F_16[15]=table0F_32[15]=function(a){a.trigger_ud()};table0F_16[16]=table0F_32[16]=function(a){a.trigger_ud()};table0F_16[17]=table0F_32[17]=function(a){a.trigger_ud()};table0F_16[18]=table0F_32[18]=function(a){a.trigger_ud()}; |
| table0F_16[19]=table0F_32[19]=function(a){a.trigger_ud()};table0F_16[20]=table0F_32[20]=function(a){a.trigger_ud()};table0F_16[21]=table0F_32[21]=function(a){a.trigger_ud()};table0F_16[22]=table0F_32[22]=function(a){a.trigger_ud()};table0F_16[23]=table0F_32[23]=function(a){a.trigger_ud()};table0F_16[24]=table0F_32[24]=function(a){var b=a.read_imm8();192>b&&a.modrm_resolve(b)};table0F_16[25]=table0F_32[25]=function(a){a.trigger_ud()};table0F_16[26]=table0F_32[26]=function(a){a.trigger_ud()}; |
| table0F_16[27]=table0F_32[27]=function(a){a.trigger_ud()};table0F_16[28]=table0F_32[28]=function(a){a.trigger_ud()};table0F_16[29]=table0F_32[29]=function(a){a.trigger_ud()};table0F_16[30]=table0F_32[30]=function(a){a.trigger_ud()};table0F_16[31]=table0F_32[31]=function(a){a.trigger_ud()}; |
| table0F_16[32]=table0F_32[32]=function(a){var b=a.read_imm8();a.cpl&&a.trigger_gp(0);switch(b>>3&7){case 0:a.reg32s[b&7]=a.cr0;break;case 2:a.reg32s[b&7]=a.cr2;break;case 3:a.reg32s[b&7]=a.cr3;break;case 4:a.reg32s[b&7]=a.cr4;break;default:a.trigger_ud()}};table0F_16[33]=table0F_32[33]=function(a){var b=a.read_imm8();a.cpl&&a.trigger_gp(0);a.reg32s[b&7]=a.dreg[b>>3&7]}; |
| table0F_16[34]=table0F_32[34]=function(a){var b=a.read_imm8();a.cpl&&a.trigger_gp(0);var c=a.reg32s[b&7];switch(b>>3&7){case 0:a.cr0=c;if(-2147483648===(a.cr0&-2147483647))throw a.debug.unimpl("#GP handler");a.cr0_changed();break;case 2:a.cr2=c;break;case 3:a.cr3=c;a.clear_tlb();break;case 4:c&-3565568&&a.trigger_gp(0);(a.cr4^c)&128&&(c&128?a.clear_tlb():a.full_clear_tlb());a.cr4=c;a.page_size_extensions=a.cr4&16?128:0;if(a.cr4&32)throw a.debug.unimpl("PAE");break;default:a.trigger_ud()}}; |
| table0F_16[35]=table0F_32[35]=function(a){var b=a.read_imm8();a.cpl&&a.trigger_gp(0);a.dreg[b>>3&7]=a.reg32s[b&7]};table0F_16[36]=table0F_32[36]=function(a){a.trigger_ud()};table0F_16[37]=table0F_32[37]=function(a){a.trigger_ud()};table0F_16[38]=table0F_32[38]=function(a){a.trigger_ud()};table0F_16[39]=table0F_32[39]=function(a){a.trigger_ud()};table0F_16[40]=table0F_32[40]=function(a){a.trigger_ud()};table0F_16[41]=table0F_32[41]=function(a){a.trigger_ud()};table0F_16[42]=table0F_32[42]=function(a){a.trigger_ud()}; |
| table0F_16[43]=table0F_32[43]=function(a){a.trigger_ud()};table0F_16[44]=table0F_32[44]=function(a){a.trigger_ud()};table0F_16[45]=table0F_32[45]=function(a){a.trigger_ud()};table0F_16[46]=table0F_32[46]=function(a){a.trigger_ud()};table0F_16[47]=table0F_32[47]=function(a){a.trigger_ud()};table0F_16[48]=table0F_32[48]=function(a){a.cpl&&a.trigger_gp(0);var b=a.reg32s[0];switch(a.reg32s[1]){case 372:a.sysenter_cs=b&65535;break;case 374:a.sysenter_eip=b;break;case 373:a.sysenter_esp=b}}; |
| table0F_16[49]=table0F_32[49]=function(a){if(a.cpl&&a.cr4&4)a.trigger_gp(0);else{var b=v86.microtick()-a.tsc_offset;a.reg32s[0]=8192*b;a.reg32s[2]=1.9073486328125E-6*b}};table0F_16[50]=table0F_32[50]=function(a){a.cpl&&a.trigger_gp(0);var b=0;switch(a.reg32s[1]){case 372:b=a.sysenter_cs;break;case 374:b=a.sysenter_eip;break;case 373:b=a.sysenter_esp}a.reg32s[0]=b;a.reg32s[2]=0};table0F_16[51]=table0F_32[51]=function(a){a.trigger_ud()}; |
| table0F_16[52]=table0F_32[52]=function(a){var b=a.sysenter_cs&65532;a.protected_mode&&0!==b||a.trigger_gp(0);a.flags&=-131585;a.instruction_pointer=a.sysenter_eip;a.reg32s[4]=a.sysenter_esp;a.sreg[1]=b;a.segment_is_null[1]=0;a.segment_limits[1]=-1;a.segment_offsets[1]=0;a.is_32||a.update_cs_size(!0);a.cpl=0;a.cpl_changed();a.sreg[2]=b+8;a.segment_is_null[2]=0;a.segment_limits[2]=-1;a.segment_offsets[2]=0;a.stack_size_32=!0;a.stack_reg=a.reg32s;a.reg_vsp=4;a.reg_vbp=5}; |
| table0F_16[53]=table0F_32[53]=function(a){var b=a.sysenter_cs&65532;a.protected_mode&&!a.cpl&&0!==b||a.trigger_gp(0);a.instruction_pointer=a.reg32s[2];a.reg32s[4]=a.reg32s[1];a.sreg[1]=b+16|3;a.segment_is_null[1]=0;a.segment_limits[1]=-1;a.segment_offsets[1]=0;a.is_32||a.update_cs_size(!0);a.cpl=3;a.cpl_changed();a.sreg[2]=b+24|3;a.segment_is_null[2]=0;a.segment_limits[2]=-1;a.segment_offsets[2]=0;a.stack_size_32=!0;a.stack_reg=a.reg32s;a.reg_vsp=4;a.reg_vbp=5};table0F_16[54]=table0F_32[54]=function(a){a.trigger_ud()}; |
| table0F_16[55]=table0F_32[55]=function(a){a.trigger_ud()};table0F_16[56]=table0F_32[56]=function(a){a.trigger_ud()};table0F_16[57]=table0F_32[57]=function(a){a.trigger_ud()};table0F_16[58]=table0F_32[58]=function(a){a.trigger_ud()};table0F_16[59]=table0F_32[59]=function(a){a.trigger_ud()};table0F_16[60]=table0F_32[60]=function(a){a.trigger_ud()};table0F_16[61]=table0F_32[61]=function(a){a.trigger_ud()};table0F_16[62]=table0F_32[62]=function(a){a.trigger_ud()};table0F_16[63]=table0F_32[63]=function(a){a.trigger_ud()}; |
| table0F_16[64]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.test_o()&&(a.reg16[b>>2&14]=c)};table0F_32[64]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.test_o()&&(a.reg32s[b>>3&7]=c)};table0F_16[65]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.test_o()||(a.reg16[b>>2&14]=c)}; |
| table0F_32[65]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.test_o()||(a.reg32s[b>>3&7]=c)};table0F_16[66]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.test_b()&&(a.reg16[b>>2&14]=c)};table0F_32[66]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.test_b()&&(a.reg32s[b>>3&7]=c)}; |
| table0F_16[67]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.test_b()||(a.reg16[b>>2&14]=c)};table0F_32[67]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.test_b()||(a.reg32s[b>>3&7]=c)};table0F_16[68]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.test_z()&&(a.reg16[b>>2&14]=c)}; |
| table0F_32[68]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.test_z()&&(a.reg32s[b>>3&7]=c)};table0F_16[69]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.test_z()||(a.reg16[b>>2&14]=c)};table0F_32[69]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.test_z()||(a.reg32s[b>>3&7]=c)}; |
| table0F_16[70]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.test_be()&&(a.reg16[b>>2&14]=c)};table0F_32[70]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.test_be()&&(a.reg32s[b>>3&7]=c)};table0F_16[71]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.test_be()||(a.reg16[b>>2&14]=c)}; |
| table0F_32[71]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.test_be()||(a.reg32s[b>>3&7]=c)};table0F_16[72]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.test_s()&&(a.reg16[b>>2&14]=c)};table0F_32[72]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.test_s()&&(a.reg32s[b>>3&7]=c)}; |
| table0F_16[73]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.test_s()||(a.reg16[b>>2&14]=c)};table0F_32[73]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.test_s()||(a.reg32s[b>>3&7]=c)};table0F_16[74]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.test_p()&&(a.reg16[b>>2&14]=c)}; |
| table0F_32[74]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.test_p()&&(a.reg32s[b>>3&7]=c)};table0F_16[75]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.test_p()||(a.reg16[b>>2&14]=c)};table0F_32[75]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.test_p()||(a.reg32s[b>>3&7]=c)}; |
| table0F_16[76]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.test_l()&&(a.reg16[b>>2&14]=c)};table0F_32[76]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.test_l()&&(a.reg32s[b>>3&7]=c)};table0F_16[77]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.test_l()||(a.reg16[b>>2&14]=c)}; |
| table0F_32[77]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.test_l()||(a.reg32s[b>>3&7]=c)};table0F_16[78]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.test_le()&&(a.reg16[b>>2&14]=c)};table0F_32[78]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.test_le()&&(a.reg32s[b>>3&7]=c)}; |
| table0F_16[79]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.test_le()||(a.reg16[b>>2&14]=c)};table0F_32[79]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.test_le()||(a.reg32s[b>>3&7]=c)};table0F_16[80]=table0F_32[80]=function(a){a.trigger_ud()};table0F_16[81]=table0F_32[81]=function(a){a.trigger_ud()};table0F_16[82]=table0F_32[82]=function(a){a.trigger_ud()};table0F_16[83]=table0F_32[83]=function(a){a.trigger_ud()}; |
| table0F_16[84]=table0F_32[84]=function(a){a.trigger_ud()};table0F_16[85]=table0F_32[85]=function(a){a.trigger_ud()};table0F_16[86]=table0F_32[86]=function(a){a.trigger_ud()};table0F_16[87]=table0F_32[87]=function(a){a.trigger_ud()};table0F_16[88]=table0F_32[88]=function(a){a.trigger_ud()};table0F_16[89]=table0F_32[89]=function(a){a.trigger_ud()};table0F_16[90]=table0F_32[90]=function(a){a.trigger_ud()};table0F_16[91]=table0F_32[91]=function(a){a.trigger_ud()};table0F_16[92]=table0F_32[92]=function(a){a.trigger_ud()}; |
| table0F_16[93]=table0F_32[93]=function(a){a.trigger_ud()};table0F_16[94]=table0F_32[94]=function(a){a.trigger_ud()};table0F_16[95]=table0F_32[95]=function(a){a.trigger_ud()};table0F_16[96]=table0F_32[96]=function(a){a.trigger_ud()};table0F_16[97]=table0F_32[97]=function(a){a.trigger_ud()};table0F_16[98]=table0F_32[98]=function(a){a.trigger_ud()};table0F_16[99]=table0F_32[99]=function(a){a.trigger_ud()};table0F_16[100]=table0F_32[100]=function(a){a.trigger_ud()};table0F_16[101]=table0F_32[101]=function(a){a.trigger_ud()}; |
| table0F_16[102]=table0F_32[102]=function(a){a.trigger_ud()};table0F_16[103]=table0F_32[103]=function(a){a.trigger_ud()};table0F_16[104]=table0F_32[104]=function(a){a.trigger_ud()};table0F_16[105]=table0F_32[105]=function(a){a.trigger_ud()};table0F_16[106]=table0F_32[106]=function(a){a.trigger_ud()};table0F_16[107]=table0F_32[107]=function(a){a.trigger_ud()};table0F_16[108]=table0F_32[108]=function(a){a.trigger_ud()};table0F_16[109]=table0F_32[109]=function(a){a.trigger_ud()}; |
| table0F_16[110]=table0F_32[110]=function(a){a.trigger_ud()};table0F_16[111]=table0F_32[111]=function(a){a.trigger_ud()};table0F_16[112]=table0F_32[112]=function(a){a.trigger_ud()};table0F_16[113]=table0F_32[113]=function(a){a.trigger_ud()};table0F_16[114]=table0F_32[114]=function(a){a.trigger_ud()};table0F_16[115]=table0F_32[115]=function(a){a.trigger_ud()};table0F_16[116]=table0F_32[116]=function(a){a.trigger_ud()};table0F_16[117]=table0F_32[117]=function(a){a.trigger_ud()}; |
| table0F_16[118]=table0F_32[118]=function(a){a.trigger_ud()};table0F_16[119]=table0F_32[119]=function(a){a.trigger_ud()};table0F_16[120]=table0F_32[120]=function(a){a.trigger_ud()};table0F_16[121]=table0F_32[121]=function(a){a.trigger_ud()};table0F_16[122]=table0F_32[122]=function(a){a.trigger_ud()};table0F_16[123]=table0F_32[123]=function(a){a.trigger_ud()};table0F_16[124]=table0F_32[124]=function(a){a.trigger_ud()};table0F_16[125]=table0F_32[125]=function(a){a.trigger_ud()}; |
| table0F_16[126]=table0F_32[126]=function(a){a.trigger_ud()};table0F_16[127]=table0F_32[127]=function(a){a.trigger_ud()};table0F_16[128]=function(a){a.jmpcc16(a.test_o())};table0F_32[128]=function(a){a.jmpcc32(a.test_o())};table0F_16[129]=function(a){a.jmpcc16(!a.test_o())};table0F_32[129]=function(a){a.jmpcc32(!a.test_o())};table0F_16[130]=function(a){a.jmpcc16(a.test_b())};table0F_32[130]=function(a){a.jmpcc32(a.test_b())};table0F_16[131]=function(a){a.jmpcc16(!a.test_b())};table0F_32[131]=function(a){a.jmpcc32(!a.test_b())}; |
| table0F_16[132]=function(a){a.jmpcc16(a.test_z())};table0F_32[132]=function(a){a.jmpcc32(a.test_z())};table0F_16[133]=function(a){a.jmpcc16(!a.test_z())};table0F_32[133]=function(a){a.jmpcc32(!a.test_z())};table0F_16[134]=function(a){a.jmpcc16(a.test_be())};table0F_32[134]=function(a){a.jmpcc32(a.test_be())};table0F_16[135]=function(a){a.jmpcc16(!a.test_be())};table0F_32[135]=function(a){a.jmpcc32(!a.test_be())};table0F_16[136]=function(a){a.jmpcc16(a.test_s())};table0F_32[136]=function(a){a.jmpcc32(a.test_s())}; |
| table0F_16[137]=function(a){a.jmpcc16(!a.test_s())};table0F_32[137]=function(a){a.jmpcc32(!a.test_s())};table0F_16[138]=function(a){a.jmpcc16(a.test_p())};table0F_32[138]=function(a){a.jmpcc32(a.test_p())};table0F_16[139]=function(a){a.jmpcc16(!a.test_p())};table0F_32[139]=function(a){a.jmpcc32(!a.test_p())};table0F_16[140]=function(a){a.jmpcc16(a.test_l())};table0F_32[140]=function(a){a.jmpcc32(a.test_l())};table0F_16[141]=function(a){a.jmpcc16(!a.test_l())};table0F_32[141]=function(a){a.jmpcc32(!a.test_l())}; |
| table0F_16[142]=function(a){a.jmpcc16(a.test_le())};table0F_32[142]=function(a){a.jmpcc32(a.test_le())};table0F_16[143]=function(a){a.jmpcc16(!a.test_le())};table0F_32[143]=function(a){a.jmpcc32(!a.test_le())};table0F_16[144]=table0F_32[144]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=!a.test_o()^1;192>b?a.safe_write8(c,d):a.reg8[b<<2&12|b>>2&1]=d}; |
| table0F_16[145]=table0F_32[145]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=!!a.test_o()^1;192>b?a.safe_write8(c,d):a.reg8[b<<2&12|b>>2&1]=d};table0F_16[146]=table0F_32[146]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=!a.test_b()^1;192>b?a.safe_write8(c,d):a.reg8[b<<2&12|b>>2&1]=d}; |
| table0F_16[147]=table0F_32[147]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=!!a.test_b()^1;192>b?a.safe_write8(c,d):a.reg8[b<<2&12|b>>2&1]=d};table0F_16[148]=table0F_32[148]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=!a.test_z()^1;192>b?a.safe_write8(c,d):a.reg8[b<<2&12|b>>2&1]=d}; |
| table0F_16[149]=table0F_32[149]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=!!a.test_z()^1;192>b?a.safe_write8(c,d):a.reg8[b<<2&12|b>>2&1]=d};table0F_16[150]=table0F_32[150]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=!a.test_be()^1;192>b?a.safe_write8(c,d):a.reg8[b<<2&12|b>>2&1]=d}; |
| table0F_16[151]=table0F_32[151]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=!!a.test_be()^1;192>b?a.safe_write8(c,d):a.reg8[b<<2&12|b>>2&1]=d};table0F_16[152]=table0F_32[152]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=!a.test_s()^1;192>b?a.safe_write8(c,d):a.reg8[b<<2&12|b>>2&1]=d}; |
| table0F_16[153]=table0F_32[153]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=!!a.test_s()^1;192>b?a.safe_write8(c,d):a.reg8[b<<2&12|b>>2&1]=d};table0F_16[154]=table0F_32[154]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=!a.test_p()^1;192>b?a.safe_write8(c,d):a.reg8[b<<2&12|b>>2&1]=d}; |
| table0F_16[155]=table0F_32[155]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=!!a.test_p()^1;192>b?a.safe_write8(c,d):a.reg8[b<<2&12|b>>2&1]=d};table0F_16[156]=table0F_32[156]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=!a.test_l()^1;192>b?a.safe_write8(c,d):a.reg8[b<<2&12|b>>2&1]=d}; |
| table0F_16[157]=table0F_32[157]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=!!a.test_l()^1;192>b?a.safe_write8(c,d):a.reg8[b<<2&12|b>>2&1]=d};table0F_16[158]=table0F_32[158]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=!a.test_le()^1;192>b?a.safe_write8(c,d):a.reg8[b<<2&12|b>>2&1]=d}; |
| table0F_16[159]=table0F_32[159]=function(a){var b=a.read_imm8();if(192>b)var c=a.modrm_resolve(b);var d=!!a.test_le()^1;192>b?a.safe_write8(c,d):a.reg8[b<<2&12|b>>2&1]=d};table0F_16[160]=function(a){a.push16(a.sreg[4])};table0F_32[160]=function(a){a.push32(a.sreg[4])};table0F_16[161]=function(a){a.switch_seg(4,a.safe_read16(a.get_stack_pointer(0)));a.stack_reg[a.reg_vsp]+=2};table0F_32[161]=function(a){a.switch_seg(4,a.safe_read16(a.get_stack_pointer(0)));a.stack_reg[a.reg_vsp]+=4}; |
| table0F_16[162]=table0F_32[162]=function(a){a.cpuid()};table0F_16[163]=function(a){var b=a.read_imm8();192>b?a.bt_mem(a.modrm_resolve(b),a.reg16s[b>>2&14]):a.bt_reg(a.reg16[b<<1&14],a.reg16[b>>2&14]&15)};table0F_32[163]=function(a){var b=a.read_imm8();192>b?a.bt_mem(a.modrm_resolve(b),a.reg32s[b>>3&7]):a.bt_reg(a.reg32s[b&7],a.reg32s[b>>3&7]&31)}; |
| table0F_16[164]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c=a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];c=a.shld16(c,a.reg16[b>>2&14],a.read_imm8()&31);192>b?e?a.virt_boundary_write16(d,e,c):a.memory.write16(d,c):a.reg16[b<<1&14]=c}; |
| table0F_32[164]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(e=a.translate_address_write(c+3),c=a.virt_boundary_read32s(d,e)):c=a.memory.read32s(d)):c=a.reg32s[b&7];c=a.shld32(c,a.reg32s[b>>3&7],a.read_imm8()&31);192>b?e?a.virt_boundary_write32(d,e,c):a.memory.write32(d,c):a.reg32s[b&7]=c}; |
| table0F_16[165]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c=a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];c=a.shld16(c,a.reg16[b>>2&14],a.reg8[4]&31);192>b?e?a.virt_boundary_write16(d,e,c):a.memory.write16(d,c):a.reg16[b<<1&14]=c}; |
| table0F_32[165]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(e=a.translate_address_write(c+3),c=a.virt_boundary_read32s(d,e)):c=a.memory.read32s(d)):c=a.reg32s[b&7];c=a.shld32(c,a.reg32s[b>>3&7],a.reg8[4]&31);192>b?e?a.virt_boundary_write32(d,e,c):a.memory.write32(d,c):a.reg32s[b&7]=c};table0F_16[166]=table0F_32[166]=function(a){a.trigger_ud()};table0F_16[167]=table0F_32[167]=function(a){a.trigger_ud()}; |
| table0F_16[168]=function(a){a.push16(a.sreg[5])};table0F_32[168]=function(a){a.push32(a.sreg[5])};table0F_16[169]=function(a){a.switch_seg(5,a.safe_read16(a.get_stack_pointer(0)));a.stack_reg[a.reg_vsp]+=2};table0F_32[169]=function(a){a.switch_seg(5,a.safe_read16(a.get_stack_pointer(0)));a.stack_reg[a.reg_vsp]+=4};table0F_16[170]=table0F_32[170]=function(a){a.trigger_ud()}; |
| table0F_16[171]=function(a){var b=a.read_imm8();192>b?a.bts_mem(a.modrm_resolve(b),a.reg16s[b>>2&14]):a.reg16[b<<1&14]=a.bts_reg(a.reg16[b<<1&14],a.reg16s[b>>2&14]&15)};table0F_32[171]=function(a){var b=a.read_imm8();192>b?a.bts_mem(a.modrm_resolve(b),a.reg32s[b>>3&7]):a.reg32s[b&7]=a.bts_reg(a.reg32s[b&7],a.reg32s[b>>3&7]&31)}; |
| table0F_16[172]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c=a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];c=a.shrd16(c,a.reg16[b>>2&14],a.read_imm8()&31);192>b?e?a.virt_boundary_write16(d,e,c):a.memory.write16(d,c):a.reg16[b<<1&14]=c}; |
| table0F_32[172]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(e=a.translate_address_write(c+3),c=a.virt_boundary_read32s(d,e)):c=a.memory.read32s(d)):c=a.reg32s[b&7];c=a.shrd32(c,a.reg32s[b>>3&7],a.read_imm8()&31);192>b?e?a.virt_boundary_write32(d,e,c):a.memory.write32(d,c):a.reg32s[b&7]=c}; |
| table0F_16[173]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c=a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];c=a.shrd16(c,a.reg16[b>>2&14],a.reg8[4]&31);192>b?e?a.virt_boundary_write16(d,e,c):a.memory.write16(d,c):a.reg16[b<<1&14]=c}; |
| table0F_32[173]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(e=a.translate_address_write(c+3),c=a.virt_boundary_read32s(d,e)):c=a.memory.read32s(d)):c=a.reg32s[b&7];c=a.shrd32(c,a.reg32s[b>>3&7],a.reg8[4]&31);192>b?e?a.virt_boundary_write32(d,e,c):a.memory.write32(d,c):a.reg32s[b&7]=c};table0F_16[174]=table0F_32[174]=function(a){switch(a.read_imm8()>>3&7){case 6:break;default:a.trigger_ud()}}; |
| table0F_16[175]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b))<<16>>16:a.reg16s[b<<1&14];a.reg16[b>>2&14]=a.imul_reg16(a.reg16s[b>>2&14],c)};table0F_32[175]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.reg32s[b>>3&7]=a.imul_reg32(a.reg32s[b>>3&7],c)}; |
| table0F_16[176]=table0F_32[176]=function(a){var b=a.read_imm8();if(192>b){var c=a.modrm_resolve(b);a.writable_or_pagefault(c,1);var d=a.safe_read8(c)}else d=a.reg8[b<<2&12|b>>2&1];a.sub(d,a.reg8[0],7);a.getzf()?192>b?a.safe_write8(c,a.reg8[b>>1&12|b>>5&1]):a.reg8[b<<2&12|b>>2&1]=a.reg8[b>>1&12|b>>5&1]:a.reg8[0]=d}; |
| table0F_16[177]=function(a){var b=a.read_imm8();if(192>b){var c=a.modrm_resolve(b);a.writable_or_pagefault(c,2);var d=a.safe_read16(c)}else d=a.reg16[b<<1&14];a.sub(d,a.reg16[0],15);a.getzf()?192>b?a.safe_write16(c,a.reg16[b>>2&14]):a.reg16[b<<1&14]=a.reg16[b>>2&14]:a.reg16[0]=d}; |
| table0F_32[177]=function(a){var b=a.read_imm8();if(192>b){var c=a.modrm_resolve(b);a.writable_or_pagefault(c,4);var d=a.safe_read32s(c)}else d=a.reg32s[b&7];a.sub(d,a.reg32s[0],31);a.getzf()?192>b?a.safe_write32(c,a.reg32s[b>>3&7]):a.reg32s[b&7]=a.reg32s[b>>3&7]:a.reg32s[0]=d};table0F_16[178]=function(a){var b=a.read_imm8();192<=b&&a.trigger_ud();a.lss16(2,a.modrm_resolve(b),b>>2&14)};table0F_32[178]=function(a){var b=a.read_imm8();192<=b&&a.trigger_ud();a.lss32(2,a.modrm_resolve(b),b>>3&7)}; |
| table0F_16[179]=function(a){var b=a.read_imm8();192>b?a.btr_mem(a.modrm_resolve(b),a.reg16s[b>>2&14]):a.reg16[b<<1&14]=a.btr_reg(a.reg16[b<<1&14],a.reg16s[b>>2&14]&15)};table0F_32[179]=function(a){var b=a.read_imm8();192>b?a.btr_mem(a.modrm_resolve(b),a.reg32s[b>>3&7]):a.reg32s[b&7]=a.btr_reg(a.reg32s[b&7],a.reg32s[b>>3&7]&31)};table0F_16[180]=function(a){var b=a.read_imm8();192<=b&&a.trigger_ud();a.lss16(4,a.modrm_resolve(b),b>>2&14)}; |
| table0F_32[180]=function(a){var b=a.read_imm8();192<=b&&a.trigger_ud();a.lss32(4,a.modrm_resolve(b),b>>3&7)};table0F_16[181]=function(a){var b=a.read_imm8();192<=b&&a.trigger_ud();a.lss16(5,a.modrm_resolve(b),b>>2&14)};table0F_32[181]=function(a){var b=a.read_imm8();192<=b&&a.trigger_ud();a.lss32(5,a.modrm_resolve(b),b>>3&7)};table0F_16[182]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read8(a.modrm_resolve(b)):a.reg8[b<<2&12|b>>2&1];a.reg16[b>>2&14]=c}; |
| table0F_32[182]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read8(a.modrm_resolve(b)):a.reg8[b<<2&12|b>>2&1];a.reg32s[b>>3&7]=c};table0F_16[183]=table0F_32[183]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.reg32s[b>>3&7]=c};table0F_16[184]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.reg16[b>>2&14]=a.popcnt(c)}; |
| table0F_32[184]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.reg32s[b>>3&7]=a.popcnt(c)};table0F_16[185]=table0F_32[185]=function(a){a.trigger_ud()}; |
| table0F_16[186]=function(a){var b=a.read_imm8();switch(b>>3&7){case 4:192>b?a.bt_mem(a.modrm_resolve(b),a.read_imm8()&15):a.bt_reg(a.reg16[b<<1&14],a.read_imm8()&15);break;case 5:192>b?a.bts_mem(a.modrm_resolve(b),a.read_imm8()):a.reg16[b<<1&14]=a.bts_reg(a.reg16[b<<1&14],a.read_imm8()&15);break;case 6:192>b?a.btr_mem(a.modrm_resolve(b),a.read_imm8()):a.reg16[b<<1&14]=a.btr_reg(a.reg16[b<<1&14],a.read_imm8()&15);break;case 7:192>b?a.btc_mem(a.modrm_resolve(b),a.read_imm8()):a.reg16[b<<1&14]=a.btc_reg(a.reg16[b<< |
| 1&14],a.read_imm8()&15);break;default:a.trigger_ud()}}; |
| table0F_32[186]=function(a){var b=a.read_imm8();switch(b>>3&7){case 4:192>b?a.bt_mem(a.modrm_resolve(b),a.read_imm8()&31):a.bt_reg(a.reg32s[b&7],a.read_imm8()&31);break;case 5:192>b?a.bts_mem(a.modrm_resolve(b),a.read_imm8()):a.reg32s[b&7]=a.bts_reg(a.reg32s[b&7],a.read_imm8()&31);break;case 6:192>b?a.btr_mem(a.modrm_resolve(b),a.read_imm8()):a.reg32s[b&7]=a.btr_reg(a.reg32s[b&7],a.read_imm8()&31);break;case 7:192>b?a.btc_mem(a.modrm_resolve(b),a.read_imm8()):a.reg32s[b&7]=a.btc_reg(a.reg32s[b&7], |
| a.read_imm8()&31);break;default:a.trigger_ud()}};table0F_16[187]=function(a){var b=a.read_imm8();192>b?a.btc_mem(a.modrm_resolve(b),a.reg16s[b>>2&14]):a.reg16[b<<1&14]=a.btc_reg(a.reg16[b<<1&14],a.reg16s[b>>2&14]&15)};table0F_32[187]=function(a){var b=a.read_imm8();192>b?a.btc_mem(a.modrm_resolve(b),a.reg32s[b>>3&7]):a.reg32s[b&7]=a.btc_reg(a.reg32s[b&7],a.reg32s[b>>3&7]&31)}; |
| table0F_16[188]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.reg16[b>>2&14]=a.bsf16(a.reg16[b>>2&14],c)};table0F_32[188]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.reg32s[b>>3&7]=a.bsf32(a.reg32s[b>>3&7],c)};table0F_16[189]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b)):a.reg16[b<<1&14];a.reg16[b>>2&14]=a.bsr16(a.reg16[b>>2&14],c)}; |
| table0F_32[189]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read32s(a.modrm_resolve(b)):a.reg32s[b&7];a.reg32s[b>>3&7]=a.bsr32(a.reg32s[b>>3&7],c)};table0F_16[190]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read8(a.modrm_resolve(b))<<24>>24:a.reg8s[b<<2&12|b>>2&1];a.reg16[b>>2&14]=c};table0F_32[190]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read8(a.modrm_resolve(b))<<24>>24:a.reg8s[b<<2&12|b>>2&1];a.reg32s[b>>3&7]=c}; |
| table0F_16[191]=table0F_32[191]=function(a){var b=a.read_imm8(),c=192>b?a.safe_read16(a.modrm_resolve(b))<<16>>16:a.reg16s[b<<1&14];a.reg32s[b>>3&7]=c};table0F_16[192]=table0F_32[192]=function(a){var b=a.read_imm8(),c,d;192>b?(d=a.translate_address_write(a.modrm_resolve(b)),c=a.memory.read8(d)):c=a.reg8[b<<2&12|b>>2&1];c=a.xadd8(c,b>>1&12|b>>5&1);192>b?a.memory.write8(d,c):a.reg8[b<<2&12|b>>2&1]=c}; |
| table0F_16[193]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4095===(c&4095)?(e=a.translate_address_write(c+1),c=a.virt_boundary_read16(d,e)):c=a.memory.read16(d)):c=a.reg16[b<<1&14];c=a.xadd16(c,b>>2&14);192>b?e?a.virt_boundary_write16(d,e,c):a.memory.write16(d,c):a.reg16[b<<1&14]=c}; |
| table0F_32[193]=function(a){var b=a.read_imm8(),c,d,e=0;192>b?(c=a.modrm_resolve(b),d=a.translate_address_write(c),a.paging&&4093<=(c&4095)?(e=a.translate_address_write(c+3),c=a.virt_boundary_read32s(d,e)):c=a.memory.read32s(d)):c=a.reg32s[b&7];c=a.xadd32(c,b>>3&7);192>b?e?a.virt_boundary_write32(d,e,c):a.memory.write32(d,c):a.reg32s[b&7]=c};table0F_16[194]=table0F_32[194]=function(a){a.trigger_ud()};table0F_16[195]=table0F_32[195]=function(a){a.trigger_ud()};table0F_16[196]=table0F_32[196]=function(a){a.trigger_ud()}; |
| table0F_16[197]=table0F_32[197]=function(a){a.trigger_ud()};table0F_16[198]=table0F_32[198]=function(a){a.trigger_ud()};table0F_16[199]=table0F_32[199]=function(a){var b=a.read_imm8();192<=b&&a.trigger_ud();b=a.modrm_resolve(b);a.writable_or_pagefault(b,8);var c=a.safe_read32s(b),d=a.safe_read32s(b+4);a.reg32s[0]===c&&a.reg32s[2]===d?(a.flags|=64,a.safe_write32(b,a.reg32s[3]),a.safe_write32(b+4,a.reg32s[1])):(a.flags&=-65,a.reg32s[0]=c,a.reg32s[2]=d);a.flags_changed&=-65}; |
| table0F_16[200]=table0F_32[200]=function(a){a.bswap(0)};table0F_16[201]=table0F_32[201]=function(a){a.bswap(1)};table0F_16[202]=table0F_32[202]=function(a){a.bswap(2)};table0F_16[203]=table0F_32[203]=function(a){a.bswap(3)};table0F_16[204]=table0F_32[204]=function(a){a.bswap(4)};table0F_16[205]=table0F_32[205]=function(a){a.bswap(5)};table0F_16[206]=table0F_32[206]=function(a){a.bswap(6)};table0F_16[207]=table0F_32[207]=function(a){a.bswap(7)};table0F_16[208]=table0F_32[208]=function(a){a.trigger_ud()}; |
| table0F_16[209]=table0F_32[209]=function(a){a.trigger_ud()};table0F_16[210]=table0F_32[210]=function(a){a.trigger_ud()};table0F_16[211]=table0F_32[211]=function(a){a.trigger_ud()};table0F_16[212]=table0F_32[212]=function(a){a.trigger_ud()};table0F_16[213]=table0F_32[213]=function(a){a.trigger_ud()};table0F_16[214]=table0F_32[214]=function(a){a.trigger_ud()};table0F_16[215]=table0F_32[215]=function(a){a.trigger_ud()};table0F_16[216]=table0F_32[216]=function(a){a.trigger_ud()}; |
| table0F_16[217]=table0F_32[217]=function(a){a.trigger_ud()};table0F_16[218]=table0F_32[218]=function(a){a.trigger_ud()};table0F_16[219]=table0F_32[219]=function(a){a.trigger_ud()};table0F_16[220]=table0F_32[220]=function(a){a.trigger_ud()};table0F_16[221]=table0F_32[221]=function(a){a.trigger_ud()};table0F_16[222]=table0F_32[222]=function(a){a.trigger_ud()};table0F_16[223]=table0F_32[223]=function(a){a.trigger_ud()};table0F_16[224]=table0F_32[224]=function(a){a.trigger_ud()}; |
| table0F_16[225]=table0F_32[225]=function(a){a.trigger_ud()};table0F_16[226]=table0F_32[226]=function(a){a.trigger_ud()};table0F_16[227]=table0F_32[227]=function(a){a.trigger_ud()};table0F_16[228]=table0F_32[228]=function(a){a.trigger_ud()};table0F_16[229]=table0F_32[229]=function(a){a.trigger_ud()};table0F_16[230]=table0F_32[230]=function(a){a.trigger_ud()};table0F_16[231]=table0F_32[231]=function(a){a.trigger_ud()};table0F_16[232]=table0F_32[232]=function(a){a.trigger_ud()}; |
| table0F_16[233]=table0F_32[233]=function(a){a.trigger_ud()};table0F_16[234]=table0F_32[234]=function(a){a.trigger_ud()};table0F_16[235]=table0F_32[235]=function(a){a.trigger_ud()};table0F_16[236]=table0F_32[236]=function(a){a.trigger_ud()};table0F_16[237]=table0F_32[237]=function(a){a.trigger_ud()};table0F_16[238]=table0F_32[238]=function(a){a.trigger_ud()};table0F_16[239]=table0F_32[239]=function(a){a.trigger_ud()};table0F_16[240]=table0F_32[240]=function(a){a.trigger_ud()}; |
| table0F_16[241]=table0F_32[241]=function(a){a.trigger_ud()};table0F_16[242]=table0F_32[242]=function(a){a.trigger_ud()};table0F_16[243]=table0F_32[243]=function(a){a.trigger_ud()};table0F_16[244]=table0F_32[244]=function(a){a.trigger_ud()};table0F_16[245]=table0F_32[245]=function(a){a.trigger_ud()};table0F_16[246]=table0F_32[246]=function(a){a.trigger_ud()};table0F_16[247]=table0F_32[247]=function(a){a.trigger_ud()};table0F_16[248]=table0F_32[248]=function(a){a.trigger_ud()}; |
| table0F_16[249]=table0F_32[249]=function(a){a.trigger_ud()};table0F_16[250]=table0F_32[250]=function(a){a.trigger_ud()};table0F_16[251]=table0F_32[251]=function(a){a.trigger_ud()};table0F_16[252]=table0F_32[252]=function(a){a.trigger_ud()};table0F_16[253]=table0F_32[253]=function(a){a.trigger_ud()};table0F_16[254]=table0F_32[254]=function(a){a.trigger_ud()};table0F_16[255]=table0F_32[255]=function(a){a.trigger_ud()};"use strict"; |
| CPU.prototype.jmp_rel16=function(a){var b=this.get_seg(1);this.instruction_pointer-=b;this.instruction_pointer=this.instruction_pointer+a&65535;this.instruction_pointer=this.instruction_pointer+b|0;this.last_instr_jump=!0};CPU.prototype.jmpcc16=function(a){a?this.jmp_rel16(this.read_imm16()):this.instruction_pointer=this.instruction_pointer+2|0;this.last_instr_jump=!0}; |
| CPU.prototype.jmpcc32=function(a){a?(a=this.read_imm32s(),this.instruction_pointer=this.instruction_pointer+a|0):this.instruction_pointer=this.instruction_pointer+4|0;this.last_instr_jump=!0};CPU.prototype.loopne=function(){if(--this.regv[this.reg_vcx]&&!this.getzf()){var a=this.read_imm8s();this.instruction_pointer=this.instruction_pointer+a|0}else this.instruction_pointer++;this.last_instr_jump=!0}; |
| CPU.prototype.loope=function(){if(--this.regv[this.reg_vcx]&&this.getzf()){var a=this.read_imm8s();this.instruction_pointer=this.instruction_pointer+a|0}else this.instruction_pointer++;this.last_instr_jump=!0};CPU.prototype.loop=function(){if(--this.regv[this.reg_vcx]){var a=this.read_imm8s();this.instruction_pointer=this.instruction_pointer+a|0}else this.instruction_pointer++;this.last_instr_jump=!0}; |
| CPU.prototype.jcxz=function(){var a=this.read_imm8s();0===this.regv[this.reg_vcx]&&(this.instruction_pointer=this.instruction_pointer+a|0);this.last_instr_jump=!0};CPU.prototype.getcf=function(){return this.flags_changed&1?(this.last_op1^(this.last_op1^this.last_op2)&(this.last_op2^this.last_add_result))>>>this.last_op_size&1:this.flags&1};CPU.prototype.getpf=function(){return this.flags_changed&4?154020>>((this.last_result^this.last_result>>4)&15)&4:this.flags&4}; |
| CPU.prototype.getaf=function(){return this.flags_changed&16?(this.last_op1^this.last_op2^this.last_add_result)&16:this.flags&16};CPU.prototype.getzf=function(){return this.flags_changed&64?(~this.last_result&this.last_result-1)>>>this.last_op_size&1:this.flags&64};CPU.prototype.getsf=function(){return this.flags_changed&128?this.last_result>>>this.last_op_size&1:this.flags&128}; |
| CPU.prototype.getof=function(){return this.flags_changed&2048?((this.last_op1^this.last_add_result)&(this.last_op2^this.last_add_result))>>>this.last_op_size&1:this.flags&2048};CPU.prototype.test_o=CPU.prototype.getof;CPU.prototype.test_b=CPU.prototype.getcf;CPU.prototype.test_z=CPU.prototype.getzf;CPU.prototype.test_s=CPU.prototype.getsf;CPU.prototype.test_p=CPU.prototype.getpf;CPU.prototype.test_be=function(){return this.getcf()||this.getzf()}; |
| CPU.prototype.test_l=function(){return!this.getsf()!==!this.getof()};CPU.prototype.test_le=function(){return this.getzf()||!this.getsf()!==!this.getof()};CPU.prototype.push16=function(a){var b=this.get_stack_pointer(-2);this.safe_write16(b,a);this.stack_reg[this.reg_vsp]-=2};CPU.prototype.push32=function(a){var b=this.get_stack_pointer(-4);this.safe_write32(b,a);this.stack_reg[this.reg_vsp]-=4}; |
| CPU.prototype.pop16=function(){var a=this.get_seg(2)+this.stack_reg[this.reg_vsp]|0,a=this.safe_read16(a);this.stack_reg[this.reg_vsp]+=2;return a};CPU.prototype.pop32s=function(){var a=this.get_seg(2)+this.stack_reg[this.reg_vsp]|0,a=this.safe_read32s(a);this.stack_reg[this.reg_vsp]+=4;return a}; |
| CPU.prototype.pusha16=function(){var a=this.reg16[8];this.translate_address_write(this.get_seg(2)+a-15|0);this.push16(this.reg16[0]);this.push16(this.reg16[2]);this.push16(this.reg16[4]);this.push16(this.reg16[6]);this.push16(a);this.push16(this.reg16[10]);this.push16(this.reg16[12]);this.push16(this.reg16[14])}; |
| CPU.prototype.pusha32=function(){var a=this.reg32s[4];this.translate_address_write(this.get_seg(2)+a-31|0);this.push32(this.reg32s[0]);this.push32(this.reg32s[1]);this.push32(this.reg32s[2]);this.push32(this.reg32s[3]);this.push32(a);this.push32(this.reg32s[5]);this.push32(this.reg32s[6]);this.push32(this.reg32s[7])}; |
| CPU.prototype.popa16=function(){this.translate_address_read(this.get_seg(2)+this.stack_reg[this.reg_vsp]+15|0);this.reg16[14]=this.pop16();this.reg16[12]=this.pop16();this.reg16[10]=this.pop16();this.stack_reg[this.reg_vsp]+=2;this.reg16[6]=this.pop16();this.reg16[4]=this.pop16();this.reg16[2]=this.pop16();this.reg16[0]=this.pop16()}; |
| CPU.prototype.popa32=function(){this.translate_address_read(this.get_seg(2)+this.stack_reg[this.reg_vsp]+31|0);this.reg32s[7]=this.pop32s();this.reg32s[6]=this.pop32s();this.reg32s[5]=this.pop32s();this.stack_reg[this.reg_vsp]+=4;this.reg32s[3]=this.pop32s();this.reg32s[2]=this.pop32s();this.reg32s[1]=this.pop32s();this.reg32s[0]=this.pop32s()};CPU.prototype.xchg8=function(a,b){var c=b>>1&12|b>>5&1,d=this.reg8[c];this.reg8[c]=a;return d}; |
| CPU.prototype.xchg16=function(a,b){var c=b>>2&14,d=this.reg16[c];this.reg16[c]=a;return d};CPU.prototype.xchg16r=function(a){var b=this.reg16[0];this.reg16[0]=this.reg16[a];this.reg16[a]=b};CPU.prototype.xchg32=function(a,b){var c=b>>3&7,d=this.reg32s[c];this.reg32s[c]=a;return d};CPU.prototype.xchg32r=function(a){var b=this.reg32s[0];this.reg32s[0]=this.reg32s[a];this.reg32s[a]=b}; |
| CPU.prototype.lss16=function(a,b,c){var d=this.safe_read16(b);b=this.safe_read16(b+2|0);this.switch_seg(a,b);this.reg16[c]=d};CPU.prototype.lss32=function(a,b,c){var d=this.safe_read32s(b);b=this.safe_read16(b+4|0);this.switch_seg(a,b);this.reg32s[c]=d}; |
| CPU.prototype.enter16=function(){var a=this.read_imm16(),b=this.read_imm8()&31,c,d;this.push16(this.reg16[10]);c=this.reg16[8];if(0<b){d=this.reg16[5];for(var e=1;e<b;e++)d-=2,this.push16(this.safe_read16(this.get_seg(2)+d|0));this.push16(c)}this.reg16[10]=c;this.reg16[8]-=a}; |
| CPU.prototype.enter32=function(){var a=this.read_imm16(),b=this.read_imm8()&31,c,d;this.push32(this.reg32s[5]);c=this.reg32s[4];if(0<b){d=this.reg32s[5];for(var e=1;e<b;e++)d-=4,this.push32(this.safe_read32s(this.get_seg(2)+d|0));this.push32(c)}this.reg32s[5]=c;this.reg32s[4]-=a};CPU.prototype.bswap=function(a){var b=this.reg32s[a];this.reg32s[a]=b>>>24|b<<24|b>>8&65280|b<<8&16711680};CPU.prototype.main_run=function(){try{if(this.in_hlt)return this.hlt_loop();this.do_run()}catch(a){this.exception_cleanup(a)}return 0}; |
| CPU.prototype.exception_cleanup=function(a){if(233495534===a)this.page_fault=!1,this.repeat_string_prefix=0,this.segment_prefix=-1,this.address_size_32=this.is_32,this.update_address_size(),this.operand_size_32=this.is_32,this.update_operand_size();else throw console.log(a),console.log(a.stack),a;};CPU.prototype.reboot_internal=function(){this.CPU_prototype$reset();this.load_bios();throw 233495534;}; |
| CPU.prototype.CPU_prototype$reset=function(){this.segment_is_null=new Uint8Array(8);this.segment_limits=new Uint32Array(8);this.segment_offsets=new Int32Array(8);this.full_clear_tlb();this.reg32s=new Int32Array(8);this.reg32=new Uint32Array(this.reg32s.buffer);this.reg16s=new Int16Array(this.reg32s.buffer);this.reg16=new Uint16Array(this.reg32s.buffer);this.reg8s=new Int8Array(this.reg32s.buffer);this.reg8=new Uint8Array(this.reg32s.buffer);this.sreg=new Uint16Array(8);this.dreg=new Int32Array(8); |
| this.protected_mode=!1;this.gdtr_offset=this.gdtr_size=this.idtr_offset=this.idtr_size=0;this.page_fault=!1;this.cr0=1610612752;this.cr4=this.cr3=this.cr2=0;this.dreg[6]=-61456;this.dreg[7]=1024;this.cpl=0;this.paging=!1;this.page_size_extensions=0;this.address_size_32=this.stack_size_32=this.operand_size_32=this.is_32=!1;this.paging_changed();this.update_operand_size();this.update_address_size();this.stack_reg=this.reg16;this.reg_vsp=8;this.reg_vbp=10;this.previous_ip=this.timestamp_counter=0;this.in_hlt= |
| !1;this.sysenter_eip=this.sysenter_esp=this.sysenter_cs=0;this.segment_prefix=-1;this.repeat_string_prefix=0;this.flags=2;this.last_op_size=this.last_op2=this.last_op1=this.last_add_result=this.last_result=this.flags_changed=0;this.tsc_offset=v86.microtick();this.instruction_pointer=1048560;this.switch_seg(2,48);this.reg16[8]=256}; |
| CPU.prototype.init=function(a,b){this.memory_size=a.memory_size||67108864;this.memory=new Memory(this.memory_size);this.CPU_prototype$reset();var c=new IO(this.memory);this.io=c;this.bios.main=a.bios;this.bios.vga=a.vga_bios;this.load_bios();var d=0;c.register_read(146,this,function(){return d});c.register_write(146,this,function(a){d=a});this.devices={};a.load_devices&&(this.devices.pic=new PIC(this),this.devices.pci=new PCI(this),this.devices.dma=new DMA(this),this.devices.acpi=new ACPI,this.devices.vga= |
| new VGAScreen(this,b,a.vga_memory_size||8388608),this.fpu=new FPU(this),this.devices.ps2=new PS2(this,b),this.devices.uart=new UART(this,1016,b),this.devices.fdc=new FloppyController(this,a.fda,a.fdb),a.cdrom&&(this.devices.cdrom=new IDEDevice(this,a.cdrom,!0,1)),a.hda&&(this.devices.hda=new IDEDevice(this,a.hda,!1,0)),this.devices.pit=new PIT(this),this.devices.rtc=new RTC(this,this.devices.fdc.type,a.boot_order||531),a.enable_ne2k&&(this.devices.net=new Ne2k(this,b)),a.fs9p&&(this.devices.virtio= |
| new VirtIO(this,a.fs9p)))};CPU.prototype.load_bios=function(){var a=this.bios.main,b=this.bios.vga;if(a){var c=new Uint8Array(a);this.memory.mem8.set(c,1048576-a.byteLength);b&&(c=new Uint8Array(b),this.memory.mem8.set(c,786432));this.io.mmap_register(4293918720,1048576,function(a){return this.memory.mem8[a&1048575]}.bind(this),function(a,b){this.memory.mem8[a&1048575]=b}.bind(this))}}; |
| CPU.prototype.do_run=function(){var a=Date.now(),b=a;for(this.devices.vga.timer();33>b-a;){this.devices.pit.timer(b,!1);this.devices.rtc.timer(b,!1);this.handle_irqs();for(b=11001;b--;)this.cycle();b=Date.now()}};"undefined"!==typeof window&&(window.__no_inline1=CPU.prototype.do_run,window.__no_inline2=CPU.prototype.exception_cleanup,window.__no_inline3=CPU.prototype.hlt_loop); |
| CPU.prototype.cycle=function(){this.timestamp_counter++;this.previous_ip=this.instruction_pointer;var a=this.read_imm8();this.table[a](this)};CPU.prototype.do_op=function(){this.table[this.read_imm8()](this)};CPU.prototype.hlt_loop=function(){var a=Date.now();this.devices.pit.timer(a,!1);this.devices.rtc.timer(a,!1);this.devices.vga.timer(a);return 4}; |
| CPU.prototype.cr0_changed=function(){var a=-2147483648===(this.cr0&-2147483648);this.fpu||(this.cr0|=4);this.cr0|=16;a!==this.paging&&(this.paging=a,this.full_clear_tlb())};CPU.prototype.paging_changed=function(){this.last_virt_eip=-1};CPU.prototype.cpl_changed=function(){this.last_virt_eip=-1}; |
| CPU.prototype.read_imm8=function(){this.instruction_pointer&-4096^this.last_virt_eip&&(this.eip_phys=this.translate_address_read(this.instruction_pointer)^this.instruction_pointer,this.last_virt_eip=this.instruction_pointer&-4096);var a=this.memory.mem8[this.eip_phys^this.instruction_pointer]|0;this.instruction_pointer=this.instruction_pointer+1|0;return a};CPU.prototype.read_imm8s=function(){return this.read_imm8()<<24>>24}; |
| CPU.prototype.read_imm16=function(){if(4094<(this.instruction_pointer^this.last_virt_eip)>>>0)return this.read_imm8()|this.read_imm8()<<8;var a=this.memory.read16(this.eip_phys^this.instruction_pointer);this.instruction_pointer=this.instruction_pointer+2|0;return a};CPU.prototype.read_imm16s=function(){return this.read_imm16()<<16>>16}; |
| CPU.prototype.read_imm32s=function(){if(4092<(this.instruction_pointer^this.last_virt_eip)>>>0)return this.read_imm16()|this.read_imm16()<<16;var a=this.memory.read32s(this.eip_phys^this.instruction_pointer);this.instruction_pointer=this.instruction_pointer+4|0;return a};CPU.prototype.virt_boundary_read16=function(a,b){return this.memory.read8(a)|this.memory.read8(b)<<8}; |
| CPU.prototype.virt_boundary_read32s=function(a,b){var c;c=a&1?a&2?this.memory.read_aligned16(b-2>>1):this.memory.read_aligned16(a+1>>1):this.virt_boundary_read16(a+1,b-1);return this.memory.read8(a)|c<<8|this.memory.read8(b)<<24};CPU.prototype.virt_boundary_write16=function(a,b,c){this.memory.write8(a,c);this.memory.write8(b,c>>8)}; |
| CPU.prototype.virt_boundary_write32=function(a,b,c){this.memory.write8(a,c);this.memory.write8(b,c>>24);a&1?a&2?(this.memory.write8(b-2,c>>8),this.memory.write8(b-1,c>>16)):(this.memory.write8(a+1,c>>8),this.memory.write8(a+2,c>>16)):(this.memory.write8(a+1,c>>8),this.memory.write8(b-1,c>>16))};CPU.prototype.safe_read8=function(a){return this.memory.read8(this.translate_address_read(a))}; |
| CPU.prototype.safe_read16=function(a){return this.paging&&4095===(a&4095)?this.safe_read8(a)|this.safe_read8(a+1)<<8:this.memory.read16(this.translate_address_read(a))};CPU.prototype.safe_read32s=function(a){return this.paging&&4093<=(a&4095)?this.safe_read16(a)|this.safe_read16(a+2)<<16:this.memory.read32s(this.translate_address_read(a))};CPU.prototype.safe_write8=function(a,b){this.memory.write8(this.translate_address_write(a),b)}; |
| CPU.prototype.safe_write16=function(a,b){var c=this.translate_address_write(a);4095===(a&4095)?this.virt_boundary_write16(c,this.translate_address_write(a+1),b):this.memory.write16(c,b)};CPU.prototype.safe_write32=function(a,b){var c=this.translate_address_write(a);4093<=(a&4095)?this.virt_boundary_write32(c,this.translate_address_write(a+3),b):this.memory.write32(c,b)}; |
| CPU.prototype.read_moffs=function(){return this.address_size_32?this.get_seg_prefix(3)+this.read_imm32s()|0:this.get_seg_prefix(3)+this.read_imm16()|0};CPU.prototype.getiopl=function(){return this.flags>>12&3};CPU.prototype.vm86_mode=function(){return!!(this.flags&131072)};CPU.prototype.get_eflags=function(){return this.flags&-2262|!!this.getcf()|!!this.getpf()<<2|!!this.getaf()<<4|!!this.getzf()<<6|!!this.getsf()<<7|!!this.getof()<<11}; |
| CPU.prototype.load_eflags=function(){this.flags=this.get_eflags();this.flags_changed=0};CPU.prototype.update_eflags=function(a){var b=1769472,c=2588629;this.flags&131072?(b|=12288,c|=1572864):this.cpl&&(b|=12288,this.cpl>this.getiopl()&&(b|=512));this.flags=(a^(this.flags^a)&b)&c|2;this.flags_changed=0};CPU.prototype.get_stack_pointer=function(a){return this.get_seg(2)+this.stack_reg[this.reg_vsp]+a|0};CPU.prototype.get_real_eip=function(){return this.instruction_pointer-this.get_seg(1)|0}; |
| CPU.prototype.call_interrupt_vector=function(a,b,c){this.in_hlt=!1;if(this.protected_mode){if(this.vm86_mode()&&this.cr4&1)throw this.debug.unimpl("VME");this.vm86_mode()&&b&&3>this.getiopl()&&this.trigger_gp(0);if((a<<3|7)>this.idtr_size)throw this.debug.unimpl("#GP handler");var d=this.idtr_offset+(a<<3)|0;this.paging&&(d=this.translate_address_system_read(d));var e=this.memory.read16(d)|this.memory.read16(d+6)<<16,f=this.memory.read16(d+2),d=this.memory.read8(d+5),g=d>>5&3;if(0===(d&128))throw this.debug.unimpl("#NP handler"); |
| b&&g<this.cpl&&this.trigger_gp(a<<3|2);d&=31;if(14===d)a=!1;else if(15===d)a=!0;else{if(5===d)throw this.debug.unimpl("call int to task gate");if(6===d)throw this.debug.unimpl("16 bit interrupt gate");if(7===d)throw this.debug.unimpl("16 bit trap gate");throw this.debug.unimpl("#GP handler");}b=this.lookup_segment_selector(f);if(b.is_null)throw this.debug.unimpl("#GP handler");if(!b.is_executable||b.dpl>this.cpl)throw this.debug.unimpl("#GP handler");if(!b.is_present)throw this.debug.unimpl("#NP handler"); |
| this.load_eflags();d=this.flags;if(!b.dc_bit&&b.dpl<this.cpl){var l=(b.dpl<<3)+4;if(l+5>this.segment_limits[6])throw this.debug.unimpl("#TS handler");l=l+this.segment_offsets[6]|0;this.paging&&(l=this.translate_address_system_read(l));var g=this.memory.read32s(l),l=this.memory.read16(l+4),k=this.lookup_segment_selector(l);if(k.is_null)throw this.debug.unimpl("#TS handler");if(k.rpl!==b.dpl)throw this.debug.unimpl("#TS handler");if(k.dpl!==b.dpl||!k.rw_bit)throw this.debug.unimpl("#TS handler");if(!k.is_present)throw this.debug.unimpl("#TS handler"); |
| var k=this.reg32s[4],m=this.sreg[2];this.cpl=b.dpl;this.cpl_changed();this.is_32!==b.size&&this.update_cs_size(b.size);this.flags&=-196609;this.reg32s[4]=g;this.switch_seg(2,l);d&131072&&(this.push32(this.sreg[5]),this.push32(this.sreg[4]),this.push32(this.sreg[3]),this.push32(this.sreg[0]));this.push32(m);this.push32(k)}else if(b.dc_bit||b.dpl===this.cpl)this.flags&131072&&this.trigger_gp(f&-4);else throw this.debug.unimpl("#GP handler");this.push32(d);this.push32(this.sreg[1]);this.push32(this.get_real_eip()); |
| d&131072&&(this.switch_seg(5,0),this.switch_seg(4,0),this.switch_seg(3,0),this.switch_seg(0,0));!1!==c&&this.push32(c);this.sreg[1]=f;this.is_32!==b.size&&this.update_cs_size(b.size);this.segment_limits[1]=b.effective_limit;this.segment_offsets[1]=b.base;this.instruction_pointer=this.get_seg(1)+e|0;a?this.handle_irqs():this.flags&=-513}else this.load_eflags(),this.push16(this.flags),this.push16(this.sreg[1]),this.push16(this.get_real_eip()),this.flags&=-513,this.switch_seg(1,this.memory.read16((a<< |
| 2)+2)),this.instruction_pointer=this.get_seg(1)+this.memory.read16(a<<2)|0;this.last_instr_jump=!0};CPU.prototype.iret16=function(){if(!this.protected_mode||this.vm86_mode()&&3===this.getiopl()){var a=this.pop16();this.switch_seg(1,this.pop16());var b=this.pop16();this.instruction_pointer=a+this.get_seg(1)|0;this.update_eflags(b);this.handle_irqs()}else throw this.vm86_mode()&&this.trigger_gp(0),this.debug.unimpl("16 bit iret in protected mode");this.last_instr_jump=!0}; |
| CPU.prototype.iret32=function(){if(!this.protected_mode||this.vm86_mode()&&3===this.getiopl()){var a=this.pop32s();this.switch_seg(1,this.pop32s()&65535);var b=this.pop32s();this.instruction_pointer=a+this.get_seg(1)|0;this.update_eflags(b);this.handle_irqs()}else{this.vm86_mode()&&this.trigger_gp(0);this.instruction_pointer=this.pop32s();this.sreg[1]=this.pop32s();b=this.pop32s();if(b&131072){if(0===this.cpl){this.update_eflags(b);this.flags|=131072;this.switch_seg(1,this.sreg[1]);this.instruction_pointer= |
| this.instruction_pointer+this.get_seg(1)|0;var a=this.pop32s(),c=this.pop32s();this.switch_seg(0,this.pop32s()&65535);this.switch_seg(3,this.pop32s()&65535);this.switch_seg(4,this.pop32s()&65535);this.switch_seg(5,this.pop32s()&65535);this.reg32s[4]=a;this.switch_seg(2,c&65535);this.cpl=3;this.update_cs_size(!1);return}b&=-131073}var d=this.lookup_segment_selector(this.sreg[1]);if(d.is_null)throw this.debug.unimpl("is null");if(!d.is_present)throw this.debug.unimpl("not present");if(!d.is_executable)throw this.debug.unimpl("not exec"); |
| if(d.rpl<this.cpl)throw this.debug.unimpl("rpl < cpl");if(d.dc_bit&&d.dpl>d.rpl)throw this.debug.unimpl("conforming and dpl > rpl");d.rpl>this.cpl?(a=this.pop32s(),c=this.pop32s(),this.reg32s[4]=a,this.update_eflags(b),this.cpl=d.rpl,this.switch_seg(2,c&65535),this.cpl_changed()):this.update_eflags(b);d.size!==this.is_32&&this.update_cs_size(d.size);this.segment_limits[1]=d.effective_limit;this.segment_offsets[1]=d.base;this.instruction_pointer=this.instruction_pointer+this.get_seg(1)|0;this.handle_irqs(); |
| this.last_instr_jump=!0}};CPU.prototype.hlt_op=function(){this.cpl&&this.trigger_gp(0);if(0===(this.flags&512))throw this.debug.show("cpu halted"),"HALT";this.in_hlt=!0;throw 233495534;};CPU.prototype.raise_exception=function(a){this.call_interrupt_vector(a,!1,!1);throw 233495534;};CPU.prototype.raise_exception_with_code=function(a,b){this.call_interrupt_vector(a,!1,b);throw 233495534;};CPU.prototype.trigger_de=function(){this.instruction_pointer=this.previous_ip;this.raise_exception(0)}; |
| CPU.prototype.trigger_ud=function(){this.instruction_pointer=this.previous_ip;this.raise_exception(6)};CPU.prototype.trigger_nm=function(){this.instruction_pointer=this.previous_ip;this.raise_exception(7)};CPU.prototype.trigger_gp=function(a){this.instruction_pointer=this.previous_ip;this.raise_exception_with_code(13,a)};CPU.prototype.trigger_np=function(a){this.instruction_pointer=this.previous_ip;this.raise_exception_with_code(11,a)}; |
| CPU.prototype.trigger_ss=function(a){this.instruction_pointer=this.previous_ip;this.raise_exception_with_code(12,a)};CPU.prototype.seg_prefix=function(a){this.segment_prefix=a;this.table[this.read_imm8()](this);this.segment_prefix=-1};CPU.prototype.get_seg_prefix_ds=function(){return this.get_seg_prefix(3)};CPU.prototype.get_seg_prefix_ss=function(){return this.get_seg_prefix(2)};CPU.prototype.get_seg_prefix=function(a){return-1===this.segment_prefix?this.get_seg(a):9===this.segment_prefix?0:this.get_seg(this.segment_prefix)}; |
| CPU.prototype.get_seg=function(a){return this.segment_offsets[a]};CPU.prototype.handle_irqs=function(){this.devices.pic&&this.flags&512&&!this.page_fault&&this.devices.pic.check_irqs()}; |
| CPU.prototype.test_privileges_for_io=function(a,b){if(this.protected_mode&&(this.cpl>this.getiopl()||this.flags&131072)){var c=this.segment_limits[6],d=this.segment_offsets[6];if(103<=c){var e=this.memory.read16(this.translate_address_system_read(d+100+2));if(c>=e+(a+b-1>>3)&&(c=(1<<b)-1<<(a&7),d=this.translate_address_system_read(d+e+(a>>3)),!((c&65280?this.memory.read16(d):this.memory.read8(d))&c)))return}this.trigger_gp(0)}}; |
| CPU.prototype.cpuid=function(){var a=0,b=0,c=0,d=0;switch(this.reg32s[0]){case 0:a=5;d=1970169159;c=1231384169;b=1818588270;break;case 1:a=3939;d=0;b=8388608;c=(this.fpu?1:0)|43322;break;case 2:a=1717260289;b=d=0;c=8024064;break;case 4:switch(this.reg32s[1]){case 0:a=289;d=29360191;b=63;c=1;break;case 1:a=290;d=29360191;b=63;c=1;break;case 2:a=323,d=96469055,b=4095,c=1}break;case -2147483648:a=5}this.reg32s[0]=a;this.reg32s[1]=b;this.reg32s[2]=c;this.reg32s[3]=d}; |
| CPU.prototype.update_cs_size=function(a){this.is_32=this.operand_size_32=this.address_size_32=a;this.update_operand_size();this.update_address_size()};CPU.prototype.update_operand_size=function(){this.operand_size_32?(this.table=this.table32,this.table0F=this.table0F_32):(this.table=this.table16,this.table0F=this.table0F_16)}; |
| CPU.prototype.update_address_size=function(){this.address_size_32?(this.regv=this.reg32s,this.reg_vcx=1,this.reg_vsi=6,this.reg_vdi=7):(this.regv=this.reg16,this.reg_vcx=2,this.reg_vsi=12,this.reg_vdi=14)}; |
| CPU.prototype.lookup_segment_selector=function(a){var b=0===(a&4),c=a&-8,d,e;d={rpl:a&3,from_gdt:b,is_null:!1,is_valid:!0,base:0,access:0,flags:0,type:0,dpl:0,is_system:!1,is_present:!1,is_executable:!1,rw_bit:!1,dc_bit:!1,size:!1,effective_limit:0,is_writable:!1,is_readable:!1,table_offset:0};b?(b=this.gdtr_offset,e=this.gdtr_size):(b=this.segment_offsets[7],e=this.segment_limits[7]);if(0===c)return d.is_null=!0,d;if((a|7)>e)return d.is_valid=!1,d;b=b+c|0;this.paging&&(b=this.translate_address_system_read(b)); |
| d.table_offset=b;d.base=this.memory.read16(b+2)|this.memory.read8(b+4)<<16|this.memory.read8(b+7)<<24;d.access=this.memory.read8(b+5);d.flags=this.memory.read8(b+6)>>4;d.type=d.access&15;d.dpl=d.access>>5&3;d.is_system=0===(d.access&16);d.is_present=128===(d.access&128);d.is_executable=8===(d.access&8);d.rw_bit=2===(d.access&2);d.dc_bit=4===(d.access&4);d.size=4===(d.flags&4);a=this.memory.read16(b)|(this.memory.read8(b+6)&15)<<16;d.effective_limit=d.flags&8?(a<<12|4095)>>>0:a;d.is_writable=d.rw_bit&& |
| !d.is_executable;d.is_readable=d.rw_bit||!d.is_executable;return d}; |
| CPU.prototype.switch_seg=function(a,b){1===a&&(this.protected_mode=1===(this.cr0&1));if(!this.protected_mode||this.vm86_mode())this.sreg[a]=b,this.segment_is_null[a]=0,this.segment_limits[a]=1048575,this.segment_offsets[a]=b<<4;else{var c=this.lookup_segment_selector(b);if(2===a){if(c.is_null){this.trigger_gp(0);return}if(!c.is_valid||c.is_system||c.rpl!==this.cpl||!c.is_writable||c.dpl!==this.cpl){this.trigger_gp(b&-4);return}if(!c.is_present){this.trigger_ss(b&-4);return}(this.stack_size_32=c.size)? |
| (this.stack_reg=this.reg32s,this.reg_vsp=4,this.reg_vbp=5):(this.stack_reg=this.reg16,this.reg_vsp=8,this.reg_vbp=10)}else if(1===a){if(!c.is_executable)throw this.debug.unimpl("#GP handler");if(c.is_system)throw this.debug.unimpl("load system segment descriptor, type = "+(c.access&15));if(c.rpl!==this.cpl)throw this.debug.unimpl("privilege change");if(!c.dc_bit&&c.dpl<this.cpl)throw this.debug.unimpl("inter privilege call");if(!c.dc_bit&&c.dpl!==this.cpl)throw this.debug.unimpl("#GP handler");c.size!== |
| this.is_32&&this.update_cs_size(c.size)}else{if(c.is_null){this.sreg[a]=b;this.segment_is_null[a]=1;return}if(!c.is_valid||c.is_system||!c.is_readable||(!c.is_executable||!c.dc_bit)&&c.rpl>c.dpl&&this.cpl>c.dpl){this.trigger_gp(b&-4);return}if(!c.is_present){this.trigger_np(b&-4);return}}this.segment_is_null[a]=0;this.segment_limits[a]=c.effective_limit;this.segment_offsets[a]=c.base;this.sreg[a]=b}}; |
| CPU.prototype.load_tr=function(a){var b=this.lookup_segment_selector(a);if(!b.from_gdt)throw this.debug.unimpl("TR can only be loaded from GDT");if(b.is_null)throw this.debug.unimpl("#GP handler");if(!b.is_present)throw this.debug.unimpl("#GP handler");if(!b.is_system)throw this.debug.unimpl("#GP handler");if(9!==b.type)throw this.debug.unimpl("#GP handler");this.segment_offsets[6]=b.base;this.segment_limits[6]=b.effective_limit;this.sreg[6]=a;this.memory.write8(b.table_offset+5,this.memory.read8(b.table_offset+ |
| 5)|2)};CPU.prototype.load_ldt=function(a){var b=this.lookup_segment_selector(a);if(b.is_null)this.segment_offsets[7]=0,this.segment_limits[7]=0;else{if(!b.from_gdt)throw this.debug.unimpl("LDTR can only be loaded from GDT");if(!b.is_present)throw this.debug.unimpl("#GP handler");if(!b.is_system)throw this.debug.unimpl("#GP handler");if(2!==b.type)throw this.debug.unimpl("#GP handler");this.segment_offsets[7]=b.base;this.segment_limits[7]=b.effective_limit;this.sreg[7]=a}}; |
| CPU.prototype.arpl=function(a,b){this.flags_changed&=-65;if((a&3)<(this.reg16[b]&3))return this.flags|=64,a&-4|this.reg16[b]&3;this.flags&=-65;return a};CPU.prototype.clear_tlb=function(){this.last_virt_eip=-1;this.tlb_info.set(this.tlb_info_global)};CPU.prototype.full_clear_tlb=function(){for(var a=new Int32Array(this.tlb_info_global.buffer),b=0;262144>b;)a[b++]=a[b++]=a[b++]=a[b++]=0;this.clear_tlb()}; |
| CPU.prototype.invlpg=function(a){a=a>>>12;this.tlb_info[a]=0;this.tlb_info_global[a]=0;this.last_virt_eip=-1};CPU.prototype.translate_address_read=function(a){return this.paging?3===this.cpl?this.translate_address_user_read(a):this.translate_address_system_read(a):a};CPU.prototype.translate_address_write=function(a){return this.paging?3===this.cpl?this.translate_address_user_write(a):this.translate_address_system_write(a):a}; |
| CPU.prototype.translate_address_user_write=function(a){var b=a>>>12;return this.tlb_info[b]&8?this.tlb_data[b]^a:this.do_page_translation(a,1,1)|a&4095};CPU.prototype.translate_address_user_read=function(a){var b=a>>>12;return this.tlb_info[b]&4?this.tlb_data[b]^a:this.do_page_translation(a,0,1)|a&4095};CPU.prototype.translate_address_system_write=function(a){var b=a>>>12;return this.tlb_info[b]&2?this.tlb_data[b]^a:this.do_page_translation(a,1,0)|a&4095}; |
| CPU.prototype.translate_address_system_read=function(a){var b=a>>>12;return this.tlb_info[b]&1?this.tlb_data[b]^a:this.do_page_translation(a,0,0)|a&4095}; |
| CPU.prototype.do_page_translation=function(a,b,c){var d=a>>>12,e=(this.cr3>>>2)+(d>>10),f=this.memory.mem32s[e],g=!0,l=!0;f&1||(this.cr2=a,this.trigger_pagefault(b,c,0));0===(f&2)&&(g=!1,b&&(c||this.cr0&65536)&&(this.cr2=a,this.trigger_pagefault(b,c,1)));0===(f&4)&&(l=!1,c&&(this.cr2=a,this.trigger_pagefault(b,c,1)));if(f&this.page_size_extensions)this.memory.mem32s[e]=f|32|b<<6,a=f&4290772992|a&4190208,f=f&256;else{var k=((f&4294963200)>>>2)+(d&1023),m=this.memory.mem32s[k];0===(m&1)&&(this.cr2= |
| a,this.trigger_pagefault(b,c,0));0===(m&2)&&(g=!1,b&&(c||this.cr0&65536)&&(this.cr2=a,this.trigger_pagefault(b,c,1)));0===(m&4)&&(l=!1,c&&(this.cr2=a,this.trigger_pagefault(b,c,1)));this.memory.mem32s[e]=f|32;this.memory.mem32s[k]=m|32|b<<6;a=m&4294963200;f=m&256}this.tlb_data[d]=a^d<<12;g=l?g?15:5:g?3:1;this.tlb_info[d]=g;f&&this.cr4&128&&(this.tlb_info_global[d]=g);return a}; |
| CPU.prototype.writable_or_pagefault=function(a,b){if(this.paging){var c=3===this.cpl?1:0,d=c?8:2,e=a>>>12;0===(this.tlb_info[e]&d)&&this.do_page_translation(a,1,c);4096<=(a&4095)+b-1&&0===(this.tlb_info[e+1]&d)&&this.do_page_translation(a+b-1,1,c)}}; |
| CPU.prototype.trigger_pagefault=function(a,b,c){if(this.page_fault)throw this.debug.unimpl("Double fault");var d=this.cr2>>>12;this.tlb_info[d]=0;this.tlb_info_global[d]=0;this.instruction_pointer=this.previous_ip;this.page_fault=!0;this.call_interrupt_vector(14,!1,b<<2|a<<1|c);throw 233495534;};(function(){function a(){for(var a=location.search.substr(1).split("&"),b={},c=0;c<a.length;c++){var d=a[c].split("=");b[d[0]]=decodeURIComponent(d[1])}return b}function b(a,b){for(var c="";0<b--;)c+=a;return c}function c(a){var b=document.getElementById(a);b||console.log("Element with id `"+a+"` not found");return b}function d(){function b(a){c("boot_options").style.display="none";document.title=a.name+" - Virtual x86";d.filesystem=a.filesystem;a.state&&(c("reset").style.display="none",d.initial_state= |
| {url:a.state});d.fda={url:a.fda};d.cdrom={url:a.cdrom};a.hda?d.hda={url:a.hda}:a.async_hda&&(d.hda={url:a.async_hda,async:!0,size:a.async_hda_size});d.memory_size=a.memory_size;d.vga_memory_size=a.vga_memory_size;e({settings:d,done:function(a){a.run();g.c&&a.serial0_send(g.c+"\n")}})}if("responseType"in new XMLHttpRequest){var d={};c("start_emulation").onclick=function(){c("boot_options").style.display="none";l("custom");var a,b=c("floppy_image").files[0];b&&(a=b,d.fda={buffer:b});if(b=c("cd_image").files[0])a= |
| b,d.cdrom={buffer:b};if(b=c("hd_image").files[0])a=b,d.hda={buffer:b};a&&(document.title=a.name+" - Virtual x86");e({settings:d,done:function(a){a.run()}})};for(var f=[{id:"archlinux",state:"http://localhost/v86-images/v86state.bin",size:75550474,name:"Arch Linux",memory_size:67108864,vga_memory_size:8388608,async_hda:"http://localhost/v86-images/arch3.img",async_hda_size:8589934592,filesystem:{basefs:"http://localhost/v86-images/fs.json",baseurl:"http://localhost/v86-images/arch/"}},{id:"freedos", |
| fda:"images/freedos722.img",size:737280,name:"FreeDOS"},{id:"windows1",fda:"images/windows101.img",size:1474560,name:"Windows"},{id:"linux26",cdrom:"images/linux.iso",size:5666816,name:"Linux"},{id:"kolibrios",fda:"images/kolibri.img",size:1474560,name:"KolibriOS"},{id:"openbsd",fda:"images/openbsd.img",size:1474560,name:"OpenBSD"},{id:"solos",fda:"images/os8.dsk",size:1474560,name:"Sol OS"}],g=a(),k=g.profile,q=0;q<f.length;q++){var w=f[q],B="start_"+w.id;c(B).onclick=function(a,d){l(a.id);c(d).blur(); |
| b(a)}.bind(this,w,B);if(k===w.id){b(w);break}}}else alert("Your browser is not supported because it doesn't have XMLHttpRequest.responseType")}function e(a){var d=a.settings,e=d.memory_size;!e&&(e=1048576*parseInt(c("memory_size").value,10),16777216>e||2147483648<=e)&&(alert("Invalid memory size - ignored."),e=33554432);var g=d.vga_memory_size;!g&&(g=1048576*parseInt(c("video_memory_size").value,10),65536>=g||2147483648<=g)&&(alert("Invalid video memory size - ignored."),g=8388608);var l=new V86Starter({memory_size:e, |
| vga_memory_size:g,screen_container:c("screen_container"),serial_container:c("serial"),boot_order:parseInt(c("boot_order").value,16)||0,network_relay_url:"ws://relay.widgetry.org/",bios:{url:"bios/seabios.bin"},vga_bios:{url:"bios/bochs-vgabios-0.7a.bin"},fda:d.fda,hda:d.hda,cdrom:d.cdrom,initial_state:d.initial_state,filesystem:d.filesystem});l.add_listener("emulator-ready",function(){f(l);a.done(l)});l.add_listener("download-progress",function(a){var d=c("loading");d.style.display="block";var e= |
| "Downloading images ";"number"===typeof a.file_index&&a.file_count&&(e+="["+(a.file_index+1)+"/"+a.file_count+"] ");if(a.total&&"number"===typeof a.loaded){a=Math.floor(a.loaded/a.total*100);a=Math.min(100,Math.max(0,a));var f=Math.floor(a/2),e=e+(a+"% [")+b("#",f),e=e+(b(" ",50-f)+"]")}else e+=b(".",k++%50);d.textContent=e})}function f(a){var b={};function d(){if(a.is_running()){var b=a.get_statistics(),e=Date.now(),f=b.cpu.instruction_counter-D;y+=f;t+=e-u;u=e;k.textContent=f/1E3|0;C.textContent= |
| y/t|0;e=t/1E3|0;l.textContent=60>e?e+"s":3600>e?(e/60|0)+"m "+v86util.pad0(e%60,2)+"s":(e/3600|0)+"h "+v86util.pad0((e/60|0)%60,2)+"m "+v86util.pad0(e%60,2)+"s";D=b.cpu.instruction_counter;c("info_mouse_enabled").textContent=b.mouse.enabled?"Yes":"No";b.hda?(c("info_hda_sectors_read").textContent=b.hda.sectors_read,c("info_hda_bytes_read").textContent=b.hda.bytes_read,c("info_hda_sectors_written").textContent=b.hda.sectors_written,c("info_hda_bytes_written").textContent=b.hda.bytes_written,c("info_hda_status").textContent= |
| b.hda.loading?"Loading ...":"Idle"):c("info_hda").style.display="none";b.cdrom?(c("info_cdrom_sectors_read").textContent=b.cdrom.sectors_read,c("info_cdrom_bytes_read").textContent=b.cdrom.bytes_read,c("info_cdrom_status").textContent=b.cdrom.loading?"Loading ...":"Idle"):c("info_cdrom").style.display="none";b.vga.is_graphical?(c("info_vga_mode").textContent="Graphical",c("info_res").textContent=b.vga.res_x+"x"+b.vga.res_y,c("info_bpp").textContent=b.vga.bpp):(c("info_vga_mode").textContent="Text", |
| c("info_res").textContent="-",c("info_bpp").textContent="-")}setTimeout(d,1E3)}function e(a){a.ctrlKey?window.onbeforeunload=function(){window.onbeforeunload=null;return"CTRL-W cannot be sent to the emulator."}:window.onbeforeunload=null}c("boot_options").style.display="none";c("loading").style.display="none";c("runtime_options").style.display="block";c("runtime_infos").style.display="block";document.getElementsByClassName("phone_keyboard")[0].style.display="block";var f=c("news");f&&(f.style.display= |
| "none");c("run").onclick=function(){a.is_running()?(t+=Date.now()-u,c("run").value="Run",a.stop()):(c("run").value="Pause",a.run(),u=Date.now());c("run").blur()};c("exit").onclick=function(){location.href=location.pathname};c("lock_mouse").onclick=function(){if(!g)c("toggle_mouse").onclick();a.lock_mouse();c("lock_mouse").blur()};var g=!0;c("toggle_mouse").onclick=function(){g=!g;a.mouse_set_status(g);c("toggle_mouse").value=(g?"Dis":"En")+"able mouse";c("toggle_mouse").blur()};var l=c("running_time"), |
| k=c("speed"),C=c("avg_speed"),u=Date.now(),t=0,y=0,D=0;setTimeout(d,1E3);f=a.get_statistics();f.cdrom||(c("info_cdrom").style.display="none");f.hda||(c("info_hda").style.display="none");c("reset").onclick=function(){a.restart();c("reset").blur()};for(var f=["hda","hdb","fda","fdb"],v=0;v<f.length;v++){var x=c("get_"+f[v]+"_image"),z=b[f[v]];z&&16777216>z.byteLength?x.onclick=function(a){z.get_buffer(function(b){var c=a+".img",d=new Blob([b]);b=document.createElement("a");b.download=c;b.href=window.URL.createObjectURL(d); |
| b.dataset.downloadurl=["application/octet-stream",b.download,b.href].join(":");document.createEvent?(c=document.createEvent("MouseEvent"),c.initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),b.dispatchEvent(c)):b.click()});this.blur()}.bind(x,f[v]):x.style.display="none"}c("ctrlaltdel").onclick=function(){a.keyboard_send_scancodes([29,56,83,157,184,211]);c("ctrlaltdel").blur()};c("alttab").onclick=function(){a.keyboard_send_scancodes([56,15,184,143]);c("alttab").blur()};c("scale").onchange= |
| function(){var b=parseFloat(this.value);(b||0<b)&&a.screen_set_scale(b,b)};c("fullscreen").onclick=function(){a.screen_go_fullscreen()};c("screen_container").onclick=function(){window.getSelection().isCollapsed&&document.getElementsByClassName("phone_keyboard")[0].focus()};c("take_screenshot").onclick=function(){a.screen_make_screenshot();c("take_screenshot").blur()};c("serial").style.display="block";window.addEventListener("keydown",e,!1);window.addEventListener("keyup",e,!1);window.addEventListener("blur", |
| e,!1)}function g(){location.reload()}function l(a){window.history.pushState&&window.history.pushState({profile:a},"","?profile="+a)}var k=0;window.addEventListener("load",d,!1);window.addEventListener("load",function(){setTimeout(function(){window.addEventListener("popstate",g)},0)});"complete"===document.readyState&&d()})();function IO(a){function b(){return 255}function c(){return 65535}function d(){return-1}function e(){}var f=a.size;this.IO$ports=[];this.devices=Array(65536);this._state_skip=[this.IO$ports,this.devices];for(var g=0;65536>g;g++)this.IO$ports[g]={read8:b,read16:c,read32:d,write8:e,write16:e,write32:e,device:void 0};this.register_read=function(a,b,c,d,e){c&&(this.IO$ports[a].read8=c);d&&(this.IO$ports[a].read16=d);e&&(this.IO$ports[a].read32=e);this.IO$ports[a].device=b};this.register_write=function(a, |
| b,c,d,e){c&&(this.IO$ports[a].write8=c);d&&(this.IO$ports[a].write16=d);e&&(this.IO$ports[a].write32=e);this.IO$ports[a].device=b};this.register_read_consecutive=function(a,b,c,d,e,f){function g(){return c.call(this)|d.call(this)<<8}function q(){return e.call(this)|f.call(this)<<8}function w(){return c.call(this)|d.call(this)<<8|e.call(this)<<16|f.call(this)<<24}e&&f?(this.register_read(a,b,c,g,w),this.register_read(a+1,b,d),this.register_read(a+2,b,e,q),this.register_read(a+3,b,f)):(this.register_read(a, |
| b,c,g),this.register_read(a+1,b,d))};this.register_write_consecutive=function(a,b,c,d,e,f){function g(a){c.call(this,a&255);d.call(this,a>>8&255)}function q(a){e.call(this,a&255);f.call(this,a>>8&255)}function w(a){c.call(this,a&255);d.call(this,a>>8&255);e.call(this,a>>16&255);f.call(this,a>>>24)}e&&f?(this.register_write(a,b,c,g,w),this.register_write(a+1,b,d),this.register_write(a+2,b,e,q),this.register_write(a+3,b,f)):(this.register_write(a,b,c,g),this.register_write(a+1,b,d))};this.mmap_read32_shim= |
| function(b){var c=a.memory_map_read8[b>>>14];return c(b)|c(b+1)<<8|c(b+2)<<16|c(b+3)<<24};this.mmap_write32_shim=function(b,c){var d=a.memory_map_write8[b>>>14];d(b,c&255);d(b+1,c>>8&255);d(b+2,c>>16&255);d(b+3,c>>>24)};this.mmap_register=function(b,c,d,e,f,g){f||(f=this.mmap_read32_shim);g||(g=this.mmap_write32_shim);for(b>>>=14;0<c;b++)a.memory_map_registered[b]=1,a.memory_map_read8[b]=d,a.memory_map_write8[b]=e,a.memory_map_read32[b]=f,a.memory_map_write32[b]=g,c-=16384};for(g=0;g<<14<f;g++)a.memory_map_read8[g]= |
| a.memory_map_write8[g]=void 0,a.memory_map_read32[g]=a.memory_map_write32[g]=void 0;this.mmap_register(f,4294967296-f,function(){return 255},function(){},function(){return-1},function(){});this.in_mmap_range=function(b,c){b>>>=0;var d=b+(c>>>0);if(d>=f)return!0;for(b&=-16384;b<d;){if(a.memory_map_registered[b>>14])return!0;b+=16384}return!1};this.port_write8=function(a,b){var c=this.IO$ports[a];c.write8.call(c.device,b)};this.port_write16=function(a,b){var c=this.IO$ports[a];c.write16.call(c.device, |
| b)};this.port_write32=function(a,b){var c=this.IO$ports[a];c.write32.call(c.device,b)};this.port_read8=function(a){a=this.IO$ports[a];return a.read8.call(a.device)};this.port_read16=function(a){a=this.IO$ports[a];return a.read16.call(a.device)};this.port_read32=function(a){a=this.IO$ports[a];return a.read32.call(a.device)}};function v86(a){this.first_init=!0;this.stopped=this.running=!1;this.cpu=new CPU;this.bus=a;a.register("cpu-init",this.init,this);a.register("cpu-run",this.run,this);a.register("cpu-stop",this.stop,this);this.fast_next_tick=function(){console.assert(!1)};this.v86$next_tick=function(){console.assert(!1)}}v86.prototype.run=function(){this.running||this.fast_next_tick()};v86.prototype.do_tick=function(){if(this.stopped)this.stopped=this.running=!1;else{this.running=!0;var a=this.cpu.main_run();this.v86$next_tick(a)}}; |
| v86.prototype.stop=function(){this.running&&(this.stopped=!0)};v86.prototype.restart=function(){this.cpu.CPU_prototype$reset();this.cpu.load_bios()};v86.prototype.init=function(a){this.first_init&&(this.first_init=!1,this.lazy_init());this.cpu.init(a,this.bus);this.bus.send_async()}; |
| v86.prototype.lazy_init=function(){var a=this;"undefined"!==typeof setImmediate?this.fast_next_tick=function(){setImmediate(function(){a.do_tick()})}:"undefined"!==typeof window&&"undefined"!==typeof postMessage?(window.addEventListener("message",function(b){b.source===window&&43605===b.data&&a.do_tick()},!1),this.fast_next_tick=function(){window.postMessage(43605,"*")}):this.fast_next_tick=function(){setTimeout(function(){a.do_tick()},0)};this.v86$next_tick="undefined"!==typeof document&&"boolean"=== |
| typeof document.hidden?function(b){4>b||document.hidden?this.fast_next_tick():setTimeout(function(){a.do_tick()},b)}:function(b){setTimeout(function(){a.do_tick()},b)}};v86.prototype.save_state=function(){return this.cpu.save_state()};v86.prototype.v86_prototype$restore_state=function(a){this.cpu.CPU_prototype$restore_state(a)};"object"===typeof performance&&performance.now?v86.microtick=function(){return performance.now()}:v86.microtick=Date.now;var v86util;v86util=v86util||{};v86util.pads=function(a){for(a=a?a+"":"";20>a.length;)a+=" ";return a};v86util.pad0=function(a,b){for(a=a?a+"":"";a.length<b;)a="0"+a;return a};function h(a){return a?a.toString(16).toUpperCase():v86util.pad0("",1)}function SyncBuffer(a){this.buffer=a;this.byteLength=a.byteLength}SyncBuffer.prototype.get=function(a,b,c){c(new Uint8Array(this.buffer,a,b))};SyncBuffer.prototype.set=function(a,b,c){(new Uint8Array(this.buffer,a,b.byteLength)).set(b);c()}; |
| SyncBuffer.prototype.get_buffer=function(a){a(this.buffer)};(function(){for(var a=new Int8Array(256),b=0,c=-2;256>b;b++)b&b-1||c++,a[b]=c;v86util.int_log2_byte=function(b){return a[b]};v86util.int_log2=function(b){var c=b>>>16;if(c){var f=c>>>8;return f?24+a[f]:16+a[c]}return(f=b>>>8)?8+a[f]:a[b]}})(); |
| function ByteQueue(a){var b=new Uint8Array(a),c,d;this.length=0;this.push=function(c){this.length!==a&&this.length++;b[d]=c;d=d+1&a-1};this.shift=function(){if(this.length){var d=b[c];c=c+1&a-1;this.length--;return d}return-1};this.clear=function(){this.length=d=c=0};this.clear()};function FPU(a){this.cpu=a;this.st=new Float64Array(8);this._state_restore();this.stack_empty=255;this.stack_ptr=0;this.control_word=895;this.fpu_dp_selector=this.fpu_dp=this.fpu_opcode=this.fpu_ip_selector=this.fpu_ip=this.status_word=0;this.indefinite_nan=NaN;this.constants=new Float64Array([1,Math.log(10)/Math.LN2,Math.LOG2E,Math.PI,Math.log(2)/Math.LN10,Math.LN2,0])} |
| FPU.prototype._state_restore=function(){this.float32=new Float32Array(1);this.float32_byte=new Uint8Array(this.float32.buffer);this.float32_int=new Int32Array(this.float32.buffer);this.float64=new Float64Array(1);this.float64_byte=new Uint8Array(this.float64.buffer);this.float64_int=new Int32Array(this.float64.buffer);this.st8=new Uint8Array(this.st.buffer);this.st32=new Int32Array(this.st.buffer);this._state_skip=[this.cpu,this.float32,this.float32_byte,this.float32_int,this.float64,this.float64_byte, |
| this.float64_int,this.st8,this.st32]};FPU.prototype.fpu_unimpl=function(){this.cpu.trigger_ud()};FPU.prototype.stack_fault=function(){this.status_word|=65};FPU.prototype.invalid_arithmatic=function(){this.status_word|=1};FPU.prototype.fcom=function(a){var b=this.get_st0();this.status_word&=-18177;b>a||(this.status_word=a>b?this.status_word|256:b===a?this.status_word|16384:this.status_word|17664)};FPU.prototype.fucom=function(a){this.fcom(a)}; |
| FPU.prototype.fcomi=function(a){var b=this.st[this.stack_ptr];this.cpu.flags_changed&=-70;this.cpu.flags&=-70;b>a||(this.cpu.flags=a>b?this.cpu.flags|1:b===a?this.cpu.flags|64:this.cpu.flags|69)};FPU.prototype.fucomi=function(a){this.fcomi(a)};FPU.prototype.ftst=function(a){this.status_word&=-18177;isNaN(a)?this.status_word|=17664:0===a?this.status_word|=16384:0>a&&(this.status_word|=256)}; |
| FPU.prototype.fxam=function(a){this.status_word&=-18177;this.status_word|=this.sign(0)<<9;this.status_word=this.stack_empty>>this.stack_ptr&1?this.status_word|16640:isNaN(a)?this.status_word|256:0===a?this.status_word|16384:Infinity===a||-Infinity===a?this.status_word|1280:this.status_word|1024};FPU.prototype.finit=function(){this.control_word=895;this.fpu_opcode=this.fpu_dp=this.fpu_ip=this.status_word=0;this.stack_empty=255;this.stack_ptr=0}; |
| FPU.prototype.load_status_word=function(){return this.status_word&-14337|this.stack_ptr<<11};FPU.prototype.safe_status_word=function(a){this.status_word=a&-14337;this.stack_ptr=a>>11&7};FPU.prototype.load_tag_word=function(){for(var a=0,b,c=0;8>c;c++)b=this.st[c],this.stack_empty>>c&1?a|=3<<(c<<1):0===b?a|=1<<(c<<1):isFinite(b)||(a|=2<<(c<<1));return a};FPU.prototype.safe_tag_word=function(a){for(var b=this.stack_empty=0;8>b;b++)this.stack_empty|=a>>b&a>>b+1&1<<b}; |
| FPU.prototype.fstenv=function(a){this.cpu.operand_size_32?(this.cpu.writable_or_pagefault(a,26),this.cpu.safe_write16(a,this.control_word),this.cpu.safe_write16(a+4,this.load_status_word()),this.cpu.safe_write16(a+8,this.load_tag_word()),this.cpu.safe_write32(a+12,this.fpu_ip),this.cpu.safe_write16(a+16,this.fpu_ip_selector),this.cpu.safe_write16(a+18,this.fpu_opcode),this.cpu.safe_write32(a+20,this.fpu_dp),this.cpu.safe_write16(a+24,this.fpu_dp_selector)):this.fpu_unimpl()}; |
| FPU.prototype.fldenv=function(a){this.cpu.operand_size_32?(this.control_word=this.cpu.safe_read16(a),this.safe_status_word(this.cpu.safe_read16(a+4)),this.safe_tag_word(this.cpu.safe_read16(a+8)),this.fpu_ip=this.cpu.safe_read32s(a+12),this.fpu_ip_selector=this.cpu.safe_read16(a+16),this.fpu_opcode=this.cpu.safe_read16(a+18),this.fpu_dp=this.cpu.safe_read32s(a+20),this.fpu_dp_selector=this.cpu.safe_read16(a+24)):this.fpu_unimpl()}; |
| FPU.prototype.fsave=function(a){this.cpu.writable_or_pagefault(a,108);this.fstenv(a);a+=28;for(var b=0;8>b;b++)this.store_m80(a,b-this.stack_ptr&7),a+=10;this.finit()};FPU.prototype.frstor=function(a){this.fldenv(a);a+=28;for(var b=0;8>b;b++)this.st[b]=this.load_m80(a),a+=10};FPU.prototype.integer_round=function(a){var b=this.control_word>>10&3;return 0===b?(b=Math.round(a),.5===b-a&&b%2&&b--,b):1===b||3===b&&0<a?Math.floor(a):Math.ceil(a)}; |
| FPU.prototype.FPU_prototype$truncate=function(a){return 0<a?Math.floor(a):Math.ceil(a)};FPU.prototype.push=function(a){this.stack_ptr=this.stack_ptr-1&7;this.stack_empty>>this.stack_ptr&1?(this.status_word&=-513,this.stack_empty&=~(1<<this.stack_ptr),this.st[this.stack_ptr]=a):(this.status_word|=512,this.stack_fault(),this.st[this.stack_ptr]=this.indefinite_nan)};FPU.prototype.pop=function(){this.stack_empty|=1<<this.stack_ptr;this.stack_ptr=this.stack_ptr+1&7}; |
| FPU.prototype.get_sti=function(a){a=a+this.stack_ptr&7;return this.stack_empty>>a&1?(this.status_word&=-513,this.stack_fault(),this.indefinite_nan):this.st[a]};FPU.prototype.get_st0=function(){return this.stack_empty>>this.stack_ptr&1?(this.status_word&=-513,this.stack_fault(),this.indefinite_nan):this.st[this.stack_ptr]}; |
| FPU.prototype.load_m80=function(a){var b=this.cpu.safe_read16(a+8),c=this.cpu.safe_read32s(a)>>>0,d=this.cpu.safe_read32s(a+4)>>>0;a=b>>15;b&=-32769;if(0===b)return 0;if(!(32767>b))return this.float64_byte[7]=127|a<<7,this.float64_byte[6]=240|d>>30<<3&8,this.float64_byte[5]=0,this.float64_byte[4]=0,this.float64_int[0]=0,this.float64[0];c+=4294967296*d;a&&(c=-c);return c*Math.pow(2,b-16383-63)}; |
| FPU.prototype.store_m80=function(a,b){this.float64[0]=this.st[this.stack_ptr+b&7];var c=this.float64_byte[7]&128,d=(this.float64_byte[7]&127)<<4|this.float64_byte[6]>>4,e,f;2047===d?(d=32767,e=0,f=2147483648|(this.float64_int[1]&524288)<<11):0===d?f=e=0:(d+=15360,e=this.float64_int[0]<<11,f=2147483648|(this.float64_int[1]&1048575)<<11|this.float64_int[0]>>>21);this.cpu.safe_write32(a,e);this.cpu.safe_write32(a+4,f);this.cpu.safe_write16(a+8,c<<8|d)}; |
| FPU.prototype.load_m64=function(a){var b=this.cpu.safe_read32s(a);a=this.cpu.safe_read32s(a+4);this.float64_int[0]=b;this.float64_int[1]=a;return this.float64[0]};FPU.prototype.store_m64=function(a){this.cpu.writable_or_pagefault(a,8);this.float64[0]=this.get_sti(0);this.cpu.safe_write32(a,this.float64_int[0]);this.cpu.safe_write32(a+4,this.float64_int[1])};FPU.prototype.load_m32=function(a){this.float32_int[0]=this.cpu.safe_read32s(a);return this.float32[0]}; |
| FPU.prototype.store_m32=function(a,b){this.float32[0]=b;this.cpu.safe_write32(a,this.float32_int[0])};FPU.prototype.sign=function(a){return this.st8[(this.stack_ptr+a&7)<<3|7]>>7}; |
| FPU.prototype.op_D8_reg=function(a){var b=a>>3&7;a=this.get_sti(a&7);var c=this.get_st0();switch(b){case 0:this.st[this.stack_ptr]=c+a;break;case 1:this.st[this.stack_ptr]=c*a;break;case 2:this.fcom(a);break;case 3:this.fcom(a);this.pop();break;case 4:this.st[this.stack_ptr]=c-a;break;case 5:this.st[this.stack_ptr]=a-c;break;case 6:this.st[this.stack_ptr]=c/a;break;case 7:this.st[this.stack_ptr]=a/c}}; |
| FPU.prototype.op_D8_mem=function(a,b){var c=a>>3&7,d=this.load_m32(b),e=this.get_st0();switch(c){case 0:this.st[this.stack_ptr]=e+d;break;case 1:this.st[this.stack_ptr]=e*d;break;case 2:this.fcom(d);break;case 3:this.fcom(d);this.pop();break;case 4:this.st[this.stack_ptr]=e-d;break;case 5:this.st[this.stack_ptr]=d-e;break;case 6:this.st[this.stack_ptr]=e/d;break;case 7:this.st[this.stack_ptr]=d/e}}; |
| FPU.prototype.op_D9_reg=function(a){var b=a&7;switch(a>>3&7){case 0:a=this.get_sti(b);this.push(a);break;case 1:a=this.get_sti(b);this.st[this.stack_ptr+b&7]=this.get_st0();this.st[this.stack_ptr]=a;break;case 2:switch(b){case 0:break;default:this.fpu_unimpl()}break;case 3:this.fpu_unimpl();break;case 4:a=this.get_st0();switch(b){case 0:this.st[this.stack_ptr]=-a;break;case 1:this.st[this.stack_ptr]=Math.abs(a);break;case 4:this.ftst(a);break;case 5:this.fxam(a);break;default:this.fpu_unimpl()}break; |
| case 5:this.push(this.constants[b]);break;case 6:a=this.get_st0();switch(b){case 0:this.st[this.stack_ptr]=Math.pow(2,a)-1;break;case 1:this.st[this.stack_ptr+1&7]=this.get_sti(1)*Math.log(a)/Math.LN2;this.pop();break;case 2:this.st[this.stack_ptr]=Math.tan(a);this.push(1);break;case 3:this.st[this.stack_ptr+1&7]=Math.atan2(this.get_sti(1),a);this.pop();break;case 4:this.fpu_unimpl();break;case 5:this.st[this.stack_ptr]=a%this.get_sti(1);break;case 6:this.fpu_unimpl();break;case 7:this.fpu_unimpl()}break; |
| case 7:switch(a=this.get_st0(),b){case 0:this.st[this.stack_ptr]=a%this.get_sti(1);break;case 1:this.st[this.stack_ptr+1&7]=this.get_sti(1)*Math.log(a+1)/Math.LN2;this.pop();break;case 2:this.st[this.stack_ptr]=Math.sqrt(a);break;case 3:this.st[this.stack_ptr]=Math.sin(a);this.push(Math.cos(a));break;case 4:this.st[this.stack_ptr]=this.integer_round(a);break;case 5:this.st[this.stack_ptr]=a*Math.pow(2,this.FPU_prototype$truncate(this.get_sti(1)));break;case 6:this.st[this.stack_ptr]=Math.sin(a);break; |
| case 7:this.st[this.stack_ptr]=Math.cos(a)}}};FPU.prototype.op_D9_mem=function(a,b){switch(a>>3&7){case 0:var c=this.load_m32(b);this.push(c);break;case 1:this.fpu_unimpl();break;case 2:this.store_m32(b,this.get_st0());break;case 3:this.store_m32(b,this.get_st0());this.pop();break;case 4:this.fldenv(b);break;case 5:this.control_word=this.cpu.safe_read16(b);break;case 6:this.fstenv(b);break;case 7:this.cpu.safe_write16(b,this.control_word)}}; |
| FPU.prototype.op_DA_reg=function(a){var b=a&7;switch(a>>3&7){case 0:this.cpu.test_b()&&(this.st[this.stack_ptr]=this.get_sti(b),this.stack_empty&=~(1<<this.stack_ptr));break;case 1:this.cpu.test_z()&&(this.st[this.stack_ptr]=this.get_sti(b),this.stack_empty&=~(1<<this.stack_ptr));break;case 2:this.cpu.test_be()&&(this.st[this.stack_ptr]=this.get_sti(b),this.stack_empty&=~(1<<this.stack_ptr));break;case 3:this.cpu.test_p()&&(this.st[this.stack_ptr]=this.get_sti(b),this.stack_empty&=~(1<<this.stack_ptr)); |
| break;case 5:1===b?(this.fucom(this.get_sti(1)),this.pop(),this.pop()):this.fpu_unimpl();break;default:this.fpu_unimpl()}}; |
| FPU.prototype.op_DA_mem=function(a,b){var c=a>>3&7,d=this.cpu.safe_read32s(b),e=this.get_st0();switch(c){case 0:this.st[this.stack_ptr]=e+d;break;case 1:this.st[this.stack_ptr]=e*d;break;case 2:this.fcom(d);break;case 3:this.fcom(d);this.pop();break;case 4:this.st[this.stack_ptr]=e-d;break;case 5:this.st[this.stack_ptr]=d-e;break;case 6:this.st[this.stack_ptr]=e/d;break;case 7:this.st[this.stack_ptr]=d/e}}; |
| FPU.prototype.op_DB_reg=function(a){var b=a&7;switch(a>>3&7){case 0:this.cpu.test_b()||(this.st[this.stack_ptr]=this.get_sti(b),this.stack_empty&=~(1<<this.stack_ptr));break;case 1:this.cpu.test_z()||(this.st[this.stack_ptr]=this.get_sti(b),this.stack_empty&=~(1<<this.stack_ptr));break;case 2:this.cpu.test_be()||(this.st[this.stack_ptr]=this.get_sti(b),this.stack_empty&=~(1<<this.stack_ptr));break;case 3:this.cpu.test_p()||(this.st[this.stack_ptr]=this.get_sti(b),this.stack_empty&=~(1<<this.stack_ptr)); |
| break;case 4:227===a?this.finit():228!==a&&225!==a&&(226===a?this.status_word=0:this.fpu_unimpl());break;case 5:this.fucomi(this.get_sti(b));break;case 6:this.fcomi(this.get_sti(b));break;default:this.fpu_unimpl()}}; |
| FPU.prototype.op_DB_mem=function(a,b){switch(a>>3&7){case 0:var c=this.cpu.safe_read32s(b);this.push(c);break;case 2:c=this.integer_round(this.get_st0());2147483647>=c&&-2147483648<=c?this.cpu.safe_write32(b,c):(this.invalid_arithmatic(),this.cpu.safe_write32(b,-2147483648));break;case 3:c=this.integer_round(this.get_st0());2147483647>=c&&-2147483648<=c?this.cpu.safe_write32(b,c):(this.invalid_arithmatic(),this.cpu.safe_write32(b,-2147483648));this.pop();break;case 5:this.push(this.load_m80(b));break; |
| case 7:this.cpu.writable_or_pagefault(b,10);this.store_m80(b,0);this.pop();break;default:this.fpu_unimpl()}};FPU.prototype.op_DC_reg=function(a){var b=a>>3&7,c=a&7;a=this.stack_ptr+c&7;var c=this.get_sti(c),d=this.get_st0();switch(b){case 0:this.st[a]=c+d;break;case 1:this.st[a]=c*d;break;case 2:this.fcom(c);break;case 3:this.fcom(c);this.pop();break;case 4:this.st[a]=d-c;break;case 5:this.st[a]=c-d;break;case 6:this.st[a]=d/c;break;case 7:this.st[a]=c/d}}; |
| FPU.prototype.op_DC_mem=function(a,b){var c=a>>3&7,d=this.load_m64(b),e=this.get_st0();switch(c){case 0:this.st[this.stack_ptr]=e+d;break;case 1:this.st[this.stack_ptr]=e*d;break;case 2:this.fcom(d);break;case 3:this.fcom(d);this.pop();break;case 4:this.st[this.stack_ptr]=e-d;break;case 5:this.st[this.stack_ptr]=d-e;break;case 6:this.st[this.stack_ptr]=e/d;break;case 7:this.st[this.stack_ptr]=d/e}}; |
| FPU.prototype.op_DD_reg=function(a){var b=a&7;switch(a>>3&7){case 0:this.stack_empty|=1<<(this.stack_ptr+b&7);break;case 2:this.st[this.stack_ptr+b&7]=this.get_st0();break;case 3:0!==b&&(this.st[this.stack_ptr+b&7]=this.get_st0());this.pop();break;case 4:this.fucom(this.get_sti(b));break;case 5:this.fucom(this.get_sti(b));this.pop();break;default:this.fpu_unimpl()}}; |
| FPU.prototype.op_DD_mem=function(a,b){switch(a>>3&7){case 0:var c=this.load_m64(b);this.push(c);break;case 1:this.fpu_unimpl();break;case 2:this.store_m64(b);break;case 3:this.store_m64(b);this.pop();break;case 4:this.frstor(b);break;case 5:this.fpu_unimpl();break;case 6:this.fsave(b);break;case 7:this.cpu.safe_write16(b,this.load_status_word())}}; |
| FPU.prototype.op_DE_reg=function(a){var b=a>>3&7;a=a&7;var c=this.stack_ptr+a&7,d=this.get_sti(a),e=this.get_st0();switch(b){case 0:this.st[c]=d+e;break;case 1:this.st[c]=d*e;break;case 2:this.fcom(d);break;case 3:1===a?(this.fcom(this.st[c]),this.pop()):this.fpu_unimpl();break;case 4:this.st[c]=e-d;break;case 5:this.st[c]=d-e;break;case 6:this.st[c]=e/d;break;case 7:this.st[c]=d/e}this.pop()}; |
| FPU.prototype.op_DE_mem=function(a,b){var c=a>>3&7,d=this.cpu.safe_read16(b)<<16>>16,e=this.get_st0();switch(c){case 0:this.st[this.stack_ptr]=e+d;break;case 1:this.st[this.stack_ptr]=e*d;break;case 2:this.fcom(d);break;case 3:this.fcom(d);this.pop();break;case 4:this.st[this.stack_ptr]=e-d;break;case 5:this.st[this.stack_ptr]=d-e;break;case 6:this.st[this.stack_ptr]=e/d;break;case 7:this.st[this.stack_ptr]=d/e}}; |
| FPU.prototype.op_DF_reg=function(a){var b=a&7;switch(a>>3&7){case 4:224===a?this.cpu.reg16[0]=this.load_status_word():this.fpu_unimpl();break;case 5:this.fucomi(this.get_sti(b));this.pop();break;case 6:this.fcomi(this.get_sti(b));this.pop();break;default:this.fpu_unimpl()}}; |
| FPU.prototype.op_DF_mem=function(a,b){switch(a>>3&7){case 0:var c=this.cpu.safe_read16(b)<<16>>16;this.push(c);break;case 1:this.fpu_unimpl();break;case 2:c=this.integer_round(this.get_st0());32767>=c&&-32768<=c?this.cpu.safe_write16(b,c):(this.invalid_arithmatic(),this.cpu.safe_write16(b,32768));break;case 3:c=this.integer_round(this.get_st0());32767>=c&&-32768<=c?this.cpu.safe_write16(b,c):(this.invalid_arithmatic(),this.cpu.safe_write16(b,32768));this.pop();break;case 4:this.fpu_unimpl();break; |
| case 5:var d=this.cpu.safe_read32s(b)>>>0,c=this.cpu.safe_read32s(b+4)>>>0,d=d+4294967296*c;c>>31&&(d-=1.8446744073709552E19);this.push(d);break;case 6:this.fpu_unimpl();break;case 7:this.cpu.writable_or_pagefault(b,8);var c=this.integer_round(this.get_st0()),e;0x7fffffffffffffff>c&&-9223372036854775808<=c?(d=c|0,e=c/4294967296|0,0===e&&0>c&&(e=-1)):(d=0,e=-2147483648,this.invalid_arithmatic());this.cpu.safe_write32(b,d);this.cpu.safe_write32(b+4,e);this.pop()}};function IDEDevice(a,b,c,d){0===d?(this.ata_port=496,this.IDEDevice$irq=14,this.pci_id=240):(this.ata_port=496,this.IDEDevice$irq=14,this.pci_id=248);this.ata_port_high=this.ata_port|516;this.pic=a.devices.pic;this.memory=a.memory;this.buffer=b;this.sector_size=c?2048:512;this.is_atapi=c;this.cylinder_count=this.IDEDevice$sectors_per_track=this.head_count=this.sector_count=0;this.buffer&&(this.sector_count=this.buffer.byteLength/this.sector_size,this.sector_count!==(this.sector_count|0)&&(this.sector_count= |
| Math.ceil(this.sector_count)),c?(this.head_count=1,this.IDEDevice$sectors_per_track=0):(this.head_count=255,this.IDEDevice$sectors_per_track=63),this.cylinder_count=this.sector_count/(this.head_count+1)/(this.IDEDevice$sectors_per_track+1),this.cylinder_count!==(this.cylinder_count|0)&&(this.cylinder_count=Math.ceil(this.cylinder_count)));this.stats={sectors_read:0,sectors_written:0,bytes_read:0,bytes_written:0,loading:!1};this.pci_space=[134,128,32,58,5,0,160,2,0,143,1,1,0,0,0,0,this.ata_port&255| |
| 1,this.ata_port>>8,0,0,this.ata_port_high&255|1,this.ata_port_high>>8,0,0,0,0,0,0,0,0,0,0,1,192,0,0,0,0,0,0,0,0,0,0,67,16,212,130,0,0,0,0,0,0,0,0,0,0,0,0,this.IDEDevice$irq,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.pci_bars=[{size:8},{size:4},!1,!1,{size:16}];a.devices.pci.register_device(this);a.io.register_read(this.ata_port|7,this,this.read_status); |
| a.io.register_read(this.ata_port_high|2,this,this.read_status);a.io.register_write(this.ata_port|7,this,this.write_control);a.io.register_write(this.ata_port_high|2,this,this.write_control);this.device_control=2;this.data_pointer=0;this.pio_data=new Uint8Array(0);this.drive_head=this.head=this.cylinder_high=this.cylinder_low=this.lba_count=this.sector=this.bytecount=this.is_lba=0;this.status=80;this.sectors_per_drq=1;this.data_port_current=this.data_port_count=this.write_dest=0;this.data_port_buffer= |
| new Uint8Array(0);this.data_port_callback=0;this.next_status=-1;this.dma_status=this.prdt_addr=0;a.io.register_read(this.ata_port|0,this,this.read_data_port8,this.read_data_port16,this.read_data_port32);a.io.register_read(this.ata_port|1,this,this.read_lba_port);a.io.register_read(this.ata_port|2,this,this.read_bytecount_port);a.io.register_read(this.ata_port|3,this,this.read_sector_port);a.io.register_read(this.ata_port|4,this,function(){return this.cylinder_low&255});a.io.register_read(this.ata_port| |
| 5,this,function(){return this.cylinder_high&255});a.io.register_read(this.ata_port|6,this,function(){return this.drive_head});a.io.register_write(this.ata_port|0,this,this.write_data_port8,this.write_data_port16,this.write_data_port32);a.io.register_write(this.ata_port|1,this,this.write_lba_port);a.io.register_write(this.ata_port|2,this,this.write_bytecount_port);a.io.register_write(this.ata_port|3,this,this.write_sector_port);a.io.register_write(this.ata_port|4,this,function(a){this.cylinder_low= |
| (this.cylinder_low<<8|a)&65535});a.io.register_write(this.ata_port|5,this,function(a){this.cylinder_high=(this.cylinder_high<<8|a)&65535});a.io.register_write(this.ata_port|6,this,function(a){a&16||(this.drive_head=a,this.is_lba=a>>6&1,this.head=a&15)});a.io.register_write(this.ata_port|7,this,this.ata_command);a.io.register_read(49156,this,void 0,void 0,this.dma_read_addr);a.io.register_write(49156,this,void 0,void 0,this.dma_set_addr);a.io.register_read(49152,this,this.dma_read_command8,void 0, |
| this.dma_read_command);a.io.register_write(49152,this,this.dma_write_command8,void 0,this.dma_write_command);a.io.register_read(49154,this,this.dma_read_status);a.io.register_write(49154,this,this.dma_write_status);this._state_skip=[this.memory,this.pic,this.stats,this.buffer]}IDEDevice.prototype.do_callback=function(){switch(this.data_port_callback){case 1:this.do_write();break;case 2:this.atapi_handle()}};IDEDevice.prototype.push_irq=function(){0===(this.device_control&2)&&(this.dma_status|=4,this.pic.push_irq(this.IDEDevice$irq))}; |
| IDEDevice.prototype.ata_command=function(a){switch(a){case 0:this.push_irq();this.status=80;break;case 8:this.data_pointer=0;this.pio_data=new Uint8Array(0);this.status=80;this.push_irq();break;case 16:this.push_irq();break;case 39:this.push_irq();this.pio_data=new Uint8Array([0,0,0,0,this.buffer.byteLength&255,this.buffer.byteLength>>8&255,this.buffer.byteLength>>16&255,this.buffer.byteLength>>24&255,0,0,0,0]);this.status=88;break;case 32:case 41:case 36:case 196:this.ata_read_sectors(a);break;case 48:case 52:case 57:this.ata_write(a); |
| break;case 144:this.push_irq();this.lba_count=257;this.status=80;break;case 145:this.push_irq();break;case 160:this.is_atapi&&(this.status=88,this.allocate_in_buffer(12),this.data_port_callback=2,this.bytecount=1,this.push_irq());break;case 161:this.is_atapi?(this.create_identify_packet(),this.status=88):this.status=80;this.push_irq();break;case 198:this.sectors_per_drq=this.bytecount;this.push_irq();break;case 200:this.ata_read_sectors_dma();break;case 202:this.ata_write_dma();break;case 225:this.push_irq(); |
| break;case 236:if(this.is_atapi)break;this.create_identify_packet();this.status=88;this.push_irq();break;case 234:this.push_irq();break;case 239:this.push_irq();break;default:this.lba_count=4}}; |
| IDEDevice.prototype.atapi_handle=function(){this.bytecount=2;switch(this.data_port_buffer[0]){case 0:this.status=64;this.cylinder_low=8;this.cylinder_high=0;this.push_irq();break;case 3:this.pio_data=new Uint8Array(Math.min(this.data_port_buffer[4],15));this.status=88;this.pio_data[0]=240;this.pio_data[7]=8;this.data_pointer=0;this.bytecount=2;this.cylinder_low=8;this.cylinder_high=0;this.push_irq();break;case 18:this.pio_data=new Uint8Array(Math.min(this.data_port_buffer[4],36));this.status=88;this.pio_data.set([5, |
| 128,1,49,0,0,0,0,83,79,78,89,32,32,32,32,67,68,45,82,79,77,32,67,68,85,45,49,48,48,48,32,49,46,49,97]);this.data_pointer=0;this.bytecount=2;this.push_irq();break;case 30:this.pio_data=new Uint8Array(0);this.status=80;this.data_pointer=0;this.bytecount=2;this.push_irq();break;case 37:this.pio_data=new Uint8Array([this.sector_count>>24&255,this.sector_count>>16&255,this.sector_count>>8&255,this.sector_count&255,0,0,this.sector_size>>8&255,this.sector_size&255]);this.status=88;this.data_pointer=0;this.bytecount= |
| 2;this.cylinder_low=8;this.cylinder_high=0;this.push_irq();break;case 40:this.lba_count&1?this.atapi_read_dma(this.data_port_buffer):this.atapi_read(this.data_port_buffer);break;case 67:this.pio_data=new Uint8Array(2048);this.pio_data[0]=0;this.pio_data[1]=10;this.pio_data[2]=1;this.pio_data[3]=1;this.status=88;this.data_pointer=0;this.bytecount=2;this.cylinder_high=8;this.cylinder_low=0;this.push_irq();break;case 70:this.pio_data=new Uint8Array(this.data_port_buffer[8]|this.data_port_buffer[7]<< |
| 8);this.status=88;this.data_pointer=0;this.bytecount=2;this.push_irq();break;case 74:this.pio_data=new Uint8Array(this.data_port_buffer[8]|this.data_port_buffer[7]<<8);this.status=88;this.data_pointer=0;this.bytecount=2;this.push_irq();break;case 81:this.pio_data=new Uint8Array(0);this.status=80;this.data_pointer=0;this.bytecount=2;this.push_irq();break;case 90:this.push_irq();this.status=80;break;default:this.status=80}}; |
| IDEDevice.prototype.do_write=function(){this.status=80;this.buffer.set(this.write_dest,this.data_port_buffer.subarray(0,this.data_port_count),function(){this.push_irq()}.bind(this));this.stats.sectors_written+=this.data_port_count/this.sector_size|0;this.stats.bytes_written+=this.data_port_count};IDEDevice.prototype.read_status=function(){var a=this.status;0<=this.next_status&&(this.status=this.next_status,this.next_status=-1);return a}; |
| IDEDevice.prototype.write_control=function(a){this.device_control=a;a&4&&(this.is_atapi?(this.status=81,this.sector=this.lba_count=this.bytecount=1,this.cylinder_low=20,this.cylinder_high=235):(this.status=81,this.sector=this.lba_count=this.bytecount=1,this.cylinder_low=60,this.cylinder_high=195))};IDEDevice.prototype.allocate_in_buffer=function(a){a>this.data_port_buffer.length&&(this.data_port_buffer=new Uint8Array(a));this.data_port_count=a;this.data_port_current=0}; |
| IDEDevice.prototype.atapi_read=function(a){var b=(a[7]<<8|a[8])*this.sector_size,c=(this.cylinder_high&255)<<8|this.cylinder_low&255;a=(a[2]<<24|a[3]<<16|a[4]<<8|a[5])*this.sector_size;c||(c=32768);c=Math.min(b,c);this.cylinder_low=c&255;this.cylinder_high=c>>8&255;a>=this.buffer.byteLength?(this.status=255,this.push_irq()):(b=Math.min(b,this.buffer.byteLength-a),this.status=128,this.stats.loading=!0,this.buffer.get(a,b,function(a){this.pio_data=a;this.status=88;this.data_pointer=0;this.push_irq(); |
| this.stats.loading=!1;this.stats.sectors_read+=b/this.sector_size|0;this.stats.bytes_read+=b}.bind(this)))}; |
| IDEDevice.prototype.atapi_read_dma=function(a){var b=(a[7]<<8|a[8])*this.sector_size;a=(a[2]<<24|a[3]<<16|a[4]<<8|a[5])*this.sector_size;a>=this.buffer.byteLength?(this.status=255,this.push_irq()):(b=Math.min(b,this.buffer.byteLength-a),this.status=128,this.stats.loading=!0,this.buffer.get(a,b,function(a){var d=this.prdt_addr,e=0;do{var f=this.memory.read32s(d),g=this.memory.read16(d+4),l=this.memory.read8(d+7)&128;g||(g=65536);this.memory.write_blob(a.subarray(e,e+g),f);e+=g;d+=8}while(!l);this.status= |
| 80;this.dma_status&=-4;this.dma_status|=4;this.push_irq();this.stats.loading=!1;this.stats.sectors_read+=b/this.sector_size|0;this.stats.bytes_read+=b}.bind(this)))};IDEDevice.prototype.read_data_port8=function(){return this.read_data()};IDEDevice.prototype.read_data_port16=function(){return this.read_data()|this.read_data()<<8};IDEDevice.prototype.read_data_port32=function(){return this.read_data()|this.read_data()<<8|this.read_data()<<16|this.read_data()<<24}; |
| IDEDevice.prototype.read_lba_port=function(){return this.lba_count&255};IDEDevice.prototype.read_bytecount_port=function(){return this.bytecount&255};IDEDevice.prototype.read_sector_port=function(){return this.sector&255}; |
| IDEDevice.prototype.read_data=function(){if(this.data_pointer<this.pio_data.length){0!==(this.data_pointer+1)%(512*this.sectors_per_drq)&&this.data_pointer+1!==this.pio_data.length||this.push_irq();this.cylinder_low?this.cylinder_low--:this.cylinder_high&&(this.cylinder_high--,this.cylinder_low=255);if(!this.cylinder_low&&!this.cylinder_high){var a=this.pio_data.length-this.data_pointer-1;65536<=a?(this.cylinder_high=240,this.cylinder_low=0):(this.cylinder_high=a>>8,this.cylinder_low=a)}this.data_pointer+ |
| 1>=this.pio_data.length&&(this.status=80);return this.pio_data[this.data_pointer++]}this.data_pointer++;return 0};IDEDevice.prototype.write_data_port8=function(a){this.data_port_current>=this.data_port_count||(this.data_port_buffer[this.data_port_current++]=a,0===this.data_port_current%(512*this.sectors_per_drq)&&this.push_irq(),this.data_port_current===this.data_port_count&&this.do_callback())}; |
| IDEDevice.prototype.write_data_port16=function(a){this.write_data_port8(a&255);this.write_data_port8(a>>8&255)};IDEDevice.prototype.write_data_port32=function(a){this.write_data_port8(a&255);this.write_data_port8(a>>8&255);this.write_data_port8(a>>16&255);this.write_data_port8(a>>24&255)};IDEDevice.prototype.write_lba_port=function(a){this.lba_count=(this.lba_count<<8|a)&65535};IDEDevice.prototype.write_bytecount_port=function(a){this.bytecount=(this.bytecount<<8|a)&65535}; |
| IDEDevice.prototype.write_sector_port=function(a){this.sector=(this.sector<<8|a)&65535}; |
| IDEDevice.prototype.ata_read_sectors=function(a){if(32===a||196===a){a=this.bytecount&255;var b=this.is_lba?this.get_lba28():this.get_chs();0===a&&(a=256)}else if(36===a||41===a)a=this.bytecount,b=this.get_lba48(),0===a&&(a=65536);else return;var c=a*this.sector_size,b=b*this.sector_size;this.cylinder_low+=a;b+c>this.buffer.byteLength?(this.status=255,this.push_irq()):(this.status=128,this.stats.loading=!0,this.buffer.get(b,c,function(a){this.pio_data=a;this.status=88;this.data_pointer=0;this.push_irq(); |
| this.stats.loading=!1;this.stats.sectors_read+=c/this.sector_size|0;this.stats.bytes_read+=c}.bind(this)))}; |
| IDEDevice.prototype.ata_read_sectors_dma=function(){var a=this.bytecount&255,b=a*this.sector_size,c=this.get_lba28()*this.sector_size;this.cylinder_low+=a;c+b>this.buffer.byteLength?(this.status=255,this.push_irq()):(this.status=128,this.dma_status|=1,this.stats.loading=!0,this.buffer.get(c,b,function(a){var c=this.prdt_addr,f=0;do{var g=this.memory.read32s(c),l=this.memory.read16(c+4),k=this.memory.read8(c+7)&128;l||(l=65536);this.memory.write_blob(a.subarray(f,f+l),g);f+=l;c+=8}while(!k);this.status= |
| 80;this.dma_status&=-4;this.dma_status|=4;this.push_irq();this.stats.loading=!1;this.stats.sectors_read+=b/this.sector_size|0;this.stats.bytes_read+=b}.bind(this)))}; |
| IDEDevice.prototype.ata_write=function(a){if(48===a){a=this.bytecount&255;var b=this.is_lba?this.get_lba28():this.get_chs();0===a&&(a=256)}else if(52===a||57===a)a=this.bytecount,b=this.get_lba48(),0===a&&(a=65536);else return;var c=a*this.sector_size,b=b*this.sector_size;this.cylinder_low+=a;b+c>this.buffer.byteLength?this.status=255:(this.status=80,this.next_status=88,this.allocate_in_buffer(c),this.write_dest=b,this.data_port_callback=1);this.push_irq()}; |
| IDEDevice.prototype.ata_write_dma=function(){var a=this.bytecount&255,b=a*this.sector_size,c=this.get_lba28()*this.sector_size;this.cylinder_low+=a;if(c+b>this.buffer.byteLength)this.status=255,this.push_irq();else{this.status=128;this.dma_status|=1;var a=this.prdt_addr,d=0,e=0,f=0;do{var g=this.memory.read32s(a),l=this.memory.read16(a+4),k=this.memory.read8(a+7)&128;l||(l=65536);this.buffer.set(c+f,this.memory.mem8.subarray(g,g+l),function(){e++;e===d&&(this.status=80,this.push_irq(),this.dma_status&= |
| -4,this.dma_status|=4)}.bind(this));f+=l;a+=8;d++}while(!k);e===d&&(this.status=80,this.push_irq(),this.dma_status&=-4,this.dma_status|=4);this.stats.sectors_written+=b/this.sector_size|0;this.stats.bytes_written+=b}};IDEDevice.prototype.get_chs=function(){return((this.cylinder_low&255|this.cylinder_high<<8&65280)*this.head_count+this.head)*this.IDEDevice$sectors_per_track+(this.sector&255)-1}; |
| IDEDevice.prototype.get_lba28=function(){return this.sector&255|this.cylinder_low<<8&65280|this.cylinder_high<<16&16711680};IDEDevice.prototype.get_lba48=function(){return(this.sector&255|this.cylinder_low<<8&65280|this.cylinder_high<<16&16711680|this.sector>>8<<24&4278190080)>>>0}; |
| IDEDevice.prototype.create_identify_packet=function(){this.data_pointer=0;this.drive_head&16?this.pio_data=new Uint8Array(0):(this.pio_data=new Uint8Array([64,this.is_atapi?133:0,this.cylinder_count,this.cylinder_count>>8,0,0,this.head_count,this.head_count>>8,0,0,0,0,this.IDEDevice$sectors_per_track,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,3,0,0,2,4,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, |
| 32,255,0,1,0,0,3,0,0,0,2,0,2,7,0,this.cylinder_count,this.cylinder_count>>8,this.head_count,this.head_count>>8,this.IDEDevice$sectors_per_track,0,this.sector_count&255,this.sector_count>>8&255,this.sector_count>>16&255,this.sector_count>>24&255,0,0,this.sector_count&255,this.sector_count>>8&255,this.sector_count>>16&255,this.sector_count>>24&255,0,0,0,4,0,0,30,0,30,0,30,0,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,126,0,0,0,0,0,0,116,0,64,0,64,0,116,0,64,0,0,0,0,0,0,0,0,0,0,1,96,0,0,0,0,0,0, |
| 0,0,0,0,0,0,this.sector_count&255,this.sector_count>>8&255,this.sector_count>>16&255,this.sector_count>>24&255]),16383<this.cylinder_count&&(this.pio_data[2]=this.pio_data[108]=255,this.pio_data[3]=this.pio_data[109]=63))};IDEDevice.prototype.dma_read_addr=function(){return this.prdt_addr};IDEDevice.prototype.dma_set_addr=function(a){this.prdt_addr=a};IDEDevice.prototype.dma_read_status=function(){return this.dma_status};IDEDevice.prototype.dma_write_status=function(a){this.dma_status&=~a}; |
| IDEDevice.prototype.dma_read_command=function(){return 1|this.dma_status<<16};IDEDevice.prototype.dma_read_command8=function(){return 1};IDEDevice.prototype.dma_write_command=function(a){a&1&&this.push_irq();this.dma_write_status(a>>16&255)};IDEDevice.prototype.dma_write_command8=function(a){a&1&&this.push_irq()};function PCI(a){function b(a){var b=c[2]<<8|c[1],d=c[0]&252,e=l[b],b=k[b];e&&3===a&&16<=d&&40>d&&(a=d-16>>2,b=b.pci_bars,a<b.length&&b[a]||(e[d>>2]=0))}a=a.io;var c=new Uint8Array(4),d=new Uint8Array(4),e=new Uint8Array(4);new Int32Array(c.buffer);var f=new Int32Array(d.buffer),g=new Int32Array(e.buffer),l=Array(65536),k=Array(65536);a.register_write_consecutive(3324,this,function(){b(0)},function(){b(1)},function(){b(2)},function(){b(3)});a.register_read_consecutive(3324,this,function(){return d[0]}, |
| function(){return d[1]},function(){return d[2]},function(){return d[3]});a.register_read_consecutive(3320,this,function(){return e[0]},function(){return e[1]},function(){return e[2]},function(){return e[3]});a.register_write_consecutive(3320,this,function(a){c[0]=a},function(a){c[1]=a},function(a){c[2]=a},function(a){c[3]=a;a=c[0]&252;var b=l[c[2]<<8|c[1]];void 0!==b?(g[0]=-2147483648,f[0]=a<b.byteLength?b[a>>2]:-1):(f[0]=-1,g[0]=0)});this.register_device=function(a){var b=a.pci_id;l[b]=new Int32Array((new Uint8Array(a.pci_space)).buffer); |
| k[b]=a};this.register_device({pci_id:0,pci_space:[134,128,55,18,0,0,0,0,2,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],pci_bars:[]});this.register_device({pci_id:8,pci_space:[134,128,0,112,7,0,0,2,0,0,1,6,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],pci_bars:[]})};function FloppyController(a,b,c){this.io=a.io;this.pic=a.devices.pic;this.dma=a.devices.dma;this.bytes_expecting=0;this.receiving_command=new Uint8Array(10);this.receiving_index=0;this.next_command=null;this.response_data=new Uint8Array(10);this.floppy_size=this.response_length=this.response_index=0;this.fda_image=b;this.fdb_image=c;this.last_cylinder=0;this._state_skip=[this.io,this.pic,this.dma];this.fdb_image&&this._state_skip.push(this.fdb_image);if(b){this._state_skip.push(this.fda_image);this.floppy_size= |
| b.byteLength;if((a={160:{type:1,tracks:40,sectors:8,heads:1},180:{type:1,tracks:40,sectors:9,heads:1},200:{type:1,tracks:40,sectors:10,heads:1},320:{type:1,tracks:40,sectors:8,heads:2},360:{type:1,tracks:40,sectors:9,heads:2},400:{type:1,tracks:40,sectors:10,heads:2},720:{type:3,tracks:80,sectors:9,heads:2},1200:{type:2,tracks:80,sectors:15,heads:2},1440:{type:4,tracks:80,sectors:18,heads:2},1722:{type:5,tracks:82,sectors:21,heads:2},2880:{type:5,tracks:80,sectors:36,heads:2}}[this.floppy_size>>10])&& |
| 0===(this.floppy_size&1023))this.type=a.type,b=a.sectors,a=a.heads;else throw"Unknown floppy size: "+h(b.byteLength);this.FloppyController$sectors_per_track=b;this.number_of_heads=a;this.io.register_read(1008,this,this.port3F0_read);this.io.register_read(1010,this,this.port3F2_read);this.io.register_read(1012,this,this.port3F4_read);this.io.register_read(1013,this,this.port3F5_read);this.io.register_read(1015,this,this.port3F7_read);this.io.register_write(1010,this,this.port3F2_write);this.io.register_write(1013, |
| this,this.port3F5_write)}else this.type=4,this.io.register_read(1012,this,function(){return 255})}FloppyController.prototype.port3F0_read=function(){return 0};FloppyController.prototype.port3F4_read=function(){var a=128;this.response_index<this.response_length&&(a|=80);0===(dor&8)&&(a|=32);return a};FloppyController.prototype.port3F7_read=function(){return 0}; |
| FloppyController.prototype.port3F5_read=function(){return this.response_index<this.response_length?this.response_data[this.response_index++]:255}; |
| FloppyController.prototype.port3F5_write=function(a){if(0<this.bytes_expecting)this.receiving_command[this.receiving_index++]=a,this.bytes_expecting--,0===this.bytes_expecting&&this.next_command.call(this,this.receiving_command);else{switch(a){case 3:this.next_command=this.fix_drive_data;this.bytes_expecting=2;break;case 4:this.next_command=this.check_drive_status;this.bytes_expecting=1;break;case 5:case 197:this.next_command=function(a){this.do_sector(!0,a)};this.bytes_expecting=8;break;case 230:this.next_command= |
| function(a){this.do_sector(!1,a)};this.bytes_expecting=8;break;case 7:this.next_command=this.calibrate;this.bytes_expecting=1;break;case 8:this.check_interrupt_status();break;case 74:this.next_command=this.read_sector_id;this.bytes_expecting=1;break;case 15:this.bytes_expecting=2;this.next_command=this.FloppyController_prototype$seek;break;case 14:this.response_data[0]=128,this.response_index=0,this.response_length=1,this.bytes_expecting=0}this.receiving_index=0}};var dor=0; |
| FloppyController.prototype.port3F2_read=function(){return dor};FloppyController.prototype.port3F2_write=function(a){4===(a&4)&&0===(dor&4)&&this.pic.push_irq(6);dor=a};FloppyController.prototype.check_drive_status=function(){this.response_index=0;this.response_length=1;this.response_data[0]=32};FloppyController.prototype.FloppyController_prototype$seek=function(a){this.last_cylinder=a[1];dor&8&&this.pic.push_irq(6)};FloppyController.prototype.calibrate=function(){dor&8&&this.pic.push_irq(6)}; |
| FloppyController.prototype.check_interrupt_status=function(){this.response_index=0;this.response_length=2;this.response_data[0]=32;this.response_data[1]=this.last_cylinder};FloppyController.prototype.do_sector=function(a,b){var c=b[2],d=b[1],e=b[3],f=128<<b[4],g=b[5]-b[3]+1,l=((c+this.number_of_heads*d)*this.FloppyController$sectors_per_track+e-1)*f;a?this.dma.do_write(this.fda_image,l,g*f,2,this.done.bind(this,b,d,c,e)):this.dma.do_read(this.fda_image,l,this.done.bind(this,b,d,c,e))}; |
| FloppyController.prototype.done=function(a,b,c,d,e){e||(d++,d>this.FloppyController$sectors_per_track&&(d=1,c++,c>=this.number_of_heads&&(c=0,a++)),this.last_cylinder=a,this.response_index=0,this.response_length=7,this.response_data[0]=c<<2|32,this.response_data[1]=0,this.response_data[2]=0,this.response_data[3]=a,this.response_data[4]=c,this.response_data[5]=d,this.response_data[6]=b[4],dor&8&&this.pic.push_irq(6))};FloppyController.prototype.fix_drive_data=function(){}; |
| FloppyController.prototype.read_sector_id=function(){this.response_index=0;this.response_length=7;this.response_data[0]=0;this.response_data[1]=0;this.response_data[2]=0;this.response_data[3]=0;this.response_data[4]=0;this.response_data[5]=0;this.response_data[6]=0;dor&8&&this.pic.push_irq(6)};function Memory(a){this.size=a;this.memory_map_registered=new Uint8Array(262144);this.memory_map_read8=[];this.memory_map_write8=[];this.memory_map_read32=[];this.memory_map_write32=[];this.buffer=new ArrayBuffer(a);this._state_restore()} |
| Memory.prototype._state_restore=function(){this.mem8=new Uint8Array(this.buffer);this.mem16=new Uint16Array(this.buffer);this.mem32s=new Int32Array(this.buffer);this._state_skip=[this.mem8,this.mem16,this.mem32s,this.memory_map_registered,this.memory_map_read8,this.memory_map_read32,this.memory_map_write8,this.memory_map_write32]};Memory.prototype.mmap_read8=function(a){return this.memory_map_read8[a>>>14](a)};Memory.prototype.mmap_write8=function(a,b){this.memory_map_write8[a>>>14](a,b)}; |
| Memory.prototype.mmap_read16=function(a){var b=this.memory_map_read8[a>>>14];return b(a)|b(a+1)<<8};Memory.prototype.mmap_write16=function(a,b){var c=this.memory_map_write8[a>>>14];c(a,b&255);c(a+1,b>>8&255)};Memory.prototype.mmap_read32=function(a){return this.memory_map_read32[a>>>14](a)};Memory.prototype.mmap_write32=function(a,b){this.memory_map_write32[a>>>14](a,b)};Memory.prototype.read8=function(a){return this.memory_map_registered[a>>>14]?this.mmap_read8(a):this.mem8[a]}; |
| Memory.prototype.read16=function(a){return this.memory_map_registered[a>>>14]?this.mmap_read16(a):this.mem8[a]|this.mem8[a+1]<<8};Memory.prototype.read_aligned16=function(a){return this.memory_map_registered[a>>>13]?this.mmap_read16(a<<1):this.mem16[a]};Memory.prototype.read32s=function(a){return this.memory_map_registered[a>>>14]?this.mmap_read32(a):this.mem8[a]|this.mem8[a+1]<<8|this.mem8[a+2]<<16|this.mem8[a+3]<<24}; |
| Memory.prototype.read_aligned32=function(a){return this.memory_map_registered[a>>>12]?this.mmap_read32(a<<2):this.mem32s[a]};Memory.prototype.write8=function(a,b){this.memory_map_registered[a>>>14]?this.mmap_write8(a,b):this.mem8[a]=b};Memory.prototype.write16=function(a,b){this.memory_map_registered[a>>>14]?this.mmap_write16(a,b):(this.mem8[a]=b,this.mem8[a+1]=b>>8)};Memory.prototype.write_aligned16=function(a,b){this.memory_map_registered[a>>>13]?this.mmap_write16(a<<1,b):this.mem16[a]=b}; |
| Memory.prototype.write32=function(a,b){this.memory_map_registered[a>>>14]?this.mmap_write32(a,b):(this.mem8[a]=b,this.mem8[a+1]=b>>8,this.mem8[a+2]=b>>16,this.mem8[a+3]=b>>24)};Memory.prototype.write_aligned32=function(a,b){this.memory_map_registered[a>>>12]?this.mmap_write32(a<<2,b):this.mem32s[a]=b};Memory.prototype.write_blob=function(a,b){this.mem8.set(a,b)};function DMA(a){this.memory=a.memory;this.channels=[{address:0,count:0},{address:0,count:0},{address:0,count:0},{address:0,count:0}];this.lsb_msb_flipflop=0;a=a.io;a.register_write(4,this,this.port_write.bind(this,4));a.register_write(5,this,this.port_write.bind(this,5));a.register_write(10,this,this.portA_write);a.register_write(11,this,this.portB_write);a.register_write(12,this,this.portC_write);a.register_write(129,this,this.port81_write);this._state_skip=[this.memory]} |
| DMA.prototype.port_write=function(a,b){if(8>a){var c=a>>1;a&1?this.channels[c].count=this.flipflop_get(this.channels[c].count,b):this.channels[c].address=this.flipflop_get(this.channels[c].address,b)}};DMA.prototype.portA_write=function(){};DMA.prototype.portB_write=function(){};DMA.prototype.portC_write=function(){this.lsb_msb_flipflop=0};DMA.prototype.port81_write=function(a){this.channels[2].address=this.channels[2].address&65535|a<<16}; |
| DMA.prototype.do_read=function(a,b,c){var d=this.channels[2].count+1,e=this.channels[2].address;if(b+d>a.byteLength)c(!0);else{var f=this.memory;this.channels[2].address+=d;a.get(b,d,function(a){f.write_blob(a,e);c(!1)})}};DMA.prototype.do_write=function(a,b,c,d,e){c=this.channels[d].count;var f=this.channels[d].address;b+c>a.byteLength?e(!0):(this.channels[d].address+=c,a.set(b,new Uint8Array(this.memory.buffer,f,c+1),function(){e(!1)}))}; |
| DMA.prototype.flipflop_get=function(a,b){return(this.lsb_msb_flipflop^=1)?a&-256|b:a&-65281|b<<8};function PIT(a){this.pic=a.devices.pic;this.PIT$next_tick=Date.now();this.counter_next_low=new Uint8Array(4);this.counter_enabled=new Uint8Array(4);this.counter_mode=new Uint8Array(4);this.counter_read_mode=new Uint8Array(4);this.counter_latch=new Uint8Array(4);this.counter_latch_value=new Uint16Array(3);this.counter_reload=new Uint16Array(3);this.counter_current=new Uint16Array(3);this.counter2_out=0;a.io.register_read(97,this,function(){return(66.66666666666667*v86.microtick()&1)<<4|this.counter2_out<< |
| 5});a.io.register_read(64,this,function(){return this.counter_read(0)});a.io.register_read(65,this,function(){return this.counter_read(1)});a.io.register_read(66,this,function(){return this.counter_read(2)});a.io.register_write(64,this,function(a){this.counter_write(0,a)});a.io.register_write(65,this,function(a){this.counter_write(1,a)});a.io.register_write(66,this,function(a){this.counter_write(2,a)});a.io.register_write(67,this,this.port43_write);this._state_skip=[this.pic]} |
| PIT.prototype.timer=function(a,b){var c,d,e=1193.1816666*(a-this.PIT$next_tick)>>>0;if(e){this.PIT$next_tick+=e/1193.1816666;if(!b&&this.counter_enabled[0]&&(c=this.counter_current[0]-=e,0>=c))if(this.pic.push_irq(0),d=this.counter_mode[0],0===d)this.counter_enabled[0]=0,this.counter_current[0]=0;else if(3===d||2===d)this.counter_current[0]=this.counter_reload[0]+c%this.counter_reload[0];this.counter_enabled[2]&&(c=this.counter_current[2]-=e,0>=c&&(d=this.counter_mode[2],0===d?(this.counter2_out= |
| 1,this.counter_enabled[2]=0,this.counter_current[2]=0):2===d?(this.counter2_out=1,this.counter_current[2]=this.counter_reload[2]+c%this.counter_reload[2]):3===d&&(this.counter2_out^=1,this.counter_current[2]=this.counter_reload[2]+c%this.counter_reload[2])))}}; |
| PIT.prototype.counter_read=function(a){var b=this.counter_latch[a];if(b)return this.counter_latch[a]--,2===b?this.counter_latch_value[a]&255:this.counter_latch_value[a]>>8;b=this.counter_next_low[a];3===this.counter_mode[a]&&(this.counter_next_low[a]^=1);return b?this.counter_current[a]&255:this.counter_current[a]>>8}; |
| PIT.prototype.counter_write=function(a,b){this.counter_reload[a]=this.counter_next_low[a]?this.counter_reload[a]&-256|b:this.counter_reload[a]&255|b<<8;3===this.counter_read_mode[a]&&this.counter_next_low[a]||(this.counter_reload[a]||(this.counter_reload[a]=65535),this.counter_current[a]=this.counter_reload[a],this.counter_enabled[a]=!0);3===this.counter_read_mode[a]&&(this.counter_next_low[a]^=1)}; |
| PIT.prototype.port43_write=function(a){var b=a>>1&7,c=a>>6&3;a=a>>4&3;3!==c&&(0===a?(this.counter_latch[c]=2,this.counter_latch_value[c]=this.counter_current[c]):(6<=b&&(b&=-5),this.counter_next_low[c]=1===a?0:1,this.counter_mode[c]=b,this.counter_read_mode[c]=a,2===c&&(this.counter2_out=0===b?0:1)))};function VGAScreen(a,b,c){this.bus=b;this.vga_memory_size=c;this.cursor_address=0;this.cursor_scanline_start=14;this.cursor_scanline_end=15;this.max_cols=80;this.max_rows=25;this.start_address=this.screen_height=this.screen_width=0;this.graphical_mode_is_linear=!0;this.do_complete_redraw=this.graphical_mode=!1;this.vga256_palette=new Int32Array(256);this.svga_height=this.svga_width=this.latch3=this.latch2=this.latch1=this.latch0=0;this.text_mode_width=80;this.svga_enabled=!1;this.svga_offset=this.svga_bpp= |
| 0;this.pci_space=[222,16,32,10,7,0,0,0,162,0,0,3,0,0,128,0,8,0,0,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,1,0,0];this.pci_id=144;this.pci_bars=[{size:this.vga_memory_size}];a.devices.pci.register_device(this);this.stats={is_graphical:!1,res_x:0,res_y:0,bpp:0};this.dac_color_index=this.index_crtc=0;this.attribute_controller_index=-1;this.dac_map=new Uint8Array(16);this.sequencer_index=-1;this.plane_write_bm=15;this.sequencer_memory_mode=0;this.graphics_index= |
| -1;this.planar_rotate_reg=this.planar_mode=this.plane_read=0;this.planar_bitmap=255;this.max_scan_line=0;this.port_3DA_value=this.miscellaneous_output_register=255;a=a.io;a.register_write(960,this,this.port3C0_write);a.register_read(960,this,this.port3C0_read);a.register_read(961,this,this.port3C1_read);a.register_write(962,this,this.port3C2_write);a.register_write_consecutive(964,this,this.port3C4_write,this.port3C5_write);a.register_read(964,this,this.port3C4_read);a.register_read(965,this,this.port3C5_read); |
| a.register_write_consecutive(974,this,this.port3CE_write,this.port3CF_write);a.register_read(974,this,this.port3CE_read);a.register_read(975,this,this.port3CF_read);a.register_write(967,this,this.port3C7_write);a.register_write(968,this,this.port3C8_write);a.register_write(969,this,this.port3C9_write);a.register_read(972,this,this.port3CC_read);a.register_write_consecutive(980,this,this.port3D4_write,this.port3D5_write);a.register_read(981,this,this.port3D5_read);a.register_read(986,this,this.port3DA_read); |
| this.dispi_index=-1;this.dispi_enable_value=0;a.register_write(462,this,void 0,this.port1CE_write);a.register_write(463,this,void 0,this.port1CF_write);a.register_read(463,this,void 0,this.port1CF_read);void 0===this.vga_memory_size||262144>this.vga_memory_size?this.vga_memory_size=262144:this.vga_memory_size&65535&&(this.vga_memory_size|=65535,this.vga_memory_size++);this.svga_memory=new Uint8Array(this.vga_memory_size);this._state_restore();var d=this;a.mmap_register(655360,131072,function(a){return d.vga_memory_read(a)}, |
| function(a,b){d.vga_memory_write(a,b)});a.mmap_register(3758096384,this.vga_memory_size,function(a){return d.svga_memory_read8(a)},function(a,b){d.svga_memory_write8(a,b)},function(a){return d.svga_memory_read32(a)},function(a,b){d.svga_memory_write32(a,b)})} |
| VGAScreen.prototype._state_restore=function(){this.svga_memory16=new Uint16Array(this.svga_memory.buffer);this.svga_memory32=new Int32Array(this.svga_memory.buffer);this.vga_memory=new Uint8Array(this.svga_memory.buffer,0,262144);this.plane0=new Uint8Array(this.svga_memory.buffer,0,65536);this.plane1=new Uint8Array(this.svga_memory.buffer,65536,65536);this.plane2=new Uint8Array(this.svga_memory.buffer,131072,65536);this.plane3=new Uint8Array(this.svga_memory.buffer,196608,65536);this._state_skip= |
| [this.bus,this.svga_memory16,this.svga_memory32,this.vga_memory,this.plane0,this.plane1,this.plane2,this.plane3];this.bus.send("screen-set-mode",this.graphical_mode||this.svga_enabled);this.graphical_mode||this.svga_enabled?this.set_size_graphical(this.svga_width,this.svga_height):(this.set_size_text(this.max_cols,this.max_rows),this.update_cursor_scanline(),this.update_cursor());this.do_complete_redraw=!0}; |
| VGAScreen.prototype.vga_memory_read=function(a){a-=655360;if(!this.graphical_mode||this.graphical_mode_is_linear)return this.vga_memory[a];a&=65535;this.latch0=this.plane0[a];this.latch1=this.plane1[a];this.latch2=this.plane2[a];this.latch3=this.plane3[a];return this.vga_memory[this.plane_read<<16|a]}; |
| VGAScreen.prototype.vga_memory_write=function(a,b){a-=655360;this.graphical_mode?this.graphical_mode_is_linear?this.vga_memory_write_graphical_linear(a,b):this.vga_memory_write_graphical_planar(a,b):this.vga_memory_write_text_mode(a,b)}; |
| VGAScreen.prototype.vga_memory_write_graphical_linear=function(a,b){var c=a<<2,d=this.vga256_palette[b];this.bus.send("screen-put-pixel-linear",[c|2,d>>16&255]);this.bus.send("screen-put-pixel-linear",[c|1,d>>8&255]);this.bus.send("screen-put-pixel-linear",[c,d&255]);this.vga_memory[a]=b}; |
| VGAScreen.prototype.vga_memory_write_graphical_planar=function(a,b){if(!(65535<a)){var c,d,e,f,g=this.planar_mode&3;0===g?c=d=e=f=b:2===g&&(this.plane_write_bm&1&&(c=this.latch0&~this.planar_bitmap|(b&1?255:0)&this.planar_bitmap),this.plane_write_bm&2&&(d=this.latch1&~this.planar_bitmap|(b&2?255:0)&this.planar_bitmap),this.plane_write_bm&4&&(e=this.latch2&~this.planar_bitmap|(b&4?255:0)&this.planar_bitmap),this.plane_write_bm&8&&(f=this.latch3&~this.planar_bitmap|(b&8?255:0)&this.planar_bitmap)); |
| if(0===g||2===g){switch(this.planar_rotate_reg&24){case 8:c&=this.latch0;d&=this.latch1;e&=this.latch2;f&=this.latch3;break;case 16:c|=this.latch0;d|=this.latch1;e|=this.latch2;f|=this.latch3;break;case 24:c^=this.latch0,d^=this.latch1,e^=this.latch2,f^=this.latch3}this.plane_write_bm&1&&(c=this.latch0&~this.planar_bitmap|c&this.planar_bitmap);this.plane_write_bm&2&&(d=this.latch1&~this.planar_bitmap|d&this.planar_bitmap);this.plane_write_bm&4&&(e=this.latch2&~this.planar_bitmap|e&this.planar_bitmap); |
| this.plane_write_bm&8&&(f=this.latch3&~this.planar_bitmap|f&this.planar_bitmap)}else 1===g&&(c=this.latch0,d=this.latch1,e=this.latch2,f=this.latch3);this.plane_write_bm&1?this.plane0[a]=c:c=this.plane0[a];this.plane_write_bm&2?this.plane1[a]=d:d=this.plane1[a];this.plane_write_bm&4?this.plane2[a]=e:e=this.plane2[a];this.plane_write_bm&8?this.plane3[a]=f:f=this.plane3[a];if(!(a>=this.screen_width*this.screen_height<<3)){d<<=1;e<<=2;f<<=3;for(var g=(a<<3|7)<<2,l=0;8>l;l++){var k=this.vga256_palette[this.dac_map[c>> |
| l&1|d>>l&2|e>>l&4|f>>l&8]];this.bus.send("screen-put-pixel-linear",[g|2,k>>16]);this.bus.send("screen-put-pixel-linear",[g|1,k>>8&255]);this.bus.send("screen-put-pixel-linear",[g,k&255]);g-=4}}}};VGAScreen.prototype.text_mode_redraw=function(){for(var a=98304|this.start_address<<1,b,c,d=0;d<this.max_rows;d++)for(var e=0;e<this.max_cols;e++)b=this.vga_memory[a],c=this.vga_memory[a|1],this.bus.send("screen-put-char",[d,e,b,this.vga256_palette[c>>4&15],this.vga256_palette[c&15]]),a+=2}; |
| VGAScreen.prototype.graphical_planar_redraw=function(){for(var a=0,b=0;b<this.screen_height;b++)for(var c=0;c<this.screen_width;c+=8){for(var d=0;8>d;d++)this.bus.send("screen-put-pixel-linear32",[b*this.screen_width+c<<2,this.vga256_palette[this.dac_map[this.plane0[a]>>d&1|this.plane1[a]>>d<<1&2|this.plane2[a]>>d<<2&4|this.plane3[a]>>d<<3&8]]]);a++}}; |
| VGAScreen.prototype.vga_memory_write_text_mode=function(a,b){if(!(98304>a)){var c=(a-98304>>1)-this.start_address,d=c/this.max_cols|0,c=c%this.max_cols,e,f;a&1?(f=b,e=this.vga_memory[a&-2]):(e=b,f=this.vga_memory[a|1]);this.bus.send("screen-put-char",[d,c,e,this.vga256_palette[f>>4&15],this.vga256_palette[f&15]]);this.vga_memory[a]=b}}; |
| VGAScreen.prototype.update_cursor=function(){var a=(this.cursor_address-this.start_address)/this.max_cols|0,b=(this.cursor_address-this.start_address)%this.max_cols,a=Math.min(this.max_rows-1,a);this.bus.send("screen-update-cursor",[a,b])};VGAScreen.prototype.svga_memory_read8=function(a){return this.svga_memory[a&268435455]}; |
| VGAScreen.prototype.svga_memory_read32=function(a){a&=268435455;return a&3?this.svga_memory[a]|this.svga_memory[a+1]<<8|this.svga_memory[a+2]<<16|this.svga_memory[a+3]<<24:this.svga_memory32[a>>2]}; |
| VGAScreen.prototype.svga_memory_write8=function(a,b){a&=268435455;this.svga_memory[a]=b;if(this.svga_enabled&&(a-=this.svga_offset,!(0>a)))switch(this.svga_bpp){case 32:3!==(a&3)&&this.bus.send("screen-put-pixel-linear",[a,b]);break;case 24:this.bus.send("screen-put-pixel-linear",[(a<<2)/3|0,b]);break;case 16:if(a&1){var c=this.svga_memory16[a>>1],d,e;e=255*(b>>3&31)/31|0;d=255*(c>>5&63)/63|0;c=255*(c&31)/31|0;a<<=1;this.bus.send("screen-put-pixel-linear",[a,c]);this.bus.send("screen-put-pixel-linear", |
| [a-1,d]);this.bus.send("screen-put-pixel-linear",[a-2,e])}break;case 8:d=this.vga256_palette[b],e=a<<2,this.bus.send("screen-put-pixel-linear",[e,d>>16&255]),this.bus.send("screen-put-pixel-linear",[e|1,d>>8&255]),this.bus.send("screen-put-pixel-linear",[e|2,d&255])}}; |
| VGAScreen.prototype.svga_memory_write32=function(a,b){a&=268435455;if(a&3||32!==this.svga_bpp)this.svga_memory_write8(a,b&255),this.svga_memory_write8(a+1,b>>8&255),this.svga_memory_write8(a+2,b>>16&255),this.svga_memory_write8(a+3,b>>24&255);else if(this.svga_memory32[a>>2]=b,this.svga_enabled&&(a-=this.svga_offset,!(0>a)))switch(this.svga_bpp){case 32:this.bus.send("screen-put-pixel-linear32",[a,b])}}; |
| VGAScreen.prototype.svga_redraw=function(){var a=this.svga_offset,b=this.svga_height*this.svga_width,c=0;if(32===this.svga_bpp)for(var d=new Int32Array(this.svga_memory.buffer),a=a>>2,b=b<<2;c<b;)this.bus.send("screen-put-pixel-linear32",[c,d[a++]]),c+=4;else if(24===this.svga_bpp)for(b<<=2;c<b;)this.bus.send("screen-put-pixel-linear",[c++,this.svga_memory[a++]]),this.bus.send("screen-put-pixel-linear",[c++,this.svga_memory[a++]]),this.bus.send("screen-put-pixel-linear",[c++,this.svga_memory[a++]]), |
| c++};VGAScreen.prototype.timer=function(){this.do_complete_redraw&&(this.do_complete_redraw=!1,this.svga_enabled?this.svga_redraw():this.graphical_mode?this.graphical_mode_is_linear||this.graphical_planar_redraw():this.text_mode_redraw())};VGAScreen.prototype.destroy=function(){};VGAScreen.prototype.set_size_text=function(a,b){this.max_cols=a;this.max_rows=b;this.bus.send("screen-set-size-text",[a,b])}; |
| VGAScreen.prototype.set_size_graphical=function(a,b){this.bus.send("screen-set-size-graphical",[a,b])};VGAScreen.prototype.update_cursor_scanline=function(){this.bus.send("screen-update-cursor-scanline",[this.cursor_scanline_start,this.cursor_scanline_end])}; |
| VGAScreen.prototype.set_video_mode=function(a){var b=!1;switch(a){case 3:this.set_size_text(this.text_mode_width,25);break;case 16:this.screen_width=640;this.screen_height=350;b=!0;this.graphical_mode_is_linear=!1;break;case 18:this.screen_width=640;this.screen_height=480;b=!0;this.graphical_mode_is_linear=!1;break;case 19:this.screen_width=320,this.screen_height=200,this.graphical_mode_is_linear=b=!0}this.bus.send("screen-set-mode",b);if(this.stats.is_graphical=b)this.set_size_graphical(this.screen_width, |
| this.screen_height),this.stats.res_x=this.screen_width,this.stats.res_y=this.screen_height,this.stats.bpp=8;this.graphical_mode=b};VGAScreen.prototype.port3C0_write=function(a){-1===this.attribute_controller_index?this.attribute_controller_index=a:(16>this.attribute_controller_index&&(this.dac_map[this.attribute_controller_index]=a),this.attribute_controller_index=-1)};VGAScreen.prototype.port3C0_read=function(){var a=this.attribute_controller_index;this.attribute_controller_index=-1;return a}; |
| VGAScreen.prototype.port3C1_read=function(){return this.attribute_controller_index=-1};VGAScreen.prototype.port3C2_write=function(a){this.miscellaneous_output_register=a;this.switch_video_mode(a)};VGAScreen.prototype.port3C4_write=function(a){this.sequencer_index=a};VGAScreen.prototype.port3C4_read=function(){return this.sequencer_index};VGAScreen.prototype.port3C5_write=function(a){switch(this.sequencer_index){case 2:this.plane_write_bm=a;break;case 4:this.sequencer_memory_mode=a}}; |
| VGAScreen.prototype.port3C5_read=function(){switch(this.sequencer_index){case 2:return this.plane_write_bm;case 4:return this.sequencer_memory_mode;case 6:return 18}return 0};VGAScreen.prototype.port3C7_write=function(){};VGAScreen.prototype.port3C8_write=function(a){this.dac_color_index=3*a}; |
| VGAScreen.prototype.port3C9_write=function(a){var b=this.dac_color_index/3|0,c=this.dac_color_index%3,d=this.vga256_palette[b];a=255*a/63&255;this.vga256_palette[b]=0===c?d&-16711681|a<<16:1===c?d&-65281|a<<8:d&-256|a;this.dac_color_index++;this.do_complete_redraw=!0};VGAScreen.prototype.port3CC_read=function(){return this.miscellaneous_output_register};VGAScreen.prototype.port3CE_write=function(a){this.graphics_index=a};VGAScreen.prototype.port3CE_read=function(){return this.graphics_index}; |
| VGAScreen.prototype.port3CF_write=function(a){switch(this.graphics_index){case 3:this.planar_rotate_reg=a;break;case 4:this.plane_read=a;break;case 5:this.planar_mode=a;break;case 8:this.planar_bitmap=a}};VGAScreen.prototype.port3CF_read=function(){switch(this.graphics_index){case 3:return this.planar_rotate_reg;case 4:return this.plane_read;case 5:return this.planar_mode;case 8:return this.planar_bitmap}return 0};VGAScreen.prototype.port3D4_write=function(a){this.index_crtc=a}; |
| VGAScreen.prototype.port3D5_write=function(a){switch(this.index_crtc){case 2:this.text_mode_width=a;break;case 9:this.max_scan_line=a;7===(a&31)?this.set_size_text(this.text_mode_width,50):this.set_size_text(this.text_mode_width,25);break;case 10:this.cursor_scanline_start=a;this.update_cursor_scanline();break;case 11:this.cursor_scanline_end=a;this.update_cursor_scanline();break;case 12:this.start_address=this.start_address&255|a<<8;this.do_complete_redraw=!0;break;case 13:this.start_address=this.start_address& |
| 65280|a;this.do_complete_redraw=!0;break;case 14:this.cursor_address=this.cursor_address&255|a<<8;this.update_cursor();break;case 15:this.cursor_address=this.cursor_address&65280|a,this.update_cursor()}};VGAScreen.prototype.port3D5_read=function(){return 9===this.index_crtc?this.max_scan_line:10===this.index_crtc?this.cursor_scanline_start:11===this.index_crtc?this.cursor_scanline_end:14===this.index_crtc?this.cursor_address>>8:15===this.index_crtc?this.cursor_address&255:0}; |
| VGAScreen.prototype.port3DA_read=function(){this.port_3DA_value^=8;this.attribute_controller_index=-1;return this.port_3DA_value};VGAScreen.prototype.switch_video_mode=function(a){103===a?this.set_video_mode(3):227===a?this.set_video_mode(18):99===a?this.set_video_mode(19):163===a?this.set_video_mode(16):this.set_video_mode(3)};VGAScreen.prototype.svga_bytes_per_line=function(){return this.svga_width*(15===this.svga_bpp?16:this.svga_bpp)/8}; |
| VGAScreen.prototype.port1CE_write=function(a){this.dispi_index=a}; |
| VGAScreen.prototype.port1CF_write=function(a){switch(this.dispi_index){case 1:this.svga_width=a;2560<this.svga_width&&(this.svga_width=2560);break;case 2:this.svga_height=a;1600<this.svga_height&&(this.svga_height=1600);break;case 3:this.svga_bpp=a;break;case 4:this.svga_enabled=1===(a&1);this.dispi_enable_value=a;break;case 9:this.svga_offset=a*this.svga_bytes_per_line(),this.do_complete_redraw=!0}!this.svga_enabled||this.svga_width&&this.svga_height||(this.svga_enabled=!1);this.svga_enabled&&4=== |
| this.dispi_index&&(this.set_size_graphical(this.svga_width,this.svga_height),this.bus.send("screen-set-mode",!0),this.stats.bpp=this.svga_bpp,this.stats.is_graphical=!0,this.stats.res_x=this.svga_width,this.stats.res_y=this.svga_height)};VGAScreen.prototype.port1CF_read=function(){return this.svga_register_read(this.dispi_index)}; |
| VGAScreen.prototype.svga_register_read=function(a){switch(a){case 0:return 45248;case 1:return this.dispi_enable_value&2?2560:this.svga_width;case 2:return this.dispi_enable_value&2?1600:this.svga_height;case 3:return this.dispi_enable_value&2?32:this.svga_bpp;case 4:return this.dispi_enable_value;case 6:return this.svga_width;case 10:return this.vga_memory_size/65536|0}return 255};function PS2(a,b){this.pic=a.devices.pic;this.cpu=a;this.bus=b;this.use_mouse=this.enable_mouse_stream=!1;this.mouse_clicks=this.mouse_delta_y=this.mouse_delta_x=0;this.next_read_resolution=this.next_read_rate=this.next_handle_scan_code_set=this.next_read_led=this.next_read_sample=this.next_is_mouse_command=this.enable_keyboard_stream=!1;this.kbd_buffer=new ByteQueue(32);this.last_port60_byte=0;this.sample_rate=100;this.resolution=4;this.scaling2=!1;this.last_mouse_packet=-1;this.mouse_buffer=new ByteQueue(32); |
| this.bus.register("keyboard-code",function(a){this.kbd_send_code(a)},this);this.bus.register("mouse-click",function(a){this.mouse_send_click(a[0],a[1],a[2])},this);this.bus.register("mouse-delta",function(a){this.mouse_send_delta(a[0],a[1])},this);this.bus.register("mouse-wheel",function(){},this);this.command_register=5;this.read_command_register=this.read_output_register=!1;a.io.register_read(96,this,this.port60_read);a.io.register_read(100,this,this.port64_read);a.io.register_write(96,this,this.port60_write); |
| a.io.register_write(100,this,this.port64_write);this._state_skip=[this.bus,this.pic,this.cpu]}PS2.prototype.mouse_irq=function(){this.command_register&2&&this.pic.push_irq(12)};PS2.prototype.kbd_irq=function(){this.command_register&1&&this.pic.push_irq(1)};PS2.prototype.kbd_send_code=function(a){this.enable_keyboard_stream&&(this.kbd_buffer.push(a),this.kbd_irq())}; |
| PS2.prototype.mouse_send_delta=function(a,b){if(this.use_mouse){var c=this.resolution*this.sample_rate/80;this.mouse_delta_x+=a*c;this.mouse_delta_y+=b*c;if(this.enable_mouse_stream){var c=this.mouse_delta_x|0,d=this.mouse_delta_y|0;!c&&!d||Date.now()-this.last_mouse_packet<1E3/this.sample_rate||(this.mouse_delta_x-=c,this.mouse_delta_y-=d,this.send_mouse_packet(c,d))}}}; |
| PS2.prototype.mouse_send_click=function(a,b,c){this.use_mouse&&(this.mouse_clicks=a|c<<1|b<<2,this.enable_mouse_stream&&this.send_mouse_packet(0,0))};PS2.prototype.send_mouse_packet=function(a,b){var c=(0>b)<<5|(0>a)<<4|8|this.mouse_clicks,d=a,e=b;this.last_mouse_packet=Date.now();this.scaling2&&(d=this.apply_scaling2(d),e=this.apply_scaling2(e));this.mouse_buffer.push(c);this.mouse_buffer.push(d);this.mouse_buffer.push(e);this.mouse_irq()}; |
| PS2.prototype.apply_scaling2=function(a){var b=a>>31;switch(Math.abs(a)){case 0:case 1:case 3:return a;case 2:return b;case 4:return 6*b;case 5:return 9*b;default:return a<<1}};PS2.prototype.destroy=function(){}; |
| PS2.prototype.port60_read=function(){if(!this.kbd_buffer.length&&!this.mouse_buffer.length)return this.last_port60_byte;(this.kbd_buffer.length&&this.mouse_buffer.length?0!==(this.pic.isr&2):this.kbd_buffer.length)?(this.last_port60_byte=this.kbd_buffer.shift(),1<=this.kbd_buffer.length&&this.kbd_irq()):(this.last_port60_byte=this.mouse_buffer.shift(),1<=this.mouse_buffer.length&&this.mouse_irq());return this.last_port60_byte}; |
| PS2.prototype.port64_read=function(){var a=16;if(this.mouse_buffer.length||this.kbd_buffer.length)a|=1;this.mouse_buffer.length&&(a|=32);return a}; |
| PS2.prototype.port60_write=function(a){if(this.read_command_register)this.kbd_irq(),this.command_register=a,this.read_command_register=!1;else if(this.read_output_register)this.read_output_register=!1,this.mouse_buffer.clear(),this.mouse_buffer.push(a),this.mouse_irq();else if(this.next_read_sample)this.next_read_sample=!1,this.mouse_buffer.clear(),this.mouse_buffer.push(250),this.sample_rate=a,this.mouse_irq();else if(this.next_read_resolution)this.next_read_resolution=!1,this.mouse_buffer.clear(), |
| this.mouse_buffer.push(250),this.resolution=3<a?4:1<<a,this.mouse_irq();else if(this.next_read_led)this.next_read_led=!1,this.kbd_buffer.push(250),this.kbd_irq();else if(this.next_handle_scan_code_set)this.next_handle_scan_code_set=!1,this.kbd_buffer.push(250),this.kbd_irq(),a||this.kbd_buffer.push(2);else if(this.next_read_rate)this.next_read_rate=!1,this.kbd_buffer.push(250),this.kbd_irq();else if(this.next_is_mouse_command){this.next_is_mouse_command=!1;this.kbd_buffer.clear();this.mouse_buffer.clear(); |
| this.mouse_buffer.push(250);switch(a){case 230:this.scaling2=!1;break;case 231:this.scaling2=!0;break;case 232:this.next_read_resolution=!0;break;case 233:this.send_mouse_packet(0,0);break;case 242:this.mouse_buffer.push(0);this.mouse_buffer.push(0);this.mouse_clicks=this.mouse_delta_x=this.mouse_delta_y=0;break;case 243:this.next_read_sample=!0;break;case 244:this.use_mouse=this.enable_mouse_stream=!0;this.bus.send("mouse-enable",!0);this.mouse_clicks=this.mouse_delta_x=this.mouse_delta_y=0;break; |
| case 245:this.enable_mouse_stream=!1;break;case 246:this.enable_mouse_stream=!1;this.sample_rate=100;this.scaling2=!1;this.resolution=4;break;case 255:this.mouse_buffer.push(170),this.mouse_buffer.push(0),this.use_mouse=!0,this.bus.send("mouse-enable",!0),this.enable_mouse_stream=!1,this.sample_rate=100,this.scaling2=!1,this.resolution=4,this.mouse_clicks=this.mouse_delta_x=this.mouse_delta_y=0}this.mouse_irq()}else{this.mouse_buffer.clear();this.kbd_buffer.clear();this.kbd_buffer.push(250);switch(a){case 237:this.next_read_led= |
| !0;break;case 240:this.next_handle_scan_code_set=!0;break;case 242:this.kbd_buffer.push(171);this.kbd_buffer.push(83);break;case 243:this.next_read_rate=!0;break;case 244:this.enable_keyboard_stream=!0;break;case 245:this.enable_keyboard_stream=!1;break;case 255:this.kbd_buffer.clear(),this.kbd_buffer.push(250),this.kbd_buffer.push(170)}this.kbd_irq()}}; |
| PS2.prototype.port64_write=function(a){switch(a){case 32:this.kbd_buffer.clear();this.mouse_buffer.clear();this.kbd_buffer.push(this.command_register);break;case 96:this.read_command_register=!0;break;case 211:this.read_output_register=!0;break;case 212:this.next_is_mouse_command=!0;break;case 167:this.command_register|=32;break;case 168:this.command_register&=-33;break;case 169:this.kbd_buffer.clear();this.mouse_buffer.clear();this.kbd_buffer.push(0);break;case 170:this.kbd_buffer.clear();this.mouse_buffer.clear(); |
| this.kbd_buffer.push(85);break;case 171:this.kbd_buffer.clear();this.mouse_buffer.clear();this.kbd_buffer.push(0);break;case 173:this.command_register|=16;break;case 174:this.command_register&=-17;break;case 254:this.cpu.reboot_internal()}};function PIC(a,b){this.irr=this.isr=this.irq_map=this.irq_mask=0;this.is_master=void 0===b;this.slave=void 0;this.expect_icw4=!1;this.state=0;this.auto_eoi=this.read_irr=1;this.is_master?(this.slave=new PIC(a,this),this.check_irqs=function(){var b=this.irr&this.irq_mask;if(!b)return this.slave.check_irqs();b&=-b;if(this.isr&&(this.isr&-this.isr)<=b)return!1;var c=v86util.int_log2_byte(b),b=1<<c;this.irr&=~b;if(4===b)return this.slave.check_irqs();this.auto_eoi||(this.isr|=b);a.previous_ip=a.instruction_pointer; |
| a.call_interrupt_vector(this.irq_map|c,!1,!1);return!0}):this.check_irqs=function(){var c=this.irr&this.irq_mask;if(!c)return!1;c&=-c;if(this.isr&&(this.isr&-this.isr)<=c)return!1;var e=v86util.int_log2_byte(c),c=1<<e;this.irr&=~c;this.isr|=c;a.previous_ip=a.instruction_pointer;a.call_interrupt_vector(this.irq_map|e,!1,!1);this.irr&&b.push_irq(2);this.auto_eoi||(this.isr&=~c);return!0};this.PIC$dump=function(){this.is_master&&this.slave.PIC$dump()};var c;c=this.is_master?32:160;a.io.register_write(c, |
| this,function(a){if(a&16)this.expect_icw4=a&1,this.state=1;else if(a&8)this.read_irr=a&1;else{var b=a>>5;1===b?this.isr&=this.isr-1:3===b&&(this.isr&=~(1<<(a&7)))}});a.io.register_read(c,this,function(){return this.read_irr?this.irr:this.isr});a.io.register_write(c|1,this,function(a){0===this.state?this.expect_icw4?(this.expect_icw4=!1,this.auto_eoi=a&2):this.irq_mask=~a:1===this.state?(this.irq_map=a,this.state++):2===this.state&&(this.state=0)});a.io.register_read(c|1,this,function(){return~this.irq_mask& |
| 255});this.push_irq=this.is_master?function(b){8<=b&&(this.slave.push_irq(b-8),b=2);this.irr|=1<<b;a.handle_irqs()}:function(a){this.irr|=1<<a}};function RTC(a,b,c){this.cpu=a;this.pic=a.devices.pic;this.cmos_index=0;this.boot_order=c;this.diskette_type=b;this.last_update=this.rtc_time=Date.now();this.next_interrupt=0;this.cmos_c_was_read=!0;this.periodic_interrupt=!1;this.periodic_interrupt_time=.9765625;this.cmos_a=38;this.cmos_b=2;this.cmos_c=0;a.io.register_write(112,this,function(a){this.cmos_index=a&127});a.io.register_write(113,this,this.cmos_write);a.io.register_read(113,this,this.cmos_read);this._state_skip=[this.cpu,this.pic]} |
| RTC.prototype.timer=function(a){this.periodic_interrupt&&this.cmos_c_was_read&&this.next_interrupt<a&&(this.cmos_c_was_read=!1,this.pic.push_irq(8),this.cmos_c|=64,this.next_interrupt+=this.periodic_interrupt_time*Math.ceil((a-this.next_interrupt)/this.periodic_interrupt_time));this.rtc_time+=a-this.last_update;this.last_update=a};RTC.prototype.bcd_pack=function(a){for(var b=0,c=0,d;a;)d=a%10,c|=d<<4*b,b++,a=(a-d)/10;return c};RTC.prototype.encode_time=function(a){return this.cmos_b&4?a:this.bcd_pack(a)}; |
| RTC.prototype.cmos_read=function(){switch(this.cmos_index){case 0:return this.encode_time((new Date(this.rtc_time)).getUTCSeconds());case 2:return this.encode_time((new Date(this.rtc_time)).getUTCMinutes());case 4:return this.encode_time((new Date(this.rtc_time)).getUTCHours());case 7:return this.encode_time((new Date(this.rtc_time)).getUTCDate());case 8:return this.encode_time((new Date(this.rtc_time)).getUTCMonth()+1);case 9:return this.encode_time((new Date(this.rtc_time)).getUTCFullYear()%100); |
| case 10:return this.cmos_a;case 11:return this.cmos_b;case 14:return 0;case 12:return this.cmos_c_was_read=!0,this.cmos_c;case 15:return 0;case 16:return this.diskette_type;case 20:return 45;case 50:return this.encode_time((new Date(this.rtc_time)).getUTCFullYear()/100|0);case 52:return this.cpu.memory_size-16777216>>16&255;case 53:return this.cpu.memory_size-16777216>>24&255;case 56:return 1|this.boot_order>>4&240;case 61:return this.boot_order&255;case 91:case 92:case 93:return 0}return 255}; |
| RTC.prototype.cmos_write=function(a){switch(this.cmos_index){case 10:this.cmos_a=a&127;this.periodic_interrupt_time=1E3/(32768>>(this.cmos_a&15)-1);break;case 11:this.cmos_b=a,this.cmos_b&64&&(this.next_interrupt=Date.now())}this.periodic_interrupt=64===(this.cmos_b&64)&&0<(this.cmos_a&15)};function UART(a,b,c){this.bus=c;this.pic=a.devices.pic;this.ier=this.line_control=this.baud_rate=this.ints=0;this.iir=1;this.UART$irq=this.scratch_register=this.modem_status=this.modem_control=0;this.input=new ByteQueue(4096);this.current_line="";if(1E3===b||1016===b)this.UART$irq=4;else if(1E3===b||1E3===b)this.UART$irq=3;else return;this.bus.register("serial0-input",function(a){this.data_received(a)},this);a=a.io;a.register_write(b,this,function(a){this.line_control&128?this.baud_rate=this.baud_rate& |
| -256|a:(this.ThrowTHRI(),255!==a&&(a=String.fromCharCode(a),this.bus.send("serial0-output-char",a),this.bus.should_send()&&(this.current_line+=a,"\n"===a&&(this.bus.send("serial0-output-line",this.current_line),this.current_line=""))))});a.register_write(b|1,this,function(a){this.line_control&128?this.baud_rate=this.baud_rate&255|a<<8:(this.ier=a,this.NextInterrupt())});a.register_read(b,this,function(){if(this.line_control&128)return this.baud_rate&255;var a=this.input.shift();this.input.length&& |
| this.ThrowCTI();return a});a.register_read(b|1,this,function(){return this.line_control&128?this.baud_rate>>8:this.ier});a.register_read(b|2,this,function(){var a=this.iir&15|192;2===this.iir?this.ClearInterrupt(2):12===this.iir&&this.ClearInterrupt(12);return a});a.register_write(b|2,this,function(){});a.register_read(b|3,this,function(){return this.line_control});a.register_write(b|3,this,function(a){this.line_control=a});a.register_read(b|4,this,function(){return this.modem_control});a.register_write(b| |
| 4,this,function(a){this.modem_control=a});a.register_read(b|5,this,function(){var a=0;this.input.length&&(a|=1);return a|96});a.register_write(b|5,this,function(){});a.register_read(b|6,this,function(){return this.modem_status});a.register_write(b|6,this,function(){});a.register_read(b|7,this,function(){return this.scratch_register});a.register_write(b|7,this,function(a){this.scratch_register=a});this._state_skip=[this.bus,this.pic]}UART.prototype.push_irq=function(){this.pic.push_irq(this.UART$irq)}; |
| UART.prototype.ClearInterrupt=function(a){this.ints&=~(1<<a);this.iir=1;a===this.iir&&this.NextInterrupt()};UART.prototype.ThrowCTI=function(){this.ints|=4096;this.ier&1&&6!=this.iir&&4!=this.iir&&(this.iir=12,this.push_irq())};UART.prototype.ThrowTHRI=function(){this.ints|=4;this.ier&2&&(this.iir&1||0==this.iir||2==this.iir)&&(this.iir=2,this.push_irq())};UART.prototype.NextInterrupt=function(){this.ints&4096&&this.ier&1?this.ThrowCTI():this.ints&4&&this.ier&2?this.ThrowTHRI():this.iir=1}; |
| UART.prototype.data_received=function(a){this.input.push(a);this.ints|=4096;this.ier&1&&this.ThrowCTI()};function ACPI(){};function StateLoadError(a){this.message=a}StateLoadError.prototype=Error(); |
| function save_object(a,b){if("object"!==typeof a||null===a||a instanceof Array)return a;if(a.constructor===Object){for(var c=Object.keys(a),d={},e=0;e<c.length;e++){var f=c[e];d[f]=save_object(a[f],b)}return d}if(a.BYTES_PER_ELEMENT)return{__state_type__:a.constructor.name,buffer_id:b.push(a.buffer)-1};if(a instanceof ArrayBuffer)return{__state_type__:"ArrayBuffer",buffer_id:b.push(a)-1};var g;a._state_skip&&(g=a._state_skip.slice(),g.push(a._state_skip));c=Object.keys(a);d={};e=0;a:for(;e<c.length;e++){var f= |
| c[e],l=a[f];if("function"!==typeof l){if(g&&"object"===typeof l&&l)for(var k=0;k<g.length;k++)if(g[k]===l)continue a;d[f]=save_object(l,b)}}return d} |
| function restore_object(a,b,c){if("object"!==typeof b||b instanceof Array||null===b)return b;var d=b.__state_type__;if(void 0===d){for(var d=Object.keys(b),e=0;e<d.length;e++){var f=d[e];a[f]=restore_object(a[f],b[f],c)}a._state_restore&&a._state_restore();return a}if("ArrayBuffer"===d)return b=c.infos[b.buffer_id],a&&a.byteLength===b.length&&(new Uint8Array(a)).set(new Uint8Array(c.full,b.offset,b.length)),a;d={Uint8Array:Uint8Array,Int8Array:Int8Array,Uint16Array:Uint16Array,Int16Array:Int16Array, |
| Uint32Array:Uint32Array,Int32Array:Int32Array,Float32Array:Float32Array,Float64Array:Float64Array}[d];b=c.infos[b.buffer_id];return a&&a.constructor===d&&0===a.byteOffset&&a.byteLength===b.length?((new Uint8Array(a.buffer)).set(new Uint8Array(c.full,b.offset,b.length),a.byteOffset),a):new d(c.full.slice(b.offset,b.offset+b.length))} |
| CPU.prototype.save_state=function(){for(var a=[],b=save_object(this,a),c=[],d=0,e=0;e<a.length;e++){var f=a[e].byteLength;c[e]={offset:d,length:f};d+=f;d=d+3&-4}var b=JSON.stringify({buffer_infos:c,state:b}),e=16+2*b.length,g=e+d,d=new ArrayBuffer(g),l=new Int32Array(d,0,4),f=new Uint16Array(d,16,b.length),k=new Uint8Array(d,e);l[0]=-2039052682;l[1]=0;l[2]=g;l[3]=2*b.length;for(e=0;e<b.length;e++)f[e]=b.charCodeAt(e);for(e=0;e<a.length;e++)k.set(new Uint8Array(a[e]),c[e].offset);return d}; |
| CPU.prototype.CPU_prototype$restore_state=function(a){var b=a.byteLength;if(16>b)throw new StateLoadError("Invalid length: "+b);var c=new Int32Array(a,0,4);if(-2039052682!==c[0])throw new StateLoadError("Invalid header: "+h(c[0]>>>0));if(0!==c[1])throw new StateLoadError("Version mismatch: dump="+c[1]+" we=0");if(c[2]!==b)throw new StateLoadError("Length doesn't match header: real="+b+" header="+c[2]);c=c[3];if(0>c||c+12>=b||c%2)throw new StateLoadError("Invalid info block length: "+c);for(var d= |
| c/2,e=new Uint16Array(a,16,d),f="",b=0;b<d-8;)f+=String.fromCharCode(e[b++],e[b++],e[b++],e[b++],e[b++],e[b++],e[b++],e[b++]);for(;b<d;)f+=String.fromCharCode(e[b++]);d=JSON.parse(f);c=16+c;e=d.buffer_infos;for(b=0;b<e.length;b++)e[b].offset+=c;restore_object(this,d.state,{full:a,infos:e})};function Ne2k(a,b){this.pic=a.devices.pic;this.bus=b;this.bus.register("net0-receive",function(a){this.receive(a)},this);this.pci_space=[236,16,41,128,3,1,0,0,0,0,0,2,0,0,0,0,1,184,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,244,26,0,17,0,0,184,254,0,0,0,0,0,0,0,0,11,1,0,0];this.pci_id=40;this.pci_bars=[{size:131072}];a.devices.pci.register_device(this);this.imr=this.isr=0;this.cr=1;this.rcnt=0;this.remote_buffer=new Uint8Array(0);this.remote_pointer=0;this.receive_buffer=new Uint8Array(32768); |
| this.receive_buffer[0]=0;this.receive_buffer[1]=34;this.receive_buffer[2]=21;this.receive_buffer[3]=255*Math.random()|0;this.receive_buffer[4]=255*Math.random()|0;this.receive_buffer[5]=255*Math.random()|0;this.rsar=0;this.boundary=this.curpg=76;var c=a.io;c.register_read(47104,this,function(){return this.cr});c.register_write(47104,this,function(a){this.cr=a|this.cr&4;this.remote_pointer=0;this.rcnt>this.remote_buffer.length&&(this.remote_buffer=new Uint8Array(this.rcnt))});c.register_read(47117, |
| this,function(){return 0});c.register_read(47118,this,function(){return 0});c.register_read(47119,this,function(){return 0});c.register_read(47135,this,function(){if(0===(this.cr&192))return this.do_interrupt(128),0});c.register_write(47135,this,function(){});c.register_read(47111,this,function(){return 0===(this.cr&192)?this.isr:this.curpg});c.register_write(47111,this,function(a){0===(this.cr&192)?this.isr&=~a:this.curpg=a});c.register_write(47117,this,function(){});c.register_write(47118,this, |
| function(){});c.register_write(47114,this,function(a){0===(this.cr&192)&&(this.rcnt=this.rcnt&65280|a&255)});c.register_write(47115,this,function(a){0===(this.cr&192)&&(this.rcnt=this.rcnt&255|a<<8&65280)});c.register_write(47112,this,function(a){0===(this.cr&192)&&(this.rsar=this.rsar&65280|a&255)});c.register_write(47113,this,function(a){0===(this.cr&192)&&(this.rsar=this.rsar&255|a<<8&65280)});c.register_write(47119,this,function(a){0===(this.cr&192)&&(this.imr=a)});c.register_read(47107,this, |
| function(){return 0===(this.cr&192)?this.boundary:0});c.register_write(47107,this,function(a){0===(this.cr&192)&&(this.boundary=a)});c.register_read(47108,this,function(){return 0===(this.cr&192)?35:0});c.register_read(47116,this,function(){return 0===(this.cr&192)?9:0});c.register_read(47120,this,this.data_port_read,this.data_port_read16,this.data_port_read32);c.register_write(47120,this,this.data_port_write,this.data_port_write16,this.data_port_write32);this._state_skip=[this.bus,this.pic]} |
| Ne2k.prototype.do_interrupt=function(a){this.isr|=a;this.imr&a&&this.pic.push_irq(11)};Ne2k.prototype.data_port_write=function(a){this.remote_buffer[this.remote_pointer++]=a;this.remote_pointer===this.rcnt&&(a=this.remote_buffer.subarray(0,this.rcnt),this.do_interrupt(64),this.cr&=-5,this.bus.send("net0-send",a),this.do_interrupt(2))};Ne2k.prototype.data_port_write16=function(a){this.data_port_write(a);this.data_port_write(a>>8)}; |
| Ne2k.prototype.data_port_write32=function(a){this.data_port_write(a);this.data_port_write(a>>8);this.data_port_write(a>>16);this.data_port_write(a>>24)};Ne2k.prototype.data_port_read=function(){return this.receive_buffer[this.rsar++]};Ne2k.prototype.data_port_read16=function(){return this.data_port_read()|this.data_port_read()<<8};Ne2k.prototype.data_port_read32=function(){return this.data_port_read()|this.data_port_read()<<8|this.data_port_read()<<16|this.data_port_read()<<24}; |
| Ne2k.prototype.receive=function(a){if(!(this.cr&1)){if(60>a.length){var b=a;a=new Uint8Array(60);a.set(b)}var b=this.curpg<<8,c=a.length+4,d=b+4,e=this.curpg+1+(c>>8);if(b+c>this.receive_buffer.length){var f=this.receive_buffer.length-d;this.receive_buffer.set(a.subarray(0,f),d);this.receive_buffer.set(a.subarray(f),76)}else this.receive_buffer.set(a,d);128<=e&&(e+=-52);this.receive_buffer[b]=1;this.receive_buffer[b+1]=e;this.receive_buffer[b+2]=c;this.receive_buffer[b+3]=c>>8;this.curpg=e;this.do_interrupt(1)}};function VirtIO(a,b){this.pci_space=[244,26,9,16,7,5,16,0,0,0,2,0,0,0,0,0,1,168,0,0,0,16,191,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,244,26,9,0,0,0,0,0,64,0,0,0,0,0,0,0,12,1,0,0];this.pci_id=48;this.pci_bars=[{size:131072}];a.devices.pci.register_device(this);var c=a.io;c.register_read(43008,this,void 0,void 0,function(){return 1});c.register_write(43012,this,void 0,void 0,function(){});c.register_write(43022,this,void 0,function(a){this.queue_select=a},void 0);c.register_read(43020,this,void 0, |
| function(){return this.queue_size},void 0);c.register_read(43016,this,void 0,void 0,function(){return 0===this.queue_select?this.queue_address:0});c.register_write(43016,this,void 0,void 0,function(a){this.queue_address=a});c.register_write(43026,this,function(a){this.device_status=a});c.register_read(43026,this,function(){return this.device_status});c.register_read(43027,this,function(){var a=this.isr;this.isr=0;return a});c.register_write(43024,this,void 0,function(){var a=(this.queue_address<< |
| 12)+16*this.queue_size,b=a+4;this.memory.read16(a);for(var a=this.memory.read16(a+2),c=this.queue_size-1,a=a&c;this.last_idx!==a;){var d=this.memory.read16(b+2*this.last_idx);this.handle_descriptor(d);this.last_idx=this.last_idx+1&c}});this.pic=a.devices.pic;this.last_idx=this.isr=this.device_status=this.queue_select=0;this.queue_size=32;this.queue_address=0;this.memory=a.memory;for(var d=0;128>d;d++)c.register_read(43028+d,this,function(a){return this.device.configspace[a]}.bind(this,d),void 0,void 0), |
| c.register_write(43028+d,this,function(){}.bind(this,d),void 0,void 0);this.device=new Virtio9p(b);this.device.SendReply=this.device_reply.bind(this);this._state_skip=[this.memory,this.pic,this.device];this._state_restore=function(){this.device.SendReply=this.device_reply.bind(this)}} |
| VirtIO.prototype.handle_descriptor=function(a){var b=a,c=this.queue_address<<12,d=0,e=[];do{var f=c+16*b,g=this.memory.read16(f+12);if(g&2)break;var l=this.memory.read32s(f),b=this.memory.read32s(f+4),k=this.memory.read32s(f+8)>>>0;e.push({addr_low:l,addr_high:b,len:k});if(g&1)b=this.memory.read16(f+14);else{b=-1;break}}while(1);var m=-1,n=0;this.device.ReceiveRequest({start:a,next:b},function(){if(n>=m){if(d===e.length)return 0;var a=e[d++];l=a.addr_low;m=a.len;n=0}return this.memory.read8(l+n++)}.bind(this))}; |
| VirtIO.prototype.device_reply=function(a){if(-1!==a.next){var b=this.device.replybuffersize,c=a.next,d=this.queue_address<<12,e=0,f=[];do{var c=d+16*c,g=this.memory.read16(c+12);if(0===(g&2))break;var l=this.memory.read32s(c),k=this.memory.read32s(c+4),m=this.memory.read32s(c+8)>>>0;f.push({addr_low:l,addr_high:k,len:m});if(g&1)c=this.memory.read16(c+14);else break}while(1);g=-1;for(d=k=0;d<b;d++){c=this.device.replybuffer[d];if(k>=g){if(e===f.length)return 0;g=f[e++];l=g.addr_low;g=g.len;k=0}this.memory.write8(l+ |
| k++,c)}e=(this.queue_address<<12)+580;e=e+4095&-4096;this.memory.read16(e);f=this.memory.read16(e+2);this.memory.write16(e+2,f+1);e=e+4+8*(f&31);this.memory.write32(e,a.start);this.memory.write32(e+4,b);this.isr|=1;this.pic.push_irq(12)}};var Bus={Connector:function(){this.listeners={};this.pair=void 0}};Bus.Connector.prototype.register=function(a,b,c){var d=this.listeners[a];void 0===d&&(d=this.listeners[a]=[]);d.push({fn:b,this_value:c})};Bus.Connector.prototype.unregister=function(a,b){var c=this.listeners[a];void 0!==c&&(this.listeners[a]=c.filter(function(a){return a.fn!==b}))}; |
| Bus.Connector.prototype.send=function(a,b){if(this.pair){var c=this.pair.listeners[a];if(void 0!==c)for(var d=0;d<c.length;d++){var e=c[d];e.fn.call(e.this_value,b)}}};Bus.Connector.prototype.send_async=function(){setTimeout(this.send.bind(this,"emulator-ready",void 0),0)};Bus.Connector.prototype.should_send=function(){if(!this.pair)return!1;var a=this.pair.listeners["serial0-output-line"];return void 0!==a&&0<a.length}; |
| Bus.create=function(){var a=new Bus.Connector,b=new Bus.Connector;a.pair=b;b.pair=a;return[a,b]};[[1,""],[2,"CPU"],[32768,"DISK"],[4,"FPU"],[8,"MEM"],[16,"DMA"],[32,"IO"],[64,"PS2"],[128,"PIC"],[256,"VGA"],[512,"PIT"],[1024,"MOUS"],[2048,"PCI"],[4096,"BIOS"],[8192,"CD"],[16384,"SERI"],[65536,"RTC"],[131072,"HPET"],[262144,"ACPI"],[524288,"APIC"],[1048576,"NET"],[2097152,"VIO"],[4194304,"9P"]].reduce(function(a,b){a[b[0]]=b[1];return a},{});function dbg_assert(){};var S_IFDIR=16384;function FS(a){this.inodes=[];this.events=[];this.baseurl=a;this.filesinloadingqueue=this.qidnumber=0;this.OnLoaded=function(){};this.inodedata={};this.CreateDirectory("",-1);this._state_skip=["OnLoaded"]}FS.prototype.LoadFilesystem=function(a){this.LoadFSXML(a.basefsURL)};FS.prototype.AddEvent=function(a,b){0==this.inodes[a].status?b():this.events.push({id:a,OnEvent:b})}; |
| FS.prototype.HandleEvent=function(a){0==this.filesinloadingqueue&&(this.OnLoaded=function(){});for(var b=this.events.length-1;0<=b;b--)this.events[b].id==a&&(this.events[b].OnEvent(),this.events.splice(b,1))};FS.prototype.LoadFSXML=function(a){LoadXMLResource(a,this.OnJSONLoaded.bind(this),function(a){throw a;})};FS.prototype.OnJSONLoaded=function(a){var b=JSON.parse(a).fsroot,c=this;setTimeout(function(){for(var a=0;a<b.length;a++)c.LoadRecursive(b[a],0);c.OnLoaded=function(){}},0)}; |
| FS.prototype.LoadRecursive=function(a,b){var c=this.CreateInode();c.name=a.name;c.uid=a.uid||0;c.gid=a.gid||0;c.ctime=a.ctime||Math.floor(Date.now()/1E3);c.mtime=a.mtime||c.ctime;c.atime=a.atime||c.ctime;c.parentid=b;c.mode=void 0===a.mode?420:a.mode&511;c.size=a.size||0;0===a.type?this.LoadDir(c,a.children):(1===a.type?(c.mode|=32768,c.status=2):(c.mode|=40960,c.symlink=a.target),this.PushInode(c))}; |
| FS.prototype.LoadDir=function(a,b){a.updatedir=!0;a.mode|=S_IFDIR;var c=this.inodes.length;this.PushInode(a);for(var d=0;d<b.length;d++)this.LoadRecursive(b[d],c)};FS.prototype.LoadFile=function(a){var b=this.inodes[a];2==b.status&&(b.status=3,this.filesinloadingqueue++,LoadBinaryResource(this.baseurl+this.GetFullPath(b.fid),function(c){c=this.inodedata[a]=new Uint8Array(c);b.size=c.length;b.status=0;this.filesinloadingqueue--;this.HandleEvent(a)}.bind(this),function(a){throw a;}))}; |
| FS.prototype.PushInode=function(a){-1!=a.parentid?(this.inodes.push(a),a.fid=this.inodes.length-1,this.inodes[a.parentid].updatedir=!0,a.nextid=this.inodes[a.parentid].firstid,this.inodes[a.parentid].firstid=this.inodes.length-1):0==this.inodes.length&&this.inodes.push(a)}; |
| function Inode(a){this.updatedir=!1;this.nextid=this.firstid=this.parentid=-1;this.status=0;this.name="";this.minor=this.major=this.mtime=this.atime=this.ctime=this.fid=this.gid=this.uid=this.size=0;this.symlink="";this.mode=493;this.qid={type:0,version:0,path:a}}FS.prototype.CreateInode=function(){return new Inode(++this.qidnumber)}; |
| FS.prototype.CreateDirectory=function(a,b){var c=this.CreateInode();c.name=a;c.parentid=b;c.mode=511|S_IFDIR;0<=b&&(c.uid=this.inodes[b].uid,c.gid=this.inodes[b].gid,c.mode=this.inodes[b].mode&511|S_IFDIR);c.qid.type=S_IFDIR>>8;this.PushInode(c);return this.inodes.length-1}; |
| FS.prototype.CreateFile=function(a,b){var c=this.CreateInode();c.name=a;c.parentid=b;c.uid=this.inodes[b].uid;c.gid=this.inodes[b].gid;c.qid.type=128;c.mode=this.inodes[b].mode&438|32768;this.PushInode(c);return this.inodes.length-1};FS.prototype.CreateNode=function(a,b,c,d){var e=this.CreateInode();e.name=a;e.parentid=b;e.major=c;e.minor=d;e.uid=this.inodes[b].uid;e.gid=this.inodes[b].gid;e.qid.type=192;e.mode=this.inodes[b].mode&438;this.PushInode(e);return this.inodes.length-1}; |
| FS.prototype.CreateSymlink=function(a,b,c){var d=this.CreateInode();d.name=a;d.parentid=b;d.uid=this.inodes[b].uid;d.gid=this.inodes[b].gid;d.qid.type=160;d.symlink=c;d.mode=40960;this.PushInode(d);return this.inodes.length-1};FS.prototype.OpenInode=function(a){var b=this.GetInode(a);(b.mode&61440)==S_IFDIR&&this.FillDirectory(a);return 2==b.status?(this.LoadFile(a),!1):!0};FS.prototype.CloseInode=function(a){var b=this.GetInode(a);4==b.status&&(-1==b.status,delete this.inodedata[a],b.size=0)}; |
| FS.prototype.Rename=function(a,b,c,d){if(a==c&&b==d)return!0;b=this.Search(a,b);if(-1==b)return!1;var e=this.Search(c,d);-1!=e&&this.Unlink(e);e=this.inodes[b];if(this.inodes[e.parentid].firstid==b)this.inodes[e.parentid].firstid=e.nextid;else{var f=this.FindPreviousID(b);this.inodes[f].nextid=e.nextid}e.parentid=c;e.name=d;e.qid.version++;e.nextid=this.inodes[e.parentid].firstid;this.inodes[e.parentid].firstid=b;this.inodes[a].updatedir=!0;return this.inodes[c].updatedir=!0}; |
| FS.prototype.Write=function(a,b,c,d){var e=this.inodes[a],f=this.inodedata[a];!f||f.length<b+c?(this.ChangeSize(a,Math.floor(3*(b+c)/2)),e.size=b+c,f=this.inodedata[a]):e.size<b+c&&(e.size=b+c);for(a=0;a<c;a++)f[b+a]=d()};FS.prototype.Search=function(a,b){for(var c=this.inodes[a].firstid;-1!=c;){if(this.inodes[c].name==b)return c;c=this.inodes[c].nextid}return-1};FS.prototype.GetFullPath=function(a){for(var b="";0!=a;)b="/"+this.inodes[a].name+b,a=this.inodes[a].parentid;return b.substring(1)}; |
| FS.prototype.FindPreviousID=function(a){for(var b=this.GetInode(a),b=this.inodes[b.parentid].firstid;-1!=b&&this.inodes[b].nextid!=a;)b=this.inodes[b].nextid;return b}; |
| FS.prototype.Unlink=function(a){if(0==a)return!1;var b=this.GetInode(a);if((b.mode&61440)==S_IFDIR&&-1!=b.firstid)return!1;this.inodes[b.parentid].firstid==a?this.inodes[b.parentid].firstid=b.nextid:(a=this.FindPreviousID(a),this.inodes[a].nextid=b.nextid);this.inodes[b.parentid].updatedir=!0;b.status=4;b.nextid=-1;b.firstid=-1;b.parentid=-1;return!0};FS.prototype.GetInode=function(a){return isNaN(a)||0>a||a>this.inodes.length?0:this.inodes[a]}; |
| FS.prototype.ChangeSize=function(a,b){var c=this.GetInode(a),d=this.inodedata[a];if(b!=c.size){var e=this.inodedata[a]=new Uint8Array(b);c.size=b;if(d)for(var c=Math.min(d.length,c.size),f=0;f<c;f++)e[f]=d[f]}}; |
| FS.prototype.FillDirectory=function(a){var b=this.GetInode(a);if(b.updatedir){var c=b.parentid;-1==c&&(c=0);for(var d=0,e=this.inodes[a].firstid;-1!=e;)d+=24+UTF8Length(this.inodes[e].name),e=this.inodes[e].nextid;var d=d+25+26,f=this.inodedata[a]=new Uint8Array(d);b.size=d;d=0;d+=Marshall(["Q","d","b","s"],[this.MakeQid(this.inodes[a]),d+13+8+1+2+1,this.inodes[a].mode>>12,"."],f,d);d+=Marshall(["Q","d","b","s"],[this.MakeQid(this.inodes[c]),d+13+8+1+2+2,this.inodes[c].mode>>12,".."],f,d);for(e=this.inodes[a].firstid;-1!= |
| e;)d+=Marshall(["Q","d","b","s"],[this.MakeQid(this.inodes[e]),d+13+8+1+2+UTF8Length(this.inodes[e].name),this.inodes[e].mode>>12,this.inodes[e].name],f,d),e=this.inodes[e].nextid;b.updatedir=!1}};FS.prototype.PrepareCAPs=function(a){a=this.GetInode(a);if(a.caps)return a.caps.length;a.caps=new Uint8Array(12);a.caps[0]=0;a.caps[1]=0;a.caps[2]=0;a.caps[3]=1;a.caps[4]=255;a.caps[5]=255;a.caps[6]=255;a.caps[7]=255;a.caps[8]=255;a.caps[9]=255;a.caps[10]=255;a.caps[11]=255;return a.caps.length}; |
| FS.prototype.MakeQid=function(a){return a.qid};function LoadXMLResource(a,b,c){var d=new XMLHttpRequest;d.open("GET",a,!0);d.onreadystatechange=function(){4==d.readyState&&(200!=d.status&&0!=d.status?c("Error: Could not load XML file "+a):b(d.responseText))};d.send(null)} |
| function LoadBinaryResource(a,b,c){var d=new XMLHttpRequest;d.open("GET",a,!0);d.responseType="arraybuffer";d.onreadystatechange=function(){if(4==d.readyState)if(200!=d.status&&0!=d.status)c("Error: Could not load file "+a);else{var e=d.response;e?b(e):c("Error: No data received from: "+a)}};d.send(null)};function Marshall(a,b,c,d){for(var e,f=0,g=0;g<a.length;g++)switch(e=b[g],a[g]){case "w":c[d++]=e&255;c[d++]=e>>8&255;c[d++]=e>>16&255;c[d++]=e>>24&255;f+=4;break;case "d":c[d++]=e&255;c[d++]=e>>8&255;c[d++]=e>>16&255;c[d++]=e>>24&255;c[d++]=0;c[d++]=0;c[d++]=0;c[d++]=0;f+=8;break;case "h":c[d++]=e&255;c[d++]=e>>8;f+=2;break;case "b":c[d++]=e;f+=1;break;case "s":var l=d,k=0;c[d++]=0;c[d++]=0;var f=f+2,m;for(m in e)UnicodeToUTF8Stream(e.charCodeAt(m)).forEach(function(a){c[d++]=a;f+=1;k++});c[l+0]= |
| k&255;c[l+1]=k>>8&255;break;case "Q":Marshall(["b","w","d"],[e.type,e.version,e.path],c,d),d+=13,f+=13}return f} |
| function Unmarshall2(a,b){for(var c=[],d=0;d<a.length;d++)switch(a[d]){case "w":var e=b(),e=e+(b()<<8),e=e+(b()<<16),e=e+(b()<<24>>>0);c.push(e);break;case "d":e=b();e+=b()<<8;e+=b()<<16;e+=b()<<24>>>0;b();b();b();b();c.push(e);break;case "h":e=b();c.push(e+(b()<<8));break;case "b":c.push(b());break;case "s":for(var e=b(),e=e+(b()<<8),f="",g=new UTF8StreamToUnicode,l=0;l<e;l++){var k=g.Put(b());-1!=k&&(f+=String.fromCharCode(k))}c.push(f)}return c};function UTF8StreamToUnicode(){this.UTF8StreamToUnicode$stream=new Uint8Array(5);this.ofs=0;this.Put=function(a){this.UTF8StreamToUnicode$stream[this.ofs]=a;this.ofs++;switch(this.ofs){case 1:if(128>this.UTF8StreamToUnicode$stream[0])return this.ofs=0,this.UTF8StreamToUnicode$stream[0];break;case 2:if(192==(this.UTF8StreamToUnicode$stream[0]&224)&&128==(this.UTF8StreamToUnicode$stream[1]&192))return this.ofs=0,(this.UTF8StreamToUnicode$stream[0]&31)<<6|this.UTF8StreamToUnicode$stream[1]&63}return-1}} |
| function UnicodeToUTF8Stream(a){if(128>a)return[a];if(2048>a)return[192|a>>6&31,128|a&63]}function UTF8Length(a){for(var b=0,c=0;c<a.length;c++)b+=128>a.charCodeAt(c)?1:2;return b};function KeyboardAdapter(a){function b(a){return a.shiftKey&&a.ctrlKey&&74===a.keyCode||!k.KeyboardAdapter$emu_enabled?!1:a.target?"phone_keyboard"===a.target.className||"INPUT"!==a.target.nodeName&&"TEXTAREA"!==a.target.nodeName:!0}function c(a){if(b(a)){var c=a.keyCode;if(!l[c])return!1;l[c]=!1;f(c,!1)||a.preventDefault()}}function d(a){if(b(a)){var c=a.keyCode;l[c]&&f(c,!1);l[c]=!0;f(c,!0)||a.preventDefault()}}function e(){for(var a=Object.keys(l),b,c=0;c<a.length;c++)b=+a[c],l[b]&&f(b,!1);l={}} |
| function f(a,b){if(k.bus){if(a>=m.length||0===m[a])return console.log("Missing char in map: "+a.toString(16)),!0;var c=m[a];b||(c|=128);255<c?(g(c>>8),g(c&255)):g(c);return!1}}function g(a){k.bus.send("keyboard-code",a)}var l={},k=this;this.KeyboardAdapter$emu_enabled=!0;var m=new Uint16Array([0,0,0,0,0,0,0,0,14,15,0,0,0,28,0,0,42,29,56,0,58,0,0,0,0,0,0,1,0,0,0,0,57,57417,57425,57423,57415,57419,57416,57421,80,0,0,0,0,82,83,0,11,2,3,4,5,6,7,8,9,10,0,39,0,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,57435,57436,57437,0,0,82,79,80,81,75,76,77,71,72,73,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,39,13,51,12,52,53,41,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,57435,57400,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);this.bus=a;this.destroy=function(){window.removeEventListener("keyup",c,!1);window.removeEventListener("keydown", |
| d,!1);window.removeEventListener("blur",e,!1)};this.init=function(){this.destroy();window.addEventListener("keyup",c,!1);window.addEventListener("keydown",d,!1);window.addEventListener("blur",e,!1)};this.init()};function MouseAdapter(a){function b(a){return n.enabled&&n.MouseAdapter$emu_enabled&&(!a.target||"mousemove"===a.type||"INPUT"!==a.target.nodeName&&"TEXTAREA"!==a.target.nodeName)}function c(a){if(n.bus&&b(a)){var c;c=a.webkitMovementX||a.mozMovementX||0;a=a.webkitMovementY||a.mozMovementY||0;a=-(.15*a);n.bus.send("mouse-delta",[.15*c,a])}}function d(a){b(a)&&a.preventDefault()}function e(a){b(a)&&g(a,!0)}function f(a){b(a)&&g(a,!1)}function g(a,b){n.bus&&(1===a.which?l=b:2===a.which?m=b:3===a.which? |
| k=b:console.log("Unknown event.which: "+a.which),n.bus.send("mouse-click",[l,m,k]),a.preventDefault())}var l=!1,k=!1,m=!1,n=this;this.enabled=!1;this.MouseAdapter$emu_enabled=!0;this.bus=a;this.bus.register("mouse-enable",function(a){this.enabled=a},this);this.destroy=function(){window.removeEventListener("mousemove",c,!1);document.removeEventListener("contextmenu",d,!1);window.removeEventListener("mousedown",e,!1);window.removeEventListener("mouseup",f,!1)};this.init=function(){this.destroy();window.addEventListener("mousemove", |
| c,!1);document.addEventListener("contextmenu",d,!1);window.addEventListener("mousedown",e,!1);window.addEventListener("mouseup",f,!1)};this.init()};function SerialAdapter(a,b){function c(a){f.bus&&f.enabled&&(f.send_char(a.keyCode),a.preventDefault())}function d(a){8===a.keyCode&&(f.send_char(127),a.preventDefault())}function e(a){for(var b=a.clipboardData.getData("text/plain"),c=0;c<b.length;c++)f.send_char(b.charCodeAt(c));a.preventDefault()}var f=this;this.enabled=!0;this.bus=b;this.bus.register("serial0-output-char",function(a){this.show_char(a)},this);this.destroy=function(){a.removeEventListener("keypress",c,!1);a.removeEventListener("keydown", |
| d,!1);a.removeEventListener("paste",e,!1)};this.init=function(){this.destroy();a.addEventListener("keypress",c,!1);a.addEventListener("keydown",d,!1);a.addEventListener("paste",e,!1)};this.init();this.show_char=function(b){"\b"===b?(b=a.value,a.value=b.substr(0,b.length-1)):"\r"!==b&&(a.value+=b,"\n"===b&&(a.scrollTop=1E9))};this.send_char=function(a){f.bus&&f.bus.send("serial0-input",a)}};function NetworkAdapter(a,b){this.bus=b;this.socket=void 0;this.send_queue=[];this.url=a;this.last_connect_attempt=Date.now()-1E4;this.bus.register("net0-send",function(a){this.send(a)},this)}NetworkAdapter.prototype.handle_message=function(a){this.bus&&this.bus.send("net0-receive",new Uint8Array(a.data))};NetworkAdapter.prototype.handle_close=function(){this.connect();setTimeout(this.connect.bind(this),1E4)}; |
| NetworkAdapter.prototype.handle_open=function(){for(var a=0;a<this.send_queue.length;a++)this.send(this.send_queue[a]);this.send_queue=[]};NetworkAdapter.prototype.handle_error=function(){};NetworkAdapter.prototype.destroy=function(){this.socket&&this.socket.close()}; |
| NetworkAdapter.prototype.connect=function(){if(this.socket){var a=this.socket.readyState;if(0===a||1===a)return}this.last_connect_attempt+1E4>Date.now()||(this.last_connect_attempt=Date.now(),this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onopen=this.handle_open.bind(this),this.socket.onmessage=this.handle_message.bind(this),this.socket.onclose=this.handle_close.bind(this),this.socket.onerror=this.handle_error.bind(this))}; |
| NetworkAdapter.prototype.send=function(a){this.socket&&1===this.socket.readyState?this.socket.send(a):(this.send_queue.push(a),128<this.send_queue.length&&(this.send_queue=this.send_queue.slice(-64)),this.connect())};(function(){function a(a,b,c,d){var k=new XMLHttpRequest;k.open("get",a,!0);k.responseType="arraybuffer";if(d)for(var m=Object.keys(d),n=0;n<m.length;n++){var p=m[n];k.setRequestHeader(p,d[p])}k.onload=function(){4===k.readyState&&(200!==k.status&&206!==k.status?console.log("Loading the image `"+a+"` failed"):k.response&&b(k.response))};c&&(k.onprogress=function(a){c(a)});k.send(null)}function b(a,b,c){console.assert(a+b.length<=this.byteLength);var d=b.length;console.assert(0===a%this.block_size); |
| console.assert(0===d%this.block_size);console.assert(d);a=a/this.block_size;for(var d=d/this.block_size,k=0;k<d;k++){var m=this.loaded_blocks[a+k];void 0===m&&(m=this.loaded_blocks[a+k]=new Uint8Array(this.block_size));var n=b.subarray(k*this.block_size,(k+1)*this.block_size);m.set(n);console.assert(m.byteLength===n.length)}c()}function c(a,b,c){this.AsyncXHRBuffer$filename=a;this.block_size=b;this.AsyncXHRBuffer$block_count=c/b;console.assert(this.AsyncXHRBuffer$block_count===(this.AsyncXHRBuffer$block_count| |
| 0));this.loaded_blocks={};this.byteLength=c;this.get_buffer=function(){}}function d(a){this.AsyncFileBuffer$file=a;this.byteLength=a.size;this.block_size=512;this.loaded_blocks={};this.get_buffer=function(){};this.load=function(){this.onload&&this.onload({})}}v86util.load_file=a;v86util.AsyncXHRBuffer=c;v86util.AsyncFileBuffer=d;v86util.SyncFileBuffer=function(a){var b=!1,c=this;this.byteLength=a.size;1073741824<a.size&&console.log("Warning: Allocating buffer of "+(a.size>>20)+" MB ...");var d=new ArrayBuffer(a.size), |
| k=0,m=new FileReader;this.load=function(){function n(){if(c.onprogress)c.onprogress({loaded:k,total:a.size,lengthComputable:!0});if(k<a.size)m.readAsArrayBuffer(a.slice(k,Math.min(k+4194304,a.size)));else if(b=!0,c.onload)c.onload({})}m.onload=function(a){(new Uint8Array(d,k)).set(new Uint8Array(a.target.result));k+=4194304;n()};n()};this.get=function(a,c,e){if(b)console.assert(a+c<=d.byteLength),e(new Uint8Array(d,a,c));else throw"SyncFileBuffer: Wait for ready";};this.get_buffer=function(a){if(b)a(d); |
| else throw"SyncFileBuffer: Wait for ready";};this.set=function(a,c,e){if(b)console.assert(a+c.byteLength<=d.byteLength),(new Uint8Array(d,a,c.byteLength)).set(c),e();else throw"SyncFileBuffer: Wait for ready";}};c.prototype.get=function(b,c,d){console.assert(0===b%this.block_size);console.assert(0===c%this.block_size);console.assert(c);a(this.AsyncXHRBuffer$filename,function(a){a=new Uint8Array(a);this.handle_read(b,c,a);d(a)}.bind(this),null,{Range:"bytes="+b+"-"+(b+c-1)})};c.prototype.set=b;c.prototype.handle_read= |
| function(a,b,c){a=a/this.block_size;b=b/this.block_size;for(var d=0;d<b;d++){var k=this.loaded_blocks[a+d];k&&c.set(k,d*this.block_size)}};d.prototype.get=function(a,b,c){console.assert(0===a%this.block_size);console.assert(0===b%this.block_size);console.assert(b);var d=new FileReader;d.onload=function(d){d=new Uint8Array(d.target.result);this.handle_read(a,b,d);c(d)}.bind(this);d.readAsArrayBuffer(this.AsyncFileBuffer$file.slice(a,a+b))};d.prototype.set=b;d.prototype.handle_read=c.prototype.handle_read})();function V86Starter(a){function b(a,b){a&&(a.buffer?(console.assert(a.buffer instanceof ArrayBuffer||a.buffer instanceof File,"buffer should be ArrayBuffer or File"),b(a.buffer)):a.url&&(a.async?b(a):m.push({url:a.url,handler:b,size:a.size})))}function c(a,b){switch(a){case "hda":k.hda=b;break;case "hdb":k.hdb=b;break;case "cdrom":k.cdrom=b;break;case "fda":k.fda=b;break;case "fdb":k.fdb=b;break;case "bios":k.bios=b;break;case "vga_bios":k.vga_bios=b}}function d(a,b){if(b instanceof ArrayBuffer)var d= |
| new SyncBuffer(b);else b instanceof File?d=new v86util.AsyncFileBuffer(b):b.async?d=new v86util.AsyncXHRBuffer(b.url,512,b.size):console.assert(!1);c(a,d)}function e(b){var c=m.length;if(b<c){var d=m[b];v86util.load_file(d.url,function(a){d.handler(a);e(b+1)},function(a){p.emulator_bus.send("download-progress",{file_index:b,file_count:c,lengthComputable:a.lengthComputable,total:d.size||a.total,loaded:a.loaded})})}else l.init(k),n&&l.v86_prototype$restore_state(n),a.autostart&&l.run()}var f=Bus.create(), |
| g=this.bus=f[0];this.emulator_bus=f[1];var l=this.v86=new v86(f[1]),k={load_devices:!0};k.memory_size=a.memory_size||67108864;k.vga_memory_size=a.vga_memory_size||8388608;k.boot_order=a.boot_order||531;k.fda=void 0;k.fdb=void 0;a.network_relay_url&&(new NetworkAdapter(a.network_relay_url,g),k.enable_ne2k=!0);a.disable_keyboard||(this.keyboard_adapter=new KeyboardAdapter(g));a.disable_mouse||(this.mouse_adapter=new MouseAdapter(g));a.screen_container&&(this.screen_adapter=new ScreenAdapter(a.screen_container, |
| g));a.serial_container&&new SerialAdapter(a.serial_container,g);var m=[];b(a.bios,c.bind(this,"bios"));b(a.vga_bios,c.bind(this,"vga_bios"));b(a.cdrom,d.bind(this,"cdrom"));b(a.hda,d.bind(this,"hda"));b(a.hdb,d.bind(this,"hdb"));b(a.fda,d.bind(this,"fda"));b(a.fdb,d.bind(this,"fdb"));a.filesystem&&(f=new FS(a.filesystem.baseurl),k.fs9p=f,f.LoadFilesystem({basefsURL:a.filesystem.basefs}));var n;a.initial_state&&b(a.initial_state,function(a){n=a});var p=this;e(0)}V86Starter.prototype.run=function(){this.v86.run()}; |
| V86Starter.prototype.stop=function(){this.v86.stop()};V86Starter.prototype.restart=function(){this.v86.restart()};V86Starter.prototype.add_listener=function(a,b){this.bus.register(a,b,this)};V86Starter.prototype.remove_listener=function(a,b){this.bus.unregister(a,b)};V86Starter.prototype.V86Starter_prototype$restore_state=function(a){this.v86.v86_prototype$restore_state(a)}; |
| V86Starter.prototype.save_state=function(a){var b=this;setTimeout(function(){try{a(null,b.v86.save_state())}catch(c){a(c,null)}},0)};V86Starter.prototype.get_statistics=function(){var a={cpu:{instruction_counter:this.v86.cpu.timestamp_counter}},b=this.v86.cpu.devices;b.hda&&(a.hda=b.hda.stats);b.cdrom&&(a.cdrom=b.cdrom.stats);b.ps2&&(a.mouse={enabled:b.ps2.use_mouse});b.vga&&(a.vga=b.vga.stats);return a};V86Starter.prototype.is_running=function(){return this.v86.running}; |
| V86Starter.prototype.keyboard_send_scancodes=function(a){for(var b=this.v86.cpu.devices.ps2,c=0;c<a.length;c++)b.kbd_send_code(a[c])};V86Starter.prototype.screen_make_screenshot=function(){this.screen_adapter&&this.screen_adapter.make_screenshot()};V86Starter.prototype.screen_set_scale=function(a,b){this.screen_adapter&&this.screen_adapter.set_scale(a,b)}; |
| V86Starter.prototype.screen_go_fullscreen=function(){if(this.screen_adapter){var a=document.getElementById("screen_container");if(a){var b=a.requestFullScreen||a.webkitRequestFullscreen||a.mozRequestFullScreen||a.msRequestFullScreen;b&&(b.call(a),(a=document.getElementsByClassName("phone_keyboard")[0])&&a.focus());this.lock_mouse()}}};V86Starter.prototype.lock_mouse=function(){var a=document.body,b=a.requestPointerLock||a.mozRequestPointerLock||a.webkitRequestPointerLock;b&&b.call(a)}; |
| V86Starter.prototype.mouse_set_status=function(a){this.mouse_adapter&&(this.mouse_adapter.MouseAdapter$emu_enabled=a)};V86Starter.prototype.keyboard_set_status=function(a){this.keyboard_adapter&&(this.keyboard_adapter.KeyboardAdapter$emu_enabled=a)};V86Starter.prototype.serial0_send=function(a){for(var b=0;b<a.length;b++)this.bus.send("serial0-input",a.charCodeAt(b))}; |
| "undefined"!==typeof window&&(window.V86Starter=V86Starter,V86Starter.prototype.run=V86Starter.prototype.run,V86Starter.prototype.stop=V86Starter.prototype.stop,V86Starter.prototype.restart=V86Starter.prototype.restart,V86Starter.prototype.add_listener=V86Starter.prototype.add_listener,V86Starter.prototype.remove_listener=V86Starter.prototype.remove_listener,V86Starter.prototype.restore_state=V86Starter.prototype.V86Starter_prototype$restore_state,V86Starter.prototype.save_state=V86Starter.prototype.save_state, |
| V86Starter.prototype.get_statistics=V86Starter.prototype.get_statistics,V86Starter.prototype.is_running=V86Starter.prototype.is_running,V86Starter.prototype.keyboard_send_scancodes=V86Starter.prototype.keyboard_send_scancodes,V86Starter.prototype.screen_make_screenshot=V86Starter.prototype.screen_make_screenshot,V86Starter.prototype.screen_set_scale=V86Starter.prototype.screen_set_scale,V86Starter.prototype.screen_go_fullscreen=V86Starter.prototype.screen_go_fullscreen,V86Starter.prototype.lock_mouse= |
| V86Starter.prototype.lock_mouse,V86Starter.prototype.mouse_set_status=V86Starter.prototype.mouse_set_status,V86Starter.prototype.keyboard_set_status=V86Starter.prototype.keyboard_set_status,V86Starter.prototype.serial0_send=V86Starter.prototype.serial0_send); |
| //# sourceMappingURL=v86_all.js.map |