blob: 803a8d5e7cfea3738a00dc3d57c053dfbbf173c7 [file] [log] [blame] [raw]
'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=[]}Virtio9p.prototype.BuildReply=function(a,c,d){Marshall(["w","b","h"],[d+7,a+1,c],this.replybuffer,0);this.replybuffersize=d+7};Virtio9p.prototype.SendError=function(a,c){var d=Marshall(["w"],[c],this.replybuffer,7);this.BuildReply(6,a,d)};
Virtio9p.prototype.ReceiveRequest=function(a,c){var d=Unmarshall2(["w","b","h"],c),e=d[1],f=d[2];switch(e){case 8:var d=1234567,g=[16914839];g[1]=this.BLOCKSIZE;g[2]=Math.floor(1073741824/g[1]);g[3]=g[2]-Math.floor(d/g[1]);g[4]=g[2]-Math.floor(d/g[1]);g[5]=this.fs.inodes.length;g[6]=1048576;g[7]=0;g[8]=256;d=Marshall("wwddddddw".split(""),g,this.replybuffer,7);this.BuildReply(e,f,d);this.SendReply(a);break;case 112:case 12:var g=Unmarshall2(["w","w"],c),k=g[0],m=g[1],l=this.fs.GetInode(this.fid2inode[k]);
g[0]=l.qid;g[1]=this.msize-24;Marshall(["Q","w"],g,this.replybuffer,7);this.BuildReply(e,f,17);d=this.fs.OpenInode(this.fid2inode[k]);this.fs.AddEvent(this.fid2inode[k],function(){g[0]=l.qid;g[1]=this.msize-24;Marshall(["Q","w"],g,this.replybuffer,7);this.BuildReply(e,f,17);this.SendReply(a)}.bind(this));break;case 70:var g=Unmarshall2(["w","w","s"],c),m=g[0],k=g[1],d=g[2],l=this.fs.CreateInode(),n=this.fs.GetInode(this.fid2inode[k]),p=this.fs.inodedata[this.fid2inode[k]];l.mode=n.mode;l.size=n.size;
l.symlink=n.symlink;var s=this.fs.inodedata[this.fs.inodes.length]=new Uint8Array(l.size);l.waswritten=!0;for(n=0;n<l.size;n++)s[n]=p[n];l.name=d;l.parentid=this.fid2inode[m];this.fs.PushInode(l);this.BuildReply(e,f,0);this.SendReply(a);break;case 16:g=Unmarshall2(["w","s","s","w"],c);k=g[0];d=g[1];n=g[3];d=this.fs.CreateSymlink(d,this.fid2inode[k],g[2]);l=this.fs.GetInode(d);l.uid=n;l.gid=n;Marshall(["Q"],[l.qid],this.replybuffer,7);this.BuildReply(e,f,13);this.SendReply(a);break;case 18:g=Unmarshall2("wswwww".split(""),
c);k=g[0];d=g[1];m=g[2];d=this.fs.CreateNode(d,this.fid2inode[k],g[3],g[4]);l=this.fs.GetInode(d);l.mode=m;l.uid=n;l.gid=n;Marshall(["Q"],[l.qid],this.replybuffer,7);this.BuildReply(e,f,13);this.SendReply(a);break;case 22:g=Unmarshall2(["w"],c);k=g[0];l=this.fs.GetInode(this.fid2inode[k]);d=Marshall(["s"],[l.symlink],this.replybuffer,7);this.BuildReply(e,f,d);this.SendReply(a);break;case 72:g=Unmarshall2(["w","s","w","w"],c);k=g[0];d=g[1];m=g[2];n=g[3];d=this.fs.CreateDirectory(d,this.fid2inode[k]);
l=this.fs.GetInode(d);l.mode=m|S_IFDIR;l.uid=n;l.gid=n;Marshall(["Q"],[l.qid],this.replybuffer,7);this.BuildReply(e,f,13);this.SendReply(a);break;case 14:g=Unmarshall2(["w","s","w","w","w"],c);k=g[0];d=g[1];m=g[3];n=g[4];d=this.fs.CreateFile(d,this.fid2inode[k]);this.fid2inode[k]=d;this.fidtype[k]=1;l=this.fs.GetInode(d);l.uid=n;l.gid=n;l.mode=m;Marshall(["Q","w"],[l.qid,this.msize-24],this.replybuffer,7);this.BuildReply(e,f,17);this.SendReply(a);break;case 52:Marshall(["w"],[0],this.replybuffer,
7);this.BuildReply(e,f,1);this.SendReply(a);break;case 24:g=Unmarshall2(["w","d"],c);k=g[0];l=this.fs.GetInode(this.fid2inode[k]);g[0]|=4096;g[0]=g[1];g[1]=l.qid;g[2]=l.mode;g[3]=l.uid;g[4]=l.gid;g[5]=1;g[6]=l.major<<8|l.minor;g[7]=l.size;g[8]=l.size;g[9]=Math.floor(l.size/this.BLOCKSIZE+1);g[10]=l.atime;g[11]=0;g[12]=l.mtime;g[13]=0;g[14]=l.ctime;g[15]=0;g[16]=0;g[17]=0;g[18]=0;g[19]=0;Marshall("dQwwwddddddddddddddd".split(""),g,this.replybuffer,7);this.BuildReply(e,f,153);this.SendReply(a);break;
case 26:g=Unmarshall2("wwwwwddddd".split(""),c);k=g[0];l=this.fs.GetInode(this.fid2inode[k]);g[1]&1&&(l.mode=g[2]);g[1]&2&&(l.uid=g[3]);g[1]&4&&(l.gid=g[4]);g[1]&128&&(l.atime=g[6]);g[1]&256&&(l.atime=g[8]);g[1]&16&&(l.atime=Math.floor((new Date).getTime()/1E3));g[1]&32&&(l.mtime=Math.floor((new Date).getTime()/1E3));g[1]&64&&(l.ctime=Math.floor((new Date).getTime()/1E3));g[1]&8&&this.fs.ChangeSize(this.fid2inode[k],g[5]);this.BuildReply(e,f,0);this.SendReply(a);break;case 50:g=Unmarshall2(["w","d"],
c);k=g[0];this.BuildReply(e,f,0);this.SendReply(a);break;case 40:case 116:var g=Unmarshall2(["w","d","w"],c),k=g[0],q=g[1],r=g[2],l=this.fs.GetInode(this.fid2inode[k]);if(2==this.fidtype[k]){l.caps.length<q+r&&(r=l.caps.length-q);for(n=0;n<r;n++)this.replybuffer[11+n]=l.caps[q+n];Marshall(["w"],[r],this.replybuffer,7);this.BuildReply(e,f,4+r);this.SendReply(a)}else this.fs.OpenInode(this.fid2inode[k]),this.fs.AddEvent(this.fid2inode[k],function(){l.size<q+r&&(r=l.size-q);var c=this.fs.inodedata[this.fid2inode[k]];
if(c)for(var d=0;d<r;d++)this.replybuffer[11+d]=c[q+d];Marshall(["w"],[r],this.replybuffer,7);this.BuildReply(e,f,4+r);this.SendReply(a)}.bind(this));break;case 118:g=Unmarshall2(["w","d","w"],c);k=g[0];q=g[1];r=g[2];this.fs.Write(this.fid2inode[k],q,r,c);Marshall(["w"],[r],this.replybuffer,7);this.BuildReply(e,f,4);this.SendReply(a);break;case 74:g=Unmarshall2(["w","s","w","s"],c);d=this.fs.Rename(this.fid2inode[g[0]],g[1],this.fid2inode[g[2]],g[3]);if(0==d){this.SendError(f,2);this.SendReply(a);
break}this.BuildReply(e,f,0);this.SendReply(a);break;case 76:g=Unmarshall2(["w","s","w"],c);n=g[0];d=g[1];k=this.fs.Search(this.fid2inode[n],d);if(-1==k){this.SendError(f,2);this.SendReply(a);break}d=this.fs.Unlink(k);if(!d){this.SendError(f,39);this.SendReply(a);break}this.BuildReply(k,f,0);this.SendReply(a);break;case 100:this.msize=Unmarshall2(["w","s"],c)[0];d=Marshall(["w","s"],[this.msize,"9P2000.L"],this.replybuffer,7);this.BuildReply(e,f,d);this.SendReply(a);break;case 104:g=Unmarshall2(["w",
"w","s","s"],c);k=g[0];this.fid2inode[k]=0;this.fidtype[k]=1;l=this.fs.GetInode(this.fid2inode[k]);Marshall(["Q"],[l.qid],this.replybuffer,7);this.BuildReply(e,f,13);this.SendReply(a);break;case 108:g=Unmarshall2(["h"],c);this.BuildReply(e,f,0);this.SendReply(a);break;case 110:g=Unmarshall2(["w","w","h"],c);k=g[0];m=g[1];p=g[2];if(0==p){this.fid2inode[m]=this.fid2inode[k];Marshall(["h"],[0],this.replybuffer,7);this.BuildReply(e,f,2);this.SendReply(a);break}d=[];for(n=0;n<p;n++)d.push("s");for(var s=
Unmarshall2(d,c),d=this.fid2inode[k],q=9,t=0,n=0;n<p;n++){d=this.fs.Search(d,s[n]);if(-1==d)break;q+=Marshall(["Q"],[this.fs.inodes[d].qid],this.replybuffer,q);t++;this.fid2inode[m]=d;this.fidtype[m]=1}Marshall(["h"],[t],this.replybuffer,7);this.BuildReply(e,f,q-7);this.SendReply(a);break;case 120:g=Unmarshall2(["w"],c);0<=this.fid2inode[g[0]]&&(this.fs.CloseInode(this.fid2inode[g[0]]),this.fid2inode[g[0]]=-1,this.fidtype[g[0]]=-1);this.BuildReply(e,f,0);this.SendReply(a);break;case 32:this.SendError(f,
524);this.SendReply(a);break;case 30:g=Unmarshall2(["w","w","s"],c),k=g[0],n=g[1],d=g[2],this.fid2inode[n]=this.fid2inode[k],this.fidtype[n]=-1,m=0,"security.capability"==d&&(m=this.fs.PrepareCAPs(this.fid2inode[k]),this.fidtype[n]=2),Marshall(["d"],[m],this.replybuffer,7),this.BuildReply(e,f,8),this.SendReply(a)}};(function(){function a(){for(var a=location.search.substr(1).split("&"),c,f={},d=0;d<a.length;d++)c=a[d].split("="),f[c[0]]=c[1];return f}function c(a){var c=a.requestPointerLock||a.mozRequestPointerLock||a.webkitRequestPointerLock;c&&c.call(a)}function d(a,c){for(var f="";0<c--;)f+=a;return f}function e(a,c){var e=f("loading");e.style.display="block";if(c.lengthComputable||a.total&&"number"===typeof c.loaded){var g=c.loaded/(c.total||a.total)*100|0,g=Math.min(100,Math.max(0,g));e.textContent=a.msg+
" "+g+"% ["+d("#",g>>1)+d(" ",50-(g>>1))+"]"}else a.ticks||(a.ticks=0),e.textContent=a.msg+" "+d(".",a.ticks++%50)}function f(a){document.getElementById(a)||console.log("Element with id `"+a+"` not found");return document.getElementById(a)}function g(){function d(a,c,f){document.title=a.name+" - Virtual x86";if(67108864>a.size){var g=new v86util.SyncFileBuffer(a);g.onprogress=e.bind(this,{msg:"Loading disk image into memory"})}else g=new v86util.AsyncFileBuffer(a);g.onload=function(){switch(c){case "floppy":m.fda=
g;break;case "hd":m.hda=g;break;case "cdrom":m.cdrom=g}f()};g.load()}function g(a,c,d){c.memory_size=a.memory_size;c.vga_memory_size=a.vga_memory_size;a.async_hda&&(c.hda=new v86util.AsyncXHRBuffer(a.async_hda,512,a.async_hda_size));a.filesystem&&(c.fs9p=new FS(a.filesystem.baseurl),a.filesystem.basefs&&c.fs9p.LoadFilesystem({lazyloadimages:[],earlyload:[],basefsURL:a.filesystem.basefs}));a.fda?c.fda=new SyncBuffer(d):a.cdrom&&(c.cdrom=new SyncBuffer(d));k(c,function(c){a.state&&(f("reset").style.display=
"none",c.restore_state(d));c.run()})}if("responseType"in new XMLHttpRequest){var m={load_devices:!0};f("toggle_mouse").onclick=function(){var a=m.mouse_adapter;a&&(a=a.emu_enabled=!a.emu_enabled,f("toggle_mouse").value=(a?"Dis":"En")+"able mouse")};f("lock_mouse").onclick=function(){var a=m.mouse_adapter;if(a&&!a.emu_enabled)f("toggle_mouse").onclick();c(document.body);f("lock_mouse").blur()};v86util.load_file("bios/seabios.bin",function(a){m.bios=a;l&&l()});v86util.load_file("bios/bochs-vgabios-0.7a.bin",
function(a){m.vga_bios=a;l&&l()});f("start_emulation").onclick=function(){function a(){if(0===c.length)k(m,function(a){a.run()});else{var f=c.pop();d(f.file,f.type,a)}}f("boot_options").style.display="none";var c=[];f("floppy_image").files.length&&c.push({file:f("floppy_image").files[0],type:"floppy"});f("cd_image").files.length&&c.push({file:f("cd_image").files[0],type:"cdrom"});f("hd_image").files.length&&c.push({file:f("hd_image").files[0],type:"hd"});a()};for(var q=[{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"}],r=a().profile,t=0;t<q.length;t++){var x=q[t],A="start_"+x.id;f(A).onclick=function(a){v86util.load_file(a.state||a.fda||a.cdrom,g.bind(this,a,m),e.bind(this,{msg:"Downloading image",total:a.size}));var c;(c=r===a.id?window.history.replaceState:window.history.pushState)&&c.call(window.history,{profile:a.id},"","?profile="+a.id);document.title=
a.name+" - Virtual x86";f(A).blur();f("boot_options").style.display="none"}.bind(this,x);if(r===x.id){f(A).onclick();break}}}else alert("Your browser is not supported because it doesn't have XMLHttpRequest.responseType")}function k(a,c){if(a.bios&&a.vga_bios){var d=new v86;a.fdb=void 0;a.screen_adapter=new ScreenAdapter(f("screen_container"));a.keyboard_adapter=new KeyboardAdapter;a.mouse_adapter=new MouseAdapter;a.boot_order=parseInt(f("boot_order").value,16);a.serial_adapter=new SerialAdapter(f("serial"));
a.network_adapter=new NetworkAdapter("ws://relay.widgetry.org/");if(!a.memory_size){var e=1048576*parseInt(f("memory_size").value,10);16777216<=e&&2147483648>e?a.memory_size=e:(alert("Invalid memory size - ignored."),a.memory_size=33554432)}a.vga_memory_size||(e=1048576*parseInt(f("video_memory_size").value,10),65536<e&&2147483648>e?a.vga_memory_size=e:(alert("Invalid video memory size - ignored."),a.vga_memory_size=8388608));m(a,d);d.init(a);c(d)}else l=k.bind(this,a,c)}function m(a,d){function e(){if(m){var a=
Date.now(),c=(d.timestamp_counter-E)/1E3|0;B+=c;w+=a-u;u=a;A.textContent=c;y.textContent=B/w*1E3|0;a=w/1E3|0;l.textContent=60>a?a+"s":3600>a?(a/60|0)+"m "+String.pad0(a%60,2)+"s":(a/3600|0)+"h "+String.pad0((a/60|0)%60,2)+"m "+String.pad0(a%60,2)+"s";E=d.timestamp_counter}setTimeout(e,1E3)}function g(){if(m){var c=d.devices.vga.stats;c.is_graphical?(f("info_vga_mode").textContent="graphical",f("info_res").textContent=c.res_x+"x"+c.res_y,f("info_bpp").textContent=c.bpp):(f("info_vga_mode").textContent=
"text",f("info_res").textContent="-",f("info_bpp").textContent="-");a.mouse_adapter&&(f("info_mouse_enabled").textContent=a.mouse_adapter.enabled?"Yes":"No");d.devices.hda?(c=d.devices.hda.stats,f("info_hda_sectors_read").textContent=c.sectors_read,f("info_hda_bytes_read").textContent=c.bytes_read,f("info_hda_sectors_written").textContent=c.sectors_written,f("info_hda_bytes_written").textContent=c.bytes_written,f("info_hda_status").textContent=c.loading?"Loading ...":"Idle"):f("info_hda").style.display=
"none";d.devices.cdrom?(c=d.devices.cdrom.stats,f("info_cdrom_sectors_read").textContent=c.sectors_read,f("info_cdrom_bytes_read").textContent=c.bytes_read,f("info_cdrom_status").textContent=c.loading?"Loading ...":"Idle"):f("info_cdrom").style.display="none"}setTimeout(g,1E3)}function k(a){a.ctrlKey?window.onbeforeunload=function(){window.onbeforeunload=null;return"CTRL-W cannot be sent to the emulator."}:window.onbeforeunload=null}f("boot_options").style.display="none";f("loading").style.display=
"none";f("runtime_options").style.display="block";f("runtime_infos").style.display="block";document.getElementsByClassName("phone_keyboard")[0].style.display="block";f("news")&&(f("news").style.display="none");var m=!0;f("run").onclick=function(){m?(w+=Date.now()-u,f("run").value="Run",d.stop()):(f("run").value="Pause",d.run(),u=Date.now());m=!m;f("run").blur()};f("exit").onclick=function(){location.href=location.pathname};var l=f("running_time"),A=f("speed"),y=f("avg_speed"),u=Date.now(),w=0,B=0,
E=0;setTimeout(e,1E3);setTimeout(g,0);f("reset").onclick=function(){d.restart();f("reset").blur()};for(var v=["hda","hdb","fda","fdb"],z=0;z<v.length;z++){var D=f("get_"+v[z]+"_image"),F=a[v[z]];F&&16777216>F.byteLength?D.onclick=function(a){F.get_buffer(function(c){var d=a+".img",f=new Blob([c]);c=document.createElement("a");c.download=d;c.href=window.URL.createObjectURL(f);c.dataset.downloadurl=["application/octet-stream",c.download,c.href].join(":");document.createEvent?(d=document.createEvent("MouseEvent"),
d.initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),c.dispatchEvent(d)):c.click()});this.blur()}.bind(D,v[z]):D.style.display="none"}f("ctrlaltdel").onclick=function(){var a=d.devices.ps2;a.kbd_send_code(29);a.kbd_send_code(56);a.kbd_send_code(83);a.kbd_send_code(157);a.kbd_send_code(184);a.kbd_send_code(211);f("ctrlaltdel").blur()};f("scale").onchange=function(){var c=parseFloat(this.value);(c||0<c)&&a.screen_adapter.set_scale(c,c)};f("fullscreen").onclick=function(){var a=document.getElementById("screen_container"),
d=a.requestFullScreen||a.webkitRequestFullscreen||a.mozRequestFullScreen||a.msRequestFullScreen;d&&(d.call(a),document.getElementsByClassName("phone_keyboard")[0].focus());c(a)};f("screen_container").onclick=function(){window.getSelection().isCollapsed&&document.getElementsByClassName("phone_keyboard")[0].focus()};f("take_screenshot").onclick=function(){a.screen_adapter.make_screenshot();f("take_screenshot").blur()};a.serial_adapter&&(f("serial").style.display="block");window.addEventListener("keydown",
k,!1);window.addEventListener("keyup",k,!1);window.addEventListener("blur",k,!1)}var l;window.addEventListener("load",g,!1);window.addEventListener("popstate",function(){location.reload()},!1);"complete"===document.readyState&&g()})();function v86(){this.memory_size=0;this.segment_is_null=[];this.segment_offsets=[];this.segment_limits=[];this.tlb_data=[];this.tlb_info=[];this.tlb_info_global=[];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.stopped=this.running=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.current_settings={};this.paging=!1;this.timestamp_counter=this.previous_ip=this.instruction_pointer=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.first_init=!0;this.v86$next_tick=function(){};this.microtick=function(){};
this.fpu=this.io=void 0;"use strict";(function(a){var c={};a.debug=c;c.step_mode=!1;c.ops={};c.show=function(a){if("undefined"!==typeof document){var c=document.getElementById("log");if(c){c.textContent+=a+"\n";c.style.display="block";c.scrollTop=1E9;return}}console.log(c)};c.init=function(){};c.dump_regs=function(){};c.dump_instructions=function(){};c.dump_regs_short=function(){};c.dump_stack=function(){};c.dump_page_directory=function(){};c.dump_gdt_ldt=function(){};c.dump_idt=function(){};c.get_memory_dump=
function(){};c.memory_hex_dump=function(){};c.used_memory_dump=function(){};c.step=function(){};c.run_until=function(){};c.debugger=function(){};c.unimpl=function(a){a="Unimplemented"+(a?": "+a:"");c.show(a);c.show("Execution stopped");return a};c.logop=function(){}})(this)}
v86.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};"use strict";
(function(){v86.prototype.modrm_table16=Array(192);v86.prototype.modrm_table32=Array(192);v86.prototype.sib_table=Array(256);v86.prototype.modrm_table16[0]=function(a){return a.get_seg_prefix_ds()+(a.reg16[6]+a.reg16[12]&65535)|0};v86.prototype.modrm_table16[64]=function(a){return a.get_seg_prefix_ds()+(a.reg16[6]+a.reg16[12]+a.read_imm8s()&65535)|0};v86.prototype.modrm_table16[128]=function(a){return a.get_seg_prefix_ds()+(a.reg16[6]+a.reg16[12]+a.read_imm16()&65535)|0};v86.prototype.modrm_table16[1]=
function(a){return a.get_seg_prefix_ds()+(a.reg16[6]+a.reg16[14]&65535)|0};v86.prototype.modrm_table16[65]=function(a){return a.get_seg_prefix_ds()+(a.reg16[6]+a.reg16[14]+a.read_imm8s()&65535)|0};v86.prototype.modrm_table16[129]=function(a){return a.get_seg_prefix_ds()+(a.reg16[6]+a.reg16[14]+a.read_imm16()&65535)|0};v86.prototype.modrm_table16[2]=function(a){return a.get_seg_prefix_ss()+(a.reg16[10]+a.reg16[12]&65535)|0};v86.prototype.modrm_table16[66]=function(a){return a.get_seg_prefix_ss()+(a.reg16[10]+
a.reg16[12]+a.read_imm8s()&65535)|0};v86.prototype.modrm_table16[130]=function(a){return a.get_seg_prefix_ss()+(a.reg16[10]+a.reg16[12]+a.read_imm16()&65535)|0};v86.prototype.modrm_table16[3]=function(a){return a.get_seg_prefix_ss()+(a.reg16[10]+a.reg16[14]&65535)|0};v86.prototype.modrm_table16[67]=function(a){return a.get_seg_prefix_ss()+(a.reg16[10]+a.reg16[14]+a.read_imm8s()&65535)|0};v86.prototype.modrm_table16[131]=function(a){return a.get_seg_prefix_ss()+(a.reg16[10]+a.reg16[14]+a.read_imm16()&
65535)|0};v86.prototype.modrm_table16[4]=function(a){return a.get_seg_prefix_ds()+(a.reg16[12]&65535)|0};v86.prototype.modrm_table16[68]=function(a){return a.get_seg_prefix_ds()+(a.reg16[12]+a.read_imm8s()&65535)|0};v86.prototype.modrm_table16[132]=function(a){return a.get_seg_prefix_ds()+(a.reg16[12]+a.read_imm16()&65535)|0};v86.prototype.modrm_table16[5]=function(a){return a.get_seg_prefix_ds()+(a.reg16[14]&65535)|0};v86.prototype.modrm_table16[69]=function(a){return a.get_seg_prefix_ds()+(a.reg16[14]+
a.read_imm8s()&65535)|0};v86.prototype.modrm_table16[133]=function(a){return a.get_seg_prefix_ds()+(a.reg16[14]+a.read_imm16()&65535)|0};v86.prototype.modrm_table16[6]=function(a){return a.get_seg_prefix_ss()+(a.reg16[10]&65535)|0};v86.prototype.modrm_table16[70]=function(a){return a.get_seg_prefix_ss()+(a.reg16[10]+a.read_imm8s()&65535)|0};v86.prototype.modrm_table16[134]=function(a){return a.get_seg_prefix_ss()+(a.reg16[10]+a.read_imm16()&65535)|0};v86.prototype.modrm_table16[7]=function(a){return a.get_seg_prefix_ds()+
(a.reg16[6]&65535)|0};v86.prototype.modrm_table16[71]=function(a){return a.get_seg_prefix_ds()+(a.reg16[6]+a.read_imm8s()&65535)|0};v86.prototype.modrm_table16[135]=function(a){return a.get_seg_prefix_ds()+(a.reg16[6]+a.read_imm16()&65535)|0};v86.prototype.modrm_table32[0]=function(a){return a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.modrm_table32[64]=function(a){return a.get_seg_prefix_ds()+a.reg32s[0]+a.read_imm8s()|0};v86.prototype.modrm_table32[128]=function(a){return a.get_seg_prefix_ds()+
a.reg32s[0]+a.read_imm32s()|0};v86.prototype.modrm_table32[1]=function(a){return a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.modrm_table32[65]=function(a){return a.get_seg_prefix_ds()+a.reg32s[1]+a.read_imm8s()|0};v86.prototype.modrm_table32[129]=function(a){return a.get_seg_prefix_ds()+a.reg32s[1]+a.read_imm32s()|0};v86.prototype.modrm_table32[2]=function(a){return a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.modrm_table32[66]=function(a){return a.get_seg_prefix_ds()+a.reg32s[2]+a.read_imm8s()|
0};v86.prototype.modrm_table32[130]=function(a){return a.get_seg_prefix_ds()+a.reg32s[2]+a.read_imm32s()|0};v86.prototype.modrm_table32[3]=function(a){return a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.modrm_table32[67]=function(a){return a.get_seg_prefix_ds()+a.reg32s[3]+a.read_imm8s()|0};v86.prototype.modrm_table32[131]=function(a){return a.get_seg_prefix_ds()+a.reg32s[3]+a.read_imm32s()|0};v86.prototype.modrm_table32[4]=function(a){return a.sib_table[a.read_imm8()](a,!1)|0};v86.prototype.modrm_table32[68]=
function(a){return a.sib_table[a.read_imm8()](a,!1)+a.read_imm8s()|0};v86.prototype.modrm_table32[132]=function(a){return a.sib_table[a.read_imm8()](a,!1)+a.read_imm32s()|0};v86.prototype.modrm_table32[5]=function(a){return a.get_seg_prefix_ss()+a.reg32s[5]|0};v86.prototype.modrm_table32[69]=function(a){return a.get_seg_prefix_ss()+a.reg32s[5]+a.read_imm8s()|0};v86.prototype.modrm_table32[133]=function(a){return a.get_seg_prefix_ss()+a.reg32s[5]+a.read_imm32s()|0};v86.prototype.modrm_table32[6]=function(a){return a.get_seg_prefix_ds()+
a.reg32s[6]|0};v86.prototype.modrm_table32[70]=function(a){return a.get_seg_prefix_ds()+a.reg32s[6]+a.read_imm8s()|0};v86.prototype.modrm_table32[134]=function(a){return a.get_seg_prefix_ds()+a.reg32s[6]+a.read_imm32s()|0};v86.prototype.modrm_table32[7]=function(a){return a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.modrm_table32[71]=function(a){return a.get_seg_prefix_ds()+a.reg32s[7]+a.read_imm8s()|0};v86.prototype.modrm_table32[135]=function(a){return a.get_seg_prefix_ds()+a.reg32s[7]+a.read_imm32s()|
0};v86.prototype.modrm_table16[6]=function(a){return a.get_seg_prefix_ds()+a.read_imm16()|0};v86.prototype.modrm_table32[5]=function(a){return a.get_seg_prefix_ds()+a.read_imm32s()|0};v86.prototype.modrm_table32[4]=function(a){return a.sib_table[a.read_imm8()](a,!1)|0};v86.prototype.modrm_table32[68]=function(a){return a.sib_table[a.read_imm8()](a,!0)+a.read_imm8s()|0};v86.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 c=
0;3>c;c++)for(var d=a|c<<6,e=1;8>e;e++)v86.prototype.modrm_table32[d|e<<3]=v86.prototype.modrm_table32[d],v86.prototype.modrm_table16[d|e<<3]=v86.prototype.modrm_table16[d];v86.prototype.sib_table[0]=function(a){return a.reg32s[0]+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[1]=function(a){return a.reg32s[0]+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[2]=function(a){return a.reg32s[0]+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[3]=function(a){return a.reg32s[0]+
a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[4]=function(a){return a.reg32s[0]+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[5]=function(a,c){return a.reg32s[0]+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[6]=function(a){return a.reg32s[0]+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[7]=function(a){return a.reg32s[0]+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[64]=function(a){return(a.reg32s[0]<<
1)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[65]=function(a){return(a.reg32s[0]<<1)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[66]=function(a){return(a.reg32s[0]<<1)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[67]=function(a){return(a.reg32s[0]<<1)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[68]=function(a){return(a.reg32s[0]<<1)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[69]=function(a,c){return(a.reg32s[0]<<
1)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[70]=function(a){return(a.reg32s[0]<<1)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[71]=function(a){return(a.reg32s[0]<<1)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[128]=function(a){return(a.reg32s[0]<<2)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[129]=function(a){return(a.reg32s[0]<<2)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[130]=
function(a){return(a.reg32s[0]<<2)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[131]=function(a){return(a.reg32s[0]<<2)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[132]=function(a){return(a.reg32s[0]<<2)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[133]=function(a,c){return(a.reg32s[0]<<2)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[134]=function(a){return(a.reg32s[0]<<2)+a.get_seg_prefix_ds()+
a.reg32s[6]|0};v86.prototype.sib_table[135]=function(a){return(a.reg32s[0]<<2)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[192]=function(a){return(a.reg32s[0]<<3)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[193]=function(a){return(a.reg32s[0]<<3)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[194]=function(a){return(a.reg32s[0]<<3)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[195]=function(a){return(a.reg32s[0]<<3)+a.get_seg_prefix_ds()+
a.reg32s[3]|0};v86.prototype.sib_table[196]=function(a){return(a.reg32s[0]<<3)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[197]=function(a,c){return(a.reg32s[0]<<3)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[198]=function(a){return(a.reg32s[0]<<3)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[199]=function(a){return(a.reg32s[0]<<3)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[8]=function(a){return a.reg32s[1]+
a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[9]=function(a){return a.reg32s[1]+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[10]=function(a){return a.reg32s[1]+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[11]=function(a){return a.reg32s[1]+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[12]=function(a){return a.reg32s[1]+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[13]=function(a,c){return a.reg32s[1]+(c?a.get_seg_prefix_ss()+
a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[14]=function(a){return a.reg32s[1]+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[15]=function(a){return a.reg32s[1]+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[72]=function(a){return(a.reg32s[1]<<1)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[73]=function(a){return(a.reg32s[1]<<1)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[74]=function(a){return(a.reg32s[1]<<
1)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[75]=function(a){return(a.reg32s[1]<<1)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[76]=function(a){return(a.reg32s[1]<<1)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[77]=function(a,c){return(a.reg32s[1]<<1)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[78]=function(a){return(a.reg32s[1]<<1)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[79]=
function(a){return(a.reg32s[1]<<1)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[136]=function(a){return(a.reg32s[1]<<2)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[137]=function(a){return(a.reg32s[1]<<2)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[138]=function(a){return(a.reg32s[1]<<2)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[139]=function(a){return(a.reg32s[1]<<2)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[140]=
function(a){return(a.reg32s[1]<<2)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[141]=function(a,c){return(a.reg32s[1]<<2)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[142]=function(a){return(a.reg32s[1]<<2)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[143]=function(a){return(a.reg32s[1]<<2)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[200]=function(a){return(a.reg32s[1]<<3)+a.get_seg_prefix_ds()+
a.reg32s[0]|0};v86.prototype.sib_table[201]=function(a){return(a.reg32s[1]<<3)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[202]=function(a){return(a.reg32s[1]<<3)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[203]=function(a){return(a.reg32s[1]<<3)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[204]=function(a){return(a.reg32s[1]<<3)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[205]=function(a,c){return(a.reg32s[1]<<3)+(c?a.get_seg_prefix_ss()+
a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[206]=function(a){return(a.reg32s[1]<<3)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[207]=function(a){return(a.reg32s[1]<<3)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[16]=function(a){return a.reg32s[2]+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[17]=function(a){return a.reg32s[2]+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[18]=function(a){return a.reg32s[2]+
a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[19]=function(a){return a.reg32s[2]+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[20]=function(a){return a.reg32s[2]+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[21]=function(a,c){return a.reg32s[2]+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[22]=function(a){return a.reg32s[2]+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[23]=function(a){return a.reg32s[2]+
a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[80]=function(a){return(a.reg32s[2]<<1)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[81]=function(a){return(a.reg32s[2]<<1)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[82]=function(a){return(a.reg32s[2]<<1)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[83]=function(a){return(a.reg32s[2]<<1)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[84]=function(a){return(a.reg32s[2]<<1)+a.get_seg_prefix_ss()+
a.reg32s[4]|0};v86.prototype.sib_table[85]=function(a,c){return(a.reg32s[2]<<1)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[86]=function(a){return(a.reg32s[2]<<1)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[87]=function(a){return(a.reg32s[2]<<1)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[144]=function(a){return(a.reg32s[2]<<2)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[145]=function(a){return(a.reg32s[2]<<
2)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[146]=function(a){return(a.reg32s[2]<<2)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[147]=function(a){return(a.reg32s[2]<<2)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[148]=function(a){return(a.reg32s[2]<<2)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[149]=function(a,c){return(a.reg32s[2]<<2)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[150]=
function(a){return(a.reg32s[2]<<2)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[151]=function(a){return(a.reg32s[2]<<2)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[208]=function(a){return(a.reg32s[2]<<3)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[209]=function(a){return(a.reg32s[2]<<3)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[210]=function(a){return(a.reg32s[2]<<3)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[211]=
function(a){return(a.reg32s[2]<<3)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[212]=function(a){return(a.reg32s[2]<<3)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[213]=function(a,c){return(a.reg32s[2]<<3)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[214]=function(a){return(a.reg32s[2]<<3)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[215]=function(a){return(a.reg32s[2]<<3)+a.get_seg_prefix_ds()+
a.reg32s[7]|0};v86.prototype.sib_table[24]=function(a){return a.reg32s[3]+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[25]=function(a){return a.reg32s[3]+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[26]=function(a){return a.reg32s[3]+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[27]=function(a){return a.reg32s[3]+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[28]=function(a){return a.reg32s[3]+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[29]=
function(a,c){return a.reg32s[3]+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[30]=function(a){return a.reg32s[3]+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[31]=function(a){return a.reg32s[3]+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[88]=function(a){return(a.reg32s[3]<<1)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[89]=function(a){return(a.reg32s[3]<<1)+a.get_seg_prefix_ds()+a.reg32s[1]|
0};v86.prototype.sib_table[90]=function(a){return(a.reg32s[3]<<1)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[91]=function(a){return(a.reg32s[3]<<1)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[92]=function(a){return(a.reg32s[3]<<1)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[93]=function(a,c){return(a.reg32s[3]<<1)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[94]=function(a){return(a.reg32s[3]<<
1)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[95]=function(a){return(a.reg32s[3]<<1)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[152]=function(a){return(a.reg32s[3]<<2)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[153]=function(a){return(a.reg32s[3]<<2)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[154]=function(a){return(a.reg32s[3]<<2)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[155]=function(a){return(a.reg32s[3]<<
2)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[156]=function(a){return(a.reg32s[3]<<2)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[157]=function(a,c){return(a.reg32s[3]<<2)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[158]=function(a){return(a.reg32s[3]<<2)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[159]=function(a){return(a.reg32s[3]<<2)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[216]=
function(a){return(a.reg32s[3]<<3)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[217]=function(a){return(a.reg32s[3]<<3)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[218]=function(a){return(a.reg32s[3]<<3)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[219]=function(a){return(a.reg32s[3]<<3)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[220]=function(a){return(a.reg32s[3]<<3)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[221]=
function(a,c){return(a.reg32s[3]<<3)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[222]=function(a){return(a.reg32s[3]<<3)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[223]=function(a){return(a.reg32s[3]<<3)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[32]=function(a){return a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[33]=function(a){return a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[34]=
function(a){return a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[35]=function(a){return a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[36]=function(a){return a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[37]=function(a,c){return(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[38]=function(a){return a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[39]=function(a){return a.get_seg_prefix_ds()+
a.reg32s[7]|0};v86.prototype.sib_table[96]=function(a){return a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[97]=function(a){return a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[98]=function(a){return a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[99]=function(a){return a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[100]=function(a){return a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[101]=function(a,c){return(c?a.get_seg_prefix_ss()+
a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[102]=function(a){return a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[103]=function(a){return a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[160]=function(a){return a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[161]=function(a){return a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[162]=function(a){return a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[163]=
function(a){return a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[164]=function(a){return a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[165]=function(a,c){return(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[166]=function(a){return a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[167]=function(a){return a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[224]=function(a){return a.get_seg_prefix_ds()+
a.reg32s[0]|0};v86.prototype.sib_table[225]=function(a){return a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[226]=function(a){return a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[227]=function(a){return a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[228]=function(a){return a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[229]=function(a,c){return(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[230]=
function(a){return a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[231]=function(a){return a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[40]=function(a){return a.reg32s[5]+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[41]=function(a){return a.reg32s[5]+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[42]=function(a){return a.reg32s[5]+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[43]=function(a){return a.reg32s[5]+a.get_seg_prefix_ds()+
a.reg32s[3]|0};v86.prototype.sib_table[44]=function(a){return a.reg32s[5]+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[45]=function(a,c){return a.reg32s[5]+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[46]=function(a){return a.reg32s[5]+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[47]=function(a){return a.reg32s[5]+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[104]=function(a){return(a.reg32s[5]<<
1)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[105]=function(a){return(a.reg32s[5]<<1)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[106]=function(a){return(a.reg32s[5]<<1)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[107]=function(a){return(a.reg32s[5]<<1)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[108]=function(a){return(a.reg32s[5]<<1)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[109]=function(a,c){return(a.reg32s[5]<<
1)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[110]=function(a){return(a.reg32s[5]<<1)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[111]=function(a){return(a.reg32s[5]<<1)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[168]=function(a){return(a.reg32s[5]<<2)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[169]=function(a){return(a.reg32s[5]<<2)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[170]=
function(a){return(a.reg32s[5]<<2)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[171]=function(a){return(a.reg32s[5]<<2)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[172]=function(a){return(a.reg32s[5]<<2)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[173]=function(a,c){return(a.reg32s[5]<<2)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[174]=function(a){return(a.reg32s[5]<<2)+a.get_seg_prefix_ds()+
a.reg32s[6]|0};v86.prototype.sib_table[175]=function(a){return(a.reg32s[5]<<2)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[232]=function(a){return(a.reg32s[5]<<3)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[233]=function(a){return(a.reg32s[5]<<3)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[234]=function(a){return(a.reg32s[5]<<3)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[235]=function(a){return(a.reg32s[5]<<3)+a.get_seg_prefix_ds()+
a.reg32s[3]|0};v86.prototype.sib_table[236]=function(a){return(a.reg32s[5]<<3)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[237]=function(a,c){return(a.reg32s[5]<<3)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[238]=function(a){return(a.reg32s[5]<<3)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[239]=function(a){return(a.reg32s[5]<<3)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[48]=function(a){return a.reg32s[6]+
a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[49]=function(a){return a.reg32s[6]+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[50]=function(a){return a.reg32s[6]+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[51]=function(a){return a.reg32s[6]+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[52]=function(a){return a.reg32s[6]+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[53]=function(a,c){return a.reg32s[6]+(c?a.get_seg_prefix_ss()+
a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[54]=function(a){return a.reg32s[6]+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[55]=function(a){return a.reg32s[6]+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[112]=function(a){return(a.reg32s[6]<<1)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[113]=function(a){return(a.reg32s[6]<<1)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[114]=function(a){return(a.reg32s[6]<<
1)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[115]=function(a){return(a.reg32s[6]<<1)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[116]=function(a){return(a.reg32s[6]<<1)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[117]=function(a,c){return(a.reg32s[6]<<1)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[118]=function(a){return(a.reg32s[6]<<1)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[119]=
function(a){return(a.reg32s[6]<<1)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[176]=function(a){return(a.reg32s[6]<<2)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[177]=function(a){return(a.reg32s[6]<<2)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[178]=function(a){return(a.reg32s[6]<<2)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[179]=function(a){return(a.reg32s[6]<<2)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[180]=
function(a){return(a.reg32s[6]<<2)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[181]=function(a,c){return(a.reg32s[6]<<2)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[182]=function(a){return(a.reg32s[6]<<2)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[183]=function(a){return(a.reg32s[6]<<2)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[240]=function(a){return(a.reg32s[6]<<3)+a.get_seg_prefix_ds()+
a.reg32s[0]|0};v86.prototype.sib_table[241]=function(a){return(a.reg32s[6]<<3)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[242]=function(a){return(a.reg32s[6]<<3)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[243]=function(a){return(a.reg32s[6]<<3)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[244]=function(a){return(a.reg32s[6]<<3)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[245]=function(a,c){return(a.reg32s[6]<<3)+(c?a.get_seg_prefix_ss()+
a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[246]=function(a){return(a.reg32s[6]<<3)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[247]=function(a){return(a.reg32s[6]<<3)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[56]=function(a){return a.reg32s[7]+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[57]=function(a){return a.reg32s[7]+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[58]=function(a){return a.reg32s[7]+
a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[59]=function(a){return a.reg32s[7]+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[60]=function(a){return a.reg32s[7]+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[61]=function(a,c){return a.reg32s[7]+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[62]=function(a){return a.reg32s[7]+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[63]=function(a){return a.reg32s[7]+
a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[120]=function(a){return(a.reg32s[7]<<1)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[121]=function(a){return(a.reg32s[7]<<1)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[122]=function(a){return(a.reg32s[7]<<1)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[123]=function(a){return(a.reg32s[7]<<1)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[124]=function(a){return(a.reg32s[7]<<
1)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[125]=function(a,c){return(a.reg32s[7]<<1)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[126]=function(a){return(a.reg32s[7]<<1)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[127]=function(a){return(a.reg32s[7]<<1)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[184]=function(a){return(a.reg32s[7]<<2)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[185]=
function(a){return(a.reg32s[7]<<2)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[186]=function(a){return(a.reg32s[7]<<2)+a.get_seg_prefix_ds()+a.reg32s[2]|0};v86.prototype.sib_table[187]=function(a){return(a.reg32s[7]<<2)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[188]=function(a){return(a.reg32s[7]<<2)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[189]=function(a,c){return(a.reg32s[7]<<2)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|
0};v86.prototype.sib_table[190]=function(a){return(a.reg32s[7]<<2)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[191]=function(a){return(a.reg32s[7]<<2)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.sib_table[248]=function(a){return(a.reg32s[7]<<3)+a.get_seg_prefix_ds()+a.reg32s[0]|0};v86.prototype.sib_table[249]=function(a){return(a.reg32s[7]<<3)+a.get_seg_prefix_ds()+a.reg32s[1]|0};v86.prototype.sib_table[250]=function(a){return(a.reg32s[7]<<3)+a.get_seg_prefix_ds()+a.reg32s[2]|
0};v86.prototype.sib_table[251]=function(a){return(a.reg32s[7]<<3)+a.get_seg_prefix_ds()+a.reg32s[3]|0};v86.prototype.sib_table[252]=function(a){return(a.reg32s[7]<<3)+a.get_seg_prefix_ss()+a.reg32s[4]|0};v86.prototype.sib_table[253]=function(a,c){return(a.reg32s[7]<<3)+(c?a.get_seg_prefix_ss()+a.reg32s[5]:a.get_seg_prefix_ds()+a.read_imm32s())|0};v86.prototype.sib_table[254]=function(a){return(a.reg32s[7]<<3)+a.get_seg_prefix_ds()+a.reg32s[6]|0};v86.prototype.sib_table[255]=function(a){return(a.reg32s[7]<<
3)+a.get_seg_prefix_ds()+a.reg32s[7]|0};v86.prototype.modrm_resolve=function(a){return(this.address_size_32?this.modrm_table32:this.modrm_table16)[a](this)}})();"use strict";v86.prototype.add=function(a,c,d){this.last_op1=a;this.last_op2=c;this.last_add_result=this.last_result=a+c|0;this.last_op_size=d;this.flags_changed=2261;return this.last_result};
v86.prototype.adc=function(a,c,d){var e=this.getcf();this.last_op1=a;this.last_op2=c;this.last_add_result=this.last_result=(a+c|0)+e|0;this.last_op_size=d;this.flags_changed=2261;return this.last_result};v86.prototype.sub=function(a,c,d){this.last_add_result=a;this.last_op2=c;this.last_op1=this.last_result=a-c|0;this.last_op_size=d;this.flags_changed=2261;return this.last_result};
v86.prototype.sbb=function(a,c,d){var e=this.getcf();this.last_add_result=a;this.last_op2=c;this.last_op1=this.last_result=a-c-e|0;this.last_op_size=d;this.flags_changed=2261;return this.last_result};v86.prototype.inc=function(a,c){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=c;this.flags_changed=2260;return this.last_result};
v86.prototype.dec=function(a,c){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=c;this.flags_changed=2260;return this.last_result};v86.prototype.neg=function(a,c){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=c;return this.last_result};
v86.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};v86.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};v86.prototype.mul16=function(a){a=a*this.reg16[0];var c=a>>>16;this.reg16[0]=a;this.reg16[4]=c;this.flags=0===c?this.flags&-2050:this.flags|2049;this.flags_changed=0};
v86.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};v86.prototype.imul_reg16=function(a,c){var d=a*c;this.flags=32767<d||-32768>d?this.flags|2049:this.flags&-2050;this.flags_changed=0;return d};
v86.prototype.mul32=function(a){var c=this.reg32s[0],d=c&65535,c=c>>>16,e=a&65535;a=a>>>16;var f=d*e,e=(f>>>16)+(c*e|0)|0,g=e>>>16,e=(e&65535)+(d*a|0)|0,g=((e>>>16)+(c*a|0)|0)+g|0;this.reg32s[0]=e<<16|f&65535;this.reg32s[2]=g;this.flags=0===g?this.flags&-2050:this.flags|2049;this.flags_changed=0};
v86.prototype.imul32=function(a){var c=this.reg32s[0],d=!1;0>c&&(d=!0,c=-c|0);0>a&&(d=!d,a=-a|0);var e=c&65535,c=c>>>16,f=a&65535;a=a>>>16;var g=e*f,f=(g>>>16)+(c*f|0)|0,k=f>>>16,f=(f&65535)+(e*a|0)|0,g=f<<16|g&65535,k=((f>>>16)+(c*a|0)|0)+k|0;d&&(g=-g|0,k=~k+!g|0);this.reg32s[0]=g;this.reg32s[2]=k;this.flags=k===g>>31?this.flags&-2050:this.flags|2049;this.flags_changed=0};
v86.prototype.imul_reg32=function(a,c){var d=!1;0>a&&(d=!0,a=-a|0);0>c&&(d=!d,c=-c|0);var e=a&65535,f=a>>>16,g=c&65535,k=c>>>16,m=e*g,g=(m>>>16)+(f*g|0)|0,l=g>>>16,g=(g&65535)+(e*k|0)|0,m=g<<16|m&65535,l=((g>>>16)+(f*k|0)|0)+l|0;d&&(m=-m|0,l=~l+!m|0);this.flags=l===m>>31?this.flags&-2050:this.flags|2049;this.flags_changed=0;return m};v86.prototype.div8=function(a){var c=this.reg16[0],d=c/a|0;256<=d||0===a?this.trigger_de():(this.reg8[0]=d,this.reg8[1]=c%a)};
v86.prototype.idiv8=function(a){var c=this.reg16s[0],d=c/a|0;128<=d||-129>=d||0===a?this.trigger_de():(this.reg8[0]=d,this.reg8[1]=c%a)};v86.prototype.div16=function(a){var c=(this.reg16[0]|this.reg16[4]<<16)>>>0,d=c/a|0;65536<=d||0>d||0===a?this.trigger_de():(this.reg16[0]=d,this.reg16[4]=c%a)};v86.prototype.idiv16=function(a){var c=this.reg16[0]|this.reg16[4]<<16,d=c/a|0;32768<=d||-32769>=d||0===a?this.trigger_de():(this.reg16[0]=d,this.reg16[4]=c%a)};
v86.prototype.div32=function(a){var c=this.reg32[0],d=this.reg32[2];(d>=a||!a)&&this.trigger_de();var e=0;if(1048576<d){for(var f=32,g=a;g>d;)g>>>=1,f--;for(;1048576<d;){if(d>=g){var d=d-g,k=a<<f>>>0;k>c&&d--;c=c-k>>>0;e|=1<<f}f--;g>>=1}e>>>=0}c+=4294967296*d;d=c%a;e+=c/a|0;4294967296<=e||0===a?this.trigger_de():(this.reg32s[0]=e,this.reg32s[2]=d)};
v86.prototype.idiv32=function(a){var c=this.reg32[0],d=this.reg32s[2],e=!1,f=!1;0>a&&(f=!0,a=-a);0>d&&(e=!0,f=!f,c=-c|0,d=~d+!c);(d>=a||!a)&&this.trigger_de();var g=0;if(1048576<d){for(var k=32,m=a;m>d;)m>>>=1,k--;for(;1048576<d;){if(d>=m){var d=d-m,l=a<<k>>>0;l>c&&d--;c=c-l>>>0;g|=1<<k}k--;m>>=1}g>>>=0}c+=4294967296*d;d=c%a;g+=c/a|0;f&&(g=-g|0);e&&(d=-d|0);2147483648<=g||-2147483649>=g||0===a?this.trigger_de():(this.reg32s[0]=g,this.reg32s[2]=d)};
v86.prototype.xadd8=function(a,c){var d=this.reg8[c];this.reg8[c]=a;return this.add(a,d,7)};v86.prototype.xadd16=function(a,c){var d=this.reg16[c];this.reg16[c]=a;return this.add(a,d,15)};v86.prototype.xadd32=function(a,c){var d=this.reg32s[c];this.reg32s[c]=a;return this.add(a,d,31)};
v86.prototype.bcd_daa=function(){var a=this.reg8[0],c=this.getcf(),d=this.getaf();this.flags&=-18;if(9<(a&15)||d)this.reg8[0]+=6,this.flags|=16;if(153<a||c)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};
v86.prototype.bcd_das=function(){var a=this.reg8[0],c=this.getcf();this.flags&=-2;9<(a&15)||this.getaf()?(this.reg8[0]-=6,this.flags|=16,this.flags=this.flags&-2|c|this.reg8[0]>>7):this.flags&=-17;if(153<a||c)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};
v86.prototype.bcd_aam=function(){var a=this.read_imm8();if(0===a)this.trigger_de();else{var c=this.reg8[0];this.reg8[1]=c/a;this.reg8[0]=c%a;this.last_result=this.reg8[0];this.flags_changed=196;this.flags&=-2066}};v86.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};
v86.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};v86.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};v86.prototype.and=function(a,c,d){this.last_result=a&c;this.last_op_size=d;this.flags&=-2066;this.flags_changed=196;return this.last_result};
v86.prototype.or=function(a,c,d){this.last_result=a|c;this.last_op_size=d;this.flags&=-2066;this.flags_changed=196;return this.last_result};v86.prototype.xor=function(a,c,d){this.last_result=a^c;this.last_op_size=d;this.flags&=-2066;this.flags_changed=196;return this.last_result};v86.prototype.rol8=function(a,c){if(!c)return a;c&=7;var d=a<<c|a>>8-c;this.flags_changed&=-2050;this.flags=this.flags&-2050|d&1|(d<<11^d<<4)&2048;return d};
v86.prototype.rol16=function(a,c){if(!c)return a;c&=15;var d=a<<c|a>>16-c;this.flags_changed&=-2050;this.flags=this.flags&-2050|d&1|(d<<11^d>>4)&2048;return d};v86.prototype.rol32=function(a,c){if(!c)return a;var d=a<<c|a>>>32-c;this.flags_changed&=-2050;this.flags=this.flags&-2050|d&1|(d<<11^d>>20)&2048;return d};v86.prototype.rcl8=function(a,c){c%=9;if(!c)return a;var d=a<<c|this.getcf()<<c-1|a>>9-c;this.flags_changed&=-2050;this.flags=this.flags&-2050|d>>8&1|(d<<3^d<<4)&2048;return d};
v86.prototype.rcl16=function(a,c){c%=17;if(!c)return a;var d=a<<c|this.getcf()<<c-1|a>>17-c;this.flags_changed&=-2050;this.flags=this.flags&-2050|d>>16&1|(d>>5^d>>4)&2048;return d};v86.prototype.rcl32=function(a,c){if(!c)return a;var d=a<<c|this.getcf()<<c-1;1<c&&(d|=a>>>33-c);this.flags_changed&=-2050;this.flags=this.flags&-2050|a>>>32-c&1;this.flags|=(this.flags<<11^d>>20)&2048;return d};
v86.prototype.ror8=function(a,c){c&=7;if(!c)return a;var d=a>>c|a<<8-c;this.flags_changed&=-2050;this.flags=this.flags&-2050|d>>7&1|(d<<4^d<<5)&2048;return d};v86.prototype.ror16=function(a,c){c&=15;if(!c)return a;var d=a>>c|a<<16-c;this.flags_changed&=-2050;this.flags=this.flags&-2050|d>>15&1|(d>>4^d>>3)&2048;return d};v86.prototype.ror32=function(a,c){if(!c)return a;var d=a>>>c|a<<32-c;this.flags_changed&=-2050;this.flags=this.flags&-2050|d>>31&1|(d>>20^d>>19)&2048;return d};
v86.prototype.rcr8=function(a,c){c%=9;if(!c)return a;var d=a>>c|this.getcf()<<8-c|a<<9-c;this.flags_changed&=-2050;this.flags=this.flags&-2050|d>>8&1|(d<<4^d<<5)&2048;return d};v86.prototype.rcr16=function(a,c){c%=17;if(!c)return a;var d=a>>c|this.getcf()<<16-c|a<<17-c;this.flags_changed&=-2050;this.flags=this.flags&-2050|d>>16&1|(d>>4^d>>3)&2048;return d};
v86.prototype.rcr32=function(a,c){if(!c)return a;var d=a>>>c|this.getcf()<<32-c;1<c&&(d|=a<<33-c);this.flags_changed&=-2050;this.flags=this.flags&-2050|a>>c-1&1|(d>>20^d>>19)&2048;return d};v86.prototype.shl8=function(a,c){if(0===c)return a;this.last_result=a<<c;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};
v86.prototype.shl16=function(a,c){if(0===c)return a;this.last_result=a<<c;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};v86.prototype.shl32=function(a,c){if(0===c)return a;this.last_result=a<<c;this.last_op_size=31;this.flags_changed=212;this.flags=this.flags&-2050|a>>>32-c&1;this.flags|=(this.flags&1^this.last_result>>31&1)<<11&2048;return this.last_result};
v86.prototype.shr8=function(a,c){if(0===c)return a;this.last_result=a>>c;this.last_op_size=7;this.flags_changed=212;this.flags=this.flags&-2050|a>>c-1&1|(a>>7&1)<<11&2048;return this.last_result};v86.prototype.shr16=function(a,c){if(0===c)return a;this.last_result=a>>c;this.last_op_size=15;this.flags_changed=212;this.flags=this.flags&-2050|a>>c-1&1|a>>4&2048;return this.last_result};
v86.prototype.shr32=function(a,c){if(0===c)return a;this.last_result=a>>>c;this.last_op_size=31;this.flags_changed=212;this.flags=this.flags&-2050|a>>>c-1&1|a>>20&2048;return this.last_result};v86.prototype.sar8=function(a,c){if(0===c)return a;this.last_result=a>>c;this.last_op_size=7;this.flags_changed=212;this.flags=this.flags&-2050|a>>c-1&1;return this.last_result};
v86.prototype.sar16=function(a,c){if(0===c)return a;this.last_result=a>>c;this.last_op_size=15;this.flags_changed=212;this.flags=this.flags&-2050|a>>c-1&1;return this.last_result};v86.prototype.sar32=function(a,c){if(0===c)return a;this.last_result=a>>c;this.last_op_size=31;this.flags_changed=212;this.flags=this.flags&-2050|a>>>c-1&1;return this.last_result};
v86.prototype.shrd16=function(a,c,d){if(0===d)return a;16>=d?(this.last_result=a>>d|c<<16-d,this.flags=this.flags&-2|a>>d-1&1):(this.last_result=a<<32-d|c>>d-16,this.flags=this.flags&-2|c>>d-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};
v86.prototype.shrd32=function(a,c,d){if(0===d)return a;this.last_result=a>>>d|c<<32-d;this.last_op_size=31;this.flags_changed=212;this.flags=this.flags&-2|a>>>d-1&1;this.flags=this.flags&-2049|(this.last_result^a)>>20&2048;return this.last_result};
v86.prototype.shld16=function(a,c,d){if(0===d)return a;16>=d?(this.last_result=a<<d|c>>>16-d,this.flags=this.flags&-2|a>>>16-d&1):(this.last_result=a>>32-d|c<<d-16,this.flags=this.flags&-2|c>>>32-d&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};
v86.prototype.shld32=function(a,c,d){if(0===d)return a;this.last_result=a<<d|c>>>32-d;this.last_op_size=31;this.flags_changed=212;this.flags=this.flags&-2|a>>>32-d&1;this.flags=this.flags&-2049|(this.flags&1^this.last_result>>31&1)<<11;return this.last_result};v86.prototype.bt_reg=function(a,c){this.flags=this.flags&-2|a>>c&1;this.flags_changed&=-2};v86.prototype.btc_reg=function(a,c){this.flags=this.flags&-2|a>>c&1;this.flags_changed&=-2;return a^1<<c};
v86.prototype.bts_reg=function(a,c){this.flags=this.flags&-2|a>>c&1;this.flags_changed&=-2;return a|1<<c};v86.prototype.btr_reg=function(a,c){this.flags=this.flags&-2|a>>c&1;this.flags_changed&=-2;return a&~(1<<c)};v86.prototype.bt_mem=function(a,c){var d=this.safe_read8(a+(c>>3));this.flags=this.flags&-2|d>>(c&7)&1;this.flags_changed&=-2};
v86.prototype.btc_mem=function(a,c){var d=this.translate_address_write(a+(c>>3)),e=this.memory.read8(d);c&=7;this.flags=this.flags&-2|e>>c&1;this.flags_changed&=-2;this.memory.write8(d,e^1<<c)};v86.prototype.btr_mem=function(a,c){var d=this.translate_address_write(a+(c>>3)),e=this.memory.read8(d);c&=7;this.flags=this.flags&-2|e>>c&1;this.flags_changed&=-2;this.memory.write8(d,e&~(1<<c))};
v86.prototype.bts_mem=function(a,c){var d=this.translate_address_write(a+(c>>3)),e=this.memory.read8(d);c&=7;this.flags=this.flags&-2|e>>c&1;this.flags_changed&=-2;this.memory.write8(d,e|1<<c)};v86.prototype.bsf16=function(a,c){this.flags_changed=0;if(0===c)return this.flags|=64,a;this.flags&=-65;return Math.int_log2(-c&c)};v86.prototype.bsf32=function(a,c){this.flags_changed=0;if(0===c)return this.flags|=64,a;this.flags&=-65;return Math.int_log2((-c&c)>>>0)};
v86.prototype.bsr16=function(a,c){this.flags_changed=0;if(0===c)return this.flags|=64,a;this.flags&=-65;return Math.int_log2(c)};v86.prototype.bsr32=function(a,c){this.flags_changed=0;if(0===c)return this.flags|=64,a;this.flags&=-65;return Math.int_log2(c>>>0)};v86.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";"use strict";
var table16=[],table32=[],table0F_16=[],table0F_32=[];v86.prototype.table16=table16;v86.prototype.table32=table32;v86.prototype.table0F_16=table0F_16;v86.prototype.table0F_32=table0F_32;table16[0]=table32[0]=function(a){var c=a.read_imm8(),d,e;192>c?(e=a.translate_address_write(a.modrm_resolve(c)),d=a.memory.read8(e)):d=a.reg8[c<<2&12|c>>2&1];d=a.add(d,a.reg8[c>>1&12|c>>5&1],7);192>c?a.memory.write8(e,d):a.reg8[c<<2&12|c>>2&1]=d};
table16[1]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];d=a.add(d,a.reg16[c>>2&14],15);192>c?f?a.virt_boundary_write16(e,f,d):a.memory.write16(e,d):a.reg16[c<<1&14]=d};
table32[1]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(f=a.translate_address_write(d+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[c&7];d=a.add(d,a.reg32s[c>>3&7],31);192>c?f?a.virt_boundary_write32(e,f,d):a.memory.write32(e,d):a.reg32s[c&7]=d};
table16[2]=table32[2]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read8(a.modrm_resolve(c)):a.reg8[c<<2&12|c>>2&1];a.reg8[c>>1&12|c>>5&1]=a.add(a.reg8[c>>1&12|c>>5&1],d,7)};table16[3]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.reg16[c>>2&14]=a.add(a.reg16[c>>2&14],d,15)};table32[3]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.reg32s[c>>3&7]=a.add(a.reg32s[c>>3&7],d,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 c=a.read_imm8(),d,e;192>c?(e=a.translate_address_write(a.modrm_resolve(c)),d=a.memory.read8(e)):d=a.reg8[c<<2&12|c>>2&1];d=a.or(d,a.reg8[c>>1&12|c>>5&1],7);192>c?a.memory.write8(e,d):a.reg8[c<<2&12|c>>2&1]=d};
table16[9]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];d=a.or(d,a.reg16[c>>2&14],15);192>c?f?a.virt_boundary_write16(e,f,d):a.memory.write16(e,d):a.reg16[c<<1&14]=d};
table32[9]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(f=a.translate_address_write(d+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[c&7];d=a.or(d,a.reg32s[c>>3&7],31);192>c?f?a.virt_boundary_write32(e,f,d):a.memory.write32(e,d):a.reg32s[c&7]=d};
table16[10]=table32[10]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read8(a.modrm_resolve(c)):a.reg8[c<<2&12|c>>2&1];a.reg8[c>>1&12|c>>5&1]=a.or(a.reg8[c>>1&12|c>>5&1],d,7)};table16[11]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.reg16[c>>2&14]=a.or(a.reg16[c>>2&14],d,15)};table32[11]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.reg32s[c>>3&7]=a.or(a.reg32s[c>>3&7],d,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 c=a.read_imm8(),d,e;192>c?(e=a.translate_address_write(a.modrm_resolve(c)),d=a.memory.read8(e)):d=a.reg8[c<<2&12|c>>2&1];d=a.adc(d,a.reg8[c>>1&12|c>>5&1],7);192>c?a.memory.write8(e,d):a.reg8[c<<2&12|c>>2&1]=d};
table16[17]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];d=a.adc(d,a.reg16[c>>2&14],15);192>c?f?a.virt_boundary_write16(e,f,d):a.memory.write16(e,d):a.reg16[c<<1&14]=d};
table32[17]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(f=a.translate_address_write(d+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[c&7];d=a.adc(d,a.reg32s[c>>3&7],31);192>c?f?a.virt_boundary_write32(e,f,d):a.memory.write32(e,d):a.reg32s[c&7]=d};
table16[18]=table32[18]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read8(a.modrm_resolve(c)):a.reg8[c<<2&12|c>>2&1];a.reg8[c>>1&12|c>>5&1]=a.adc(a.reg8[c>>1&12|c>>5&1],d,7)};table16[19]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.reg16[c>>2&14]=a.adc(a.reg16[c>>2&14],d,15)};table32[19]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.reg32s[c>>3&7]=a.adc(a.reg32s[c>>3&7],d,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 c=a.read_imm8(),d,e;192>c?(e=a.translate_address_write(a.modrm_resolve(c)),d=a.memory.read8(e)):d=a.reg8[c<<2&12|c>>2&1];d=a.sbb(d,a.reg8[c>>1&12|c>>5&1],7);192>c?a.memory.write8(e,d):a.reg8[c<<2&12|c>>2&1]=d};
table16[25]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];d=a.sbb(d,a.reg16[c>>2&14],15);192>c?f?a.virt_boundary_write16(e,f,d):a.memory.write16(e,d):a.reg16[c<<1&14]=d};
table32[25]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(f=a.translate_address_write(d+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[c&7];d=a.sbb(d,a.reg32s[c>>3&7],31);192>c?f?a.virt_boundary_write32(e,f,d):a.memory.write32(e,d):a.reg32s[c&7]=d};
table16[26]=table32[26]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read8(a.modrm_resolve(c)):a.reg8[c<<2&12|c>>2&1];a.reg8[c>>1&12|c>>5&1]=a.sbb(a.reg8[c>>1&12|c>>5&1],d,7)};table16[27]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.reg16[c>>2&14]=a.sbb(a.reg16[c>>2&14],d,15)};table32[27]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.reg32s[c>>3&7]=a.sbb(a.reg32s[c>>3&7],d,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 c=a.read_imm8(),d,e;192>c?(e=a.translate_address_write(a.modrm_resolve(c)),d=a.memory.read8(e)):d=a.reg8[c<<2&12|c>>2&1];d=a.and(d,a.reg8[c>>1&12|c>>5&1],7);192>c?a.memory.write8(e,d):a.reg8[c<<2&12|c>>2&1]=d};
table16[33]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];d=a.and(d,a.reg16[c>>2&14],15);192>c?f?a.virt_boundary_write16(e,f,d):a.memory.write16(e,d):a.reg16[c<<1&14]=d};
table32[33]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(f=a.translate_address_write(d+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[c&7];d=a.and(d,a.reg32s[c>>3&7],31);192>c?f?a.virt_boundary_write32(e,f,d):a.memory.write32(e,d):a.reg32s[c&7]=d};
table16[34]=table32[34]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read8(a.modrm_resolve(c)):a.reg8[c<<2&12|c>>2&1];a.reg8[c>>1&12|c>>5&1]=a.and(a.reg8[c>>1&12|c>>5&1],d,7)};table16[35]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.reg16[c>>2&14]=a.and(a.reg16[c>>2&14],d,15)};table32[35]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.reg32s[c>>3&7]=a.and(a.reg32s[c>>3&7],d,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 c=a.read_imm8(),d,e;192>c?(e=a.translate_address_write(a.modrm_resolve(c)),d=a.memory.read8(e)):d=a.reg8[c<<2&12|c>>2&1];d=a.sub(d,a.reg8[c>>1&12|c>>5&1],7);192>c?a.memory.write8(e,d):a.reg8[c<<2&12|c>>2&1]=d};
table16[41]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];d=a.sub(d,a.reg16[c>>2&14],15);192>c?f?a.virt_boundary_write16(e,f,d):a.memory.write16(e,d):a.reg16[c<<1&14]=d};
table32[41]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(f=a.translate_address_write(d+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[c&7];d=a.sub(d,a.reg32s[c>>3&7],31);192>c?f?a.virt_boundary_write32(e,f,d):a.memory.write32(e,d):a.reg32s[c&7]=d};
table16[42]=table32[42]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read8(a.modrm_resolve(c)):a.reg8[c<<2&12|c>>2&1];a.reg8[c>>1&12|c>>5&1]=a.sub(a.reg8[c>>1&12|c>>5&1],d,7)};table16[43]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.reg16[c>>2&14]=a.sub(a.reg16[c>>2&14],d,15)};table32[43]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.reg32s[c>>3&7]=a.sub(a.reg32s[c>>3&7],d,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 c=a.read_imm8(),d,e;192>c?(e=a.translate_address_write(a.modrm_resolve(c)),d=a.memory.read8(e)):d=a.reg8[c<<2&12|c>>2&1];d=a.xor(d,a.reg8[c>>1&12|c>>5&1],7);192>c?a.memory.write8(e,d):a.reg8[c<<2&12|c>>2&1]=d};
table16[49]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];d=a.xor(d,a.reg16[c>>2&14],15);192>c?f?a.virt_boundary_write16(e,f,d):a.memory.write16(e,d):a.reg16[c<<1&14]=d};
table32[49]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(f=a.translate_address_write(d+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[c&7];d=a.xor(d,a.reg32s[c>>3&7],31);192>c?f?a.virt_boundary_write32(e,f,d):a.memory.write32(e,d):a.reg32s[c&7]=d};
table16[50]=table32[50]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read8(a.modrm_resolve(c)):a.reg8[c<<2&12|c>>2&1];a.reg8[c>>1&12|c>>5&1]=a.xor(a.reg8[c>>1&12|c>>5&1],d,7)};table16[51]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.reg16[c>>2&14]=a.xor(a.reg16[c>>2&14],d,15)};table32[51]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.reg32s[c>>3&7]=a.xor(a.reg32s[c>>3&7],d,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 c=a.read_imm8(),d=192>c?a.safe_read8(a.modrm_resolve(c)):a.reg8[c<<2&12|c>>2&1];a.sub(d,a.reg8[c>>1&12|c>>5&1],7)};
table16[57]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.sub(d,a.reg16[c>>2&14],15)};table32[57]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.sub(d,a.reg32s[c>>3&7],31)};table16[58]=table32[58]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read8(a.modrm_resolve(c)):a.reg8[c<<2&12|c>>2&1];a.sub(a.reg8[c>>1&12|c>>5&1],d,7)};
table16[59]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.sub(a.reg16[c>>2&14],d,15)};table32[59]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.sub(a.reg32s[c>>3&7],d,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 c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];d=a.arpl(d,c>>2&14);192>c?f?a.virt_boundary_write16(e,f,d):a.memory.write16(e,d):a.reg16[c<<1&14]=d};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 c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c))<<16>>16:a.reg16s[c<<1&14];a.reg16[c>>2&14]=a.imul_reg16(a.read_imm16s(),d)};table32[105]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.reg32s[c>>3&7]=a.imul_reg32(a.read_imm32s(),d)};table16[106]=function(a){a.push16(a.read_imm8s())};table32[106]=function(a){a.push32(a.read_imm8s())};
table16[107]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c))<<16>>16:a.reg16s[c<<1&14];a.reg16[c>>2&14]=a.imul_reg16(a.read_imm8s(),d)};table32[107]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.reg32s[c>>3&7]=a.imul_reg32(a.read_imm8s(),d)};
table16[108]=table32[108]=function(a){a:{var c=a.reg16[4];a.test_privileges_for_io(c,1);var d,e=a.flags&1024?-1:1,f=!1;d=a.get_seg(0)+a.regv[a.reg_vdi]|0;if(0!==a.repeat_string_prefix){var g=a.regv[a.reg_vcx]>>>0,k=g;if(0===g)break a;var m=16384,l=e>>31|1;a.paging&&(m=Math.min(m,(l>>1^~d)&4095),d=a.translate_address_write(d));do a.memory.write8(d,a.io.port_read8(c)),d+=l,f=0!==--g&&!0;while(f&&m--);a.regv[a.reg_vdi]+=e*(k-g)|0;a.regv[a.reg_vcx]=g;a.timestamp_counter+=k-g}else d=a.translate_address_write(d),
a.memory.write8(d,a.io.port_read8(c)),a.regv[a.reg_vdi]+=e;f&&(a.instruction_pointer=a.previous_ip)}};
table16[109]=function(a){a:{var c=a.reg16[4];a.test_privileges_for_io(c,2);var d,e=a.flags&1024?-2:2,f=!1;d=a.get_seg(0)+a.regv[a.reg_vdi]|0;if(0!==a.repeat_string_prefix){var g=a.regv[a.reg_vcx]>>>0,k=g;if(0===g)break a;var m=16384;if(d&1){do a.safe_write16(d,a.io.port_read16(c)),d+=e,a.regv[a.reg_vdi]+=e,f=0!==--a.regv[a.reg_vcx]&&!0;while(f&&m--)}else{var l=e>>31|1;a.paging&&(m=Math.min(m,(l>>1^~d)&4095),d=a.translate_address_write(d),m>>=1);d>>>=1;do a.memory.write_aligned16(d,a.io.port_read16(c)),
d+=l,f=0!==--g&&!0;while(f&&m--);a.regv[a.reg_vdi]+=e*(k-g)|0;a.regv[a.reg_vcx]=g;a.timestamp_counter+=k-g}}else a.safe_write16(d,a.io.port_read16(c)),a.regv[a.reg_vdi]+=e;f&&(a.instruction_pointer=a.previous_ip)}};
table32[109]=function(a){a:{var c=a.reg16[4];a.test_privileges_for_io(c,4);var d,e=a.flags&1024?-4:4,f=!1;d=a.get_seg(0)+a.regv[a.reg_vdi]|0;if(0!==a.repeat_string_prefix){var g=a.regv[a.reg_vcx]>>>0,k=g;if(0===g)break a;var m=16384;if(d&3){do a.safe_write32(d,a.io.port_read32(c)),d+=e,a.regv[a.reg_vdi]+=e,f=0!==--a.regv[a.reg_vcx]&&!0;while(f&&m--)}else{var l=e>>31|1;a.paging&&(m=Math.min(m,(l>>1^~d)&4095),d=a.translate_address_write(d),m>>=2);d>>>=2;do a.memory.write_aligned32(d,a.io.port_read32(c)),
d+=l,f=0!==--g&&!0;while(f&&m--);a.regv[a.reg_vdi]+=e*(k-g)|0;a.regv[a.reg_vcx]=g;a.timestamp_counter+=k-g}}else a.safe_write32(d,a.io.port_read32(c)),a.regv[a.reg_vdi]+=e;f&&(a.instruction_pointer=a.previous_ip)}};
table16[110]=table32[110]=function(a){a:{var c=a.reg16[4];a.test_privileges_for_io(c,1);var d,e=a.flags&1024?-1:1,f=!1;d=a.get_seg_prefix(3)+a.regv[a.reg_vsi]|0;if(0!==a.repeat_string_prefix){var g=a.regv[a.reg_vcx]>>>0,k=g;if(0===g)break a;var m=16384,l=e>>31|1;a.paging&&(m=(l>>1^~d)&4095,d=a.translate_address_read(d));do a.io.port_write8(c,a.memory.read8(d)),d+=l,f=0!==--g&&!0;while(f&&m--);a.regv[a.reg_vsi]+=e*(k-g)|0;a.regv[a.reg_vcx]=g;a.timestamp_counter+=k-g}else d=a.translate_address_read(d),
a.io.port_write8(c,a.memory.read8(d)),a.regv[a.reg_vsi]+=e;f&&(a.instruction_pointer=a.previous_ip)}};
table16[111]=function(a){a:{var c=a.reg16[4];a.test_privileges_for_io(c,2);var d,e=a.flags&1024?-2:2,f=!1;d=a.get_seg_prefix(3)+a.regv[a.reg_vsi]|0;if(0!==a.repeat_string_prefix){var g=a.regv[a.reg_vcx]>>>0,k=g;if(0===g)break a;var m=16384;if(d&1){do a.io.port_write16(c,a.safe_read16(d)),d+=e,a.regv[a.reg_vsi]+=e,f=0!==--a.regv[a.reg_vcx]&&!0;while(f&&m--)}else{var l=e>>31|1;a.paging&&(m=(l>>1^~d)&4095,d=a.translate_address_read(d),m>>=1);d>>>=1;do a.io.port_write16(c,a.memory.read_aligned16(d)),
d+=l,f=0!==--g&&!0;while(f&&m--);a.regv[a.reg_vsi]+=e*(k-g)|0;a.regv[a.reg_vcx]=g;a.timestamp_counter+=k-g}}else a.io.port_write16(c,a.safe_read16(d)),a.regv[a.reg_vsi]+=e;f&&(a.instruction_pointer=a.previous_ip)}};
table32[111]=function(a){a:{var c=a.reg16[4];a.test_privileges_for_io(c,4);var d,e=a.flags&1024?-4:4,f=!1;d=a.get_seg_prefix(3)+a.regv[a.reg_vsi]|0;if(0!==a.repeat_string_prefix){var g=a.regv[a.reg_vcx]>>>0,k=g;if(0===g)break a;var m=16384;if(d&3){do a.io.port_write32(c,a.safe_read32s(d)),d+=e,a.regv[a.reg_vsi]+=e,f=0!==--a.regv[a.reg_vcx]&&!0;while(f&&m--)}else{var l=e>>31|1;a.paging&&(m=(l>>1^~d)&4095,d=a.translate_address_read(d),m>>=2);d>>>=2;do a.io.port_write32(c,a.memory.read_aligned32(d)),
d+=l,f=0!==--g&&!0;while(f&&m--);a.regv[a.reg_vsi]+=e*(k-g)|0;a.regv[a.reg_vcx]=g;a.timestamp_counter+=k-g}}else a.io.port_write32(c,a.safe_read32s(d)),a.regv[a.reg_vsi]+=e;f&&(a.instruction_pointer=a.previous_ip)}};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 c=a.read_imm8();if(56===(c&56)){var d=192>c?a.safe_read8(a.modrm_resolve(c)):a.reg8[c<<2&12|c>>2&1];a.sub(d,a.read_imm8(),7)}else{var e,f,g;192>c?(f=a.translate_address_write(a.modrm_resolve(c)),d=a.memory.read8(f)):d=a.reg8[c<<2&12|c>>2&1];g=0;e=a.read_imm8();switch(c>>3&7){case 0:g=a.add(d,e,7);break;case 1:g=a.or(d,e,7);break;case 2:g=a.adc(d,e,7);break;case 3:g=a.sbb(d,e,7);break;case 4:g=a.and(d,e,7);break;case 5:g=a.sub(d,e,7);break;case 6:g=a.xor(d,
e,7);break;case 7:g=dbg_assert.bind(this,0)(d,e)}192>c?a.memory.write8(f,g):a.reg8[c<<2&12|c>>2&1]=g}};
table16[129]=function(a){var c=a.read_imm8();if(56===(c&56)){var d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.sub(d,a.read_imm16(),15)}else{var e,f,g=0,k;192>c?(d=a.modrm_resolve(c),f=a.translate_address_write(d),a.paging&&4095===(d&4095)?(g=a.translate_address_write(d+1),d=a.virt_boundary_read16(f,g)):d=a.memory.read16(f)):d=a.reg16[c<<1&14];k=0;e=a.read_imm16();switch(c>>3&7){case 0:k=a.add(d,e,15);break;case 1:k=a.or(d,e,15);break;case 2:k=a.adc(d,e,15);break;case 3:k=a.sbb(d,e,
15);break;case 4:k=a.and(d,e,15);break;case 5:k=a.sub(d,e,15);break;case 6:k=a.xor(d,e,15);break;case 7:k=dbg_assert.bind(this,0)(d,e)}192>c?g?a.virt_boundary_write16(f,g,k):a.memory.write16(f,k):a.reg16[c<<1&14]=k}};
table32[129]=function(a){var c=a.read_imm8();if(56===(c&56)){var d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.sub(d,a.read_imm32s(),31)}else{var e,f,g=0,k;192>c?(d=a.modrm_resolve(c),f=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(g=a.translate_address_write(d+3),d=a.virt_boundary_read32s(f,g)):d=a.memory.read32s(f)):d=a.reg32s[c&7];k=0;e=a.read_imm32s();switch(c>>3&7){case 0:k=a.add(d,e,31);break;case 1:k=a.or(d,e,31);break;case 2:k=a.adc(d,e,31);break;case 3:k=a.sbb(d,e,31);
break;case 4:k=a.and(d,e,31);break;case 5:k=a.sub(d,e,31);break;case 6:k=a.xor(d,e,31);break;case 7:k=dbg_assert.bind(this,0)(d,e)}192>c?g?a.virt_boundary_write32(f,g,k):a.memory.write32(f,k):a.reg32s[c&7]=k}};table16[130]=table32[130]=function(a){a.table[128](a)};
table16[131]=function(a){var c=a.read_imm8();if(56===(c&56)){var d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.sub(d,a.read_imm8s(),15)}else{var e,f,g=0,k;192>c?(d=a.modrm_resolve(c),f=a.translate_address_write(d),a.paging&&4095===(d&4095)?(g=a.translate_address_write(d+1),d=a.virt_boundary_read16(f,g)):d=a.memory.read16(f)):d=a.reg16[c<<1&14];k=0;e=a.read_imm8s();switch(c>>3&7){case 0:k=a.add(d,e,15);break;case 1:k=a.or(d,e,15);break;case 2:k=a.adc(d,e,15);break;case 3:k=a.sbb(d,e,
15);break;case 4:k=a.and(d,e,15);break;case 5:k=a.sub(d,e,15);break;case 6:k=a.xor(d,e,15);break;case 7:k=dbg_assert.bind(this,0)(d,e)}192>c?g?a.virt_boundary_write16(f,g,k):a.memory.write16(f,k):a.reg16[c<<1&14]=k}};
table32[131]=function(a){var c=a.read_imm8();if(56===(c&56)){var d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.sub(d,a.read_imm8s(),31)}else{var e,f,g=0,k;192>c?(d=a.modrm_resolve(c),f=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(g=a.translate_address_write(d+3),d=a.virt_boundary_read32s(f,g)):d=a.memory.read32s(f)):d=a.reg32s[c&7];k=0;e=a.read_imm8s();switch(c>>3&7){case 0:k=a.add(d,e,31);break;case 1:k=a.or(d,e,31);break;case 2:k=a.adc(d,e,31);break;case 3:k=a.sbb(d,e,31);
break;case 4:k=a.and(d,e,31);break;case 5:k=a.sub(d,e,31);break;case 6:k=a.xor(d,e,31);break;case 7:k=dbg_assert.bind(this,0)(d,e)}192>c?g?a.virt_boundary_write32(f,g,k):a.memory.write32(f,k):a.reg32s[c&7]=k}};table16[132]=table32[132]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read8(a.modrm_resolve(c)):a.reg8[c<<2&12|c>>2&1];a.and(d,a.reg8[c>>1&12|c>>5&1],7)};table16[133]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.and(d,a.reg16[c>>2&14],15)};
table32[133]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.and(d,a.reg32s[c>>3&7],31)};table16[134]=table32[134]=function(a){var c=a.read_imm8(),d,e;192>c?(e=a.translate_address_write(a.modrm_resolve(c)),d=a.memory.read8(e)):d=a.reg8[c<<2&12|c>>2&1];d=a.xchg8(d,c);192>c?a.memory.write8(e,d):a.reg8[c<<2&12|c>>2&1]=d};
table16[135]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];d=a.xchg16(d,c);192>c?f?a.virt_boundary_write16(e,f,d):a.memory.write16(e,d):a.reg16[c<<1&14]=d};
table32[135]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(f=a.translate_address_write(d+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[c&7];d=a.xchg32(d,c);192>c?f?a.virt_boundary_write32(e,f,d):a.memory.write32(e,d):a.reg32s[c&7]=d};
table16[136]=table32[136]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=a.reg8[c>>1&12|c>>5&1];192>c?a.safe_write8(d,e):a.reg8[c<<2&12|c>>2&1]=e};table16[137]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=a.reg16[c>>2&14];192>c?a.safe_write16(d,e):a.reg16[c<<1&14]=e};table32[137]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=a.reg32s[c>>3&7];192>c?a.safe_write32(d,e):a.reg32[c&7]=e};
table16[138]=table32[138]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read8(a.modrm_resolve(c)):a.reg8[c<<2&12|c>>2&1];a.reg8[c>>1&12|c>>5&1]=d};table16[139]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.reg16[c>>2&14]=d};table32[139]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.reg32s[c>>3&7]=d};
table16[140]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=a.sreg[c>>3&7];192>c?a.safe_write16(d,e):a.reg16[c<<1&14]=e};table32[140]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=a.sreg[c>>3&7];192>c?a.safe_write32(d,e):a.reg32[c&7]=e};table16[141]=function(a){var c=a.read_imm8();192<=c&&a.trigger_ud();a.segment_prefix=9;a.reg16[(c>>3&7)<<1]=a.modrm_resolve(c);a.segment_prefix=-1};
table32[141]=function(a){var c=a.read_imm8();192<=c&&a.trigger_ud();a.segment_prefix=9;a.reg32s[c>>3&7]=a.modrm_resolve(c);a.segment_prefix=-1};table16[142]=table32[142]=function(a){var c=a.read_imm8(),d=c>>3&7,c=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.switch_seg(d,c)};
table16[143]=function(a){var c=a.read_imm8(),d=a.safe_read16(a.get_stack_pointer(0));a.stack_reg[a.reg_vsp]+=2;192>c?(c=a.modrm_resolve(c),a.stack_reg[a.reg_vsp]-=2,a.safe_write16(c,d),a.stack_reg[a.reg_vsp]+=2):a.reg16[c<<1&14]=d};table32[143]=function(a){var c=a.read_imm8(),d=a.safe_read32s(a.get_stack_pointer(0));a.stack_reg[a.reg_vsp]+=4;192>c?(c=a.modrm_resolve(c),a.stack_reg[a.reg_vsp]-=4,a.safe_write32(c,d),a.stack_reg[a.reg_vsp]+=4):a.reg32s[c&7]=d};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 c=a.read_imm16(),d=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,d);a.instruction_pointer=a.get_seg(1)+c|0;a.last_instr_jump=!0};
table32[154]=function(a){var c=a.read_imm32s(),d=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,d);a.instruction_pointer=a.get_seg(1)+c|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 c=a.safe_read8(a.read_moffs());a.reg8[0]=c};table16[161]=function(a){var c=a.safe_read16(a.read_moffs());a.reg16[0]=c};table32[161]=function(a){var c=a.safe_read32s(a.read_moffs());a.reg32s[0]=c};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){a:{var c,d,e=a.flags&1024?-1:1,f=!1;d=a.get_seg(0)+a.regv[a.reg_vdi]|0;c=a.get_seg_prefix(3)+a.regv[a.reg_vsi]|0;if(0!==a.repeat_string_prefix){var g=a.regv[a.reg_vcx]>>>0,k=g;if(0===g)break a;var m=16384,l=e>>31|1;a.paging&&(m=(l>>1^~c)&4095,c=a.translate_address_read(c),m=Math.min(m,(l>>1^~d)&4095),d=a.translate_address_write(d));do a.memory.write8(d,a.memory.read8(c)),d+=l,c+=l,f=0!==--g&&!0;while(f&&m--);e=e*(k-g)|0;a.regv[a.reg_vdi]+=e;a.regv[a.reg_vsi]+=
e;a.regv[a.reg_vcx]=g;a.timestamp_counter+=k-g}else c=a.translate_address_read(c),d=a.translate_address_write(d),a.memory.write8(d,a.memory.read8(c)),a.regv[a.reg_vdi]+=e,a.regv[a.reg_vsi]+=e;f&&(a.instruction_pointer=a.previous_ip)}};
table16[165]=function(a){a:{var c,d,e=a.flags&1024?-2:2,f=!1;d=a.get_seg(0)+a.regv[a.reg_vdi]|0;c=a.get_seg_prefix(3)+a.regv[a.reg_vsi]|0;if(0!==a.repeat_string_prefix){var g=a.regv[a.reg_vcx]>>>0,k=g;if(0===g)break a;var m=16384;if(d&1||c&1){do a.safe_write16(d,a.safe_read16(c)),d+=e,a.regv[a.reg_vdi]+=e,c+=e,a.regv[a.reg_vsi]+=e,f=0!==--a.regv[a.reg_vcx]&&!0;while(f&&m--)}else{var l=e>>31|1;a.paging&&(m=(l>>1^~c)&4095,c=a.translate_address_read(c),m=Math.min(m,(l>>1^~d)&4095),d=a.translate_address_write(d),
m>>=1);d>>>=1;c>>>=1;do a.memory.write_aligned16(d,a.memory.read_aligned16(c)),d+=l,c+=l,f=0!==--g&&!0;while(f&&m--);e=e*(k-g)|0;a.regv[a.reg_vdi]+=e;a.regv[a.reg_vsi]+=e;a.regv[a.reg_vcx]=g;a.timestamp_counter+=k-g}}else a.safe_write16(d,a.safe_read16(c)),a.regv[a.reg_vdi]+=e,a.regv[a.reg_vsi]+=e;f&&(a.instruction_pointer=a.previous_ip)}};
table32[165]=function(a){a:{if(0!==a.repeat_string_prefix){var c=a.get_seg_prefix(3)+a.regv[a.reg_vsi],d=a.get_seg(0)+a.regv[a.reg_vdi],e=a.regv[a.reg_vcx]>>>0;if(!e)break a;var f=a.paging?4095:3;if(0===(d&f)&&0===(c&f)&&0===(a.flags&1024)&&(f=!1,a.paging&&(c=a.translate_address_read(c),d=a.translate_address_write(d),1024<e&&(e=1024,f=!0)),!a.io.in_mmap_range(c,e)&&!a.io.in_mmap_range(d,e))){var g=e<<2;a.regv[a.reg_vcx]-=e;a.regv[a.reg_vdi]+=g;a.regv[a.reg_vsi]+=g;c>>=2;a.memory.mem32s.set(a.memory.mem32s.subarray(c,
c+e),d>>2);f&&(a.instruction_pointer=a.previous_ip);break a}}g=a.flags&1024?-4:4;f=!1;d=a.get_seg(0)+a.regv[a.reg_vdi]|0;c=a.get_seg_prefix(3)+a.regv[a.reg_vsi]|0;if(0!==a.repeat_string_prefix){var k=e=a.regv[a.reg_vcx]>>>0;if(0===e)break a;var m=16384;if(d&3||c&3){do a.safe_write32(d,a.safe_read32s(c)),d+=g,a.regv[a.reg_vdi]+=g,c+=g,a.regv[a.reg_vsi]+=g,f=0!==--a.regv[a.reg_vcx]&&!0;while(f&&m--)}else{var l=g>>31|1;a.paging&&(m=(l>>1^~c)&4095,c=a.translate_address_read(c),m=Math.min(m,(l>>1^~d)&
4095),d=a.translate_address_write(d),m>>=2);d>>>=2;c>>>=2;do a.memory.write_aligned32(d,a.memory.read_aligned32(c)),d+=l,c+=l,f=0!==--e&&!0;while(f&&m--);g=g*(k-e)|0;a.regv[a.reg_vdi]+=g;a.regv[a.reg_vsi]+=g;a.regv[a.reg_vcx]=e;a.timestamp_counter+=k-e}}else a.safe_write32(d,a.safe_read32s(c)),a.regv[a.reg_vdi]+=g,a.regv[a.reg_vsi]+=g;f&&(a.instruction_pointer=a.previous_ip)}};
table16[166]=table32[166]=function(a){a:{var c,d;d=0;var e,f,g=a.flags&1024?-1:1,k=!1;d=a.get_seg(0)+a.regv[a.reg_vdi]|0;c=a.get_seg_prefix(3)+a.regv[a.reg_vsi]|0;if(0!==a.repeat_string_prefix){var m=a.regv[a.reg_vcx]>>>0,l=m;if(0===m)break a;var n=16384,p=g>>31|1;a.paging?(n=(p>>1^~c)&4095,f=a.translate_address_read(c),n=Math.min(n,(p>>1^~d)&4095),e=a.translate_address_read(d)):(e=d,f=c);do d=a.memory.read8(e),c=a.memory.read8(f),e+=p,f+=p,k=0!==--m&&c===d===(2===a.repeat_string_prefix);while(k&&
n--);g=g*(l-m)|0;a.regv[a.reg_vdi]+=g;a.regv[a.reg_vsi]+=g;a.regv[a.reg_vcx]=m;a.timestamp_counter+=l-m}else f=a.translate_address_read(c),e=a.translate_address_read(d),d=a.memory.read8(e),c=a.memory.read8(f),a.regv[a.reg_vdi]+=g,a.regv[a.reg_vsi]+=g;a.sub(c,d,7);k&&(a.instruction_pointer=a.previous_ip)}};
table16[167]=function(a){a:{var c,d,e,f=0,g=a.flags&1024?-2:2,k=!1;d=a.get_seg(0)+a.regv[a.reg_vdi]|0;c=a.get_seg_prefix(3)+a.regv[a.reg_vsi]|0;if(0!==a.repeat_string_prefix){var m=a.regv[a.reg_vcx]>>>0,l=m;if(0===m)break a;var n=16384;if(d&1||c&1){do f=a.safe_read16(d),e=a.safe_read16(c),d+=g,a.regv[a.reg_vdi]+=g,c+=g,a.regv[a.reg_vsi]+=g,k=0!==--a.regv[a.reg_vcx]&&e===f===(2===a.repeat_string_prefix);while(k&&n--)}else{var p=g>>31|1;a.paging&&(n=(p>>1^~c)&4095,c=a.translate_address_read(c),n=Math.min(n,
(p>>1^~d)&4095),d=a.translate_address_read(d),n>>=1);d>>>=1;c>>>=1;do f=a.memory.read_aligned16(d),e=a.memory.read_aligned16(c),d+=p,c+=p,k=0!==--m&&e===f===(2===a.repeat_string_prefix);while(k&&n--);g=g*(l-m)|0;a.regv[a.reg_vdi]+=g;a.regv[a.reg_vsi]+=g;a.regv[a.reg_vcx]=m;a.timestamp_counter+=l-m}}else f=a.safe_read16(d),e=a.safe_read16(c),a.regv[a.reg_vdi]+=g,a.regv[a.reg_vsi]+=g;a.sub(e,f,15);k&&(a.instruction_pointer=a.previous_ip)}};
table32[167]=function(a){a:{var c,d,e,f=0,g=a.flags&1024?-4:4,k=!1;d=a.get_seg(0)+a.regv[a.reg_vdi]|0;c=a.get_seg_prefix(3)+a.regv[a.reg_vsi]|0;if(0!==a.repeat_string_prefix){var m=a.regv[a.reg_vcx]>>>0,l=m;if(0===m)break a;var n=16384;if(d&3||c&3){do f=a.safe_read32s(d),e=a.safe_read32s(c),d+=g,a.regv[a.reg_vdi]+=g,c+=g,a.regv[a.reg_vsi]+=g,k=0!==--a.regv[a.reg_vcx]&&e===f===(2===a.repeat_string_prefix);while(k&&n--)}else{var p=g>>31|1;a.paging&&(n=(p>>1^~c)&4095,c=a.translate_address_read(c),n=
Math.min(n,(p>>1^~d)&4095),d=a.translate_address_read(d),n>>=2);d>>>=2;c>>>=2;do f=a.memory.read_aligned32(d),e=a.memory.read_aligned32(c),d+=p,c+=p,k=0!==--m&&e===f===(2===a.repeat_string_prefix);while(k&&n--);g=g*(l-m)|0;a.regv[a.reg_vdi]+=g;a.regv[a.reg_vsi]+=g;a.regv[a.reg_vcx]=m;a.timestamp_counter+=l-m}}else f=a.safe_read32s(d),e=a.safe_read32s(c),a.regv[a.reg_vdi]+=g,a.regv[a.reg_vsi]+=g;a.sub(e,f,31);k&&(a.instruction_pointer=a.previous_ip)}};
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){a:{var c=a.reg8[0],d,e=a.flags&1024?-1:1,f=!1;d=a.get_seg(0)+a.regv[a.reg_vdi]|0;if(0!==a.repeat_string_prefix){var g=a.regv[a.reg_vcx]>>>0,k=g;if(0===g)break a;var m=16384,l=e>>31|1;a.paging&&(m=Math.min(m,(l>>1^~d)&4095),d=a.translate_address_write(d));do a.memory.write8(d,c),d+=l,f=0!==--g&&!0;while(f&&m--);a.regv[a.reg_vdi]+=e*(k-g)|0;a.regv[a.reg_vcx]=g;a.timestamp_counter+=k-g}else d=a.translate_address_write(d),a.memory.write8(d,c),a.regv[a.reg_vdi]+=e;
f&&(a.instruction_pointer=a.previous_ip)}};
table16[171]=function(a){a:{var c=a.reg16[0],d,e=a.flags&1024?-2:2,f=!1;d=a.get_seg(0)+a.regv[a.reg_vdi]|0;if(0!==a.repeat_string_prefix){var g=a.regv[a.reg_vcx]>>>0,k=g;if(0===g)break a;var m=16384;if(d&1){do a.safe_write16(d,c),d+=e,a.regv[a.reg_vdi]+=e,f=0!==--a.regv[a.reg_vcx]&&!0;while(f&&m--)}else{var l=e>>31|1;a.paging&&(m=Math.min(m,(l>>1^~d)&4095),d=a.translate_address_write(d),m>>=1);d>>>=1;do a.memory.write_aligned16(d,c),d+=l,f=0!==--g&&!0;while(f&&m--);a.regv[a.reg_vdi]+=e*(k-g)|0;a.regv[a.reg_vcx]=
g;a.timestamp_counter+=k-g}}else a.safe_write16(d,c),a.regv[a.reg_vdi]+=e;f&&(a.instruction_pointer=a.previous_ip)}};
table32[171]=function(a){a:{var c=a.reg32s[0],d,e=a.flags&1024?-4:4,f=!1;d=a.get_seg(0)+a.regv[a.reg_vdi]|0;if(0!==a.repeat_string_prefix){var g=a.regv[a.reg_vcx]>>>0,k=g;if(0===g)break a;var m=16384;if(d&3){do a.safe_write32(d,c),d+=e,a.regv[a.reg_vdi]+=e,f=0!==--a.regv[a.reg_vcx]&&!0;while(f&&m--)}else{var l=e>>31|1;a.paging&&(m=Math.min(m,(l>>1^~d)&4095),d=a.translate_address_write(d),m>>=2);d>>>=2;do a.memory.write_aligned32(d,c),d+=l,f=0!==--g&&!0;while(f&&m--);a.regv[a.reg_vdi]+=e*(k-g)|0;a.regv[a.reg_vcx]=
g;a.timestamp_counter+=k-g}}else a.safe_write32(d,c),a.regv[a.reg_vdi]+=e;f&&(a.instruction_pointer=a.previous_ip)}};
table16[172]=table32[172]=function(a){a:{var c,d=a.flags&1024?-1:1,e=!1;c=a.get_seg_prefix(3)+a.regv[a.reg_vsi]|0;if(0!==a.repeat_string_prefix){var f=a.regv[a.reg_vcx]>>>0,g=f;if(0===f)break a;var k=16384,m=d>>31|1;a.paging&&(k=(m>>1^~c)&4095,c=a.translate_address_read(c));do a.reg8[0]=a.memory.read8(c),c+=m,e=0!==--f&&!0;while(e&&k--);a.regv[a.reg_vsi]+=d*(g-f)|0;a.regv[a.reg_vcx]=f;a.timestamp_counter+=g-f}else c=a.translate_address_read(c),a.reg8[0]=a.memory.read8(c),a.regv[a.reg_vsi]+=d;e&&(a.instruction_pointer=
a.previous_ip)}};
table16[173]=function(a){a:{var c,d=a.flags&1024?-2:2,e=!1;c=a.get_seg_prefix(3)+a.regv[a.reg_vsi]|0;if(0!==a.repeat_string_prefix){var f=a.regv[a.reg_vcx]>>>0,g=f;if(0===f)break a;var k=16384;if(c&1){do a.reg16[0]=a.safe_read16(c),c+=d,a.regv[a.reg_vsi]+=d,e=0!==--a.regv[a.reg_vcx]&&!0;while(e&&k--)}else{var m=d>>31|1;a.paging&&(k=(m>>1^~c)&4095,c=a.translate_address_read(c),k>>=1);c>>>=1;do a.reg16[0]=a.memory.read_aligned16(c),c+=m,e=0!==--f&&!0;while(e&&k--);a.regv[a.reg_vsi]+=d*(g-f)|0;a.regv[a.reg_vcx]=
f;a.timestamp_counter+=g-f}}else a.reg16[0]=a.safe_read16(c),a.regv[a.reg_vsi]+=d;e&&(a.instruction_pointer=a.previous_ip)}};
table32[173]=function(a){a:{var c,d=a.flags&1024?-4:4,e=!1;c=a.get_seg_prefix(3)+a.regv[a.reg_vsi]|0;if(0!==a.repeat_string_prefix){var f=a.regv[a.reg_vcx]>>>0,g=f;if(0===f)break a;var k=16384;if(c&3){do a.reg32s[0]=a.safe_read32s(c),c+=d,a.regv[a.reg_vsi]+=d,e=0!==--a.regv[a.reg_vcx]&&!0;while(e&&k--)}else{var m=d>>31|1;a.paging&&(k=(m>>1^~c)&4095,c=a.translate_address_read(c),k>>=2);c>>>=2;do a.reg32s[0]=a.memory.read_aligned32(c),c+=m,e=0!==--f&&!0;while(e&&k--);a.regv[a.reg_vsi]+=d*(g-f)|0;a.regv[a.reg_vcx]=
f;a.timestamp_counter+=g-f}}else a.reg32s[0]=a.safe_read32s(c),a.regv[a.reg_vsi]+=d;e&&(a.instruction_pointer=a.previous_ip)}};
table16[174]=table32[174]=function(a){a:{var c,d;c=0;var e,f=a.flags&1024?-1:1,g=!1;d=a.reg8[0];c=a.get_seg(0)+a.regv[a.reg_vdi]|0;if(0!==a.repeat_string_prefix){var k=a.regv[a.reg_vcx]>>>0,m=k;if(0===k)break a;var l=16384,n=f>>31|1;a.paging?(l=Math.min(l,(n>>1^~c)&4095),e=a.translate_address_read(c)):e=c;do c=a.memory.read8(e),e+=n,g=0!==--k&&d===c===(2===a.repeat_string_prefix);while(g&&l--);a.regv[a.reg_vdi]+=f*(m-k)|0;a.regv[a.reg_vcx]=k;a.timestamp_counter+=m-k}else e=a.translate_address_read(c),
c=a.memory.read8(e),a.regv[a.reg_vdi]+=f;a.sub(d,c,7);g&&(a.instruction_pointer=a.previous_ip)}};
table16[175]=function(a){a:{var c,d,e=0,f=a.flags&1024?-2:2,g=!1;d=a.reg16[0];c=a.get_seg(0)+a.regv[a.reg_vdi]|0;if(0!==a.repeat_string_prefix){var k=a.regv[a.reg_vcx]>>>0,m=k;if(0===k)break a;var l=16384;if(c&1){do e=a.safe_read16(c),c+=f,a.regv[a.reg_vdi]+=f,g=0!==--a.regv[a.reg_vcx]&&d===e===(2===a.repeat_string_prefix);while(g&&l--)}else{var n=f>>31|1;a.paging&&(l=Math.min(l,(n>>1^~c)&4095),c=a.translate_address_read(c),l>>=1);c>>>=1;do e=a.memory.read_aligned16(c),c+=n,g=0!==--k&&d===e===(2===
a.repeat_string_prefix);while(g&&l--);a.regv[a.reg_vdi]+=f*(m-k)|0;a.regv[a.reg_vcx]=k;a.timestamp_counter+=m-k}}else e=a.safe_read16(c),a.regv[a.reg_vdi]+=f;a.sub(d,e,15);g&&(a.instruction_pointer=a.previous_ip)}};
table32[175]=function(a){a:{var c,d,e=0,f=a.flags&1024?-4:4,g=!1;d=a.reg32s[0];c=a.get_seg(0)+a.regv[a.reg_vdi]|0;if(0!==a.repeat_string_prefix){var k=a.regv[a.reg_vcx]>>>0,m=k;if(0===k)break a;var l=16384;if(c&3){do e=a.safe_read32s(c),c+=f,a.regv[a.reg_vdi]+=f,g=0!==--a.regv[a.reg_vcx]&&d===e===(2===a.repeat_string_prefix);while(g&&l--)}else{var n=f>>31|1;a.paging&&(l=Math.min(l,(n>>1^~c)&4095),c=a.translate_address_read(c),l>>=2);c>>>=2;do e=a.memory.read_aligned32(c),c+=n,g=0!==--k&&d===e===(2===
a.repeat_string_prefix);while(g&&l--);a.regv[a.reg_vdi]+=f*(m-k)|0;a.regv[a.reg_vcx]=k;a.timestamp_counter+=m-k}}else e=a.safe_read32s(c),a.regv[a.reg_vdi]+=f;a.sub(d,e,31);g&&(a.instruction_pointer=a.previous_ip)}};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 c=a.read_imm8(),d,e,f,g;192>c?(f=a.translate_address_write(a.modrm_resolve(c)),e=a.memory.read8(f)):e=a.reg8[c<<2&12|c>>2&1];g=0;d=a.read_imm8()&31;switch(c>>3&7){case 0:g=a.rol8(e,d);break;case 1:g=a.ror8(e,d);break;case 2:g=a.rcl8(e,d);break;case 3:g=a.rcr8(e,d);break;case 4:g=a.shl8(e,d);break;case 5:g=a.shr8(e,d);break;case 6:g=a.shl8(e,d);break;case 7:g=a.sar8(e,d)}192>c?a.memory.write8(f,g):a.reg8[c<<2&12|c>>2&1]=g};
table16[193]=function(a){var c=a.read_imm8(),d,e,f,g=0,k;192>c?(d=a.modrm_resolve(c),f=a.translate_address_write(d),a.paging&&4095===(d&4095)?(g=a.translate_address_write(d+1),e=a.virt_boundary_read16(f,g)):e=a.memory.read16(f)):e=a.reg16[c<<1&14];k=0;d=a.read_imm8()&31;switch(c>>3&7){case 0:k=a.rol16(e,d);break;case 1:k=a.ror16(e,d);break;case 2:k=a.rcl16(e,d);break;case 3:k=a.rcr16(e,d);break;case 4:k=a.shl16(e,d);break;case 5:k=a.shr16(e,d);break;case 6:k=a.shl16(e,d);break;case 7:k=a.sar16(e,
d)}192>c?g?a.virt_boundary_write16(f,g,k):a.memory.write16(f,k):a.reg16[c<<1&14]=k};
table32[193]=function(a){var c=a.read_imm8(),d,e,f,g=0,k;192>c?(d=a.modrm_resolve(c),f=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(g=a.translate_address_write(d+3),e=a.virt_boundary_read32s(f,g)):e=a.memory.read32s(f)):e=a.reg32s[c&7];k=0;d=a.read_imm8()&31;switch(c>>3&7){case 0:k=a.rol32(e,d);break;case 1:k=a.ror32(e,d);break;case 2:k=a.rcl32(e,d);break;case 3:k=a.rcr32(e,d);break;case 4:k=a.shl32(e,d);break;case 5:k=a.shr32(e,d);break;case 6:k=a.shl32(e,d);break;case 7:k=a.sar32(e,d)}192>
c?g?a.virt_boundary_write32(f,g,k):a.memory.write32(f,k):a.reg32s[c&7]=k};table16[194]=function(a){var c=a.read_imm16();a.instruction_pointer=a.get_seg(1)+a.pop16()|0;a.stack_reg[a.reg_vsp]+=c;a.last_instr_jump=!0};table32[194]=function(a){var c=a.read_imm16();a.instruction_pointer=a.get_seg(1)+a.pop32s()|0;a.stack_reg[a.reg_vsp]+=c;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 c=a.read_imm8();192<=c&&a.trigger_ud();a.lss16(0,a.modrm_resolve(c),c>>2&14)};table32[196]=function(a){var c=a.read_imm8();192<=c&&a.trigger_ud();a.lss32(0,a.modrm_resolve(c),c>>3&7)};table16[197]=function(a){var c=a.read_imm8();192<=c&&a.trigger_ud();a.lss16(3,a.modrm_resolve(c),c>>2&14)};
table32[197]=function(a){var c=a.read_imm8();192<=c&&a.trigger_ud();a.lss32(3,a.modrm_resolve(c),c>>3&7)};table16[198]=table32[198]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=a.read_imm8();192>c?a.safe_write8(d,e):a.reg8[c<<2&12|c>>2&1]=e};table16[199]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=a.read_imm16();192>c?a.safe_write16(d,e):a.reg16[c<<1&14]=e};
table32[199]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=a.read_imm32s();192>c?a.safe_write32(d,e):a.reg32[c&7]=e};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 c=a.read_imm16(),d=a.pop16();a.switch_seg(1,a.pop16());a.instruction_pointer=a.get_seg(1)+d|0;a.stack_reg[a.reg_vsp]+=c;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 c=a.read_imm16(),d=a.pop32s();a.switch_seg(1,a.pop32s()&65535);a.instruction_pointer=a.get_seg(1)+d|0;a.stack_reg[a.reg_vsp]+=c;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 c=a.pop16();a.switch_seg(1,a.pop16());a.instruction_pointer=a.get_seg(1)+c|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 c=a.pop32s();a.switch_seg(1,a.pop32s()&65535);a.instruction_pointer=a.get_seg(1)+c|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 c=a.read_imm8();a.call_interrupt_vector(c,!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 c=a.read_imm8(),d,e,f;192>c?(e=a.translate_address_write(a.modrm_resolve(c)),d=a.memory.read8(e)):d=a.reg8[c<<2&12|c>>2&1];f=0;switch(c>>3&7){case 0:f=a.rol8(d,1);break;case 1:f=a.ror8(d,1);break;case 2:f=a.rcl8(d,1);break;case 3:f=a.rcr8(d,1);break;case 4:f=a.shl8(d,1);break;case 5:f=a.shr8(d,1);break;case 6:f=a.shl8(d,1);break;case 7:f=a.sar8(d,1)}192>c?a.memory.write8(e,f):a.reg8[c<<2&12|c>>2&1]=f};
table16[209]=function(a){var c=a.read_imm8(),d,e,f=0,g;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];g=0;switch(c>>3&7){case 0:g=a.rol16(d,1);break;case 1:g=a.ror16(d,1);break;case 2:g=a.rcl16(d,1);break;case 3:g=a.rcr16(d,1);break;case 4:g=a.shl16(d,1);break;case 5:g=a.shr16(d,1);break;case 6:g=a.shl16(d,1);break;case 7:g=a.sar16(d,1)}192>c?f?a.virt_boundary_write16(e,
f,g):a.memory.write16(e,g):a.reg16[c<<1&14]=g};
table32[209]=function(a){var c=a.read_imm8(),d,e,f=0,g;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(f=a.translate_address_write(d+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[c&7];g=0;switch(c>>3&7){case 0:g=a.rol32(d,1);break;case 1:g=a.ror32(d,1);break;case 2:g=a.rcl32(d,1);break;case 3:g=a.rcr32(d,1);break;case 4:g=a.shl32(d,1);break;case 5:g=a.shr32(d,1);break;case 6:g=a.shl32(d,1);break;case 7:g=a.sar32(d,1)}192>c?f?a.virt_boundary_write32(e,
f,g):a.memory.write32(e,g):a.reg32s[c&7]=g};
table16[210]=table32[210]=function(a){var c=a.read_imm8(),d,e,f,g;192>c?(f=a.translate_address_write(a.modrm_resolve(c)),e=a.memory.read8(f)):e=a.reg8[c<<2&12|c>>2&1];g=0;d=a.reg8[4]&31;switch(c>>3&7){case 0:g=a.rol8(e,d);break;case 1:g=a.ror8(e,d);break;case 2:g=a.rcl8(e,d);break;case 3:g=a.rcr8(e,d);break;case 4:g=a.shl8(e,d);break;case 5:g=a.shr8(e,d);break;case 6:g=a.shl8(e,d);break;case 7:g=a.sar8(e,d)}192>c?a.memory.write8(f,g):a.reg8[c<<2&12|c>>2&1]=g};
table16[211]=function(a){var c=a.read_imm8(),d,e,f,g=0,k;192>c?(d=a.modrm_resolve(c),f=a.translate_address_write(d),a.paging&&4095===(d&4095)?(g=a.translate_address_write(d+1),e=a.virt_boundary_read16(f,g)):e=a.memory.read16(f)):e=a.reg16[c<<1&14];k=0;d=a.reg8[4]&31;switch(c>>3&7){case 0:k=a.rol16(e,d);break;case 1:k=a.ror16(e,d);break;case 2:k=a.rcl16(e,d);break;case 3:k=a.rcr16(e,d);break;case 4:k=a.shl16(e,d);break;case 5:k=a.shr16(e,d);break;case 6:k=a.shl16(e,d);break;case 7:k=a.sar16(e,d)}192>
c?g?a.virt_boundary_write16(f,g,k):a.memory.write16(f,k):a.reg16[c<<1&14]=k};
table32[211]=function(a){var c=a.read_imm8(),d,e,f,g=0,k;192>c?(d=a.modrm_resolve(c),f=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(g=a.translate_address_write(d+3),e=a.virt_boundary_read32s(f,g)):e=a.memory.read32s(f)):e=a.reg32s[c&7];k=0;d=a.reg8[4]&31;switch(c>>3&7){case 0:k=a.rol32(e,d);break;case 1:k=a.ror32(e,d);break;case 2:k=a.rcl32(e,d);break;case 3:k=a.rcr32(e,d);break;case 4:k=a.shl32(e,d);break;case 5:k=a.shr32(e,d);break;case 6:k=a.shl32(e,d);break;case 7:k=a.sar32(e,d)}192>
c?g?a.virt_boundary_write32(f,g,k):a.memory.write32(f,k):a.reg32s[c&7]=k};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 c=a.read_imm8();a.cr0&12&&a.trigger_nm();192>c?a.fpu.op_D8_mem(c,a.modrm_resolve(c)):a.fpu.op_D8_reg(c)};table16[217]=table32[217]=function(a){var c=a.read_imm8();a.cr0&12&&a.trigger_nm();192>c?a.fpu.op_D9_mem(c,a.modrm_resolve(c)):a.fpu.op_D9_reg(c)};table16[218]=table32[218]=function(a){var c=a.read_imm8();a.cr0&12&&a.trigger_nm();192>c?a.fpu.op_DA_mem(c,a.modrm_resolve(c)):a.fpu.op_DA_reg(c)};
table16[219]=table32[219]=function(a){var c=a.read_imm8();a.cr0&12&&a.trigger_nm();192>c?a.fpu.op_DB_mem(c,a.modrm_resolve(c)):a.fpu.op_DB_reg(c)};table16[220]=table32[220]=function(a){var c=a.read_imm8();a.cr0&12&&a.trigger_nm();192>c?a.fpu.op_DC_mem(c,a.modrm_resolve(c)):a.fpu.op_DC_reg(c)};table16[221]=table32[221]=function(a){var c=a.read_imm8();a.cr0&12&&a.trigger_nm();192>c?a.fpu.op_DD_mem(c,a.modrm_resolve(c)):a.fpu.op_DD_reg(c)};
table16[222]=table32[222]=function(a){var c=a.read_imm8();a.cr0&12&&a.trigger_nm();192>c?a.fpu.op_DE_mem(c,a.modrm_resolve(c)):a.fpu.op_DE_reg(c)};table16[223]=table32[223]=function(a){var c=a.read_imm8();a.cr0&12&&a.trigger_nm();192>c?a.fpu.op_DF_mem(c,a.modrm_resolve(c)):a.fpu.op_DF_reg(c)};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 c=a.read_imm8();a.test_privileges_for_io(c,1);a.reg8[0]=a.io.port_read8(c)};table16[229]=function(a){var c=a.read_imm8();a.test_privileges_for_io(c,2);a.reg16[0]=a.io.port_read16(c)};table32[229]=function(a){var c=a.read_imm8();a.test_privileges_for_io(c,4);a.reg32s[0]=a.io.port_read32(c)};table16[230]=table32[230]=function(a){var c=a.read_imm8();a.test_privileges_for_io(c,1);a.io.port_write8(c,a.reg8[0])};
table16[231]=function(a){var c=a.read_imm8();a.test_privileges_for_io(c,2);a.io.port_write16(c,a.reg16[0])};table32[231]=function(a){var c=a.read_imm8();a.test_privileges_for_io(c,4);a.io.port_write32(c,a.reg32s[0])};table16[232]=function(a){var c=a.read_imm16s();a.push16(a.get_real_eip());a.jmp_rel16(c);a.last_instr_jump=!0};table32[232]=function(a){var c=a.read_imm32s();a.push32(a.get_real_eip());a.instruction_pointer=a.instruction_pointer+c|0;a.last_instr_jump=!0};
table16[233]=function(a){var c=a.read_imm16s();a.jmp_rel16(c);a.last_instr_jump=!0};table32[233]=function(a){var c=a.read_imm32s();a.instruction_pointer=a.instruction_pointer+c|0;a.last_instr_jump=!0};table16[234]=function(a){var c=a.read_imm16();a.switch_seg(1,a.read_imm16());a.instruction_pointer=c+a.get_seg(1)|0;a.last_instr_jump=!0};table32[234]=function(a){var c=a.read_imm32s();a.switch_seg(1,a.read_imm16());a.instruction_pointer=c+a.get_seg(1)|0;a.last_instr_jump=!0};
table16[235]=table32[235]=function(a){var c=a.read_imm8s();a.instruction_pointer=a.instruction_pointer+c|0;a.last_instr_jump=!0};table16[236]=table32[236]=function(a){var c=a.reg16[4];a.test_privileges_for_io(c,1);a.reg8[0]=a.io.port_read8(c)};table16[237]=function(a){var c=a.reg16[4];a.test_privileges_for_io(c,2);a.reg16[0]=a.io.port_read16(c)};table32[237]=function(a){var c=a.reg16[4];a.test_privileges_for_io(c,4);a.reg32s[0]=a.io.port_read32(c)};
table16[238]=table32[238]=function(a){var c=a.reg16[4];a.test_privileges_for_io(c,1);a.io.port_write8(c,a.reg8[0])};table16[239]=function(a){var c=a.reg16[4];a.test_privileges_for_io(c,2);a.io.port_write16(c,a.reg16[0])};table32[239]=function(a){var c=a.reg16[4];a.test_privileges_for_io(c,4);a.io.port_write32(c,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 c=a.read_imm8();switch(c>>3&7){case 0:var d=192>c?a.safe_read8(a.modrm_resolve(c)):a.reg8[c<<2&12|c>>2&1];a.and(d,a.read_imm8(),7);break;case 1:d=192>c?a.safe_read8(a.modrm_resolve(c)):a.reg8[c<<2&12|c>>2&1];a.and(d,a.read_imm8(),7);break;case 2:var e;192>c?(e=a.translate_address_write(a.modrm_resolve(c)),d=a.memory.read8(e)):d=a.reg8[c<<2&12|c>>2&1];d=~d;192>c?a.memory.write8(e,d):a.reg8[c<<2&12|c>>2&1]=d;break;case 3:192>c?(e=a.translate_address_write(a.modrm_resolve(c)),
d=a.memory.read8(e)):d=a.reg8[c<<2&12|c>>2&1];d=a.neg(d,7);192>c?a.memory.write8(e,d):a.reg8[c<<2&12|c>>2&1]=d;break;case 4:d=192>c?a.safe_read8(a.modrm_resolve(c)):a.reg8[c<<2&12|c>>2&1];a.mul8(d);break;case 5:192>c?d=a.safe_read8(a.modrm_resolve(c))<<24>>24:d=a.reg8s[c<<2&12|c>>2&1];a.imul8(d);break;case 6:d=192>c?a.safe_read8(a.modrm_resolve(c)):a.reg8[c<<2&12|c>>2&1];a.div8(d);break;case 7:192>c?d=a.safe_read8(a.modrm_resolve(c))<<24>>24:d=a.reg8s[c<<2&12|c>>2&1],a.idiv8(d)}};
table16[247]=function(a){var c=a.read_imm8();switch(c>>3&7){case 0:var d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.and(d,a.read_imm16(),15);break;case 1:d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.and(d,a.read_imm16(),15);break;case 2:var e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];d=~d;192>c?f?a.virt_boundary_write16(e,
f,d):a.memory.write16(e,d):a.reg16[c<<1&14]=d;break;case 3:f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];d=a.neg(d,15);192>c?f?a.virt_boundary_write16(e,f,d):a.memory.write16(e,d):a.reg16[c<<1&14]=d;break;case 4:d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.mul16(d);break;case 5:192>c?d=a.safe_read16(a.modrm_resolve(c))<<16>>16:d=a.reg16s[c<<
1&14];a.imul16(d);break;case 6:d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.div16(d);break;case 7:192>c?d=a.safe_read16(a.modrm_resolve(c))<<16>>16:d=a.reg16s[c<<1&14],a.idiv16(d)}};
table32[247]=function(a){var c=a.read_imm8();switch(c>>3&7){case 0:var d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.and(d,a.read_imm32s(),31);break;case 1:d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.and(d,a.read_imm32s(),31);break;case 2:var e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(f=a.translate_address_write(d+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[c&7];d=~d;192>c?f?a.virt_boundary_write32(e,
f,d):a.memory.write32(e,d):a.reg32s[c&7]=d;break;case 3:f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(f=a.translate_address_write(d+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[c&7];d=a.neg(d,31);192>c?f?a.virt_boundary_write32(e,f,d):a.memory.write32(e,d):a.reg32s[c&7]=d;break;case 4:192>c?d=a.safe_read32s(a.modrm_resolve(c))>>>0:d=a.reg32[c&7];a.mul32(d);break;case 5:d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.imul32(d);
break;case 6:192>c?d=a.safe_read32s(a.modrm_resolve(c))>>>0:d=a.reg32[c&7];a.div32(d);break;case 7:d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7],a.idiv32(d)}};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 c=a.read_imm8(),d=c&56;if(0===d){var e;192>c?(e=a.translate_address_write(a.modrm_resolve(c)),d=a.memory.read8(e)):d=a.reg8[c<<2&12|c>>2&1];d=a.inc(d,7);192>c?a.memory.write8(e,d):a.reg8[c<<2&12|c>>2&1]=d}else 8===d?(192>c?(e=a.translate_address_write(a.modrm_resolve(c)),d=a.memory.read8(e)):d=a.reg8[c<<2&12|c>>2&1],d=a.dec(d,7),192>c?a.memory.write8(e,d):a.reg8[c<<2&12|c>>2&1]=d):a.trigger_ud()};
table16[255]=function(a){var c=a.read_imm8();switch(c>>3&7){case 0:var d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];d=a.inc(d,15);192>c?f?a.virt_boundary_write16(e,f,d):a.memory.write16(e,d):a.reg16[c<<1&14]=d;break;case 1:f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=
a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];d=a.dec(d,15);192>c?f?a.virt_boundary_write16(e,f,d):a.memory.write16(e,d):a.reg16[c<<1&14]=d;break;case 2:d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.push16(a.get_real_eip());a.instruction_pointer=a.get_seg(1)+d|0;a.last_instr_jump=!0;break;case 3:192<=c&&a.trigger_ud();d=a.modrm_resolve(c);c=a.safe_read16(d+2);e=a.safe_read16(d);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)+e|0;a.last_instr_jump=!0;break;case 4:d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.instruction_pointer=a.get_seg(1)+d|0;a.last_instr_jump=!0;break;case 5:192<=c&&a.trigger_ud();d=a.modrm_resolve(c);c=a.safe_read16(d+2);e=a.safe_read16(d);a.switch_seg(1,c);a.instruction_pointer=a.get_seg(1)+e|0;a.last_instr_jump=!0;break;case 6:d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.push16(d);break;case 7:a.trigger_ud()}};
table32[255]=function(a){var c=a.read_imm8();switch(c>>3&7){case 0:var d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(f=a.translate_address_write(d+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[c&7];d=a.inc(d,31);192>c?f?a.virt_boundary_write32(e,f,d):a.memory.write32(e,d):a.reg32s[c&7]=d;break;case 1:f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(f=a.translate_address_write(d+3),d=a.virt_boundary_read32s(e,
f)):d=a.memory.read32s(e)):d=a.reg32s[c&7];d=a.dec(d,31);192>c?f?a.virt_boundary_write32(e,f,d):a.memory.write32(e,d):a.reg32s[c&7]=d;break;case 2:d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.push32(a.get_real_eip());a.instruction_pointer=a.get_seg(1)+d|0;a.last_instr_jump=!0;break;case 3:192<=c&&a.trigger_ud();d=a.modrm_resolve(c);c=a.safe_read16(d+4);e=a.safe_read32s(d);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)+e|0;a.last_instr_jump=!0;break;case 4:d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.instruction_pointer=a.get_seg(1)+d|0;a.last_instr_jump=!0;break;case 5:192<=c&&a.trigger_ud();d=a.modrm_resolve(c);c=a.safe_read16(d+4);e=a.safe_read32s(d);a.switch_seg(1,c);a.instruction_pointer=a.get_seg(1)+e|0;a.last_instr_jump=!0;break;case 6:d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.push32(d);break;case 7:a.trigger_ud()}};
table0F_16[0]=table0F_32[0]=function(a){var c=a.read_imm8();a.protected_mode||a.trigger_ud();a.cpl&&a.trigger_gp(0);switch(c>>3&7){case 0:if(192>c)var d=a.modrm_resolve(c);var e=a.sreg[7];192>c?a.safe_write16(d,e):a.reg16[c<<1&14]=e;break;case 1:192>c&&(d=a.modrm_resolve(c));e=a.sreg[6];192>c?a.safe_write16(d,e):a.reg16[c<<1&14]=e;break;case 2:e=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.load_ldt(e);break;case 3:e=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.load_tr(e);
break;default:a.trigger_ud()}};
table0F_16[1]=table0F_32[1]=function(a){var c=a.read_imm8();a.cpl&&a.trigger_gp(0);var d=c>>3&7;if(4===d){if(192>c)var e=a.modrm_resolve(c);d=a.cr0;192>c?a.safe_write16(e,d):a.reg16[c<<1&14]=d}else if(6===d)d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14],a.cr0=a.cr0&-16|d&15,a.protected_mode&&(a.cr0|=1),a.cr0_changed();else switch(192<=c&&a.trigger_ud(),2!==d&&3!==d||!a.protected_mode||(a.segment_prefix=9),e=a.modrm_resolve(c),a.segment_prefix=-1,d){case 0:a.writable_or_pagefault(e,6);
a.safe_write16(e,a.gdtr_size);a.safe_write32(e+2,a.gdtr_offset);break;case 1:a.writable_or_pagefault(e,6);a.safe_write16(e,a.idtr_size);a.safe_write32(e+2,a.idtr_offset);break;case 2:c=a.safe_read16(e);e=a.safe_read32s(e+2);a.gdtr_size=c;a.gdtr_offset=e;a.operand_size_32||(a.gdtr_offset&=16777215);break;case 3:c=a.safe_read16(e);e=a.safe_read32s(e+2);a.idtr_size=c;a.idtr_offset=e;a.operand_size_32||(a.idtr_offset&=16777215);break;case 7:a.invlpg(e);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 c=a.read_imm8();192>c&&a.modrm_resolve(c)};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 c=a.read_imm8();a.cpl&&a.trigger_gp(0);switch(c>>3&7){case 0:a.reg32s[c&7]=a.cr0;break;case 2:a.reg32s[c&7]=a.cr2;break;case 3:a.reg32s[c&7]=a.cr3;break;case 4:a.reg32s[c&7]=a.cr4;break;default:a.trigger_ud()}};table0F_16[33]=table0F_32[33]=function(a){var c=a.read_imm8();a.cpl&&a.trigger_gp(0);a.reg32s[c&7]=a.dreg[c>>3&7]};
table0F_16[34]=table0F_32[34]=function(a){var c=a.read_imm8();a.cpl&&a.trigger_gp(0);var d=a.reg32s[c&7];switch(c>>3&7){case 0:a.cr0=d;if(-2147483648===(a.cr0&-2147483647))throw a.debug.unimpl("#GP handler");a.cr0_changed();break;case 2:a.cr2=d;break;case 3:a.cr3=d;a.clear_tlb();break;case 4:d&-3565568&&a.trigger_gp(0);(a.cr4^d)&128&&(d&128?a.clear_tlb():a.full_clear_tlb());a.cr4=d;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 c=a.read_imm8();a.cpl&&a.trigger_gp(0);a.dreg[c>>3&7]=a.reg32s[c&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 c=a.reg32s[0];switch(a.reg32s[1]){case 372:a.sysenter_cs=c&65535;break;case 374:a.sysenter_eip=c;break;case 373:a.sysenter_esp=c}};
table0F_16[49]=table0F_32[49]=function(a){if(a.cpl&&a.cr4&4)a.trigger_gp(0);else{var c=a.microtick()-a.tsc_offset;a.reg32s[0]=1024*c;a.reg32s[2]=2.384185791015625E-7*c}};table0F_16[50]=table0F_32[50]=function(a){a.cpl&&a.trigger_gp(0);var c=0;switch(a.reg32s[1]){case 372:c=a.sysenter_cs;break;case 374:c=a.sysenter_eip;break;case 373:c=a.sysenter_esp}a.reg32s[0]=c;a.reg32s[2]=0};table0F_16[51]=table0F_32[51]=function(a){a.trigger_ud()};
table0F_16[52]=table0F_32[52]=function(a){var c=a.sysenter_cs&65532;a.protected_mode&&0!==c||a.trigger_gp(0);a.flags&=-131585;a.instruction_pointer=a.sysenter_eip;a.reg32s[4]=a.sysenter_esp;a.sreg[1]=c;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]=c+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 c=a.sysenter_cs&65532;a.protected_mode&&!a.cpl&&0!==c||a.trigger_gp(0);a.instruction_pointer=a.reg32s[2];a.reg32s[4]=a.reg32s[1];a.sreg[1]=c+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]=c+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 c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.test_o()&&(a.reg16[c>>2&14]=d)};table0F_32[64]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.test_o()&&(a.reg32s[c>>3&7]=d)};table0F_16[65]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.test_o()||(a.reg16[c>>2&14]=d)};
table0F_32[65]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.test_o()||(a.reg32s[c>>3&7]=d)};table0F_16[66]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.test_b()&&(a.reg16[c>>2&14]=d)};table0F_32[66]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.test_b()&&(a.reg32s[c>>3&7]=d)};
table0F_16[67]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.test_b()||(a.reg16[c>>2&14]=d)};table0F_32[67]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.test_b()||(a.reg32s[c>>3&7]=d)};table0F_16[68]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.test_z()&&(a.reg16[c>>2&14]=d)};
table0F_32[68]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.test_z()&&(a.reg32s[c>>3&7]=d)};table0F_16[69]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.test_z()||(a.reg16[c>>2&14]=d)};table0F_32[69]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.test_z()||(a.reg32s[c>>3&7]=d)};
table0F_16[70]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.test_be()&&(a.reg16[c>>2&14]=d)};table0F_32[70]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.test_be()&&(a.reg32s[c>>3&7]=d)};table0F_16[71]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.test_be()||(a.reg16[c>>2&14]=d)};
table0F_32[71]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.test_be()||(a.reg32s[c>>3&7]=d)};table0F_16[72]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.test_s()&&(a.reg16[c>>2&14]=d)};table0F_32[72]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.test_s()&&(a.reg32s[c>>3&7]=d)};
table0F_16[73]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.test_s()||(a.reg16[c>>2&14]=d)};table0F_32[73]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.test_s()||(a.reg32s[c>>3&7]=d)};table0F_16[74]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.test_p()&&(a.reg16[c>>2&14]=d)};
table0F_32[74]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.test_p()&&(a.reg32s[c>>3&7]=d)};table0F_16[75]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.test_p()||(a.reg16[c>>2&14]=d)};table0F_32[75]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.test_p()||(a.reg32s[c>>3&7]=d)};
table0F_16[76]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.test_l()&&(a.reg16[c>>2&14]=d)};table0F_32[76]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.test_l()&&(a.reg32s[c>>3&7]=d)};table0F_16[77]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.test_l()||(a.reg16[c>>2&14]=d)};
table0F_32[77]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.test_l()||(a.reg32s[c>>3&7]=d)};table0F_16[78]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.test_le()&&(a.reg16[c>>2&14]=d)};table0F_32[78]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.test_le()&&(a.reg32s[c>>3&7]=d)};
table0F_16[79]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.test_le()||(a.reg16[c>>2&14]=d)};table0F_32[79]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.test_le()||(a.reg32s[c>>3&7]=d)};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 c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=!a.test_o()^1;192>c?a.safe_write8(d,e):a.reg8[c<<2&12|c>>2&1]=e};
table0F_16[145]=table0F_32[145]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=!!a.test_o()^1;192>c?a.safe_write8(d,e):a.reg8[c<<2&12|c>>2&1]=e};table0F_16[146]=table0F_32[146]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=!a.test_b()^1;192>c?a.safe_write8(d,e):a.reg8[c<<2&12|c>>2&1]=e};
table0F_16[147]=table0F_32[147]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=!!a.test_b()^1;192>c?a.safe_write8(d,e):a.reg8[c<<2&12|c>>2&1]=e};table0F_16[148]=table0F_32[148]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=!a.test_z()^1;192>c?a.safe_write8(d,e):a.reg8[c<<2&12|c>>2&1]=e};
table0F_16[149]=table0F_32[149]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=!!a.test_z()^1;192>c?a.safe_write8(d,e):a.reg8[c<<2&12|c>>2&1]=e};table0F_16[150]=table0F_32[150]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=!a.test_be()^1;192>c?a.safe_write8(d,e):a.reg8[c<<2&12|c>>2&1]=e};
table0F_16[151]=table0F_32[151]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=!!a.test_be()^1;192>c?a.safe_write8(d,e):a.reg8[c<<2&12|c>>2&1]=e};table0F_16[152]=table0F_32[152]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=!a.test_s()^1;192>c?a.safe_write8(d,e):a.reg8[c<<2&12|c>>2&1]=e};
table0F_16[153]=table0F_32[153]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=!!a.test_s()^1;192>c?a.safe_write8(d,e):a.reg8[c<<2&12|c>>2&1]=e};table0F_16[154]=table0F_32[154]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=!a.test_p()^1;192>c?a.safe_write8(d,e):a.reg8[c<<2&12|c>>2&1]=e};
table0F_16[155]=table0F_32[155]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=!!a.test_p()^1;192>c?a.safe_write8(d,e):a.reg8[c<<2&12|c>>2&1]=e};table0F_16[156]=table0F_32[156]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=!a.test_l()^1;192>c?a.safe_write8(d,e):a.reg8[c<<2&12|c>>2&1]=e};
table0F_16[157]=table0F_32[157]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=!!a.test_l()^1;192>c?a.safe_write8(d,e):a.reg8[c<<2&12|c>>2&1]=e};table0F_16[158]=table0F_32[158]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=!a.test_le()^1;192>c?a.safe_write8(d,e):a.reg8[c<<2&12|c>>2&1]=e};
table0F_16[159]=table0F_32[159]=function(a){var c=a.read_imm8();if(192>c)var d=a.modrm_resolve(c);var e=!!a.test_le()^1;192>c?a.safe_write8(d,e):a.reg8[c<<2&12|c>>2&1]=e};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 c=a.read_imm8();192>c?a.bt_mem(a.modrm_resolve(c),a.reg16s[c>>2&14]):a.bt_reg(a.reg16[c<<1&14],a.reg16[c>>2&14]&15)};table0F_32[163]=function(a){var c=a.read_imm8();192>c?a.bt_mem(a.modrm_resolve(c),a.reg32s[c>>3&7]):a.bt_reg(a.reg32s[c&7],a.reg32s[c>>3&7]&31)};
table0F_16[164]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];d=a.shld16(d,a.reg16[c>>2&14],a.read_imm8()&31);192>c?f?a.virt_boundary_write16(e,f,d):a.memory.write16(e,d):a.reg16[c<<1&14]=d};
table0F_32[164]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(f=a.translate_address_write(d+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[c&7];d=a.shld32(d,a.reg32s[c>>3&7],a.read_imm8()&31);192>c?f?a.virt_boundary_write32(e,f,d):a.memory.write32(e,d):a.reg32s[c&7]=d};
table0F_16[165]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];d=a.shld16(d,a.reg16[c>>2&14],a.reg8[4]&31);192>c?f?a.virt_boundary_write16(e,f,d):a.memory.write16(e,d):a.reg16[c<<1&14]=d};
table0F_32[165]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(f=a.translate_address_write(d+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[c&7];d=a.shld32(d,a.reg32s[c>>3&7],a.reg8[4]&31);192>c?f?a.virt_boundary_write32(e,f,d):a.memory.write32(e,d):a.reg32s[c&7]=d};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 c=a.read_imm8();192>c?a.bts_mem(a.modrm_resolve(c),a.reg16s[c>>2&14]):a.reg16[c<<1&14]=a.bts_reg(a.reg16[c<<1&14],a.reg16s[c>>2&14]&15)};table0F_32[171]=function(a){var c=a.read_imm8();192>c?a.bts_mem(a.modrm_resolve(c),a.reg32s[c>>3&7]):a.reg32s[c&7]=a.bts_reg(a.reg32s[c&7],a.reg32s[c>>3&7]&31)};
table0F_16[172]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];d=a.shrd16(d,a.reg16[c>>2&14],a.read_imm8()&31);192>c?f?a.virt_boundary_write16(e,f,d):a.memory.write16(e,d):a.reg16[c<<1&14]=d};
table0F_32[172]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(f=a.translate_address_write(d+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[c&7];d=a.shrd32(d,a.reg32s[c>>3&7],a.read_imm8()&31);192>c?f?a.virt_boundary_write32(e,f,d):a.memory.write32(e,d):a.reg32s[c&7]=d};
table0F_16[173]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];d=a.shrd16(d,a.reg16[c>>2&14],a.reg8[4]&31);192>c?f?a.virt_boundary_write16(e,f,d):a.memory.write16(e,d):a.reg16[c<<1&14]=d};
table0F_32[173]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(f=a.translate_address_write(d+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[c&7];d=a.shrd32(d,a.reg32s[c>>3&7],a.reg8[4]&31);192>c?f?a.virt_boundary_write32(e,f,d):a.memory.write32(e,d):a.reg32s[c&7]=d};table0F_16[174]=table0F_32[174]=function(a){a.trigger_ud()};
table0F_16[175]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c))<<16>>16:a.reg16s[c<<1&14];a.reg16[c>>2&14]=a.imul_reg16(a.reg16s[c>>2&14],d)};table0F_32[175]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.reg32s[c>>3&7]=a.imul_reg32(a.reg32s[c>>3&7],d)};
table0F_16[176]=table0F_32[176]=function(a){var c=a.read_imm8();if(192>c){var d=a.modrm_resolve(c);a.writable_or_pagefault(d,1);var e=a.safe_read8(d)}else e=a.reg8[c<<2&12|c>>2&1];a.sub(e,a.reg8[0],7);a.getzf()?192>c?a.safe_write8(d,a.reg8[c>>1&12|c>>5&1]):a.reg8[c<<2&12|c>>2&1]=a.reg8[c>>1&12|c>>5&1]:a.reg8[0]=e};
table0F_16[177]=function(a){var c=a.read_imm8();if(192>c){var d=a.modrm_resolve(c);a.writable_or_pagefault(d,2);var e=a.safe_read16(d)}else e=a.reg16[c<<1&14];a.sub(e,a.reg16[0],15);a.getzf()?192>c?a.safe_write16(d,a.reg16[c>>2&14]):a.reg16[c<<1&14]=a.reg16[c>>2&14]:a.reg16[0]=e};
table0F_32[177]=function(a){var c=a.read_imm8();if(192>c){var d=a.modrm_resolve(c);a.writable_or_pagefault(d,4);var e=a.safe_read32s(d)}else e=a.reg32s[c&7];a.sub(e,a.reg32s[0],31);a.getzf()?192>c?a.safe_write32(d,a.reg32s[c>>3&7]):a.reg32s[c&7]=a.reg32s[c>>3&7]:a.reg32s[0]=e};table0F_16[178]=function(a){var c=a.read_imm8();192<=c&&a.trigger_ud();a.lss16(2,a.modrm_resolve(c),c>>2&14)};table0F_32[178]=function(a){var c=a.read_imm8();192<=c&&a.trigger_ud();a.lss32(2,a.modrm_resolve(c),c>>3&7)};
table0F_16[179]=function(a){var c=a.read_imm8();192>c?a.btr_mem(a.modrm_resolve(c),a.reg16s[c>>2&14]):a.reg16[c<<1&14]=a.btr_reg(a.reg16[c<<1&14],a.reg16s[c>>2&14]&15)};table0F_32[179]=function(a){var c=a.read_imm8();192>c?a.btr_mem(a.modrm_resolve(c),a.reg32s[c>>3&7]):a.reg32s[c&7]=a.btr_reg(a.reg32s[c&7],a.reg32s[c>>3&7]&31)};table0F_16[180]=function(a){var c=a.read_imm8();192<=c&&a.trigger_ud();a.lss16(4,a.modrm_resolve(c),c>>2&14)};
table0F_32[180]=function(a){var c=a.read_imm8();192<=c&&a.trigger_ud();a.lss32(4,a.modrm_resolve(c),c>>3&7)};table0F_16[181]=function(a){var c=a.read_imm8();192<=c&&a.trigger_ud();a.lss16(5,a.modrm_resolve(c),c>>2&14)};table0F_32[181]=function(a){var c=a.read_imm8();192<=c&&a.trigger_ud();a.lss32(5,a.modrm_resolve(c),c>>3&7)};table0F_16[182]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read8(a.modrm_resolve(c)):a.reg8[c<<2&12|c>>2&1];a.reg16[c>>2&14]=d};
table0F_32[182]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read8(a.modrm_resolve(c)):a.reg8[c<<2&12|c>>2&1];a.reg32s[c>>3&7]=d};table0F_16[183]=table0F_32[183]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.reg32s[c>>3&7]=d};table0F_16[184]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.reg16[c>>2&14]=a.popcnt(d)};
table0F_32[184]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.reg32s[c>>3&7]=a.popcnt(d)};table0F_16[185]=table0F_32[185]=function(a){a.trigger_ud()};
table0F_16[186]=function(a){var c=a.read_imm8();switch(c>>3&7){case 4:192>c?a.bt_mem(a.modrm_resolve(c),a.read_imm8()&15):a.bt_reg(a.reg16[c<<1&14],a.read_imm8()&15);break;case 5:192>c?a.bts_mem(a.modrm_resolve(c),a.read_imm8()):a.reg16[c<<1&14]=a.bts_reg(a.reg16[c<<1&14],a.read_imm8()&15);break;case 6:192>c?a.btr_mem(a.modrm_resolve(c),a.read_imm8()):a.reg16[c<<1&14]=a.btr_reg(a.reg16[c<<1&14],a.read_imm8()&15);break;case 7:192>c?a.btc_mem(a.modrm_resolve(c),a.read_imm8()):a.reg16[c<<1&14]=a.btc_reg(a.reg16[c<<
1&14],a.read_imm8()&15);break;default:a.trigger_ud()}};
table0F_32[186]=function(a){var c=a.read_imm8();switch(c>>3&7){case 4:192>c?a.bt_mem(a.modrm_resolve(c),a.read_imm8()&31):a.bt_reg(a.reg32s[c&7],a.read_imm8()&31);break;case 5:192>c?a.bts_mem(a.modrm_resolve(c),a.read_imm8()):a.reg32s[c&7]=a.bts_reg(a.reg32s[c&7],a.read_imm8()&31);break;case 6:192>c?a.btr_mem(a.modrm_resolve(c),a.read_imm8()):a.reg32s[c&7]=a.btr_reg(a.reg32s[c&7],a.read_imm8()&31);break;case 7:192>c?a.btc_mem(a.modrm_resolve(c),a.read_imm8()):a.reg32s[c&7]=a.btc_reg(a.reg32s[c&7],
a.read_imm8()&31);break;default:a.trigger_ud()}};table0F_16[187]=function(a){var c=a.read_imm8();192>c?a.btc_mem(a.modrm_resolve(c),a.reg16s[c>>2&14]):a.reg16[c<<1&14]=a.btc_reg(a.reg16[c<<1&14],a.reg16s[c>>2&14]&15)};table0F_32[187]=function(a){var c=a.read_imm8();192>c?a.btc_mem(a.modrm_resolve(c),a.reg32s[c>>3&7]):a.reg32s[c&7]=a.btc_reg(a.reg32s[c&7],a.reg32s[c>>3&7]&31)};
table0F_16[188]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.reg16[c>>2&14]=a.bsf16(a.reg16[c>>2&14],d)};table0F_32[188]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.reg32s[c>>3&7]=a.bsf32(a.reg32s[c>>3&7],d)};table0F_16[189]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c)):a.reg16[c<<1&14];a.reg16[c>>2&14]=a.bsr16(a.reg16[c>>2&14],d)};
table0F_32[189]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read32s(a.modrm_resolve(c)):a.reg32s[c&7];a.reg32s[c>>3&7]=a.bsr32(a.reg32s[c>>3&7],d)};table0F_16[190]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read8(a.modrm_resolve(c))<<24>>24:a.reg8s[c<<2&12|c>>2&1];a.reg16[c>>2&14]=d};table0F_32[190]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read8(a.modrm_resolve(c))<<24>>24:a.reg8s[c<<2&12|c>>2&1];a.reg32s[c>>3&7]=d};
table0F_16[191]=table0F_32[191]=function(a){var c=a.read_imm8(),d=192>c?a.safe_read16(a.modrm_resolve(c))<<16>>16:a.reg16s[c<<1&14];a.reg32s[c>>3&7]=d};table0F_16[192]=table0F_32[192]=function(a){var c=a.read_imm8(),d,e;192>c?(e=a.translate_address_write(a.modrm_resolve(c)),d=a.memory.read8(e)):d=a.reg8[c<<2&12|c>>2&1];d=a.xadd8(d,c>>1&12|c>>5&1);192>c?a.memory.write8(e,d):a.reg8[c<<2&12|c>>2&1]=d};
table0F_16[193]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4095===(d&4095)?(f=a.translate_address_write(d+1),d=a.virt_boundary_read16(e,f)):d=a.memory.read16(e)):d=a.reg16[c<<1&14];d=a.xadd16(d,c>>2&14);192>c?f?a.virt_boundary_write16(e,f,d):a.memory.write16(e,d):a.reg16[c<<1&14]=d};
table0F_32[193]=function(a){var c=a.read_imm8(),d,e,f=0;192>c?(d=a.modrm_resolve(c),e=a.translate_address_write(d),a.paging&&4093<=(d&4095)?(f=a.translate_address_write(d+3),d=a.virt_boundary_read32s(e,f)):d=a.memory.read32s(e)):d=a.reg32s[c&7];d=a.xadd32(d,c>>3&7);192>c?f?a.virt_boundary_write32(e,f,d):a.memory.write32(e,d):a.reg32s[c&7]=d};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 c=a.read_imm8();192<=c&&a.trigger_ud();c=a.modrm_resolve(c);a.writable_or_pagefault(c,8);var d=a.safe_read32s(c),e=a.safe_read32s(c+4);a.reg32s[0]===d&&a.reg32s[2]===e?(a.flags|=64,a.safe_write32(c,a.reg32s[3]),a.safe_write32(c+4,a.reg32s[1])):(a.flags&=-65,a.reg32s[0]=d,a.reg32s[2]=e);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";
v86.prototype.jmp_rel16=function(a){var c=this.get_seg(1);this.instruction_pointer-=c;this.instruction_pointer=this.instruction_pointer+a&65535;this.instruction_pointer=this.instruction_pointer+c|0;this.last_instr_jump=!0};v86.prototype.jmpcc16=function(a){a?this.jmp_rel16(this.read_imm16()):this.instruction_pointer=this.instruction_pointer+2|0;this.last_instr_jump=!0};
v86.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};v86.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};
v86.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};v86.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};
v86.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};v86.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};v86.prototype.getpf=function(){return this.flags_changed&4?154020>>((this.last_result^this.last_result>>4)&15)&4:this.flags&4};
v86.prototype.getaf=function(){return this.flags_changed&16?(this.last_op1^this.last_op2^this.last_add_result)&16:this.flags&16};v86.prototype.getzf=function(){return this.flags_changed&64?(~this.last_result&this.last_result-1)>>>this.last_op_size&1:this.flags&64};v86.prototype.getsf=function(){return this.flags_changed&128?this.last_result>>>this.last_op_size&1:this.flags&128};
v86.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};v86.prototype.test_o=v86.prototype.getof;v86.prototype.test_b=v86.prototype.getcf;v86.prototype.test_z=v86.prototype.getzf;v86.prototype.test_s=v86.prototype.getsf;v86.prototype.test_p=v86.prototype.getpf;v86.prototype.test_be=function(){return this.getcf()||this.getzf()};
v86.prototype.test_l=function(){return!this.getsf()!==!this.getof()};v86.prototype.test_le=function(){return this.getzf()||!this.getsf()!==!this.getof()};v86.prototype.push16=function(a){var c=this.get_stack_pointer(-2);this.safe_write16(c,a);this.stack_reg[this.reg_vsp]-=2};v86.prototype.push32=function(a){var c=this.get_stack_pointer(-4);this.safe_write32(c,a);this.stack_reg[this.reg_vsp]-=4};
v86.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};v86.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};
v86.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])};
v86.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])};
v86.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()};
v86.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()};v86.prototype.xchg8=function(a,c){var d=c>>1&12|c>>5&1,e=this.reg8[d];this.reg8[d]=a;return e};
v86.prototype.xchg16=function(a,c){var d=c>>2&14,e=this.reg16[d];this.reg16[d]=a;return e};v86.prototype.xchg16r=function(a){var c=this.reg16[0];this.reg16[0]=this.reg16[a];this.reg16[a]=c};v86.prototype.xchg32=function(a,c){var d=c>>3&7,e=this.reg32s[d];this.reg32s[d]=a;return e};v86.prototype.xchg32r=function(a){var c=this.reg32s[0];this.reg32s[0]=this.reg32s[a];this.reg32s[a]=c};
v86.prototype.lss16=function(a,c,d){var e=this.safe_read16(c);c=this.safe_read16(c+2|0);this.switch_seg(a,c);this.reg16[d]=e};v86.prototype.lss32=function(a,c,d){var e=this.safe_read32s(c);c=this.safe_read16(c+4|0);this.switch_seg(a,c);this.reg32s[d]=e};
v86.prototype.enter16=function(){var a=this.read_imm16(),c=this.read_imm8()&31,d,e;this.push16(this.reg16[10]);d=this.reg16[8];if(0<c){e=this.reg16[5];for(var f=1;f<c;f++)e-=2,this.push16(this.safe_read16(this.get_seg(2)+e|0));this.push16(d)}this.reg16[10]=d;this.reg16[8]-=a};
v86.prototype.enter32=function(){var a=this.read_imm16(),c=this.read_imm8()&31,d,e;this.push32(this.reg32s[5]);d=this.reg32s[4];if(0<c){e=this.reg32s[5];for(var f=1;f<c;f++)e-=4,this.push32(this.safe_read32s(this.get_seg(2)+e|0));this.push32(d)}this.reg32s[5]=d;this.reg32s[4]-=a};v86.prototype.bswap=function(a){var c=this.reg32s[a];this.reg32s[a]=c>>>24|c<<24|c>>8&65280|c<<8&16711680};v86.prototype.run=function(){this.running||this.v86$next_tick()};
v86.prototype.main_run=function(){if(this.stopped)this.stopped=this.running=!1;else{this.running=!0;try{this.in_hlt?this.hlt_loop():this.do_run()}catch(a){this.exception_cleanup(a)}}};v86.prototype.stop=function(){this.running&&(this.stopped=!0)};v86.prototype.restart=function(){var a=this.running,c=this;this.stopped=!0;this.running=!1;setTimeout(function(){c.devices.ps2.destroy();c.devices.vga.destroy();c.init(c.current_settings);a&&c.v86$next_tick()},10)};
v86.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(),this.v86$next_tick();else throw this.running=!1,console.log(a),console.log(a.stack),a;};v86.prototype.reboot_internal=function(){this.devices.ps2.destroy();this.devices.vga.destroy();this.init(this.current_settings);throw 233495534;};
v86.prototype.lazy_init=function(){var a=this;"undefined"!==typeof setImmediate?this.v86$next_tick=function(){setImmediate(function(){a.main_run()})}:"undefined"!==typeof window&&"undefined"!==typeof postMessage?(window.addEventListener("message",function(c){c.source===window&&43605===c.data&&a.main_run()},!1),this.v86$next_tick=function(){window.postMessage(43605,"*")}):this.v86$next_tick=function(){setTimeout(function(){a.main_run()},0)};"object"===typeof performance&&performance.now?this.microtick=
function(){return performance.now()}:this.microtick=Date.now};
v86.prototype.init=function(a){this.first_init&&(this.first_init=!1,this.lazy_init());this.current_settings=a;this.memory_size=a.memory_size||67108864;this.memory=new Memory(new ArrayBuffer(this.memory_size),this.memory_size);this.segment_is_null=new Uint8Array(8);this.segment_limits=new Uint32Array(8);this.segment_offsets=new Int32Array(8);this.tlb_data=new Int32Array(1048576);this.tlb_info=new Uint8Array(1048576);this.tlb_info_global=new Uint8Array(1048576);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.stopped=this.running=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=this.microtick();var c=new IO(this.memory);this.io=c;var d=a.bios,e=a.vga_bios;if(d){var f=new Uint8Array(d);this.memory.mem8.set(f,1048576-d.byteLength);e&&(f=new Uint8Array(e),this.memory.mem8.set(f,786432));c.mmap_register(4293918720,1048576,function(a){return this.memory.mem8[a&1048575]}.bind(this),function(a,c){this.memory.mem8[a&1048575]=c}.bind(this));this.instruction_pointer=1048560;this.switch_seg(2,48);this.reg16[8]=256}else a.linux?(this.instruction_pointer=65536,this.memory.write_blob(new Uint8Array(a.linux.vmlinux),
1048576),this.memory.write_blob(new Uint8Array(a.linux.linuxstart),this.instruction_pointer),a.linux.root&&(this.memory.write_blob(new Uint8Array(a.linux.root),4194304),this.reg32s[3]=a.linux.root.byteLength),this.memory.write_string(a.linux.cmdline),this.reg32s[0]=this.memory_size,this.reg32s[1]=63488,this.switch_seg(1,0),this.switch_seg(2,0),this.switch_seg(3,0),this.switch_seg(0,0),this.switch_seg(5,0),this.switch_seg(4,0),this.protected_mode=this.stack_size_32=this.operand_size_32=this.address_size_32=
this.is_32=!0,this.update_operand_size(),this.update_address_size(),this.regv=this.reg32s,this.reg_vsp=4,this.reg_vbp=5,this.cr0=1):(this.switch_seg(2,48),this.reg16[8]=256,this.instruction_pointer=0);var g=0;c.register_read(146,this,function(){return g});c.register_write(146,this,function(a){g=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,a.screen_adapter,
a.vga_memory_size||8388608),this.devices.ps2=new PS2(this,a.keyboard_adapter,a.mouse_adapter),this.fpu=new FPU(this),this.devices.uart=a.serial_adapter?new UART(this,1016,a.serial_adapter):new UART(this,1016,{put_line:function(){},init:function(){}}),this.devices.fdc=new FloppyController(this,a.fda),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.network_adapter&&(this.devices.net=new Ne2k(this,a.network_adapter)),a.fs9p&&(this.devices.virtio=new VirtIO(this,a.fs9p)))};v86.prototype.do_run=function(){var a=Date.now(),c=a;for(this.devices.vga.timer(c);33>c-a;){this.devices.pit.timer(c,!1);this.devices.rtc.timer(c,!1);this.handle_irqs();for(c=11001;c--;)this.cycle();c=Date.now()}this.v86$next_tick()};
"undefined"!==typeof window&&(window.__no_inline1=v86.prototype.do_run,window.__no_inline2=v86.prototype.exception_cleanup,window.__no_inline3=v86.prototype.hlt_loop);v86.prototype.cycle=function(){this.timestamp_counter++;this.previous_ip=this.instruction_pointer;var a=this.read_imm8();this.table[a](this)};v86.prototype.do_op=function(){this.table[this.read_imm8()](this)};
v86.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);if(this.in_hlt){var c=this;setTimeout(function(){c.hlt_loop()},0)}else this.v86$next_tick()};v86.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())};v86.prototype.paging_changed=function(){this.last_virt_eip=-1};
v86.prototype.cpl_changed=function(){this.last_virt_eip=-1};v86.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};v86.prototype.read_imm8s=function(){return this.read_imm8()<<24>>24};
v86.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};v86.prototype.read_imm16s=function(){return this.read_imm16()<<16>>16};
v86.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};v86.prototype.virt_boundary_read16=function(a,c){return this.memory.read8(a)|this.memory.read8(c)<<8};
v86.prototype.virt_boundary_read32s=function(a,c){var d;d=a&1?a&2?this.memory.read_aligned16(c-2>>1):this.memory.read_aligned16(a+1>>1):this.virt_boundary_read16(a+1,c-1);return this.memory.read8(a)|d<<8|this.memory.read8(c)<<24};v86.prototype.virt_boundary_write16=function(a,c,d){this.memory.write8(a,d);this.memory.write8(c,d>>8)};
v86.prototype.virt_boundary_write32=function(a,c,d){this.memory.write8(a,d);this.memory.write8(c,d>>24);a&1?a&2?(this.memory.write8(c-2,d>>8),this.memory.write8(c-1,d>>16)):(this.memory.write8(a+1,d>>8),this.memory.write8(a+2,d>>16)):(this.memory.write8(a+1,d>>8),this.memory.write8(c-1,d>>16))};v86.prototype.safe_read8=function(a){return this.memory.read8(this.translate_address_read(a))};
v86.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))};v86.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))};v86.prototype.safe_write8=function(a,c){this.memory.write8(this.translate_address_write(a),c)};
v86.prototype.safe_write16=function(a,c){var d=this.translate_address_write(a);4095===(a&4095)?this.virt_boundary_write16(d,this.translate_address_write(a+1),c):this.memory.write16(d,c)};v86.prototype.safe_write32=function(a,c){var d=this.translate_address_write(a);4093<=(a&4095)?this.virt_boundary_write32(d,this.translate_address_write(a+3),c):this.memory.write32(d,c)};
v86.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};v86.prototype.getiopl=function(){return this.flags>>12&3};v86.prototype.vm86_mode=function(){return!!(this.flags&131072)};v86.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};
v86.prototype.load_eflags=function(){this.flags=this.get_eflags();this.flags_changed=0};v86.prototype.update_eflags=function(a){var c=1769472,d=2588629;this.flags&131072?(c|=12288,d|=1572864):this.cpl&&(c|=12288,this.cpl>this.getiopl()&&(c|=512));this.flags=(a^(this.flags^a)&c)&d|2;this.flags_changed=0};v86.prototype.get_stack_pointer=function(a){return this.get_seg(2)+this.stack_reg[this.reg_vsp]+a|0};v86.prototype.get_real_eip=function(){return this.instruction_pointer-this.get_seg(1)|0};
v86.prototype.call_interrupt_vector=function(a,c,d){this.in_hlt=!1;if(this.protected_mode){if(this.vm86_mode()&&this.cr4&1)throw this.debug.unimpl("VME");this.vm86_mode()&&c&&3>this.getiopl()&&this.trigger_gp(0);if((a<<3|7)>this.idtr_size)throw this.debug.unimpl("#GP handler");var e=this.idtr_offset+(a<<3)|0;this.paging&&(e=this.translate_address_system_read(e));var f=this.memory.read16(e)|this.memory.read16(e+6)<<16,g=this.memory.read16(e+2),e=this.memory.read8(e+5),k=e>>5&3;if(0===(e&128))throw this.debug.unimpl("#NP handler");
c&&k<this.cpl&&this.trigger_gp(a<<3|2);e&=31;if(14===e)a=!1;else if(15===e)a=!0;else{if(5===e)throw this.debug.unimpl("call int to task gate");if(6===e)throw this.debug.unimpl("16 bit interrupt gate");if(7===e)throw this.debug.unimpl("16 bit trap gate");throw this.debug.unimpl("#GP handler");}c=this.lookup_segment_selector(g);if(c.is_null)throw this.debug.unimpl("#GP handler");if(!c.is_executable||c.dpl>this.cpl)throw this.debug.unimpl("#GP handler");if(!c.is_present)throw this.debug.unimpl("#NP handler");
this.load_eflags();e=this.flags;if(!c.dc_bit&&c.dpl<this.cpl){var m=(c.dpl<<3)+4;if(m+5>this.segment_limits[6])throw this.debug.unimpl("#TS handler");m=m+this.segment_offsets[6]|0;this.paging&&(m=this.translate_address_system_read(m));var k=this.memory.read32s(m),m=this.memory.read16(m+4),l=this.lookup_segment_selector(m);if(l.is_null)throw this.debug.unimpl("#TS handler");if(l.rpl!==c.dpl)throw this.debug.unimpl("#TS handler");if(l.dpl!==c.dpl||!l.rw_bit)throw this.debug.unimpl("#TS handler");if(!l.is_present)throw this.debug.unimpl("#TS handler");
var l=this.reg32s[4],n=this.sreg[2];this.cpl=c.dpl;this.cpl_changed();this.is_32!==c.size&&this.update_cs_size(c.size);this.flags&=-196609;this.reg32s[4]=k;this.switch_seg(2,m);e&131072&&(this.push32(this.sreg[5]),this.push32(this.sreg[4]),this.push32(this.sreg[3]),this.push32(this.sreg[0]));this.push32(n);this.push32(l)}else if(c.dc_bit||c.dpl===this.cpl)this.flags&131072&&this.trigger_gp(g&-4);else throw this.debug.unimpl("#GP handler");this.push32(e);this.push32(this.sreg[1]);this.push32(this.get_real_eip());
e&131072&&(this.switch_seg(5,0),this.switch_seg(4,0),this.switch_seg(3,0),this.switch_seg(0,0));!1!==d&&this.push32(d);this.sreg[1]=g;this.is_32!==c.size&&this.update_cs_size(c.size);this.segment_limits[1]=c.effective_limit;this.segment_offsets[1]=c.base;this.instruction_pointer=this.get_seg(1)+f|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};v86.prototype.iret16=function(){if(!this.protected_mode||this.vm86_mode()&&3===this.getiopl()){var a=this.pop16();this.switch_seg(1,this.pop16());var c=this.pop16();this.instruction_pointer=a+this.get_seg(1)|0;this.update_eflags(c);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};
v86.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 c=this.pop32s();this.instruction_pointer=a+this.get_seg(1)|0;this.update_eflags(c);this.handle_irqs()}else{this.vm86_mode()&&this.trigger_gp(0);this.instruction_pointer=this.pop32s();this.sreg[1]=this.pop32s();c=this.pop32s();if(c&131072){if(0===this.cpl){this.update_eflags(c);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(),d=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,d&65535);this.cpl=3;this.update_cs_size(!1);return}c&=-131073}var e=this.lookup_segment_selector(this.sreg[1]);if(e.is_null)throw this.debug.unimpl("is null");if(!e.is_present)throw this.debug.unimpl("not present");if(!e.is_executable)throw this.debug.unimpl("not exec");
if(e.rpl<this.cpl)throw this.debug.unimpl("rpl < cpl");if(e.dc_bit&&e.dpl>e.rpl)throw this.debug.unimpl("conforming and dpl > rpl");e.rpl>this.cpl?(a=this.pop32s(),d=this.pop32s(),this.reg32s[4]=a,this.update_eflags(c),this.cpl=e.rpl,this.switch_seg(2,d&65535),this.cpl_changed()):this.update_eflags(c);e.size!==this.is_32&&this.update_cs_size(e.size);this.segment_limits[1]=e.effective_limit;this.segment_offsets[1]=e.base;this.instruction_pointer=this.instruction_pointer+this.get_seg(1)|0;this.handle_irqs();
this.last_instr_jump=!0}};v86.prototype.hlt_op=function(){this.cpl&&this.trigger_gp(0);if(0===(this.flags&512))throw this.debug.show("cpu halted"),this.stopped=!0,"HALT";this.in_hlt=!0;throw 233495534;};v86.prototype.raise_exception=function(a){this.call_interrupt_vector(a,!1,!1);throw 233495534;};v86.prototype.raise_exception_with_code=function(a,c){this.call_interrupt_vector(a,!1,c);throw 233495534;};v86.prototype.trigger_de=function(){this.instruction_pointer=this.previous_ip;this.raise_exception(0)};
v86.prototype.trigger_ud=function(){this.instruction_pointer=this.previous_ip;this.raise_exception(6)};v86.prototype.trigger_nm=function(){this.instruction_pointer=this.previous_ip;this.raise_exception(7)};v86.prototype.trigger_gp=function(a){this.instruction_pointer=this.previous_ip;this.raise_exception_with_code(13,a)};v86.prototype.trigger_np=function(a){this.instruction_pointer=this.previous_ip;this.raise_exception_with_code(11,a)};
v86.prototype.trigger_ss=function(a){this.instruction_pointer=this.previous_ip;this.raise_exception_with_code(12,a)};v86.prototype.seg_prefix=function(a){this.segment_prefix=a;this.table[this.read_imm8()](this);this.segment_prefix=-1};v86.prototype.get_seg_prefix_ds=function(){return this.get_seg_prefix(3)};v86.prototype.get_seg_prefix_ss=function(){return this.get_seg_prefix(2)};v86.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)};
v86.prototype.get_seg=function(a){return this.segment_offsets[a]};v86.prototype.handle_irqs=function(){this.devices.pic&&this.flags&512&&!this.page_fault&&this.devices.pic.check_irqs()};
v86.prototype.test_privileges_for_io=function(a,c){if(this.protected_mode&&(this.cpl>this.getiopl()||this.flags&131072)){var d=this.segment_limits[6],e=this.segment_offsets[6];if(103<=d){var f=this.memory.read16(this.translate_address_system_read(e+100+2));if(d>=f+(a+c-1>>3)&&(d=(1<<c)-1<<(a&7),e=this.translate_address_system_read(e+f+(a>>3)),!((d&65280?this.memory.read16(e):this.memory.read8(e))&d)))return}this.trigger_gp(0)}};
v86.prototype.cpuid=function(){var a=0,c=0,d=0,e=0;switch(this.reg32s[0]){case 0:a=5;e=1970169159;d=1231384169;c=1818588270;break;case 1:a=3939;e=0;c=8388608;d=(this.fpu?1:0)|43322;break;case 2:a=1717260289;c=e=0;d=8024064;break;case -2147483648:a=5}this.reg32s[0]=a;this.reg32s[1]=c;this.reg32s[2]=d;this.reg32s[3]=e};v86.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()};
v86.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)};v86.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)};
v86.prototype.lookup_segment_selector=function(a){var c=0===(a&4),d=a&-8,e,f;e={rpl:a&3,from_gdt:c,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};c?(c=this.gdtr_offset,f=this.gdtr_size):(c=this.segment_offsets[7],f=this.segment_limits[7]);if(0===d)return e.is_null=!0,e;if((a|7)>f)return e.is_valid=!1,e;c=c+d|0;this.paging&&(c=this.translate_address_system_read(c));
e.table_offset=c;e.base=this.memory.read16(c+2)|this.memory.read8(c+4)<<16|this.memory.read8(c+7)<<24;e.access=this.memory.read8(c+5);e.flags=this.memory.read8(c+6)>>4;e.type=e.access&15;e.dpl=e.access>>5&3;e.is_system=0===(e.access&16);e.is_present=128===(e.access&128);e.is_executable=8===(e.access&8);e.rw_bit=2===(e.access&2);e.dc_bit=4===(e.access&4);e.size=4===(e.flags&4);a=this.memory.read16(c)|(this.memory.read8(c+6)&15)<<16;e.effective_limit=e.flags&8?(a<<12|4095)>>>0:a;e.is_writable=e.rw_bit&&
!e.is_executable;e.is_readable=e.rw_bit||!e.is_executable;return e};
v86.prototype.switch_seg=function(a,c){1===a&&(this.protected_mode=1===(this.cr0&1));if(!this.protected_mode||this.vm86_mode())this.sreg[a]=c,this.segment_is_null[a]=0,this.segment_limits[a]=1048575,this.segment_offsets[a]=c<<4;else{var d=this.lookup_segment_selector(c);if(2===a){if(d.is_null){this.trigger_gp(0);return}if(!d.is_valid||d.is_system||d.rpl!==this.cpl||!d.is_writable||d.dpl!==this.cpl){this.trigger_gp(c&-4);return}if(!d.is_present){this.trigger_ss(c&-4);return}(this.stack_size_32=d.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(!d.is_executable)throw this.debug.unimpl("#GP handler");if(d.is_system)throw this.debug.unimpl("load system segment descriptor, type = "+(d.access&15));if(d.rpl!==this.cpl)throw this.debug.unimpl("privilege change");if(!d.dc_bit&&d.dpl<this.cpl)throw this.debug.unimpl("inter privilege call");if(!d.dc_bit&&d.dpl!==this.cpl)throw this.debug.unimpl("#GP handler");d.size!==
this.is_32&&this.update_cs_size(d.size)}else{if(d.is_null){this.sreg[a]=c;this.segment_is_null[a]=1;return}if(!d.is_valid||d.is_system||!d.is_readable||(!d.is_executable||!d.dc_bit)&&d.rpl>d.dpl&&this.cpl>d.dpl){this.trigger_gp(c&-4);return}if(!d.is_present){this.trigger_np(c&-4);return}}this.segment_is_null[a]=0;this.segment_limits[a]=d.effective_limit;this.segment_offsets[a]=d.base;this.sreg[a]=c}};
v86.prototype.load_tr=function(a){var c=this.lookup_segment_selector(a);if(!c.from_gdt)throw this.debug.unimpl("TR can only be loaded from GDT");if(c.is_null)throw this.debug.unimpl("#GP handler");if(!c.is_present)throw this.debug.unimpl("#GP handler");if(!c.is_system)throw this.debug.unimpl("#GP handler");if(9!==c.type)throw this.debug.unimpl("#GP handler");this.segment_offsets[6]=c.base;this.segment_limits[6]=c.effective_limit;this.sreg[6]=a;this.memory.write8(c.table_offset+5,this.memory.read8(c.table_offset+
5)|2)};v86.prototype.load_ldt=function(a){var c=this.lookup_segment_selector(a);if(c.is_null)this.segment_offsets[7]=0,this.segment_limits[7]=0;else{if(!c.from_gdt)throw this.debug.unimpl("LDTR can only be loaded from GDT");if(!c.is_present)throw this.debug.unimpl("#GP handler");if(!c.is_system)throw this.debug.unimpl("#GP handler");if(2!==c.type)throw this.debug.unimpl("#GP handler");this.segment_offsets[7]=c.base;this.segment_limits[7]=c.effective_limit;this.sreg[7]=a}};
v86.prototype.arpl=function(a,c){this.flags_changed&=-65;if((a&3)<(this.reg16[c]&3))return this.flags|=64,a&-4|this.reg16[c]&3;this.flags&=-65;return a};v86.prototype.clear_tlb=function(){this.last_virt_eip=-1;this.tlb_info.set(this.tlb_info_global)};v86.prototype.full_clear_tlb=function(){for(var a=new Int32Array(this.tlb_info_global.buffer),c=0;262144>c;)a[c++]=a[c++]=a[c++]=a[c++]=0;this.clear_tlb()};
v86.prototype.invlpg=function(a){a=a>>>12;this.tlb_info[a]=0;this.tlb_info_global[a]=0;this.last_virt_eip=-1};v86.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};v86.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};
v86.prototype.translate_address_user_write=function(a){var c=a>>>12;return this.tlb_info[c]&8?this.tlb_data[c]^a:this.do_page_translation(a,1,1)|a&4095};v86.prototype.translate_address_user_read=function(a){var c=a>>>12;return this.tlb_info[c]&4?this.tlb_data[c]^a:this.do_page_translation(a,0,1)|a&4095};v86.prototype.translate_address_system_write=function(a){var c=a>>>12;return this.tlb_info[c]&2?this.tlb_data[c]^a:this.do_page_translation(a,1,0)|a&4095};
v86.prototype.translate_address_system_read=function(a){var c=a>>>12;return this.tlb_info[c]&1?this.tlb_data[c]^a:this.do_page_translation(a,0,0)|a&4095};
v86.prototype.do_page_translation=function(a,c,d){var e=a>>>12,f=(this.cr3>>>2)+(e>>10),g=this.memory.mem32s[f],k=!0,m=!0;g&1||(this.cr2=a,this.trigger_pagefault(c,d,0));0===(g&2)&&(k=!1,c&&(d||this.cr0&65536)&&(this.cr2=a,this.trigger_pagefault(c,d,1)));0===(g&4)&&(m=!1,d&&(this.cr2=a,this.trigger_pagefault(c,d,1)));if(g&this.page_size_extensions)this.memory.mem32s[f]=g|32|c<<6,a=g&4290772992|a&4190208,g=g&256;else{var l=((g&4294963200)>>>2)+(e&1023),n=this.memory.mem32s[l];0===(n&1)&&(this.cr2=
a,this.trigger_pagefault(c,d,0));0===(n&2)&&(k=!1,c&&(d||this.cr0&65536)&&(this.cr2=a,this.trigger_pagefault(c,d,1)));0===(n&4)&&(m=!1,d&&(this.cr2=a,this.trigger_pagefault(c,d,1)));this.memory.mem32s[f]=g|32;this.memory.mem32s[l]=n|32|c<<6;a=n&4294963200;g=n&256}this.tlb_data[e]=a^e<<12;k=m?k?15:5:k?3:1;this.tlb_info[e]=k;g&&this.cr4&128&&(this.tlb_info_global[e]=k);return a};
v86.prototype.writable_or_pagefault=function(a,c){if(this.paging){var d=3===this.cpl?1:0,e=d?8:2,f=a>>>12;0===(this.tlb_info[f]&e)&&this.do_page_translation(a,1,d);4096<=(a&4095)+c-1&&0===(this.tlb_info[f+1]&e)&&this.do_page_translation(a+c-1,1,d)}};
v86.prototype.trigger_pagefault=function(a,c,d){if(this.page_fault)throw this.debug.unimpl("Double fault");var e=this.cr2>>>12;this.tlb_info[e]=0;this.tlb_info_global[e]=0;this.instruction_pointer=this.previous_ip;this.page_fault=!0;this.call_interrupt_vector(14,!1,c<<2|a<<1|d);throw 233495534;};function IO(a){function c(){return 255}function d(){return 65535}function e(){return-1}function f(){}var g=a.size;this.IO$ports=[];this.devices=Array(65536);for(var k=0;65536>k;k++)this.IO$ports[k]={read8:c,read16:d,read32:e,write8:f,write16:f,write32:f,device:void 0};this.register_read=function(a,c,d,e,f){d&&(this.IO$ports[a].read8=d);e&&(this.IO$ports[a].read16=e);f&&(this.IO$ports[a].read32=f);this.IO$ports[a].device=c};this.register_write=function(a,c,d,e,f){d&&(this.IO$ports[a].write8=d);e&&
(this.IO$ports[a].write16=e);f&&(this.IO$ports[a].write32=f);this.IO$ports[a].device=c};this.register_read_consecutive=function(a,c,d,e,f,g){function k(){return d.call(this)|e.call(this)<<8}function t(){return f.call(this)|g.call(this)<<8}function x(){return d.call(this)|e.call(this)<<8|f.call(this)<<16|g.call(this)<<24}f&&g?(this.register_read(a,c,d,k,x),this.register_read(a+1,c,e),this.register_read(a+2,c,f,t),this.register_read(a+3,c,g)):(this.register_read(a,c,d,k),this.register_read(a+1,c,e))};
this.register_write_consecutive=function(a,c,d,e,f,g){function k(a){d.call(this,a&255);e.call(this,a>>8&255)}function t(a){f.call(this,a&255);g.call(this,a>>8&255)}function x(a){d.call(this,a&255);e.call(this,a>>8&255);f.call(this,a>>16&255);g.call(this,a>>>24)}f&&g?(this.register_write(a,c,d,k,x),this.register_write(a+1,c,e),this.register_write(a+2,c,f,t),this.register_write(a+3,c,g)):(this.register_write(a,c,d,k),this.register_write(a+1,c,e))};this.mmap_read32_shim=function(c){var d=a.memory_map_read8[c>>>
14];return d(c)|d(c+1)<<8|d(c+2)<<16|d(c+3)<<24};this.mmap_write32_shim=function(c,d){var e=a.memory_map_write8[c>>>14];e(c,d&255);e(c+1,d>>8&255);e(c+2,d>>16&255);e(c+3,d>>>24)};this.mmap_register=function(c,d,e,f,g,k){g||(g=this.mmap_read32_shim);k||(k=this.mmap_write32_shim);for(c>>>=14;0<d;c++)a.memory_map_registered[c]=1,a.memory_map_read8[c]=e,a.memory_map_write8[c]=f,a.memory_map_read32[c]=g,a.memory_map_write32[c]=k,d-=16384};for(k=0;k<<14<g;k++)a.memory_map_read8[k]=a.memory_map_write8[k]=
void 0,a.memory_map_read32[k]=a.memory_map_write32[k]=void 0;this.mmap_register(g,4294967296-g,function(){return 255},function(){},function(){return-1},function(){});this.in_mmap_range=function(c,d){c>>>=0;var e=c+(d>>>0);if(e>=g)return!0;for(c&=-16384;c<e;){if(a.memory_map_registered[c>>14])return!0;c+=16384}return!1};this.port_write8=function(a,c){var d=this.IO$ports[a];d.write8.call(d.device,c)};this.port_write16=function(a,c){var d=this.IO$ports[a];d.write16.call(d.device,c)};this.port_write32=
function(a,c){var d=this.IO$ports[a];d.write32.call(d.device,c)};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)}};Object.fromList=function(){for(var a=[[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"]],c={},d=0;d<a.length;d++)c[a[d][0]]=a[d][1];return c};function dbg_assert(){}String.pads=function(a,c){for(a=a?a+"":"";a.length<c;)a+=" ";return a};
String.pad0=function(a,c){for(a=a?a+"":"";a.length<c;)a="0"+a;return a};function h(a){return a?a.toString(16).toUpperCase():String.pad0("",1)}function SyncBuffer(a){this.byteLength=a.byteLength;this.get=function(c,d,e){e(new Uint8Array(a,c,d))};this.set=function(c,d,e){(new Uint8Array(a,c,d.byteLength)).set(d);e()};this.get_buffer=function(c){c(a)}}for(var int_log2_table=new Int8Array(256),i=0,b=-2;256>i;i++)i&i-1||b++,int_log2_table[i]=b;
Math.int_log2=function(a){var c=a>>>16;if(c){var d=c>>>8;return d?24+int_log2_table[d]:16+int_log2_table[c]}return(d=a>>>8)?8+int_log2_table[d]:int_log2_table[a]};function ByteQueue(a){var c=new Uint8Array(a),d,e;this.length=0;this.push=function(d){this.length!==a&&this.length++;c[e]=d;e=e+1&a-1};this.shift=function(){if(this.length){var e=c[d];d=d+1&a-1;this.length--;return e}return-1};this.ByteQueue$clear=function(){this.length=e=d=0};this.ByteQueue$clear()}
Array.setify=function(a){for(var c={},d=0;d<a.length;d++)c[a[d]]=!0;return c};function FPU(a){this.cpu=a;this._st=new Float64Array(8);this._st8=new Uint8Array(this._st.buffer);new Int32Array(this._st.buffer);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.float32=new Float32Array(1);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.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);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);new Int32Array(this._st.buffer)};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 c=this._get_st0();this._status_word&=-18177;c>a||(this._status_word=a>c?this._status_word|256:c===a?this._status_word|16384:this._status_word|17664)};FPU.prototype._fucom=function(a){this._fcom(a)};FPU.prototype._fcomi=function(a){var c=this._st[this._stack_ptr];this.cpu.flags_changed&=-70;this.cpu.flags&=-70;c>a||(this.cpu.flags=a>c?this.cpu.flags|1:c===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()<<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,c,d=0;8>d;d++)c=this._st[d],this._stack_empty>>d&1?a|=3<<(d<<1):0===c?a|=1<<(d<<1):isFinite(c)||(a|=2<<(d<<1));return a};FPU.prototype._safe_tag_word=function(a){for(var c=this._stack_empty=0;8>c;c++)this._stack_empty|=a>>c&a>>c+1&1<<c};
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 c=0;8>c;c++)this._store_m80(a,c-this._stack_ptr&7),a+=10;this._finit()};FPU.prototype._frstor=function(a){this._fldenv(a);a+=28;for(var c=0;8>c;c++)this._st[c]=this._load_m80(a),a+=10};FPU.prototype._integer_round=function(a){var c=this._control_word>>10&3;return 0===c?(c=Math.round(a),.5===c-a&&c%2&&c--,c):1===c||3===c&&0<a?Math.floor(a):Math.ceil(a)};
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 c=this.cpu.safe_read16(a+8),d=this.cpu.safe_read32s(a)>>>0,e=this.cpu.safe_read32s(a+4)>>>0;a=c>>15;c&=-32769;if(0===c)return 0;if(!(32767>c))return this.float64_byte[7]=127|a<<7,this.float64_byte[6]=240|e>>30<<3&8,this.float64_byte[5]=0,this.float64_byte[4]=0,this.float64_int[0]=0,this.float64[0];d+=4294967296*e;a&&(d=-d);return d*Math.pow(2,c-16383-63)};
FPU.prototype._store_m80=function(a,c){this.float64[0]=this._st[this._stack_ptr+c&7];var d=this.float64_byte[7]&128,e=(this.float64_byte[7]&127)<<4|this.float64_byte[6]>>4,f,g;2047===e?(e=32767,f=0,g=2147483648|(this.float64_int[1]&524288)<<11):0===e?g=f=0:(e+=15360,f=this.float64_int[0]<<11,g=2147483648|(this.float64_int[1]&1048575)<<11|this.float64_int[0]>>>21);this.cpu.safe_write32(a,f);this.cpu.safe_write32(a+4,g);this.cpu.safe_write16(a+8,d<<8|e)};
FPU.prototype._load_m64=function(a){var c=this.cpu.safe_read32s(a);a=this.cpu.safe_read32s(a+4);this.float64_int[0]=c;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,c){this.float32[0]=c;this.cpu.safe_write32(a,this.float32_int[0])};FPU.prototype._sign=function(){return this._st8[(this._stack_ptr+0&7)<<3|7]>>7};
FPU.prototype.op_D8_reg=function(a){var c=a>>3&7;a=this._get_sti(a&7);var d=this._get_st0();switch(c){case 0:this._st[this._stack_ptr]=d+a;break;case 1:this._st[this._stack_ptr]=d*a;break;case 2:this._fcom(a);break;case 3:this._fcom(a);this._pop();break;case 4:this._st[this._stack_ptr]=d-a;break;case 5:this._st[this._stack_ptr]=a-d;break;case 6:this._st[this._stack_ptr]=d/a;break;case 7:this._st[this._stack_ptr]=a/d}};
FPU.prototype.op_D8_mem=function(a,c){var d=a>>3&7,e=this._load_m32(c),f=this._get_st0();switch(d){case 0:this._st[this._stack_ptr]=f+e;break;case 1:this._st[this._stack_ptr]=f*e;break;case 2:this._fcom(e);break;case 3:this._fcom(e);this._pop();break;case 4:this._st[this._stack_ptr]=f-e;break;case 5:this._st[this._stack_ptr]=e-f;break;case 6:this._st[this._stack_ptr]=f/e;break;case 7:this._st[this._stack_ptr]=e/f}};
FPU.prototype.op_D9_reg=function(a){var c=a&7;switch(a>>3&7){case 0:a=this._get_sti(c);this._push(a);break;case 1:a=this._get_sti(c);this._st[this._stack_ptr+c&7]=this._get_st0();this._st[this._stack_ptr]=a;break;case 2:switch(c){case 0:break;default:this._fpu_unimpl()}break;case 3:this._fpu_unimpl();break;case 4:a=this._get_st0();switch(c){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[c]);break;case 6:a=this._get_st0();switch(c){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(),c){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._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,c){switch(a>>3&7){case 0:var d=this._load_m32(c);this._push(d);break;case 1:this._fpu_unimpl();break;case 2:this._store_m32(c,this._get_st0());break;case 3:this._store_m32(c,this._get_st0());this._pop();break;case 4:this._fldenv(c);break;case 5:this._control_word=this.cpu.safe_read16(c);break;case 6:this._fstenv(c);break;case 7:this.cpu.safe_write16(c,this._control_word)}};
FPU.prototype.op_DA_reg=function(a){var c=a&7;switch(a>>3&7){case 0:this.cpu.test_b()&&(this._st[this._stack_ptr]=this._get_sti(c),this._stack_empty&=~(1<<this._stack_ptr));break;case 1:this.cpu.test_z()&&(this._st[this._stack_ptr]=this._get_sti(c),this._stack_empty&=~(1<<this._stack_ptr));break;case 2:this.cpu.test_be()&&(this._st[this._stack_ptr]=this._get_sti(c),this._stack_empty&=~(1<<this._stack_ptr));break;case 3:this.cpu.test_p()&&(this._st[this._stack_ptr]=this._get_sti(c),this._stack_empty&=
~(1<<this._stack_ptr));break;case 5:1===c?(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,c){var d=a>>3&7,e=this.cpu.safe_read32s(c),f=this._get_st0();switch(d){case 0:this._st[this._stack_ptr]=f+e;break;case 1:this._st[this._stack_ptr]=f*e;break;case 2:this._fcom(e);break;case 3:this._fcom(e);this._pop();break;case 4:this._st[this._stack_ptr]=f-e;break;case 5:this._st[this._stack_ptr]=e-f;break;case 6:this._st[this._stack_ptr]=f/e;break;case 7:this._st[this._stack_ptr]=e/f}};
FPU.prototype.op_DB_reg=function(a){var c=a&7;switch(a>>3&7){case 0:this.cpu.test_b()||(this._st[this._stack_ptr]=this._get_sti(c),this._stack_empty&=~(1<<this._stack_ptr));break;case 1:this.cpu.test_z()||(this._st[this._stack_ptr]=this._get_sti(c),this._stack_empty&=~(1<<this._stack_ptr));break;case 2:this.cpu.test_be()||(this._st[this._stack_ptr]=this._get_sti(c),this._stack_empty&=~(1<<this._stack_ptr));break;case 3:this.cpu.test_p()||(this._st[this._stack_ptr]=this._get_sti(c),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(c));break;case 6:this._fcomi(this._get_sti(c));break;default:this._fpu_unimpl()}};
FPU.prototype.op_DB_mem=function(a,c){switch(a>>3&7){case 0:var d=this.cpu.safe_read32s(c);this._push(d);break;case 2:d=this._integer_round(this._get_st0());2147483647>=d&&-2147483648<=d?this.cpu.safe_write32(c,d):(this._invalid_arithmatic(),this.cpu.safe_write32(c,-2147483648));break;case 3:d=this._integer_round(this._get_st0());2147483647>=d&&-2147483648<=d?this.cpu.safe_write32(c,d):(this._invalid_arithmatic(),this.cpu.safe_write32(c,-2147483648));this._pop();break;case 5:this._push(this._load_m80(c));
break;case 7:this.cpu.writable_or_pagefault(c,10);this._store_m80(c,0);this._pop();break;default:this._fpu_unimpl()}};FPU.prototype.op_DC_reg=function(a){var c=a>>3&7,d=a&7;a=this._stack_ptr+d&7;var d=this._get_sti(d),e=this._get_st0();switch(c){case 0:this._st[a]=d+e;break;case 1:this._st[a]=d*e;break;case 2:this._fcom(d);break;case 3:this._fcom(d);this._pop();break;case 4:this._st[a]=e-d;break;case 5:this._st[a]=d-e;break;case 6:this._st[a]=e/d;break;case 7:this._st[a]=d/e}};
FPU.prototype.op_DC_mem=function(a,c){var d=a>>3&7,e=this._load_m64(c),f=this._get_st0();switch(d){case 0:this._st[this._stack_ptr]=f+e;break;case 1:this._st[this._stack_ptr]=f*e;break;case 2:this._fcom(e);break;case 3:this._fcom(e);this._pop();break;case 4:this._st[this._stack_ptr]=f-e;break;case 5:this._st[this._stack_ptr]=e-f;break;case 6:this._st[this._stack_ptr]=f/e;break;case 7:this._st[this._stack_ptr]=e/f}};
FPU.prototype.op_DD_reg=function(a){var c=a&7;switch(a>>3&7){case 0:this._stack_empty|=1<<(this._stack_ptr+c&7);break;case 2:this._st[this._stack_ptr+c&7]=this._get_st0();break;case 3:0!==c&&(this._st[this._stack_ptr+c&7]=this._get_st0());this._pop();break;case 4:this._fucom(this._get_sti(c));break;case 5:this._fucom(this._get_sti(c));this._pop();break;default:this._fpu_unimpl()}};
FPU.prototype.op_DD_mem=function(a,c){switch(a>>3&7){case 0:var d=this._load_m64(c);this._push(d);break;case 1:this._fpu_unimpl();break;case 2:this._store_m64(c);break;case 3:this._store_m64(c);this._pop();break;case 4:this._frstor(c);break;case 5:this._fpu_unimpl();break;case 6:this._fsave(c);break;case 7:this.cpu.safe_write16(c,this._load_status_word())}};
FPU.prototype.op_DE_reg=function(a){var c=a>>3&7;a=a&7;var d=this._stack_ptr+a&7,e=this._get_sti(a),f=this._get_st0();switch(c){case 0:this._st[d]=e+f;break;case 1:this._st[d]=e*f;break;case 2:this._fcom(e);break;case 3:1===a?(this._fcom(this._st[d]),this._pop()):this._fpu_unimpl();break;case 4:this._st[d]=f-e;break;case 5:this._st[d]=e-f;break;case 6:this._st[d]=f/e;break;case 7:this._st[d]=e/f}this._pop()};
FPU.prototype.op_DE_mem=function(a,c){var d=a>>3&7,e=this.cpu.safe_read16(c)<<16>>16,f=this._get_st0();switch(d){case 0:this._st[this._stack_ptr]=f+e;break;case 1:this._st[this._stack_ptr]=f*e;break;case 2:this._fcom(e);break;case 3:this._fcom(e);this._pop();break;case 4:this._st[this._stack_ptr]=f-e;break;case 5:this._st[this._stack_ptr]=e-f;break;case 6:this._st[this._stack_ptr]=f/e;break;case 7:this._st[this._stack_ptr]=e/f}};
FPU.prototype.op_DF_reg=function(a){var c=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(c));this._pop();break;case 6:this._fcomi(this._get_sti(c));this._pop();break;default:this._fpu_unimpl()}};
FPU.prototype.op_DF_mem=function(a,c){switch(a>>3&7){case 0:var d=this.cpu.safe_read16(c)<<16>>16;this._push(d);break;case 1:this._fpu_unimpl();break;case 2:d=this._integer_round(this._get_st0());32767>=d&&-32768<=d?this.cpu.safe_write16(c,d):(this._invalid_arithmatic(),this.cpu.safe_write16(c,32768));break;case 3:d=this._integer_round(this._get_st0());32767>=d&&-32768<=d?this.cpu.safe_write16(c,d):(this._invalid_arithmatic(),this.cpu.safe_write16(c,32768));this._pop();break;case 4:this._fpu_unimpl();
break;case 5:var e=this.cpu.safe_read32s(c)>>>0,d=this.cpu.safe_read32s(c+4)>>>0,e=e+4294967296*d;d>>31&&(e-=1.8446744073709552E19);this._push(e);break;case 6:this._fpu_unimpl();break;case 7:this.cpu.writable_or_pagefault(c,8);var d=this._integer_round(this._get_st0()),f;0x7fffffffffffffff>d&&-9223372036854775808<=d?(e=d|0,f=d/4294967296|0,0===f&&0>d&&(f=-1)):(e=0,f=-2147483648,this._invalid_arithmatic());this.cpu.safe_write32(c,e);this.cpu.safe_write32(c+4,f);this._pop()}};function IDEDevice(a,c,d,e){0===e?(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=c;this.sector_size=d?2048:512;this.is_atapi=d;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)),d?(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=null;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)}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="atapi_handle",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 c=(a[7]<<8|a[8])*this.sector_size,d=(this.cylinder_high&255)<<8|this.cylinder_low&255;a=(a[2]<<24|a[3]<<16|a[4]<<8|a[5])*this.sector_size;d||(d=32768);d=Math.min(c,d);this.cylinder_low=d&255;this.cylinder_high=d>>8&255;a>=this.buffer.byteLength?(this.status=255,this.push_irq()):(c=Math.min(c,this.buffer.byteLength-a),this.status=128,this.stats.loading=!0,this.buffer.get(a,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.atapi_read_dma=function(a){var c=(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()):(c=Math.min(c,this.buffer.byteLength-a),this.status=128,this.stats.loading=!0,this.buffer.get(a,c,function(a){var e=this.prdt_addr,f=0;do{var g=this.memory.read32s(e),k=this.memory.read16(e+4),m=this.memory.read8(e+7)&128;k||(k=65536);this.memory.write_blob(a.subarray(f,f+k),g);f+=k;e+=8}while(!m);this.status=
80;this.dma_status&=-4;this.dma_status|=4;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.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){if(!(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[this.data_port_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){var c=this.bytecount&255,d=this.is_lba?this.get_lba28():this.get_chs();0===c&&(c=256)}else if(36===a||41===a)c=this.bytecount,d=this.get_lba48(),0===c&&(c=65536);var e=c*this.sector_size;a=d*this.sector_size;this.cylinder_low+=c;a+e>this.buffer.byteLength?(this.status=255,this.push_irq()):(this.status=128,this.stats.loading=!0,this.buffer.get(a,e,function(a){this.pio_data=a;this.status=88;this.data_pointer=0;this.push_irq();this.stats.loading=
!1;this.stats.sectors_read+=e/this.sector_size|0;this.stats.bytes_read+=e}.bind(this)))};
IDEDevice.prototype.ata_read_sectors_dma=function(){var a=this.bytecount&255,c=a*this.sector_size,d=this.get_lba28()*this.sector_size;this.cylinder_low+=a;d+c>this.buffer.byteLength?(this.status=255,this.push_irq()):(this.status=128,this.dma_status|=1,this.stats.loading=!0,this.buffer.get(d,c,function(a){var d=this.prdt_addr,g=0;do{var k=this.memory.read32s(d),m=this.memory.read16(d+4),l=this.memory.read8(d+7)&128;m||(m=65536);this.memory.write_blob(a.subarray(g,g+m),k);g+=m;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+=c/this.sector_size|0;this.stats.bytes_read+=c}.bind(this)))};
IDEDevice.prototype.ata_write=function(a){if(48===a){var c=this.bytecount&255,d=this.is_lba?this.get_lba28():this.get_chs();0===c&&(c=256)}else if(52===a||57===a)c=this.bytecount,d=this.get_lba48(),0===c&&(c=65536);a=c*this.sector_size;d=d*this.sector_size;this.cylinder_low+=c;d+a>this.buffer.byteLength?this.status=255:(this.status=80,this.next_status=88,this.allocate_in_buffer(a),this.write_dest=d,this.data_port_callback="do_write");this.push_irq()};
IDEDevice.prototype.ata_write_dma=function(){var a=this.bytecount&255,c=a*this.sector_size,d=this.get_lba28()*this.sector_size;this.cylinder_low+=a;if(d+c>this.buffer.byteLength)this.status=255,this.push_irq();else{this.status=128;this.dma_status|=1;var a=this.prdt_addr,e=0,f=0,g=0;do{var k=this.memory.read32s(a),m=this.memory.read16(a+4),l=this.memory.read8(a+7)&128;m||(m=65536);this.buffer.set(d+g,this.memory.mem8.subarray(k,k+m),function(){f++;f===e&&(this.status=80,this.push_irq(),this.dma_status&=
-4,this.dma_status|=4)}.bind(this));g+=m;a+=8;e++}while(!l);f===e&&(this.status=80,this.push_irq(),this.dma_status&=-4,this.dma_status|=4);this.stats.sectors_written+=c/this.sector_size|0;this.stats.bytes_written+=c}};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 c(a){var c=d[2]<<8|d[1],e=d[0]&252,f=m[c],c=l[c];f&&3===a&&16<=e&&40>e&&(a=e-16>>2,c=c.pci_bars,a<c.length&&c[a]||(f[e>>2]=0))}a=a.io;var d=new Uint8Array(4),e=new Uint8Array(4),f=new Uint8Array(4);new Int32Array(d.buffer);var g=new Int32Array(e.buffer),k=new Int32Array(f.buffer),m=Array(65536),l=Array(65536);a.register_write_consecutive(3324,this,function(){c(0)},function(){c(1)},function(){c(2)},function(){c(3)});a.register_read_consecutive(3324,this,function(){return e[0]},
function(){return e[1]},function(){return e[2]},function(){return e[3]});a.register_read_consecutive(3320,this,function(){return f[0]},function(){return f[1]},function(){return f[2]},function(){return f[3]});a.register_write_consecutive(3320,this,function(a){d[0]=a},function(a){d[1]=a},function(a){d[2]=a},function(a){d[3]=a;a=d[0]&252;var c=m[d[2]<<8|d[1]];void 0!==c?(k[0]=-2147483648,g[0]=a<c.byteLength?c[a>>2]:-1):(g[0]=-1,k[0]=0)});this.register_device=function(a){var c=a.pci_id;m[c]=new Int32Array((new Uint8Array(a.pci_space)).buffer);
l[c]=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,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=c;this.last_cylinder=0;if(c){this.floppy_size=c.byteLength;var d,e;if((e={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=e.type,d=e.sectors,e=e.heads;else throw"Unknown floppy size: "+h(c.byteLength);this.FloppyController$sectors_per_track=
d;this.number_of_heads=e;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}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,c){var d=c[2],e=c[1],f=c[3],g=((d+this.number_of_heads*e)*this.FloppyController$sectors_per_track+f-1)*(128<<c[4]);a?this.dma.do_write(this.fda_image,g,this.done.bind(this,c,e,d,f)):this.dma.do_read(this.fda_image,g,this.done.bind(this,c,e,d,f))};
FloppyController.prototype.done=function(a,c,d,e,f){f||(e++,e>this.FloppyController$sectors_per_track&&(e=1,d++,d>=this.number_of_heads&&(d=0,a++)),this.last_cylinder=a,this.response_index=0,this.response_length=7,this.response_data[0]=d<<2|32,this.response_data[1]=0,this.response_data[2]=0,this.response_data[3]=a,this.response_data[4]=d,this.response_data[5]=e,this.response_data[6]=c[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,c){this.mem8=new Uint8Array(a);this.mem16=new Uint16Array(a);this.mem32s=new Int32Array(a);this.buffer=a;this.size=c;this.memory_map_registered=new Uint8Array(262144);this.memory_map_read8=[];this.memory_map_write8=[];this.memory_map_read32=[];this.memory_map_write32=[]}Memory.prototype._state_restore=function(){this.mem8=new Uint8Array(this.buffer);this.mem16=new Uint16Array(this.buffer);this.mem32s=new Int32Array(this.buffer)};
Memory.prototype.mmap_read8=function(a){return this.memory_map_read8[a>>>14](a)};Memory.prototype.mmap_write8=function(a,c){this.memory_map_write8[a>>>14](a,c)};Memory.prototype.mmap_read16=function(a){var c=this.memory_map_read8[a>>>14];return c(a)|c(a+1)<<8};Memory.prototype.mmap_write16=function(a,c){var d=this.memory_map_write8[a>>>14];d(a,c&255);d(a+1,c>>8&255)};Memory.prototype.mmap_read32=function(a){return this.memory_map_read32[a>>>14](a)};
Memory.prototype.mmap_write32=function(a,c){this.memory_map_write32[a>>>14](a,c)};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,c){this.memory_map_registered[a>>>14]?this.mmap_write8(a,c):this.mem8[a]=c};
Memory.prototype.write16=function(a,c){this.memory_map_registered[a>>>14]?this.mmap_write16(a,c):(this.mem8[a]=c,this.mem8[a+1]=c>>8)};Memory.prototype.write_aligned16=function(a,c){this.memory_map_registered[a>>>13]?this.mmap_write16(a<<1,c):this.mem16[a]=c};Memory.prototype.write32=function(a,c){this.memory_map_registered[a>>>14]?this.mmap_write32(a,c):(this.mem8[a]=c,this.mem8[a+1]=c>>8,this.mem8[a+2]=c>>16,this.mem8[a+3]=c>>24)};
Memory.prototype.write_aligned32=function(a,c){this.memory_map_registered[a>>>12]?this.mmap_write32(a<<2,c):this.mem32s[a]=c};Memory.prototype.write_blob=function(a,c){this.mem8.set(a,c)};Memory.prototype.write_string=function(a){for(var c=0;c<a.length;c++)this.write8(63488+c,a.charCodeAt(c))};function DMA(a){this.io=a.io;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;this.io.register_write(4,this,this.port_write.bind(this,4));this.io.register_write(5,this,this.port_write.bind(this,5));this.io.register_write(10,this,this.portA_write);this.io.register_write(11,this,this.portB_write);this.io.register_write(12,this,this.portC_write);this.io.register_write(129,this,this.port81_write)}
DMA.prototype.port_write=function(a,c){if(8>a){var d=a>>1;a&1?this.channels[d].count=this.flipflop_get(this.channels[d].count,c):this.channels[d].address=this.flipflop_get(this.channels[d].address,c)}};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,c,d){var e=this.channels[2].count+1,f=this.channels[2].address;if(c+e>a.byteLength)d(!0);else{var g=this.memory;this.channels[2].address+=e;a.get(c,e,function(a){g.write_blob(a,f);d(!1)})}};DMA.prototype.do_write=function(a,c,d){var e=this.channels[2].count,f=this.channels[2].address;c+e>a.byteLength?d(!0):(this.channels[2].address+=e,a.set(c,new Uint8Array(this.memory.buffer,f,e+1),function(){d(!1)}))};
DMA.prototype.flipflop_get=function(a,c){return(this.lsb_msb_flipflop^=1)?a&-256|c:a&-65281|c<<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);var c=this.counter2_out=0;a.io.register_read(97,this,function(){c^=16;return c|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)}
PIT.prototype.timer=function(a,c){var d,e,f=1193.1816666*(a-this.PIT$next_tick)>>>0;if(f){this.PIT$next_tick+=f/1193.1816666;if(!c&&this.counter_enabled[0]&&(d=this.counter_current[0]-=f,0>=d))if(this.pic.push_irq(0),e=this.counter_mode[0],0===e)this.counter_enabled[0]=0,this.counter_current[0]=0;else if(3===e||2===e)this.counter_current[0]=this.counter_reload[0]+d%this.counter_reload[0];this.counter_enabled[2]&&(d=this.counter_current[2]-=f,0>=d&&(e=this.counter_mode[2],0===e?(this.counter2_out=
1,this.counter_enabled[2]=0,this.counter_current[2]=0):2===e?(this.counter2_out=1,this.counter_current[2]=this.counter_reload[2]+d%this.counter_reload[2]):3===e&&(this.counter2_out^=1,this.counter_current[2]=this.counter_reload[2]+d%this.counter_reload[2])))}};
PIT.prototype.counter_read=function(a){var c=this.counter_latch[a];if(c)return this.counter_latch[a]--,2===c?this.counter_latch_value[a]&255:this.counter_latch_value[a]>>8;c=this.counter_next_low[a];3===this.counter_mode[a]&&(this.counter_next_low[a]^=1);return c?this.counter_current[a]&255:this.counter_current[a]>>8};
PIT.prototype.counter_write=function(a,c){this.counter_reload[a]=this.counter_next_low[a]?this.counter_reload[a]&-256|c:this.counter_reload[a]&255|c<<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 c=a>>1&7,d=a>>6&3;a=a>>4&3;3!==d&&(0===a?(this.counter_latch[d]=2,this.counter_latch_value[d]=this.counter_current[d]):(6<=c&&(c&=-5),this.counter_next_low[d]=1===a?0:1,this.counter_mode[d]=c,this.counter_read_mode[d]=a,2===d&&(this.counter2_out=0===c?0:1)))};function VGAScreen(a,c,d){void 0===c?this.VGAScreen$adapter=new VGADummyAdapter:this.VGAScreen$adapter=c;this.vga_memory_size=d;this.cursor_address=0;this.cursor_scanline_start=14;this.cursor_scanline_end=15;this.start_address=this.screen_height=this.screen_width=this.max_rows=this.max_cols=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.plane0;this.plane1;this.plane2;this.plane3;this.svga_memory32=this.svga_memory16=this.svga_memory=this.vga_memory=null;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.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.set_size_text(80,25);this.update_cursor_scanline();var e=this;a.mmap_register(655360,131072,function(a){return e.vga_memory_read(a)},function(a,c){e.vga_memory_write(a,c)});a.mmap_register(3758096384,this.vga_memory_size,function(a){return e.svga_memory_read8(a)},function(a,c){e.svga_memory_write8(a,c)},function(a){return e.svga_memory_read32(a)},function(a,c){e.svga_memory_write32(a,c)})}
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.VGAScreen$adapter.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,c){a-=655360;this.graphical_mode?this.graphical_mode_is_linear?this.vga_memory_write_graphical_linear(a,c):this.vga_memory_write_graphical_planar(a,c):this.vga_memory_write_text_mode(a,c)};
VGAScreen.prototype.vga_memory_write_graphical_linear=function(a,c){var d=a<<2,e=this.vga256_palette[c];this.VGAScreen$adapter.put_pixel_linear(d|2,e>>16&255);this.VGAScreen$adapter.put_pixel_linear(d|1,e>>8&255);this.VGAScreen$adapter.put_pixel_linear(d,e&255);this.vga_memory[a]=c};
VGAScreen.prototype.vga_memory_write_graphical_planar=function(a,c){if(!(65535<a)){var d,e,f,g,k=this.planar_mode&3;0===k?d=e=f=g=c:2===k&&(this.plane_write_bm&1&&(d=this.latch0&~this.planar_bitmap|(c&1?255:0)&this.planar_bitmap),this.plane_write_bm&2&&(e=this.latch1&~this.planar_bitmap|(c&2?255:0)&this.planar_bitmap),this.plane_write_bm&4&&(f=this.latch2&~this.planar_bitmap|(c&4?255:0)&this.planar_bitmap),this.plane_write_bm&8&&(g=this.latch3&~this.planar_bitmap|(c&8?255:0)&this.planar_bitmap));
if(0===k||2===k){switch(this.planar_rotate_reg&24){case 8:d&=this.latch0;e&=this.latch1;f&=this.latch2;g&=this.latch3;break;case 16:d|=this.latch0;e|=this.latch1;f|=this.latch2;g|=this.latch3;break;case 24:d^=this.latch0,e^=this.latch1,f^=this.latch2,g^=this.latch3}this.plane_write_bm&1&&(d=this.latch0&~this.planar_bitmap|d&this.planar_bitmap);this.plane_write_bm&2&&(e=this.latch1&~this.planar_bitmap|e&this.planar_bitmap);this.plane_write_bm&4&&(f=this.latch2&~this.planar_bitmap|f&this.planar_bitmap);
this.plane_write_bm&8&&(g=this.latch3&~this.planar_bitmap|g&this.planar_bitmap)}else 1===k&&(d=this.latch0,e=this.latch1,f=this.latch2,g=this.latch3);this.plane_write_bm&1?this.plane0[a]=d:d=this.plane0[a];this.plane_write_bm&2?this.plane1[a]=e:e=this.plane1[a];this.plane_write_bm&4?this.plane2[a]=f:f=this.plane2[a];this.plane_write_bm&8?this.plane3[a]=g:g=this.plane3[a];if(!(a>=this.screen_width*this.screen_height<<3)){e<<=1;f<<=2;g<<=3;for(var k=(a<<3|7)<<2,m=0;8>m;m++){var l=this.vga256_palette[this.dac_map[d>>
m&1|e>>m&2|f>>m&4|g>>m&8]];this.VGAScreen$adapter.put_pixel_linear(k|2,l>>16);this.VGAScreen$adapter.put_pixel_linear(k|1,l>>8&255);this.VGAScreen$adapter.put_pixel_linear(k,l&255);k-=4}}}};VGAScreen.prototype.text_mode_redraw=function(){for(var a=98304|this.start_address<<1,c,d,e=0;e<this.max_rows;e++)for(var f=0;f<this.max_cols;f++)c=this.vga_memory[a],d=this.vga_memory[a|1],this.VGAScreen$adapter.put_char(e,f,c,this.vga256_palette[d>>4&15],this.vga256_palette[d&15]),a+=2};
VGAScreen.prototype.graphical_planar_redraw=function(){for(var a=0,c=0;c<this.screen_height;c++)for(var d=0;d<this.screen_width;d+=8){for(var e=0;8>e;e++)this.VGAScreen$adapter.put_pixel_linear32(c*this.screen_width+d<<2,this.vga256_palette[this.dac_map[this.plane0[a]>>e&1|this.plane1[a]>>e<<1&2|this.plane2[a]>>e<<2&4|this.plane3[a]>>e<<3&8]]);a++}};
VGAScreen.prototype.vga_memory_write_text_mode=function(a,c){if(!(98304>a)){var d=(a-98304>>1)-this.start_address,e=d/this.max_cols|0,d=d%this.max_cols,f,g;a&1?(g=c,f=this.vga_memory[a&-2]):(f=c,g=this.vga_memory[a|1]);this.VGAScreen$adapter.put_char(e,d,f,this.vga256_palette[g>>4&15],this.vga256_palette[g&15]);this.vga_memory[a]=c}};
VGAScreen.prototype.update_cursor=function(){var a=(this.cursor_address-this.start_address)/this.max_cols|0,c=(this.cursor_address-this.start_address)%this.max_cols,a=Math.min(this.max_rows-1,a);this.VGAScreen$adapter.update_cursor(a,c)};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,c){a&=268435455;this.svga_memory[a]=c;if(this.svga_enabled&&(a-=this.svga_offset,!(0>a)))switch(this.svga_bpp){case 32:3!==(a&3)&&this.VGAScreen$adapter.put_pixel_linear(a,c);break;case 24:this.VGAScreen$adapter.put_pixel_linear((a<<2)/3|0,c);break;case 16:if(a&1){var d=this.svga_memory16[a>>1],e,f;f=255*(c>>3&31)/31|0;e=255*(d>>5&63)/63|0;d=255*(d&31)/31|0;a<<=1;this.VGAScreen$adapter.put_pixel_linear(a,d);this.VGAScreen$adapter.put_pixel_linear(a-
1,e);this.VGAScreen$adapter.put_pixel_linear(a-2,f)}break;case 8:e=this.vga256_palette[c],f=a<<2,this.VGAScreen$adapter.put_pixel_linear(f,e>>16&255),this.VGAScreen$adapter.put_pixel_linear(f|1,e>>8&255),this.VGAScreen$adapter.put_pixel_linear(f|2,e&255)}};
VGAScreen.prototype.svga_memory_write32=function(a,c){a&=268435455;if(a&3||32!==this.svga_bpp)this.svga_memory_write8(a,c&255),this.svga_memory_write8(a+1,c>>8&255),this.svga_memory_write8(a+2,c>>16&255),this.svga_memory_write8(a+3,c>>24&255);else if(this.svga_memory32[a>>2]=c,this.svga_enabled&&(a-=this.svga_offset,!(0>a)))switch(this.svga_bpp){case 32:this.VGAScreen$adapter.put_pixel_linear32(a,c)}};
VGAScreen.prototype.svga_redraw=function(){var a=this.svga_offset,c=this.svga_height*this.svga_width,d=0;if(32===this.svga_bpp)for(var e=new Int32Array(this.svga_memory.buffer),a=a>>2,c=c<<2;d<c;)this.VGAScreen$adapter.put_pixel_linear32(d,e[a++]),d+=4;else if(24===this.svga_bpp)for(c<<=2;d<c;)this.VGAScreen$adapter.put_pixel_linear(d++,this.svga_memory[a++]),this.VGAScreen$adapter.put_pixel_linear(d++,this.svga_memory[a++]),this.VGAScreen$adapter.put_pixel_linear(d++,this.svga_memory[a++]),d++};
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());this.VGAScreen$adapter.timer()};VGAScreen.prototype.destroy=function(){};VGAScreen.prototype.set_size_text=function(a,c){this.max_cols=a;this.max_rows=c;this.VGAScreen$adapter.set_size_text(a,c)};
VGAScreen.prototype.set_size_graphical=function(a,c){this.VGAScreen$adapter.set_size_graphical(a,c)};VGAScreen.prototype.update_cursor_scanline=function(){this.VGAScreen$adapter.update_cursor_scanline(this.cursor_scanline_start,this.cursor_scanline_end)};
VGAScreen.prototype.set_video_mode=function(a){var c=!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;c=!0;this.graphical_mode_is_linear=!1;break;case 18:this.screen_width=640;this.screen_height=480;c=!0;this.graphical_mode_is_linear=!1;break;case 19:this.screen_width=320,this.screen_height=200,this.graphical_mode_is_linear=c=!0}this.VGAScreen$adapter.set_mode(c);if(this.stats.is_graphical=c)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=c};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 c=this.dac_color_index/3|0,d=this.dac_color_index%3,e=this.vga256_palette[c];a=255*a/63&255;this.vga256_palette[c]=0===d?e&-16711681|a<<16:1===d?e&-65281|a<<8:e&-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.VGAScreen$adapter.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 VGADummyAdapter(){this.put_pixel_linear=function(){};this.put_pixel_linear32=function(){};this.put_char=function(){};this.set_mode=function(){};this.set_size_graphical=function(){};this.set_size_text=function(){};this.update_cursor=function(){};this.update_cursor_scanline=function(){};this.timer=function(){}};function PS2(a,c,d){this.pic=a.devices.pic;this.cpu=a;this.have_mouse=this.enable_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=this.have_keyboard=!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.keyboard=c;this.mouse=d;this.keyboard&&(this.have_keyboard=!0,this.keyboard.init(this.kbd_send_code.bind(this)));this.mouse&&(this.have_mouse=!0,this.mouse.init(this.mouse_send_click.bind(this),this.mouse_send_delta.bind(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)}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.cpu.running&&this.enable_keyboard_stream&&(this.kbd_buffer.push(a),this.kbd_irq())};
PS2.prototype.mouse_send_delta=function(a,c){if(this.cpu.running&&this.have_mouse&&this.enable_mouse){var d=this.resolution*this.sample_rate/80;this.mouse_delta_x+=a*d;this.mouse_delta_y+=c*d;if(this.enable_mouse_stream){var d=this.mouse_delta_x|0,e=this.mouse_delta_y|0;!d&&!e||Date.now()-this.last_mouse_packet<1E3/this.sample_rate||(this.mouse_delta_x-=d,this.mouse_delta_y-=e,this.send_mouse_packet(d,e))}}};
PS2.prototype.mouse_send_click=function(a,c,d){this.have_mouse&&this.enable_mouse&&(this.mouse_clicks=a|d<<1|c<<2,this.enable_mouse_stream&&this.send_mouse_packet(0,0))};PS2.prototype.send_mouse_packet=function(a,c){var d=(0>c)<<5|(0>a)<<4|8|this.mouse_clicks,e=a,f=c;this.last_mouse_packet=Date.now();this.scaling2&&(e=this.apply_scaling2(e),f=this.apply_scaling2(f));this.mouse_buffer.push(d);this.mouse_buffer.push(e);this.mouse_buffer.push(f);this.mouse_irq()};
PS2.prototype.apply_scaling2=function(a){var c=a>>31;switch(Math.abs(a)){case 0:case 1:case 3:return a;case 2:return c;case 4:return 6*c;case 5:return 9*c;default:return a<<1}};PS2.prototype.destroy=function(){this.have_keyboard&&this.keyboard.destroy();this.have_mouse&&this.mouse.destroy()};
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.ByteQueue$clear(),this.mouse_buffer.push(a),this.mouse_irq();else if(this.next_read_sample)this.next_read_sample=!1,this.mouse_buffer.ByteQueue$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.ByteQueue$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){if(this.next_is_mouse_command=!1,this.have_mouse){this.kbd_buffer.ByteQueue$clear();
this.mouse_buffer.ByteQueue$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.enable_mouse=this.enable_mouse_stream=!0;this.mouse.enabled=!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.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.ByteQueue$clear();this.kbd_buffer.ByteQueue$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.ByteQueue$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.ByteQueue$clear();this.mouse_buffer.ByteQueue$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.ByteQueue$clear();this.mouse_buffer.ByteQueue$clear();this.kbd_buffer.push(0);break;
case 170:this.kbd_buffer.ByteQueue$clear();this.mouse_buffer.ByteQueue$clear();this.kbd_buffer.push(85);break;case 171:this.kbd_buffer.ByteQueue$clear();this.mouse_buffer.ByteQueue$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,c){this.irr=this.isr=this.irq_map=this.irq_mask=0;this.is_master=void 0===c;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 c=this.irr&this.irq_mask;if(!c)return this.slave.check_irqs();c&=-c;if(this.isr&&(this.isr&-this.isr)<=c)return!1;var d=int_log2_table[c],c=1<<d;this.irr&=~c;if(4===c)return this.slave.check_irqs();this.auto_eoi||(this.isr|=c);a.previous_ip=a.instruction_pointer;
a.call_interrupt_vector(this.irq_map|d,!1,!1);return!0}):this.check_irqs=function(){var d=this.irr&this.irq_mask;if(!d)return!1;d&=-d;if(this.isr&&(this.isr&-this.isr)<=d)return!1;var f=int_log2_table[d],d=1<<f;this.irr&=~d;this.isr|=d;a.previous_ip=a.instruction_pointer;a.call_interrupt_vector(this.irq_map|f,!1,!1);this.irr&&c.push_irq(2);this.auto_eoi||(this.isr&=~d);return!0};this.PIC$dump=function(){this.is_master&&this.slave.PIC$dump()};var d;d=this.is_master?32:160;a.io.register_write(d,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 c=a>>5;1===c?this.isr&=this.isr-1:3===c&&(this.isr&=~(1<<(a&7)))}});a.io.register_read(d,this,function(){return this.read_irr?this.irr:this.isr});a.io.register_write(d|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(d|1,this,function(){return~this.irq_mask&
255});this.push_irq=this.is_master?function(c){8<=c&&(this.slave.push_irq(c-8),c=2);this.irr|=1<<c;a.handle_irqs()}:function(a){this.irr|=1<<a}};function RTC(a,c,d){this.cpu=a;this.pic=a.devices.pic;this.cmos_index=0;this.boot_order=d;this.diskette_type=c;this.last_update=this.rtc_time=Date.now();this.RTC$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)}
RTC.prototype.timer=function(a){this.periodic_interrupt&&this.cmos_c_was_read&&this.RTC$next_interrupt<a&&(this.cmos_c_was_read=!1,this.pic.push_irq(8),this.cmos_c|=64,this.RTC$next_interrupt+=this.periodic_interrupt_time*Math.ceil((a-this.RTC$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 c=0,d=0,e;a;)e=a%10,d|=e<<4*c,c++,a=(a-e)/10;return d};
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.RTC$next_interrupt=Date.now())}this.periodic_interrupt=64===(this.cmos_b&64)&&0<(this.cmos_a&15)};function UART(a,c,d){this.pic=a.devices.pic;this.interrupts=0;this.line="";this.ier=this.line_control=this.baud_rate=0;this.iir=1;this.UART$irq=this.scratch_register=this.modem_status=this.modem_control=0;this.input=new ByteQueue(4096);if(1E3===c||1016===c)this.UART$irq=4;else if(1E3===c||1E3===c)this.UART$irq=3;else return;d.init(function(a){this.input.push(a);this.interrupts|=4096;this.ier&1&&(this.iir=12,this.push_irq())}.bind(this));a=a.io;a.register_write(c,this,function(a){this.line_control&
128?this.baud_rate=this.baud_rate&-256|a:(this.ier&2&&this.push_irq(),255!==a&&d&&(d.put_line?this.line=10===a?"":this.line+String.fromCharCode(a):d.put_str(String.fromCharCode(a))))});a.register_write(c|1,this,function(a){this.line_control&128?this.baud_rate=this.baud_rate&255|a<<8:this.ier=a});a.register_read(c,this,function(){return this.line_control&128?this.baud_rate&255:this.input.shift()});a.register_read(c|1,this,function(){return this.line_control&128?this.baud_rate>>8:this.ier});a.register_read(c|
2,this,function(){var a=this.iir&15|192;2===this.iir?this.clear_interrupt(2):12===this.iir&&this.clear_interrupt(12);return a});a.register_write(c|2,this,function(){});a.register_read(c|3,this,function(){return this.line_control});a.register_write(c|3,this,function(a){this.line_control=a});a.register_read(c|4,this,function(){return this.modem_control});a.register_write(c|4,this,function(a){this.modem_control=a});a.register_read(c|5,this,function(){var a=0;this.input.length&&(a|=1);return a|96});a.register_write(c|
5,this,function(){});a.register_read(c|6,this,function(){return this.modem_status});a.register_write(c|6,this,function(){});a.register_read(c|7,this,function(){return this.scratch_register});a.register_write(c|7,this,function(a){this.scratch_register=a})}UART.prototype.push_irq=function(){this.pic.push_irq(this.UART$irq)};UART.prototype.clear_interrupt=function(a){this.interrupts&=~(1<<a);this.iir=1;a===this.iir&&this.UART_prototype$next_interrupt()};
UART.prototype.UART_prototype$next_interrupt=function(){this.interrupts&4096&&this.ier&1||this.interrupts&4&&this.ier&2||(this.iir=1)};function ACPI(){};function StateLoadError(a){this.message=a}StateLoadError.prototype=Error();
function restore_object(a,c,d){if("object"!==typeof c||c instanceof Array||null===c)return c;var e=c.__state_type__;if(void 0===e){for(var e=Object.keys(c),f=0;f<e.length;f++){var g=e[f];a[g]=restore_object(a[g],c[g],d)}a._state_restore&&a._state_restore();return a}if("ArrayBuffer"===e)return c=d.infos[c.buffer_id],a&&a.byteLength===c.length&&(new Uint8Array(a)).set(new Uint8Array(d.full,c.offset,c.length)),a;e={Uint8Array:Uint8Array,Int8Array:Int8Array,Uint16Array:Uint16Array,Int16Array:Int16Array,
Uint32Array:Uint32Array,Int32Array:Int32Array,Float32Array:Float32Array,Float64Array:Float64Array}[e];c=d.infos[c.buffer_id];return a&&a.constructor===e&&0===a.byteOffset&&a.byteLength===c.length?((new Uint8Array(a.buffer)).set(new Uint8Array(d.full,c.offset,c.length),a.byteOffset),a):new e(d.full.slice(c.offset,c.offset+c.length))}
v86.prototype.restore_state=function(a){var c=a.byteLength;if(16>c)throw new StateLoadError("Invalid length: "+c);var d=new Int32Array(a,0,4);if(-2039052682!==d[0])throw new StateLoadError("Invalid header: "+h(d[0]>>>0));if(0!==d[1])throw new StateLoadError("Version mismatch: dump="+d[1]+" we=0");if(d[2]!==c)throw new StateLoadError("Length doesn't match header: real="+c+" header="+d[2]);d=d[3];if(0>d||d+12>=c||d%2)throw new StateLoadError("Invalid info block length: "+d);for(var e=d/2,f=new Uint16Array(a,
16,e),g="",c=0;c<e-8;)g+=String.fromCharCode(f[c++],f[c++],f[c++],f[c++],f[c++],f[c++],f[c++],f[c++]);for(;c<e;)g+=String.fromCharCode(f[c++]);e=JSON.parse(g);d=16+d;f=e.buffer_infos;for(c=0;c<f.length;c++)f[c].offset+=d;restore_object(this,e.state,{full:a,infos:f})};function Ne2k(a,c){this.pic=a.devices.pic;this.Ne2k$adapter=c;c.init(this.receive.bind(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 d=a.io;d.register_read(47104,this,function(){return this.cr});d.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))});d.register_read(47117,this,function(){return 0});
d.register_read(47118,this,function(){return 0});d.register_read(47119,this,function(){return 0});d.register_read(47135,this,function(){if(0===(this.cr&192))return this.do_interrupt(128),0});d.register_write(47135,this,function(){});d.register_read(47111,this,function(){return 0===(this.cr&192)?this.isr:this.curpg});d.register_write(47111,this,function(a){0===(this.cr&192)?this.isr&=~a:this.curpg=a});d.register_write(47117,this,function(){});d.register_write(47118,this,function(){});d.register_write(47114,
this,function(a){0===(this.cr&192)&&(this.rcnt=this.rcnt&65280|a&255)});d.register_write(47115,this,function(a){0===(this.cr&192)&&(this.rcnt=this.rcnt&255|a<<8&65280)});d.register_write(47112,this,function(a){0===(this.cr&192)&&(this.rsar=this.rsar&65280|a&255)});d.register_write(47113,this,function(a){0===(this.cr&192)&&(this.rsar=this.rsar&255|a<<8&65280)});d.register_write(47119,this,function(a){0===(this.cr&192)&&(this.imr=a)});d.register_read(47107,this,function(){return 0===(this.cr&192)?this.boundary:
0});d.register_write(47107,this,function(a){0===(this.cr&192)&&(this.boundary=a)});d.register_read(47108,this,function(){return 0===(this.cr&192)?35:0});d.register_read(47116,this,function(){return 0===(this.cr&192)?9:0});d.register_read(47120,this,this.data_port_read,this.data_port_read16,this.data_port_read32);d.register_write(47120,this,this.data_port_write,this.data_port_write16,this.data_port_write32)}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.Ne2k$adapter.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 c=a;a=new Uint8Array(60);a.set(c)}var c=this.curpg<<8,d=a.length+4,e=c+4,f=this.curpg+1+(d>>8);if(c+d>this.receive_buffer.length){var g=this.receive_buffer.length-e;this.receive_buffer.set(a.subarray(0,g),e);this.receive_buffer.set(a.subarray(g),76)}else this.receive_buffer.set(a,e);128<=f&&(f+=-52);this.receive_buffer[c]=1;this.receive_buffer[c+1]=f;this.receive_buffer[c+2]=d;this.receive_buffer[c+3]=d>>8;this.curpg=f;this.do_interrupt(1)}};function VirtIO(a,c){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 d=a.io;d.register_read(43008,this,void 0,void 0,function(){return 1});d.register_write(43012,this,void 0,void 0,function(){});d.register_write(43022,this,void 0,function(a){this.queue_select=a},void 0);d.register_read(43020,this,void 0,
function(){return this.queue_size},void 0);d.register_read(43016,this,void 0,void 0,function(){return 0===this.queue_select?this.queue_address:0});d.register_write(43016,this,void 0,void 0,function(a){this.queue_address=a});d.register_write(43026,this,function(a){this.device_status=a});d.register_read(43026,this,function(){return this.device_status});d.register_read(43027,this,function(){var a=this.isr;this.isr=0;return a});d.register_write(43024,this,void 0,function(){var a=(this.queue_address<<
12)+16*this.queue_size,c=a+4;this.memory.read16(a);for(var a=this.memory.read16(a+2),d=this.queue_size-1,a=a&d;this.last_idx!==a;){var e=this.memory.read16(c+2*this.last_idx);this.handle_descriptor(e);this.last_idx=this.last_idx+1&d}});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 e=0;128>e;e++)d.register_read(43028+e,this,function(a){return this.device.configspace[a]}.bind(this,e),void 0,void 0),
d.register_write(43028+e,this,function(){}.bind(this,e),void 0,void 0);this.device=new Virtio9p(c);this.device.SendReply=this.device_reply.bind(this);this._state_restore=function(){this.device.SendReply=this.device_reply.bind(this)}}
VirtIO.prototype.handle_descriptor=function(a){var c=a,d=this.queue_address<<12,e=0,f=[];do{var g=d+16*c,k=this.memory.read16(g+12);if(k&2)break;var m=this.memory.read32s(g),c=this.memory.read32s(g+4),l=this.memory.read32s(g+8)>>>0;f.push({addr_low:m,addr_high:c,len:l});if(k&1)c=this.memory.read16(g+14);else{c=-1;break}}while(1);var n=-1,p=0;this.device.ReceiveRequest({start:a,next:c},function(){if(p>=n){if(e===f.length)return 0;var a=f[e++];m=a.addr_low;n=a.len;p=0}return this.memory.read8(m+p++)}.bind(this))};
VirtIO.prototype.device_reply=function(a){if(-1!==a.next){var c=this.device.replybuffersize,d=a.next,e=this.queue_address<<12,f=0,g=[];do{var d=e+16*d,k=this.memory.read16(d+12);if(0===(k&2))break;var m=this.memory.read32s(d),l=this.memory.read32s(d+4),n=this.memory.read32s(d+8)>>>0;g.push({addr_low:m,addr_high:l,len:n});if(k&1)d=this.memory.read16(d+14);else break}while(1);k=-1;for(e=l=0;e<c;e++){d=this.device.replybuffer[e];if(l>=k){if(f===g.length)return 0;k=g[f++];m=k.addr_low;k=k.len;l=0}this.memory.write8(m+
l++,d)}f=(this.queue_address<<12)+580;f=f+4095&-4096;this.memory.read16(f);g=this.memory.read16(f+2);this.memory.write16(f+2,g+1);f=f+4+8*(g&31);this.memory.write32(f,a.start);this.memory.write32(f+4,c);this.isr|=1;this.pic.push_irq(12)}};var S_IFDIR=16384;function FS(a){this.inodes=[];this.events=[];this.baseurl=a;this.filesinloadingqueue=this.qidnumber=0;this.OnLoaded=function(){};this.userinfo=[];this.inodedata={};this.CreateDirectory("",-1)}FS.prototype.LoadFilesystem=function(a){this.userinfo=a;this.LoadFSXML(this.userinfo.basefsURL);this.OnLoaded=function(){}.bind(this)};FS.prototype.AddEvent=function(a,c){0==this.inodes[a].status?c():this.events.push({id:a,OnEvent:c})};
FS.prototype.HandleEvent=function(a){0==this.filesinloadingqueue&&(this.OnLoaded(),this.OnLoaded=function(){});for(var c=this.events.length-1;0<=c;c--)this.events[c].id==a&&(this.events[c].OnEvent(),this.events.splice(c,1))};FS.prototype.LoadFSXML=function(a){LoadXMLResource(a,this.OnJSONLoaded.bind(this),function(a){throw a;})};
FS.prototype.OnJSONLoaded=function(a){function c(a,d){var k=e.CreateInode();k.name=a.name;k.uid=a.uid||0;k.gid=a.gid||0;k.atime=Math.floor(a.atime)||k.atime;k.ctime=Math.floor(a.ctime)||k.ctime;k.mtime=Math.floor(a.mtime)||k.mtime;k.parentid=d;k.mode=a.mode&511;k.size=a.size||0;switch(a.type){case "dir":k.updatedir=!0;k.mode|=S_IFDIR;var m=e.inodes.length;e.PushInode(k);for(var k=a.children,l=0;l<k.length;l++)c(k[l],m);break;case "file":k.mode|=32768;m=e.inodes.length;k.status=2;e.PushInode(k);k.url=
e.baseurl+e.GetFullPath(m);break;case "link":k.mode|=40960,k.symlink=a.target,e.PushInode(k)}}var d=JSON.parse(a).fsroot,e=this;setTimeout(function(){for(var a=0;a<d.length;a++)c(d[a],0)},100)};
FS.prototype.AppendDateHack=function(a){if("etc/init.d/rcS"==this.GetFullPath(a)){var c=new Date,c='\ndate -s "'+c.getFullYear()+"-"+(c.getMonth()+1)+"-"+c.getDate()+" "+c.getHours()+":"+c.getMinutes()+":"+c.getSeconds()+'"\n',d=this.inodes[a].size;this.ChangeSize(a,d+c.length);a=this.inodedata[a];for(var e=0;e<c.length;e++)a[e+d]=c.charCodeAt(e)}};
FS.prototype.LoadFile=function(a){var c=this.inodes[a];2==c.status&&(c.status=3,this.filesinloadingqueue++,LoadBinaryResource(c.url,function(d){d=this.inodedata[a]=new Uint8Array(d);c.size=d.length;c.status=0;"rcS"==c.name&&this.AppendDateHack(a);this.filesinloadingqueue--;this.HandleEvent(a)}.bind(this),function(a){throw a;}))};
FS.prototype.PushInode=function(a){-1!=a.parentid?(this.inodes.push(a),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)};
FS.prototype.CreateInode=function(){this.qidnumber++;var a=Math.floor(Date.now()/1E3);return{updatedir:!1,parentid:-1,firstid:-1,nextid:-1,status:0,name:"",size:0,uid:0,gid:0,ctime:a,atime:a,mtime:a,major:0,minor:0,symlink:"",mode:493,qid:{type:0,version:0,path:this.qidnumber},url:"",waswritten:!1}};
FS.prototype.CreateDirectory=function(a,c){var d=this.CreateInode();d.name=a;d.parentid=c;d.mode=511|S_IFDIR;0<=c&&(d.uid=this.inodes[c].uid,d.gid=this.inodes[c].gid,d.mode=this.inodes[c].mode&511|S_IFDIR);d.qid.type=S_IFDIR>>8;this.PushInode(d);return this.inodes.length-1};
FS.prototype.CreateFile=function(a,c){var d=this.CreateInode();d.name=a;d.parentid=c;d.uid=this.inodes[c].uid;d.gid=this.inodes[c].gid;d.qid.type=128;d.mode=this.inodes[c].mode&438|32768;this.PushInode(d);return this.inodes.length-1};FS.prototype.CreateNode=function(a,c,d,e){var f=this.CreateInode();f.name=a;f.parentid=c;f.major=d;f.minor=e;f.uid=this.inodes[c].uid;f.gid=this.inodes[c].gid;f.qid.type=192;f.mode=this.inodes[c].mode&438;this.PushInode(f);return this.inodes.length-1};
FS.prototype.CreateSymlink=function(a,c,d){var e=this.CreateInode();e.name=a;e.parentid=c;e.uid=this.inodes[c].uid;e.gid=this.inodes[c].gid;e.qid.type=160;e.symlink=d;e.mode=40960;this.PushInode(e);return this.inodes.length-1};FS.prototype.OpenInode=function(a){var c=this.GetInode(a);(c.mode&61440)==S_IFDIR&&this.FillDirectory(a);return 2==c.status?(this.LoadFile(a),!1):!0};
FS.prototype.CloseInode=function(a){var c=this.GetInode(a);4==c.status&&(-1==c.status,delete this.inodedata[a],c.waswritten=!0,c.size=0)};
FS.prototype.Rename=function(a,c,d,e){if(a==d&&c==e)return!0;c=this.Search(a,c);if(-1==c)return!1;var f=this.Search(d,e);-1!=f&&this.Unlink(f);f=this.inodes[c];if(this.inodes[f.parentid].firstid==c)this.inodes[f.parentid].firstid=f.nextid;else{var g=this.FindPreviousID(c);this.inodes[g].nextid=f.nextid}f.parentid=d;f.name=e;f.qid.version++;f.nextid=this.inodes[f.parentid].firstid;this.inodes[f.parentid].firstid=c;this.inodes[a].updatedir=!0;return this.inodes[d].updatedir=!0};
FS.prototype.Write=function(a,c,d,e){var f=this.inodes[a],g=this.inodedata[a];f.waswritten=!0;!g||g.length<c+d?(this.ChangeSize(a,Math.floor(3*(c+d)/2)),f.size=c+d,g=this.inodedata[a]):f.size<c+d&&(f.size=c+d);for(a=0;a<d;a++)g[c+a]=e()};FS.prototype.Search=function(a,c){for(var d=this.inodes[a].firstid;-1!=d;){if(this.inodes[d].name==c)return d;d=this.inodes[d].nextid}return-1};FS.prototype.GetFullPath=function(a){for(var c="";0!=a;)c="/"+this.inodes[a].name+c,a=this.inodes[a].parentid;return c.substring(1)};
FS.prototype.FindPreviousID=function(a){for(var c=this.GetInode(a),c=this.inodes[c.parentid].firstid;-1!=c&&this.inodes[c].nextid!=a;)c=this.inodes[c].nextid;return c};
FS.prototype.Unlink=function(a){if(0==a)return!1;var c=this.GetInode(a);if((c.mode&61440)==S_IFDIR&&-1!=c.firstid)return!1;this.inodes[c.parentid].firstid==a?this.inodes[c.parentid].firstid=c.nextid:(a=this.FindPreviousID(a),this.inodes[a].nextid=c.nextid);this.inodes[c.parentid].updatedir=!0;c.status=4;c.nextid=-1;c.firstid=-1;c.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,c){var d=this.GetInode(a),e=this.inodedata[a];if(c!=d.size){var f=this.inodedata[a]=new Uint8Array(c);d.size=c;d.waswritten=!0;if(e)for(var d=Math.min(e.length,d.size),g=0;g<d;g++)f[g]=e[g]}};
FS.prototype.FillDirectory=function(a){var c=this.GetInode(a);if(c.updatedir){var d=c.parentid;-1==d&&(d=0);for(var e=0,f=this.inodes[a].firstid;-1!=f;)e+=24+UTF8Length(this.inodes[f].name),f=this.inodes[f].nextid;var e=e+25+26,g=this.inodedata[a]=new Uint8Array(e);c.waswritten=!0;c.size=e;e=0;e+=Marshall(["Q","d","b","s"],[this.inodes[a].qid,e+13+8+1+2+1,this.inodes[a].mode>>12,"."],g,e);e+=Marshall(["Q","d","b","s"],[this.inodes[d].qid,e+13+8+1+2+2,this.inodes[d].mode>>12,".."],g,e);for(f=this.inodes[a].firstid;-1!=
f;)e+=Marshall(["Q","d","b","s"],[this.inodes[f].qid,e+13+8+1+2+UTF8Length(this.inodes[f].name),this.inodes[f].mode>>12,this.inodes[f].name],g,e),f=this.inodes[f].nextid;c.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};function LoadXMLResource(a,c,d){var e=new XMLHttpRequest;e.open("GET",a,!0);e.onreadystatechange=function(){4==e.readyState&&(200!=e.status&&0!=e.status?d("Error: Could not load XML file "+a):c(e.responseText))};e.send(null)}
function LoadBinaryResource(a,c,d){var e=new XMLHttpRequest;e.open("GET",a,!0);e.responseType="arraybuffer";e.onreadystatechange=function(){if(4==e.readyState)if(200!=e.status&&0!=e.status)d("Error: Could not load file "+a);else{var f=e.response;f?c(f):d("Error: No data received from: "+a)}};e.send(null)};function Marshall(a,c,d,e){for(var f,g=0,k=0;k<a.length;k++)switch(f=c[k],a[k]){case "w":d[e++]=f&255;d[e++]=f>>8&255;d[e++]=f>>16&255;d[e++]=f>>24&255;g+=4;break;case "d":d[e++]=f&255;d[e++]=f>>8&255;d[e++]=f>>16&255;d[e++]=f>>24&255;d[e++]=0;d[e++]=0;d[e++]=0;d[e++]=0;g+=8;break;case "h":d[e++]=f&255;d[e++]=f>>8;g+=2;break;case "b":d[e++]=f;g+=1;break;case "s":var m=e,l=0;d[e++]=0;d[e++]=0;var g=g+2,n;for(n in f)UnicodeToUTF8Stream(f.charCodeAt(n)).forEach(function(a){d[e++]=a;g+=1;l++});d[m+0]=
l&255;d[m+1]=l>>8&255;break;case "Q":Marshall(["b","w","d"],[f.type,f.version,f.path],d,e),e+=13,g+=13}return g}
function Unmarshall2(a,c){for(var d=[],e=0;e<a.length;e++)switch(a[e]){case "w":var f=c(),f=f+(c()<<8),f=f+(c()<<16),f=f+(c()<<24>>>0);d.push(f);break;case "d":f=c();f+=c()<<8;f+=c()<<16;f+=c()<<24>>>0;c();c();c();c();d.push(f);break;case "h":f=c();d.push(f+(c()<<8));break;case "b":d.push(c());break;case "s":for(var f=c(),f=f+(c()<<8),g="",k=new UTF8StreamToUnicode,m=0;m<f;m++){var l=k.Put(c());-1!=l&&(g+=String.fromCharCode(l))}d.push(g)}return d};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 c=0,d=0;d<a.length;d++)c+=128>a.charCodeAt(d)?1:2;return c};window.requestAnimationFrame||(window.requestAnimationFrame=window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame);
function ScreenAdapter(a){function c(a){a=a.toString(16);return"#"+Array(7-a.length).join("0")+a}function d(){B=!0;for(var a=0;a<D;a++)w[a]&&(F.text_update_row(a),w[a]=0)}function e(){B=!0;y<u&&(k.putImageData(n,0,0,0,y/A>>2,A,((u-y)/A>>2)+1),y=1E7,u=0)}function f(a,c,d){c=""+(1===c?"":" scaleX("+c+")")+(1===d?"":" scaleY("+d+")");a.style.webkitTransform=a.style.MozTransform=c}console.assert(a,"1st argument must be a DOM container");var g=a.getElementsByTagName("canvas")[0],k=g.getContext("2d"),m=
g.nextElementSibling||g.previousElementSibling,l=document.createElement("div"),n,p,s,q,r,t=1,x=1,A,y=0,u=0,w,B=!0,E=!1,v,z,D,F=this;a=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]);for(var 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]),H=[],G,C=0;256>C;C++)127<C?G=a[C-128]:32>C?G=I[C]:G=C,H[C]=String.fromCharCode(G);k.imageSmoothingEnabled=
!1;k.mozImageSmoothingEnabled=!1;k.webkitImageSmoothingEnabled=!1;l.style.position="absolute";l.style.backgroundColor="#ccc";l.style.width="7px";l.style.display="inline-block";m.style.display="block";g.style.display="none";this.init=function(){this.set_size_text(80,25)};this.make_screenshot=function(){try{window.open(g.toDataURL())}catch(a){}};this.put_char=function(a,c,d,e,f){a<D&&c<z&&(c=3*(a*z+c),v[c]=d,v[c+1]=e,v[c+2]=f,w[a]=1)};this.timer=function(){B&&(B=!1,requestAnimationFrame(E?e:d))};this.put_pixel_linear=
function(a,c){a>=p.length||(y=a<y?a:y,u=a>u?a:u,p[a+1^3]=c)};this.put_pixel_linear32=function(a,c){y=a<y?a:y;u=a>u?a:u;s[a>>2]=4278190080|c>>16&255|c<<16|c&65280};this.destroy=function(){};this.set_mode=function(a){(E=a)?(m.style.display="none",g.style.display="block"):(m.style.display="block",g.style.display="none")};this.set_size_text=function(a,c){w=new Int8Array(c);v=new Int32Array(a*c*3);z=a;for(D=c;m.childNodes.length>c;)m.removeChild(m.firstChild);for(;m.childNodes.length<c;)m.appendChild(document.createElement("div"));
for(var d=0;d<c;d++)this.text_update_row(d)};this.set_size_graphical=function(a,c){g.style.display="block";g.width=a;g.height=c;n=k.createImageData(a,c);p=new Uint8Array(n.data.buffer);s=new Int32Array(n.data.buffer);for(var d=3;d<p.length;d+=4)p[d]=255;A=a};this.set_scale=function(a,c){t=a;x=c;f(g,t,x);f(m,t,x)};this.set_scale(t,x);this.update_cursor_scanline=function(a,c){a&32?l.style.display="none":(l.style.display="inline",l.style.height=Math.min(15,c-a)+"px",l.style.marginTop=Math.min(15,a)+
"px")};this.update_cursor=function(a,c){if(a!==q||c!==r)w[a]=1,w[q]=1,q=a,r=c};this.text_update_row=function(a){var d=3*a*z,e,f,g,k,n,p;e=m.childNodes[a];for(g=document.createDocumentFragment();e.firstChild;)e.removeChild(e.firstChild);for(var s=0;s<z;){f=document.createElement("span");k=v[d+1];n=v[d+2];f.style.backgroundColor=c(k);f.style.color=c(n);for(p="";s<z&&v[d+1]===k&&v[d+2]===n;)if(p+=H[v[d]],s++,d+=3,a===q)if(s===r)break;else if(s===r+1){g.appendChild(l);break}f.textContent=p;g.appendChild(f)}e.appendChild(g)};
this.init()};function KeyboardAdapter(){function a(a){return a.shiftKey&&a.ctrlKey&&74===a.keyCode||116===a.keyCode||!k.enabled?!1:a.target?"phone_keyboard"===a.target.className||"INPUT"!==a.target.nodeName&&"TEXTAREA"!==a.target.nodeName:!0}function c(c){if(a(c)){var d=c.keyCode;if(!g[d])return!1;g[d]=!1;f(d,!1)||c.preventDefault()}}function d(c){if(a(c)){var d=c.keyCode;g[d]&&f(d,!1);g[d]=!0;f(d,!0)||c.preventDefault()}}function e(){for(var a=Object.keys(g),c,d=0;d<a.length;d++)c=+a[d],g[c]&&f(c,!1);g={}}function f(a,
c){if(a>=l.length||0===l[a])return console.log("Missing char in map: "+a.toString(16)),!0;var d=l[a];c||(d|=128);255<d?(m(d>>8),m(d&255)):m(d);return!1}var g={},k=this,m;this.enabled=!0;var l=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,0,0,0,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]);this.init=function(a){this.destroy();m=a;window.addEventListener("keyup",c,!1);window.addEventListener("keydown",d,!1);window.addEventListener("blur",e,!1)};this.destroy=function(){window.removeEventListener("keyup",c,!1);window.removeEventListener("keydown",
d,!1);window.removeEventListener("blur",e,!1)}};function MouseAdapter(){function a(a){return s.enabled&&s.emu_enabled&&(!a.target||"mousemove"===a.type||"INPUT"!==a.target.nodeName&&"TEXTAREA"!==a.target.nodeName)}function c(c){if(a(c)){var d;d=c.webkitMovementX||c.mozMovementX||0;c=c.webkitMovementY||c.mozMovementY||0;p(.15*d,-(.15*c))}}function d(c){a(c)&&c.preventDefault()}function e(c){a(c)&&g(c,!0)}function f(c){a(c)&&g(c,!1)}function g(a,c){1===a.which?k=c:2===a.which?l=c:3===a.which?m=c:console.log("Unknown event.which: "+a.which);n(k,l,
m);a.preventDefault()}var k=!1,m=!1,l=!1,n,p,s=this;this.enabled=!1;this.emu_enabled=!0;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(a,g){this.destroy();n=a;p=g;window.addEventListener("mousemove",c,!1);document.addEventListener("contextmenu",d,!1);window.addEventListener("mousedown",e,!1);window.addEventListener("mouseup",
f,!1)}};function SerialAdapter(a){function c(a){f.enabled&&(g(a.keyCode),a.preventDefault())}function d(a){8===a.keyCode&&(g(127),a.preventDefault())}function e(a){for(var c=a.clipboardData.getData("text/plain"),d=0;d<c.length;d++)g(c.charCodeAt(d));a.preventDefault()}var f=this,g;this.enabled=!0;this.init=function(f){this.destroy();g=f;a.addEventListener("keypress",c,!1);a.addEventListener("keydown",d,!1);a.addEventListener("paste",e,!1)};this.destroy=function(){a.removeEventListener("keypress",c,!1);a.removeEventListener("keydown",
d,!1);a.removeEventListener("paste",e,!1)};this.put_str=function(c){"\b"===c?(c=a.value,a.value=c.substr(0,c.length-1)):"\r"!==c&&(a.value+=c,"\n"===c&&(a.scrollTop=1E9))}};function NetworkAdapter(a){this.send_data=function(){};this.socket=void 0;this.send_queue=[];this.url=a;this.last_connect_attempt=Date.now()-1E4}NetworkAdapter.prototype.handle_message=function(a){this.send_data(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.init=function(a){this.send_data=a};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())};var v86util=v86util||{};
(function(){function a(a,c,d,e){var l=new XMLHttpRequest;l.open("get",a,!0);l.responseType="arraybuffer";if(e)for(var n=Object.keys(e),p=0;p<n.length;p++){var s=n[p];l.setRequestHeader(s,e[s])}l.onload=function(){4===l.readyState&&(200!==l.status&&206!==l.status?console.log("Loading the image `"+a+"` failed"):l.response&&c(l.response))};d&&(l.onprogress=function(a){d(a)});l.send(null)}function c(a,c,d){console.assert(a+c.length<=this.byteLength);var e=c.length;console.assert(0===a%this.block_size);
console.assert(0===e%this.block_size);console.assert(e);a=a/this.block_size;for(var e=e/this.block_size,l=0;l<e;l++){var n=this.loaded_blocks[a+l];void 0===n&&(n=this.loaded_blocks[a+l]=new Uint8Array(this.block_size));var p=c.subarray(l*this.block_size,(l+1)*this.block_size);n.set(p);console.assert(n.byteLength===p.length)}d()}function d(a,c,d){this.AsyncXHRBuffer$filename=a;this.block_size=c;this.AsyncXHRBuffer$block_count=d/c;console.assert(this.AsyncXHRBuffer$block_count===(this.AsyncXHRBuffer$block_count|
0));this.loaded_blocks={};this.byteLength=d;this.get_buffer=function(){}}function e(a){this.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=d;v86util.AsyncFileBuffer=e;v86util.SyncFileBuffer=function(a){var c=!1,d=this;this.byteLength=a.size;1073741824<a.size&&console.log("Warning: Allocating buffer of "+(a.size>>20)+" MB ...");var e=new ArrayBuffer(a.size),
l=0,n=new FileReader;this.load=function(){function p(){if(d.onprogress)d.onprogress({loaded:l,total:a.size,lengthComputable:!0});if(l<a.size)n.readAsArrayBuffer(a.slice(l,Math.min(l+4194304,a.size)));else if(c=!0,d.onload)d.onload({})}n.onload=function(a){(new Uint8Array(e,l)).set(new Uint8Array(a.target.result));l+=4194304;p()};p()};this.get=function(a,d,f){if(c)console.assert(a+d<=e.byteLength),f(new Uint8Array(e,a,d));else throw"SyncFileBuffer: Wait for ready";};this.get_buffer=function(a){if(c)a(e);
else throw"SyncFileBuffer: Wait for ready";};this.set=function(a,d,f){if(c)console.assert(a+d.byteLength<=e.byteLength),(new Uint8Array(e,a,d.byteLength)).set(d),f();else throw"SyncFileBuffer: Wait for ready";}};d.prototype.get=function(c,d,e){console.assert(0===c%this.block_size);console.assert(0===d%this.block_size);console.assert(d);a(this.AsyncXHRBuffer$filename,function(a){a=new Uint8Array(a);this.handle_read(c,d,a);e(a)}.bind(this),null,{Range:"bytes="+c+"-"+(c+d-1)})};d.prototype.set=c;d.prototype.handle_read=
function(a,c,d){a=a/this.block_size;c=c/this.block_size;for(var e=0;e<c;e++){var l=this.loaded_blocks[a+e];l&&d.set(l,e*this.block_size)}};e.prototype.get=function(a,c,d){console.assert(0===a%this.block_size);console.assert(0===c%this.block_size);console.assert(c);var e=new FileReader;e.onload=function(e){e=new Uint8Array(e.target.result);this.handle_read(a,c,e);d(e)}.bind(this);e.readAsArrayBuffer(this.file.slice(a,a+c))};e.prototype.set=c;e.prototype.handle_read=d.prototype.handle_read})();
//# sourceMappingURL=v86_all.js.map