Last active
June 7, 2023 18:18
-
-
Save Alikberov/9b26f6e254c372b9b70b93e6e3221805 to your computer and use it in GitHub Desktop.
MMX-Instructions Simulator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta http-equiv=refresh content='3600'> | |
<title>It's Koyaanisqatsi, baby!</title> | |
<!----------------------------------------------------------------------------- | |
BigInt.prototype.PADD = function(n, mask) { | |
return (((this & mask) + (n & mask))) ^ ((this ^ n) & ~mask); | |
} | |
BigInt.prototype.PADD = function(n, mask) { | |
var m = BigInt(this); | |
'use asm'; | |
m = m|0n; | |
n = n|0n; | |
mask = mask|0n; | |
return ((((m & mask) + (n & mask))) ^ ((m ^ n) & ~mask))|0n; | |
} | |
------------------------------------------------------------------------------> | |
<style> | |
/*<!--------------------------------------------------------------------------- | |
--- User Interface Design Presets | |
---------------------------------------------------------------------------->*/ | |
:root, | |
:root.Style0 | |
{ /**********************************/ | |
/*** "Chromed" Style ***/ | |
/**********************************/ | |
/* Caption */ | |
--caption :repeating-linear-gradient(45deg, whitesmoke, grey 2px);/* Caption BackGround Color */ | |
--caption-claw :none; /* Caption/Title Shadow Effect */ | |
--caption-text :black; /* Caption/Title Text Color */ | |
/* Button */ | |
--button :silver; /* Button Face 3D Color */ | |
--button-edge :silver; /* Button Edge Color */ | |
--button-text :black; /* Button Text Color */ | |
/* Menu Topic */ | |
--menu :repeating-linear-gradient(45deg,whitesmoke,silver 2px);/* Menu Topic Color */ | |
--menu-claw :none; /* Menu Topic Shadow Effect */ | |
--menu-edge :silver; /* Menu Topic Edge Color */ | |
--menu-open :whitesmoke; /* Menu Topic Openned Color */ | |
--menu-open-claw:2px 2px 2px white; /* Menu Topic Openned Shadow Effect */ | |
--menu-open-edge:whitesmoke; /* Menu Topic Openned Edge Color */ | |
--menu-open-text:black; /* Menu Topic Openned Text Color */ | |
--menu-over :whitesmoke; /* Menu Topic Color On Mouse Over */ | |
--menu-over-claw:2px 2px 2px white; /* Menu Topic Shadow Effect On Mouse Over */ | |
--menu-over-edge:whitesmoke; /* Menu Topic Edge Color On Mouse Over */ | |
--menu-over-text:black; /* Menu Topic Text Color On Mouse Over */ | |
--menu-push :whitesmoke; /* Menu Topic Pushed Color */ | |
--menu-push-claw:2px 2px 2px white; /* Menu Topic Pushed Shadow Effect */ | |
--menu-push-edge:silver; /* Menu Topic Pushed Edge Color */ | |
--menu-push-text:black; /* Menu Topic Pushed Text Color */ | |
--menu-text :black; /* Menu Topic Text Color */ | |
/* Menu Topic Item */ | |
--item :repeating-linear-gradient(45deg, white, silver 1px); /* Menu Item Color */ | |
--item-claw :2px 2px 2px grey; /* Menu Item Shadow Effect */ | |
--item-edge :silver; /* Menu Item Edge Color */ | |
--item-over :repeating-linear-gradient(45deg, white, silver 1px); /* Menu Item Color On Mouse Over */ | |
--item-over-claw:1px 1px 1px grey; /* Menu Item Shadow Effect On Mouse Over */ | |
--item-over-edge:silver; /* Menu Item Edge Color On Mouse Over */ | |
--item-over-text:black; /* Menu Item Text Color On Mouse Over */ | |
--item-text :black; /* Menu Item Text Color */ | |
/* Floating Window */ | |
--float :repeating-linear-gradient(45deg, white,whitesmoke 8px);/* Floating Window Blank/BackGround Color */ | |
--float-edge :silver; /* Floating Window Edge Color */ | |
--float-text :black; /* Floating Window Text Color */ | |
--float-opacity :90%; /* Floating Window Opacity */ | |
/* Listing TextArea */ | |
--textarea :silver; /* Listing TextArea Blank/BackGround Color */ | |
--textarea-claw :none; /* Listing TextArea Shadow Effect */ | |
--textarea-text :black; /* Listing TextArea Text Color */ | |
--textrows :repeating-linear-gradient(45deg,whitesmoke,silver 2px);/* Listing TextArea-Rows Blank/BackGround Color */ | |
--textrows-claw :none; /* Listing TextArea-Rows Shadow Effect */ | |
--textrows-text :black; /* Listing TextArea-Rows Text Color */ | |
/* Status Bar */ | |
--status :repeating-linear-gradient(45deg,whitesmoke,silver 2px);/* Status Bar Color */ | |
--status-claw :none; /* Status Bar Shadow Effect */ | |
--status-edge :silver; /* Status Bar Edge Color */ | |
--status-text :black; /* Status Bar Text Color */ | |
/* Main Window Control Buttons */ | |
--radius :0%; /* Window Control Buttons Rounding Radius */ | |
--mini :repeating-linear-gradient(45deg,whitesmoke,silver 3px);/* Window Control Button "Collapse" BackGround Color */ | |
--mini-edge :medium whitesmoke; /* Window Control Button "Collapse" Edge Style */ | |
--mini-sign :'_'; /* Window Control Button "Collapse" Signature */ | |
--maxi :repeating-linear-gradient(45deg,whitesmoke,silver 3px);/* Window Control Button "Expanding" BackGround Color */ | |
--maxi-edge :medium whitesmoke; /* Window Control Button "Expanding" Edge Style */ | |
--maxi-sign :'\25A1'; /* Window Control Button "Expand" Signature */ | |
--maximal-sign :'\29C9'; /* Window Control Button "Expanded/Restore" Signature */ | |
--quit :repeating-linear-gradient(45deg,whitesmoke,silver 3px);/* Window Control Button "Exit" BackGround Color */ | |
--quit-edge :medium whitesmoke; /* Window Control Button "Exit" Edge Style */ | |
--quit-sign :'X'; /* Window Control Button "Exit" Signature */ | |
/* Graphical Canvas BackGround */ | |
--display-bg :linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee 100%) | |
,linear-gradient(45deg, #eee 25%, white 25%, white 75%, #eee 75%, #eee 100%); | |
} | |
:root.Style1 | |
{ /**********************************/ | |
/*** VisualBasic - Classic ***/ | |
/**********************************/ | |
/* Caption */ | |
--caption :blue; /* Caption BackGround Color */ | |
--caption-claw :none; /* Caption/Title Shadow Effect */ | |
--caption-text :white; /* Caption/Title Text Color */ | |
/* Button */ | |
--button :silver; /* Button Face 3D Color */ | |
--button-edge :silver; /* Button Edge Color */ | |
--button-text :black; /* Button Text Color */ | |
/* Menu Topic */ | |
--menu :silver; /* Menu Topic Color */ | |
--menu-claw :none; /* Menu Topic Shadow Effect */ | |
--menu-edge :transparent; /* Menu Topic Edge Color */ | |
--menu-open :black; /* Menu Topic Openned Color */ | |
--menu-open-claw:none; /* Menu Topic Openned Shadow Effect */ | |
--menu-open-edge:transparent; /* Menu Topic Openned Edge Color */ | |
--menu-open-text:white; /* Menu Topic Openned Text Color */ | |
--menu-over :none; /* Menu Topic Color On Mouse Over */ | |
--menu-over-claw:none; /* Menu Topic Shadow Effect On Mouse Over */ | |
--menu-over-edge:transparent; /* Menu Topic Edge Color On Mouse Over */ | |
--menu-over-text:white; /* Menu Topic Text Color On Mouse Over */ | |
--menu-push :blue; /* Menu Topic Pushed Color */ | |
--menu-push-claw:none; /* Menu Topic Pushed Shadow Effect */ | |
--menu-push-edge:transparent; /* Menu Topic Pushed Edge Color */ | |
--menu-push-text:white; /* Menu Topic Pushed Text Color */ | |
--menu-text :black; /* Menu Topic Text Color */ | |
/* Menu Topic Item */ | |
--item :silver; /* Menu Item Color */ | |
--item-claw :none; /* Menu Item Shadow Effect */ | |
--item-edge :transparent; /* Menu Item Edge Color */ | |
--item-over :black; /* Menu Item Color On Mouse Over */ | |
--item-over-claw:none; /* Menu Item Shadow Effect On Mouse Over */ | |
--item-over-edge:transparent; /* Menu Item Edge Color On Mouse Over */ | |
--item-over-text:silver; /* Menu Item Text Color On Mouse Over */ | |
--item-text :black; /* Menu Item Text Color */ | |
/* Floating Window */ | |
--float :silver; /* Floating Window Blank/BackGround Color */ | |
--float-edge :transparent; /* Floating Window Edge Color */ | |
--float-text :black; /* Floating Window Text Color */ | |
--float-opacity :90%; /* Floating Window Opacity */ | |
/* Listing TextArea */ | |
--textarea :navy; /* Listing TextArea Blank/BackGround Color */ | |
--textarea-claw :none; /* Listing TextArea Shadow Effect */ | |
--textarea-text :white; /* Listing TextArea Text Color */ | |
--textrows :darkcyan; /* Listing TextArea-Rows Blank/BackGround Color */ | |
--textrows-claw :none; /* Listing TextArea-Rows Shadow Effect */ | |
--textrows-text :black; /* Listing TextArea-Rows Text Color */ | |
/* Status Bar */ | |
--status :darkcyan; /* Status Bar Color */ | |
--status-claw :none; /* Status Bar Shadow Effect */ | |
--status-edge :transparent; /* Status Bar Edge Color */ | |
--status-text :white; /* Status Bar Text Color */ | |
/* Main Window Control Buttons */ | |
--radius :0%; /* Window Control Buttons Rounding Radius */ | |
--mini :white; /* Window Control Button "Collapse" BackGround Color */ | |
--mini-edge :medium silver; /* Window Control Button "Collapse" Edge Style */ | |
--mini-sign :'\25BC'; /* Window Control Button "Collapse" Signature */ | |
--maxi :white; /* Window Control Button "Expanding" BackGround Color */ | |
--maxi-edge :medium silver; /* Window Control Button "Expanding" Edge Style */ | |
--maxi-sign :'\25B4'; /* Window Control Button "Expand" Signature */ | |
--maximal-sign :'\25C6'; /* Window Control Button "Expanded/Restore" Signature */ | |
--quit :white; /* Window Control Button "Exit" BackGround Color */ | |
--quit-edge :medium silver; /* Window Control Button "Exit" Edge Style */ | |
--quit-sign :'\25AD'; /* Window Control Button "Exit" Signature */ | |
/* Graphical Canvas BackGround */ | |
--display-bg :linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee 100%) | |
,linear-gradient(45deg, #eee 25%, white 25%, white 75%, #eee 75%, #eee 100%); | |
} | |
:root.Style2 | |
{ /**********************************/ | |
/*** Macintosh Classic ***/ | |
/**********************************/ | |
/* Caption */ | |
--caption :repeating-linear-gradient(0deg, silver, white 3px); /* Caption BackGround Color */ | |
--caption-claw :none; /* Caption/Title Shadow Effect */ | |
--caption-text :black; /* Caption/Title Text Color */ | |
/* Button */ | |
--button :silver; /* Button Face 3D Color */ | |
--button-edge :silver; /* Button Edge Color */ | |
--button-text :black; /* Button Text Color */ | |
/* Menu Topic */ | |
--menu :linear-gradient(0deg, grey, white); /* Menu Topic Color */ | |
--menu-claw :none; /* Menu Topic Shadow Effect */ | |
--menu-edge :silver; /* Menu Topic Edge Color */ | |
--menu-open :linear-gradient(-90deg, white, grey); /* Menu Topic Openned Color */ | |
--menu-open-claw:2px 2px 2px white; /* Menu Topic Openned Shadow Effect */ | |
--menu-open-edge:silver; /* Menu Topic Openned Edge Color */ | |
--menu-open-text:black; /* Menu Topic Openned Text Color */ | |
--menu-over :linear-gradient(90deg, white, grey); /* Menu Topic Color On Mouse Over */ | |
--menu-over-claw:2px 2px 2px white; /* Menu Topic Shadow Effect On Mouse Over */ | |
--menu-over-edge:silver; /* Menu Topic Edge Color On Mouse Over */ | |
--menu-over-text:black; /* Menu Topic Text Color On Mouse Over */ | |
--menu-push :linear-gradient(-90deg, silver, black); /* Menu Topic Pushed Color */ | |
--menu-push-claw:2px 2px 2px white; /* Menu Topic Pushed Shadow Effect */ | |
--menu-push-edge:silver; /* Menu Topic Pushed Edge Color */ | |
--menu-push-text:black; /* Menu Topic Pushed Text Color */ | |
--menu-text :black; /* Menu Topic Text Color */ | |
/* Menu Topic Item */ | |
--item :silver; /* Menu Item Color */ | |
--item-claw :none; /* Menu Item Shadow Effect */ | |
--item-edge :silver; /* Menu Item Edge Color */ | |
--item-over :linear-gradient(0deg, grey, white); /* Menu Item Color On Mouse Over */ | |
--item-over-claw:2px 2px 2px white; /* Menu Item Shadow Effect On Mouse Over */ | |
--item-over-edge:silver; /* Menu Item Edge Color On Mouse Over */ | |
--item-over-text:black; /* Menu Item Text Color On Mouse Over */ | |
--item-text :black; /* Menu Item Text Color */ | |
/* Floating Window */ | |
--float :silver; /* Floating Window Blank/BackGround Color */ | |
--float-edge :silver; /* Floating Window Edge Color */ | |
--float-text :black; /* Floating Window Text Color */ | |
--float-opacity :90%; /* Floating Window Opacity */ | |
/* Listing TextArea */ | |
--textarea :lightcyan; /* Listing TextArea Blank/BackGround Color */ | |
--textarea-claw :none; /* Listing TextArea Shadow Effect */ | |
--textarea-text :black; /* Listing TextArea Text Color */ | |
--textrows :linear-gradient(90deg, cyan, lightcyan); /* Listing TextArea-Rows Blank/BackGround Color */ | |
--textrows-claw :none; /* Listing TextArea-Rows Shadow Effect */ | |
--textrows-text :black; /* Listing TextArea-Rows Text Color */ | |
/* Status Bar */ | |
--status :linear-gradient(0deg, grey, white); /* Status Bar Color */ | |
--status-claw :none; /* Status Bar Shadow Effect */ | |
--status-edge :silver; /* Status Bar Edge Color */ | |
--status-text :black; /* Status Bar Text Color */ | |
/* Main Window Control Buttons */ | |
--radius :50%; /* Window Control Buttons Rounding Radius */ | |
--mini :linear-gradient(135deg,lightgreen, green); /* Window Control Button "Collapse" BackGround Color */ | |
--mini-edge :thin lightgreen; /* Window Control Button "Collapse" Edge Style */ | |
--mini-sign :'\00A0\00A0'; /* Window Control Button "Collapse" Signature */ | |
--maxi :linear-gradient(135deg, yellow, orange); /* Window Control Button "Expanding" BackGround Color */ | |
--maxi-edge :thin orange; /* Window Control Button "Expanding" Edge Style */ | |
--maxi-sign :'\00A0\00A0'; /* Window Control Button "Expand" Signature */ | |
--maximal-sign :'\00A0\00A0'; /* Window Control Button "Expanded/Restore" Signature */ | |
--quit :linear-gradient(135deg, orange, red); /* Window Control Button "Exit" BackGround Color */ | |
--quit-edge :thin red; /* Window Control Button "Exit" Edge Style */ | |
--quit-sign :'\00A0\00A0'; /* Window Control Button "Exit" Signature */ | |
/* Graphical Canvas BackGround */ | |
--display-bg :linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee 100%) | |
,linear-gradient(45deg, #eee 25%, white 25%, white 75%, #eee 75%, #eee 100%); | |
} | |
:root.Style3 | |
{ /**********************************/ | |
/*** Windows'3.1 - Classic ***/ | |
/**********************************/ | |
/* Caption */ | |
--caption :darkblue; /* Caption BackGround Color */ | |
--caption-claw :none; /* Caption/Title Shadow Effect */ | |
--caption-text :white; /* Caption/Title Text Color */ | |
/* Button */ | |
--button :silver; /* Button Face 3D Color */ | |
--button-edge :silver; /* Button Edge Color */ | |
--button-text :black; /* Button Text Color */ | |
/* Menu Topic */ | |
--menu :silver; /* Menu Topic Color */ | |
--menu-claw :none; /* Menu Topic Shadow Effect */ | |
--menu-edge :silver; /* Menu Topic Edge Color */ | |
--menu-open :blue; /* Menu Topic Openned Color */ | |
--menu-open-claw:none; /* Menu Topic Openned Shadow Effect */ | |
--menu-open-edge:transparent; /* Menu Topic Openned Edge Color */ | |
--menu-open-text:white; /* Menu Topic Openned Text Color */ | |
--menu-over :none; /* Menu Topic Color On Mouse Over */ | |
--menu-over-claw:none; /* Menu Topic Shadow Effect On Mouse Over */ | |
--menu-over-edge:transparent; /* Menu Topic Edge Color On Mouse Over */ | |
--menu-over-text:black; /* Menu Topic Text Color On Mouse Over */ | |
--menu-push :blue; /* Menu Topic Pushed Color */ | |
--menu-push-claw:none; /* Menu Topic Pushed Shadow Effect */ | |
--menu-push-edge:transparent; /* Menu Topic Pushed Edge Color */ | |
--menu-push-text:white; /* Menu Topic Pushed Text Color */ | |
--menu-text :black; /* Menu Topic Text Color */ | |
/* Menu Topic Item */ | |
--item :silver; /* Menu Item Color */ | |
--item-claw :none; /* Menu Item Shadow Effect */ | |
--item-edge :silver; /* Menu Item Edge Color */ | |
--item-over :blue; /* Menu Item Color On Mouse Over */ | |
--item-over-claw:none; /* Menu Item Shadow Effect On Mouse Over */ | |
--item-over-edge:silver; /* Menu Item Edge Color On Mouse Over */ | |
--item-over-text:white; /* Menu Item Text Color On Mouse Over */ | |
--item-text :black; /* Menu Item Text Color */ | |
/* Floating Window */ | |
--float :silver; /* Floating Window Blank/BackGround Color */ | |
--float-edge :silver; /* Floating Window Edge Color */ | |
--float-text :black; /* Floating Window Text Color */ | |
--float-opacity :90%; /* Floating Window Opacity */ | |
/* Listing TextArea */ | |
--textarea :white; /* Listing TextArea Blank/BackGround Color */ | |
--textarea-claw :none; /* Listing TextArea Shadow Effect */ | |
--textarea-text :black; /* Listing TextArea Text Color */ | |
--textrows :grey; /* Listing TextArea-Rows Blank/BackGround Color */ | |
--textrows-claw :none; /* Listing TextArea-Rows Shadow Effect */ | |
--textrows-text :white; /* Listing TextArea-Rows Text Color */ | |
/* Status Bar */ | |
--status :silver; /* Status Bar Color */ | |
--status-claw :none; /* Status Bar Shadow Effect */ | |
--status-edge :silver; /* Status Bar Edge Color */ | |
--status-text :black; /* Status Bar Text Color */ | |
/* Main Window Control Buttons */ | |
--radius :0%; /* Window Control Buttons Rounding Radius */ | |
--mini :white; /* Window Control Button "Collapse" BackGround Color */ | |
--mini-edge :medium silver; /* Window Control Button "Collapse" Edge Style */ | |
--mini-sign :'\25BC'; /* Window Control Button "Collapse" Signature */ | |
--maxi :white; /* Window Control Button "Expanding" BackGround Color */ | |
--maxi-edge :medium silver; /* Window Control Button "Expanding" Edge Style */ | |
--maxi-sign :'\25B4'; /* Window Control Button "Expand" Signature */ | |
--maximal-sign :'\25C6'; /* Window Control Button "Expanded/Restore" Signature */ | |
--quit :white; /* Window Control Button "Exit" BackGround Color */ | |
--quit-edge :medium silver; /* Window Control Button "Exit" Edge Style */ | |
--quit-sign :'\25AD'; /* Window Control Button "Exit" Signature */ | |
/* Graphical Canvas BackGround */ | |
--display-bg :linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee 100%) | |
,linear-gradient(45deg, #eee 25%, white 25%, white 75%, #eee 75%, #eee 100%); | |
} | |
:root.Style4 | |
{ /**********************************/ | |
/*** Windows'3.1 - Dark ***/ | |
/**********************************/ | |
/* Caption */ | |
--caption :darkblue; /* Caption BackGround Color */ | |
--caption-claw :none; /* Caption/Title Shadow Effect */ | |
--caption-text :white; /* Caption/Title Text Color */ | |
/* Button */ | |
--button :silver; /* Button Face 3D Color */ | |
--button-edge :silver; /* Button Edge Color */ | |
--button-text :black; /* Button Text Color */ | |
/* Menu Topic */ | |
--menu :grey; /* Menu Topic Color */ | |
--menu-claw :none; /* Menu Topic Shadow Effect */ | |
--menu-edge :silver; /* Menu Topic Edge Color */ | |
--menu-open :blue; /* Menu Topic Openned Color */ | |
--menu-open-claw:none; /* Menu Topic Openned Shadow Effect */ | |
--menu-open-edge:silver; /* Menu Topic Openned Edge Color */ | |
--menu-open-text:white; /* Menu Topic Openned Text Color */ | |
--menu-over :none; /* Menu Topic Color On Mouse Over */ | |
--menu-over-claw:none; /* Menu Topic Shadow Effect On Mouse Over */ | |
--menu-over-edge:silver; /* Menu Topic Edge Color On Mouse Over */ | |
--menu-over-text:black; /* Menu Topic Text Color On Mouse Over */ | |
--menu-push :blue; /* Menu Topic Pushed Color */ | |
--menu-push-claw:none; /* Menu Topic Pushed Shadow Effect */ | |
--menu-push-edge:silver; /* Menu Topic Pushed Edge Color */ | |
--menu-push-text:black; /* Menu Topic Pushed Text Color */ | |
--menu-text :black; /* Menu Topic Text Color */ | |
/* Menu Topic Item */ | |
--item :grey; /* Menu Item Color */ | |
--item-claw :none; /* Menu Item Shadow Effect */ | |
--item-edge :silver; /* Menu Item Edge Color */ | |
--item-over :blue; /* Menu Item Color On Mouse Over */ | |
--item-over-claw:none; /* Menu Item Shadow Effect On Mouse Over */ | |
--item-over-edge:silver; /* Menu Item Edge Color On Mouse Over */ | |
--item-over-text:white; /* Menu Item Text Color On Mouse Over */ | |
--item-text :black; /* Menu Item Text Color */ | |
/* Floating Window */ | |
--float :black; /* Floating Window Blank/BackGround Color */ | |
--float-edge :grey; /* Floating Window Edge Color */ | |
--float-text :lightgreen; /* Floating Window Text Color */ | |
--float-opacity :90%; /* Floating Window Opacity */ | |
/* Listing TextArea */ | |
--textarea :black; /* Listing TextArea Blank/BackGround Color */ | |
--textarea-claw :none; /* Listing TextArea Shadow Effect */ | |
--textarea-text :white; /* Listing TextArea Text Color */ | |
--textrows :black; /* Listing TextArea-Rows Blank/BackGround Color */ | |
--textrows-claw :none; /* Listing TextArea-Rows Shadow Effect */ | |
--textrows-text :grey; /* Listing TextArea-Rows Text Color */ | |
/* Status Bar */ | |
--status :grey; /* Status Bar Color */ | |
--status-claw :none; /* Status Bar Shadow Effect */ | |
--status-edge :silver; /* Status Bar Edge Color */ | |
--status-text :black; /* Status Bar Text Color */ | |
/* Main Window Control Buttons */ | |
--radius :0%; /* Window Control Buttons Rounding Radius */ | |
--mini :grey; /* Window Control Button "Collapse" BackGround Color */ | |
--mini-edge :medium silver; /* Window Control Button "Collapse" Edge Style */ | |
--mini-sign :'\25BC'; /* Window Control Button "Collapse" Signature */ | |
--maxi :grey; /* Window Control Button "Expanding" BackGround Color */ | |
--maxi-edge :medium silver; /* Window Control Button "Expanding" Edge Style */ | |
--maxi-sign :'\25B4'; /* Window Control Button "Expand" Signature */ | |
--maximal-sign :'\25C6'; /* Window Control Button "Expanded/Restore" Signature */ | |
--quit :grey; /* Window Control Button "Exit" BackGround Color */ | |
--quit-edge :medium silver; /* Window Control Button "Exit" Edge Style */ | |
--quit-sign :'\25AD'; /* Window Control Button "Exit" Signature */ | |
/* Graphical Canvas BackGround */ | |
--display-bg :linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee 100%) | |
,linear-gradient(45deg, #eee 25%, white 25%, white 75%, #eee 75%, #eee 100%); | |
} | |
:root.Style5 | |
{ /**********************************/ | |
/*** Windows'95 - Classic ***/ | |
/**********************************/ | |
/* Caption */ | |
--caption :darkblue; /* Caption BackGround Color */ | |
--caption-claw :none; /* Caption/Title Shadow Effect */ | |
--caption-text :white; /* Caption/Title Text Color */ | |
/* Button */ | |
--button :silver; /* Button Face 3D Color */ | |
--button-edge :silver; /* Button Edge Color */ | |
--button-text :black; /* Button Text Color */ | |
/* Menu Topic */ | |
--menu :silver; /* Menu Topic Color */ | |
--menu-claw :none; /* Menu Topic Shadow Effect */ | |
--menu-edge :silver; /* Menu Topic Edge Color */ | |
--menu-open :blue; /* Menu Topic Openned Color */ | |
--menu-open-claw:none; /* Menu Topic Openned Shadow Effect */ | |
--menu-open-edge:silver; /* Menu Topic Openned Edge Color */ | |
--menu-open-text:white; /* Menu Topic Openned Text Color */ | |
--menu-over :none; /* Menu Topic Color On Mouse Over */ | |
--menu-over-claw:none; /* Menu Topic Shadow Effect On Mouse Over */ | |
--menu-over-edge:silver; /* Menu Topic Edge Color On Mouse Over */ | |
--menu-over-text:black; /* Menu Topic Text Color On Mouse Over */ | |
--menu-push :blue; /* Menu Topic Pushed Color */ | |
--menu-push-claw:none; /* Menu Topic Pushed Shadow Effect */ | |
--menu-push-edge:silver; /* Menu Topic Pushed Edge Color */ | |
--menu-push-text:white; /* Menu Topic Pushed Text Color */ | |
--menu-text :black; /* Menu Topic Text Color */ | |
/* Menu Topic Item */ | |
--item :silver; /* Menu Item Color */ | |
--item-claw :none; /* Menu Item Shadow Effect */ | |
--item-edge :silver; /* Menu Item Edge Color */ | |
--item-over :blue; /* Menu Item Color On Mouse Over */ | |
--item-over-claw:none; /* Menu Item Shadow Effect On Mouse Over */ | |
--item-over-edge:silver; /* Menu Item Edge Color On Mouse Over */ | |
--item-over-text:white; /* Menu Item Text Color On Mouse Over */ | |
--item-text :black; /* Menu Item Text Color */ | |
/* Floating Window */ | |
--float :silver; /* Floating Window Blank/BackGround Color */ | |
--float-edge :silver; /* Floating Window Edge Color */ | |
--float-text :black; /* Floating Window Text Color */ | |
--float-opacity :90%; /* Floating Window Opacity */ | |
/* Listing TextArea */ | |
--textarea :white; /* Listing TextArea Blank/BackGround Color */ | |
--textarea-claw :none; /* Listing TextArea Shadow Effect */ | |
--textarea-text :black; /* Listing TextArea Text Color */ | |
--textrows :grey; /* Listing TextArea-Rows Blank/BackGround Color */ | |
--textrows-claw :none; /* Listing TextArea-Rows Shadow Effect */ | |
--textrows-text :white; /* Listing TextArea-Rows Text Color */ | |
/* Status Bar */ | |
--status :silver; /* Status Bar Color */ | |
--status-claw :none; /* Status Bar Shadow Effect */ | |
--status-edge :silver; /* Status Bar Edge Color */ | |
--status-text :black; /* Status Bar Text Color */ | |
/* Main Window Control Buttons */ | |
--radius :0%; /* Window Control Buttons Rounding Radius */ | |
--mini :white; /* Window Control Button "Collapse" BackGround Color */ | |
--mini-edge :medium silver; /* Window Control Button "Collapse" Edge Style */ | |
--mini-sign :'_'; /* Window Control Button "Collapse" Signature */ | |
--maxi :white; /* Window Control Button "Expanding" BackGround Color */ | |
--maxi-edge :medium silver; /* Window Control Button "Expanding" Edge Style */ | |
--maxi-sign :'\25A1'; /* Window Control Button "Expand" Signature */ | |
--maximal-sign :'\29C9'; /* Window Control Button "Expanded/Restore" Signature */ | |
--quit :white; /* Window Control Button "Exit" BackGround Color */ | |
--quit-edge :medium silver; /* Window Control Button "Exit" Edge Style */ | |
--quit-sign :'X'; /* Window Control Button "Exit" Signature */ | |
/* Graphical Canvas BackGround */ | |
--display-bg :linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee 100%) | |
,linear-gradient(45deg, #eee 25%, white 25%, white 75%, #eee 75%, #eee 100%); | |
} | |
:root.Style6 | |
{ /**********************************/ | |
/*** Windows'95 - Dark ***/ | |
/**********************************/ | |
/* Caption */ | |
--caption :darkblue; /* Caption BackGround Color */ | |
--caption-claw :none; /* Caption/Title Shadow Effect */ | |
--caption-text :white; /* Caption/Title Text Color */ | |
/* Button */ | |
--button :silver; /* Button Face 3D Color */ | |
--button-edge :silver; /* Button Edge Color */ | |
--button-text :black; /* Button Text Color */ | |
/* Menu Topic */ | |
--menu :grey; /* Menu Topic Color */ | |
--menu-claw :none; /* Menu Topic Shadow Effect */ | |
--menu-edge :transparent; /* Menu Topic Edge Color */ | |
--menu-open :blue; /* Menu Topic Openned Color */ | |
--menu-open-claw:none; /* Menu Topic Openned Shadow Effect */ | |
--menu-open-edge:transparent; /* Menu Topic Openned Edge Color */ | |
--menu-open-text:white; /* Menu Topic Openned Text Color */ | |
--menu-over :none; /* Menu Topic Color On Mouse Over */ | |
--menu-over-claw:none; /* Menu Topic Shadow Effect On Mouse Over */ | |
--menu-over-edge:transparent; /* Menu Topic Edge Color On Mouse Over */ | |
--menu-over-text:black; /* Menu Topic Text Color On Mouse Over */ | |
--menu-push :blue; /* Menu Topic Pushed Color */ | |
--menu-push-claw:none; /* Menu Topic Pushed Shadow Effect */ | |
--menu-push-edge:transparent; /* Menu Topic Pushed Edge Color */ | |
--menu-push-text:white; /* Menu Topic Pushed Text Color */ | |
--menu-text :black; /* Menu Topic Text Color */ | |
/* Menu Topic Item */ | |
--item :grey; /* Menu Item Color */ | |
--item-claw :none; /* Menu Item Shadow Effect */ | |
--item-edge :silver; /* Menu Item Edge Color */ | |
--item-over :blue; /* Menu Item Color On Mouse Over */ | |
--item-over-claw:none; /* Menu Item Shadow Effect On Mouse Over */ | |
--item-over-edge:silver; /* Menu Item Edge Color On Mouse Over */ | |
--item-over-text:white; /* Menu Item Text Color On Mouse Over */ | |
--item-text :black; /* Menu Item Text Color */ | |
/* Floating Window */ | |
--float :black; /* Floating Window Blank/BackGround Color */ | |
--float-edge :grey; /* Floating Window Edge Color */ | |
--float-text :lightgreen; /* Floating Window Text Color */ | |
--float-opacity :90%; /* Floating Window Opacity */ | |
/* Listing TextArea */ | |
--textarea :black; /* Listing TextArea Blank/BackGround Color */ | |
--textarea-claw :none; /* Listing TextArea Shadow Effect */ | |
--textarea-text :white; /* Listing TextArea Text Color */ | |
--textrows :grey; /* Listing TextArea-Rows Blank/BackGround Color */ | |
--textrows-claw :none; /* Listing TextArea-Rows Shadow Effect */ | |
--textrows-text :white; /* Listing TextArea-Rows Text Color */ | |
/* Status Bar */ | |
--status :grey; /* Status Bar Color */ | |
--status-claw :none; /* Status Bar Shadow Effect */ | |
--status-edge :silver; /* Status Bar Edge Color */ | |
--status-text :black; /* Status Bar Text Color */ | |
/* Main Window Control Buttons */ | |
--radius :0%; /* Window Control Buttons Rounding Radius */ | |
--mini :silver; /* Window Control Button "Collapse" BackGround Color */ | |
--mini-edge :medium silver; /* Window Control Button "Collapse" Edge Style */ | |
--mini-sign :'_'; /* Window Control Button "Collapse" Signature */ | |
--maxi :silver; /* Window Control Button "Expanding" BackGround Color */ | |
--maxi-edge :medium silver; /* Window Control Button "Expanding" Edge Style */ | |
--maxi-sign :'\25A1'; /* Window Control Button "Expand" Signature */ | |
--maximal-sign :'\29C9'; /* Window Control Button "Expanded/Restore" Signature */ | |
--quit :silver; /* Window Control Button "Exit" BackGround Color */ | |
--quit-edge :medium silver; /* Window Control Button "Exit" Edge Style */ | |
--quit-sign :'X'; /* Window Control Button "Exit" Signature */ | |
/* Graphical Canvas BackGround */ | |
--display-bg :linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee 100%) | |
,linear-gradient(45deg, #eee 25%, white 25%, white 75%, #eee 75%, #eee 100%); | |
} | |
:root.Style7 | |
{ /**********************************/ | |
/*** TurboPascal'7 - Classic ***/ | |
/**********************************/ | |
/* Caption */ | |
--caption :blue; /* Caption BackGround Color */ | |
--caption-claw :none; /* Caption/Title Shadow Effect */ | |
--caption-text :white; /* Caption/Title Text Color */ | |
/* Button */ | |
--button :silver; /* Button Face 3D Color */ | |
--button-edge :silver; /* Button Edge Color */ | |
--button-text :black; /* Button Text Color */ | |
/* Menu Topic */ | |
--menu :darkcyan; /* Menu Topic Color */ | |
--menu-claw :none; /* Menu Topic Shadow Effect */ | |
--menu-edge :transparent; /* Menu Topic Edge Color */ | |
--menu-open :black; /* Menu Topic Openned Color */ | |
--menu-open-claw:none; /* Menu Topic Openned Shadow Effect */ | |
--menu-open-edge:transparent; /* Menu Topic Openned Edge Color */ | |
--menu-open-text:white; /* Menu Topic Openned Text Color */ | |
--menu-over :none; /* Menu Topic Color On Mouse Over */ | |
--menu-over-claw:none; /* Menu Topic Shadow Effect On Mouse Over */ | |
--menu-over-edge:transparent; /* Menu Topic Edge Color On Mouse Over */ | |
--menu-over-text:white; /* Menu Topic Text Color On Mouse Over */ | |
--menu-push :blue; /* Menu Topic Pushed Color */ | |
--menu-push-claw:none; /* Menu Topic Pushed Shadow Effect */ | |
--menu-push-edge:transparent; /* Menu Topic Pushed Edge Color */ | |
--menu-push-text:white; /* Menu Topic Pushed Text Color */ | |
--menu-text :black; /* Menu Topic Text Color */ | |
/* Menu Topic Item */ | |
--item :darkcyan; /* Menu Item Color */ | |
--item-claw :none; /* Menu Item Shadow Effect */ | |
--item-edge :transparent; /* Menu Item Edge Color */ | |
--item-over :black; /* Menu Item Color On Mouse Over */ | |
--item-over-claw:none; /* Menu Item Shadow Effect On Mouse Over */ | |
--item-over-edge:transparent; /* Menu Item Edge Color On Mouse Over */ | |
--item-over-text:white; /* Menu Item Text Color On Mouse Over */ | |
--item-text :black; /* Menu Item Text Color */ | |
/* Floating Window */ | |
--float :teal; /* Floating Window Blank/BackGround Color */ | |
--float-edge :transparent; /* Floating Window Edge Color */ | |
--float-text :white; /* Floating Window Text Color */ | |
--float-opacity :90%; /* Floating Window Opacity */ | |
/* Listing TextArea */ | |
--textarea :navy; /* Listing TextArea Blank/BackGround Color */ | |
--textarea-claw :none; /* Listing TextArea Shadow Effect */ | |
--textarea-text :white; /* Listing TextArea Text Color */ | |
--textrows :blue; /* Listing TextArea-Rows Blank/BackGround Color */ | |
--textrows-claw :none; /* Listing TextArea-Rows Shadow Effect */ | |
--textrows-text :white; /* Listing TextArea-Rows Text Color */ | |
/* Status Bar */ | |
--status :darkcyan; /* Status Bar Color */ | |
--status-claw :none; /* Status Bar Shadow Effect */ | |
--status-edge :transparent; /* Status Bar Edge Color */ | |
--status-text :black; /* Status Bar Text Color */ | |
/* Main Window Control Buttons */ | |
--radius :0%; /* Window Control Buttons Rounding Radius */ | |
--mini :white; /* Window Control Button "Collapse" BackGround Color */ | |
--mini-edge :medium silver; /* Window Control Button "Collapse" Edge Style */ | |
--mini-sign :'\25BC'; /* Window Control Button "Collapse" Signature */ | |
--maxi :white; /* Window Control Button "Expanding" BackGround Color */ | |
--maxi-edge :medium silver; /* Window Control Button "Expanding" Edge Style */ | |
--maxi-sign :'\25B4'; /* Window Control Button "Expand" Signature */ | |
--maximal-sign :'\25C6'; /* Window Control Button "Expanded/Restore" Signature */ | |
--quit :white; /* Window Control Button "Exit" BackGround Color */ | |
--quit-edge :medium silver; /* Window Control Button "Exit" Edge Style */ | |
--quit-sign :'\25AD'; /* Window Control Button "Exit" Signature */ | |
/* Graphical Canvas BackGround */ | |
--display-bg :linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee 100%) | |
,linear-gradient(45deg, #eee 25%, white 25%, white 75%, #eee 75%, #eee 100%); | |
} | |
:root.Style8 | |
{ /**********************************/ | |
/*** Windows'98 - Classic ***/ | |
/**********************************/ | |
/* Caption */ | |
--caption :linear-gradient(45deg, blue, cyan); /* Caption BackGround Color */ | |
--caption-claw :none; /* Caption/Title Shadow Effect */ | |
--caption-text :white; /* Caption/Title Text Color */ | |
/* Button */ | |
--button :silver; /* Button Face 3D Color */ | |
--button-edge :silver; /* Button Edge Color */ | |
--button-text :black; /* Button Text Color */ | |
/* Menu Topic */ | |
--menu :silver; /* Menu Topic Color */ | |
--menu-claw :none; /* Menu Topic Shadow Effect */ | |
--menu-edge :transparent; /* Menu Topic Edge Color */ | |
--menu-open :inherit; /* Menu Topic Openned Color */ | |
--menu-open-claw:2px 2px 2px white; /* Menu Topic Openned Shadow Effect */ | |
--menu-open-edge:silver; /* Menu Topic Openned Edge Color */ | |
--menu-open-text:black; /* Menu Topic Openned Text Color */ | |
--menu-over :none; /* Menu Topic Color On Mouse Over */ | |
--menu-over-claw:none; /* Menu Topic Shadow Effect On Mouse Over */ | |
--menu-over-edge:silver; /* Menu Topic Edge Color On Mouse Over */ | |
--menu-over-text:black; /* Menu Topic Text Color On Mouse Over */ | |
--menu-push :blue; /* Menu Topic Pushed Color */ | |
--menu-push-claw:2px 2px 2px white; /* Menu Topic Pushed Shadow Effect */ | |
--menu-push-edge:transparent; /* Menu Topic Pushed Edge Color */ | |
--menu-push-text:white; /* Menu Topic Pushed Text Color */ | |
--menu-text :black; /* Menu Topic Text Color */ | |
/* Menu Topic Item */ | |
--item :silver; /* Menu Item Color */ | |
--item-claw :none; /* Menu Item Shadow Effect */ | |
--item-edge :silver; /* Menu Item Edge Color */ | |
--item-over :blue; /* Menu Item Color On Mouse Over */ | |
--item-over-claw:none; /* Menu Item Shadow Effect On Mouse Over */ | |
--item-over-edge:silver; /* Menu Item Edge Color On Mouse Over */ | |
--item-over-text:white; /* Menu Item Text Color On Mouse Over */ | |
--item-text :black; /* Menu Item Text Color */ | |
/* Floating Window */ | |
--float :silver; /* Floating Window Blank/BackGround Color */ | |
--float-edge :grey; /* Floating Window Edge Color */ | |
--float-text :black; /* Floating Window Text Color */ | |
--float-opacity :90%; /* Floating Window Opacity */ | |
/* Listing TextArea */ | |
--textarea :white; /* Listing TextArea Blank/BackGround Color */ | |
--textarea-claw :none; /* Listing TextArea Shadow Effect */ | |
--textarea-text :black; /* Listing TextArea Text Color */ | |
--textrows :grey; /* Listing TextArea-Rows Blank/BackGround Color */ | |
--textrows-claw :2px 2px 2px white; /* Listing TextArea-Rows Shadow Effect */ | |
--textrows-text :white; /* Listing TextArea-Rows Text Color */ | |
/* Status Bar */ | |
--status :silver; /* Status Bar Color */ | |
--status-claw :none; /* Status Bar Shadow Effect */ | |
--status-edge :silver; /* Status Bar Edge Color */ | |
--status-text :black; /* Status Bar Text Color */ | |
/* Main Window Control Buttons */ | |
--radius :0%; /* Window Control Buttons Rounding Radius */ | |
--mini :silver; /* Window Control Button "Collapse" BackGround Color */ | |
--mini-edge :medium silver; /* Window Control Button "Collapse" Edge Style */ | |
--mini-sign :'_'; /* Window Control Button "Collapse" Signature */ | |
--maxi :silver; /* Window Control Button "Expanding" BackGround Color */ | |
--maxi-edge :medium silver; /* Window Control Button "Expanding" Edge Style */ | |
--maxi-sign :'\25A1'; /* Window Control Button "Expand" Signature */ | |
--maximal-sign :'\29C9'; /* Window Control Button "Expanded/Restore" Signature */ | |
--quit :silver; /* Window Control Button "Exit" BackGround Color */ | |
--quit-edge :medium silver; /* Window Control Button "Exit" Edge Style */ | |
--quit-sign :'X'; /* Window Control Button "Exit" Signature */ | |
/* Graphical Canvas BackGround */ | |
--display-bg :linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee 100%) | |
,linear-gradient(45deg, #eee 25%, white 25%, white 75%, #eee 75%, #eee 100%); | |
} | |
:root.Style9 | |
{ /**********************************/ | |
/*** Windows'98 - Dark ***/ | |
/**********************************/ | |
/* Caption */ | |
--caption :linear-gradient(45deg, darkblue, blue); /* Caption BackGround Color */ | |
--caption-claw :none; /* Caption/Title Shadow Effect */ | |
--caption-text :white; /* Caption/Title Text Color */ | |
/* Button */ | |
--button :silver; /* Button Face 3D Color */ | |
--button-edge :silver; /* Button Edge Color */ | |
--button-text :black; /* Button Text Color */ | |
/* Menu Topic */ | |
--menu :grey; /* Menu Topic Color */ | |
--menu-claw :none; /* Menu Topic Shadow Effect */ | |
--menu-edge :transparent; /* Menu Topic Edge Color */ | |
--menu-open :inherit; /* Menu Topic Openned Color */ | |
--menu-open-claw:2px 2px 2px silver; /* Menu Topic Openned Shadow Effect */ | |
--menu-open-edge:silver; /* Menu Topic Openned Edge Color */ | |
--menu-open-text:white; /* Menu Topic Openned Text Color */ | |
--menu-over :none; /* Menu Topic Color On Mouse Over */ | |
--menu-over-claw:none; /* Menu Topic Shadow Effect On Mouse Over */ | |
--menu-over-edge:silver; /* Menu Topic Edge Color On Mouse Over */ | |
--menu-over-text:black; /* Menu Topic Text Color On Mouse Over */ | |
--menu-push :blue; /* Menu Topic Pushed Color */ | |
--menu-push-claw:2px 2px 2px white; /* Menu Topic Pushed Shadow Effect */ | |
--menu-push-edge:transparent; /* Menu Topic Pushed Edge Color */ | |
--menu-push-text:white; /* Menu Topic Pushed Text Color */ | |
--menu-text :black; /* Menu Topic Text Color */ | |
/* Menu Topic Item */ | |
--item :grey; /* Menu Item Color */ | |
--item-claw :none; /* Menu Item Shadow Effect */ | |
--item-edge :silver; /* Menu Item Edge Color */ | |
--item-over :blue; /* Menu Item Color On Mouse Over */ | |
--item-over-claw:none; /* Menu Item Shadow Effect On Mouse Over */ | |
--item-over-edge:silver; /* Menu Item Edge Color On Mouse Over */ | |
--item-over-text:white; /* Menu Item Text Color On Mouse Over */ | |
--item-text :black; /* Menu Item Text Color */ | |
/* Floating Window */ | |
--float :black; /* Floating Window Blank/BackGround Color */ | |
--float-edge :grey; /* Floating Window Edge Color */ | |
--float-text :lightgreen; /* Floating Window Text Color */ | |
--float-opacity :90%; /* Floating Window Opacity */ | |
/* Listing TextArea */ | |
--textarea :black; /* Listing TextArea Blank/BackGround Color */ | |
--textarea-claw :none; /* Listing TextArea Shadow Effect */ | |
--textarea-text :white; /* Listing TextArea Text Color */ | |
--textrows :grey; /* Listing TextArea-Rows Blank/BackGround Color */ | |
--textrows-claw :2px 2px 2px white; /* Listing TextArea-Rows Shadow Effect */ | |
--textrows-text :white; /* Listing TextArea-Rows Text Color */ | |
/* Status Bar */ | |
--status :grey; /* Status Bar Color */ | |
--status-claw :none; /* Status Bar Shadow Effect */ | |
--status-edge :silver; /* Status Bar Edge Color */ | |
--status-text :black; /* Status Bar Text Color */ | |
/* Main Window Control Buttons */ | |
--radius :0%; /* Window Control Buttons Rounding Radius */ | |
--mini :silver; /* Window Control Button "Collapse" BackGround Color */ | |
--mini-edge :medium silver; /* Window Control Button "Collapse" Edge Style */ | |
--mini-sign :'_'; /* Window Control Button "Collapse" Signature */ | |
--maxi :silver; /* Window Control Button "Expanding" BackGround Color */ | |
--maxi-edge :medium silver; /* Window Control Button "Expanding" Edge Style */ | |
--maxi-sign :'\25A1'; /* Window Control Button "Expand" Signature */ | |
--maximal-sign :'\29C9'; /* Window Control Button "Expanded/Restore" Signature */ | |
--quit :silver; /* Window Control Button "Exit" BackGround Color */ | |
--quit-edge :medium silver; /* Window Control Button "Exit" Edge Style */ | |
--quit-sign :'X'; /* Window Control Button "Exit" Signature */ | |
/* Graphical Canvas BackGround */ | |
--display-bg :linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee 100%) | |
,linear-gradient(45deg, #eee 25%, white 25%, white 75%, #eee 75%, #eee 100%); | |
} | |
</style> | |
<script type='text/plain' title="Bresenham's x86-line (Quick Interactive Canvas)"> | |
::x86 ; revision 20230323 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; Please, Move Your Mouse over Live | |
; Canvas and Mark Line by Clicking. | |
Line: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
mov rax,0xFFBBCC9900000000 | |
mov eax,[Canvas.y1],[Canvas.x1] ; Canvas Line x1,y1 | |
mov ecx,[Canvas.y2],[Canvas.x2] ; Canvas Line x2,y2 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
add cx,ax | |
sub ecx,eax ; ecx{y2:x2} -= eax{y1:x1} | |
sbb ebx,ebx | |
sub cx,ax | |
sbb bx,bx | |
xor ecx,ebx | |
add cx,bx | |
sub ecx,ebx ; ecx{y2:x2} = abs(y2:x2) | |
or ebx,0x000010001 ; ebx{dy:dx} = sgn(dy:dx) | |
and ebx,0x07FFF7FFF | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
mov edx,ecx | |
ror edx,16 ; edx = abs(dx:dy) | |
mov edi,edx | |
add dx,cx | |
sub edx,ecx | |
sbb esi,esi | |
sub dx,cx | |
sbb si,si ; esi = abs(dx:dy) < abs(dy:dx) | |
movsx esi,si | |
and ecx,esi | |
not esi | |
and edi,esi | |
or ecx,edi ; ecx = {shorter:longer} | |
mov edx,ecx | |
shl ecx,16 | |
mov cx,dx ; ecx = {counter:longer} | |
shr dx,1 ; edx = {delta_err:error} | |
not si | |
mov [length],cx | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.canvas clear | |
.log clear | |
.log length | |
.log " ????????_YYYY_XXXX" | |
.repeat | |
.Step: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.log RAX," YYYY_XXXX" | |
.canvas rax | |
shld edi,edx,16 ; di = HI(edx) | |
add dx,di | |
cmp cx,dx | |
sbb edi,edi | |
and di,cx | |
sub dx,di | |
sar edi,16 | |
or edi,esi | |
and edi,ebx | |
add eax,edi | |
and eax,0x07FFF7FFF | |
sub ecx,0x000010000 | |
.repeat length | |
.log "Coordinates logging..." | |
</script> | |
<script type='text/plain' title="Bresenham's x86-line (Interactive Canvas)"> | |
::x86 ; revision 20230323 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; Please, Move Your Mouse over Live | |
; Canvas and Mark Line by Clicking. | |
Line: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
mov rax,0xFFBBCC9900000000 | |
mov eax,[Canvas.y1],[Canvas.x1] ; Canvas Line x1,y1 | |
mov ecx,[Canvas.y2],[Canvas.x2] ; Canvas Line x2,y2 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
add cx,ax | |
sub ecx,eax ; ecx{y2:x2} -= eax{y1:x1} | |
sbb ebx,ebx | |
sub cx,ax | |
sbb bx,bx | |
xor ecx,ebx | |
add cx,bx | |
sub ecx,ebx ; ecx{y2:x2} = abs(y2:x2) | |
or ebx,0x000010001 ; ebx{dy:dx} = sgn(dy:dx) | |
and ebx,0x07FFF7FFF | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
mov edx,ecx | |
ror edx,16 ; edx = abs(dx:dy) | |
mov edi,edx | |
add dx,cx | |
sub edx,ecx | |
sbb esi,esi | |
sub dx,cx | |
sbb si,si ; esi = abs(dx:dy) < abs(dy:dx) | |
movsx esi,si | |
and ecx,esi | |
not esi | |
and edi,esi | |
or ecx,edi ; ecx = {shorter:longer} | |
mov edx,ecx | |
shl ecx,16 | |
mov cx,dx ; ecx = {counter:longer} | |
shr dx,1 ; edx = {delta_err:error} | |
not si | |
mov length,cx | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.canvas clear | |
.log clear | |
.log length | |
.log " ????????_YYYY_XXXX" | |
.repeat | |
.Step: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.log RAX," YYYY_XXXX" | |
.canvas rax | |
shld edi,edx,16 ; di = HI(edx) | |
add dx,di | |
cmp cx,dx | |
sbb edi,edi | |
and di,cx | |
sub dx,di | |
sar edi,16 | |
or edi,esi | |
and edi,ebx | |
add eax,edi | |
and eax,0x07FFF7FFF | |
sub ecx,0x000010000 | |
.repeat length | |
.log "Coordinates logging..." | |
</script> | |
<script type='text/plain' title="Bresenham's mmx-line (Interactive Canvas)"> | |
::mmx ; revision 20230323 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; Please, Move Your Mouse over Live | |
; Canvas and Mark Line by Clicking. | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
col: .equ 0x_00000000_FFCCAA88 ; color | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
Line: ;movq mm2,[user_y2],[user_x2] ; Canvas Line x2,y2 | |
;psubd mm2,[user_y1],[user_x1] ; Canvas Line x1,y1 | |
movq mm2,[Canvas.y2],[Canvas.x2] ; Canvas Line x2,y2 | |
psubd mm2,[Canvas.y1],[Canvas.x1] ; Canvas Line x1,y1 | |
pxor mm0,mm0 | |
pcmpgtd mm0,mm2 ; { y2:x2 < 0 } | |
pxor mm2,mm0 | |
psubd mm2,mm0 ; { abs(y2:x2 - y1:x1) } | |
pcmpeqd mm1,mm1 ; { -1:-1 } | |
pslld mm0,1 | |
psubd mm0,mm1 ; { sgn(y2:x2 - y1:x1) } | |
movq mm3,mm2 | |
psrlq mm3,32 | |
punpckldq mm3,mm2 | |
movq mm4,mm2 | |
pcmpgtd mm4,mm3 ; { master:slave mask } | |
movq mm1,mm4 | |
pandn mm1,mm0 ; { slave:master directions } | |
pand mm0,mm4 ; { master:slave directions } | |
punpckldq mm4,mm4 | |
pand mm2,mm4 | |
pandn mm4,mm3 | |
por mm2,mm4 ; { length_max:length_min } | |
movq length,mm2 | |
movq mm5,mm2 | |
psrlq mm5,32 ; { delta_err = max_length } | |
movq mm4,[Canvas.y1],[Canvas.x1] ; Load Canvas Start Coordinate | |
movq mm3,mm5 | |
psrld mm3,1 ; { error = delta_err / 2 } | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.log clear | |
.log "Coordinates logging:" | |
.log " YYYYYYYY_XXXXXXXX" | |
.canvas clear | |
.repeat ; { prepare for iterations } | |
.Step: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.log mm4 | |
movq mm6,[col] ; { load pixel-color } | |
punpcklwd mm6,mm0 ; { prepare for mix with x,y-pos } | |
movq mm7,mm4 ; { load x,y-position } | |
packusdw mm7,mm6 ; { pack the color with position } | |
.canvas mm7 ; { set pixel to canvas } | |
paddd mm3,mm5 ; { error += delta_err } | |
movq mm6,mm3 ; { if error > length_min } | |
pcmpgtd mm6,mm2 | |
movq mm7,mm2 | |
pand mm7,mm6 | |
psubd mm3,mm7 ; { then error -= length_min } | |
punpckldq mm6,mm6 | |
pand mm6,mm1 | |
paddd mm4,mm6 ; { then y:x += slave:master } | |
paddd mm4,mm0 ; { y:x += master:slave } | |
.repeat length ; { repeats few times } | |
.Ready: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.log mm4 ; { y:x } | |
.log "Coordinates logging..." | |
</script> | |
<script type='text/plain' subtitle="Bresenham's line to [x,y]-array (mmx)"> | |
::mmx ; revision 20230323 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
x1: .equ 0x_0000007E_00000040 ; y1 = 126, x1 = 64 | |
x2: .equ 0x_00000064_0000005B ; y2 = 100, x2 = 86 | |
col: .equ 0x_00000000_FFCCAA88 ; color | |
Addr: .equ 64000 ; Pixel pointer | |
width: .equ 1280 ; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
Line: movq mm1,[width] | |
punpckldq mm1,mm1 | |
movq mm2,[x2] ; { mm2 = y2:x2 } | |
psubd mm2,[x1] ; { mm2 -= y1:x1 } | |
pxor mm0,mm0 | |
pcmpgtd mm0,mm2 ; { y2:x2 < 0 } | |
pxor mm2,mm0 | |
psubd mm2,mm0 ; { abs(y2:x2 - y1:x1) } | |
pcmpeqd mm7,mm7 ; { -1:-1 } | |
pxor mm1,mm0 | |
psubd mm1,mm0 | |
psrlq mm1,32 | |
por mm1,mm0 | |
pslld mm0,1 | |
psubd mm0,mm7 ; { sgn(y2:x2 - y1:x1) } | |
punpckldq mm0,mm0 | |
psrlq mm0,32 ; { mm0 = dx, mm5 = dy } | |
movq mm3,mm2 | |
psrlq mm3,32 | |
punpckldq mm3,mm2 | |
movq mm5,mm2 | |
movq mm4,mm5 | |
punpckldq mm5,mm5 | |
pand mm2,mm5 | |
pandn mm5,mm3 | |
por mm2,mm5 ; { length_max:length_min } | |
pcmpgtd mm4,mm3 ; { master:slave mask } | |
psrlq mm4,32 | |
punpckldq mm4,mm4 | |
movq mm7,mm4 | |
movq mm6,mm4 | |
movq mm5,mm4 | |
pandn mm4,mm1 ; { slave:master directions } | |
pandn mm6,mm0 | |
pand mm0,mm5 ; { master:slave directions } | |
por mm0,mm4 | |
pand mm1,mm7 | |
por mm1,mm6 | |
movq length,mm2 | |
movq mm5,mm2 | |
psrlq mm5,32 ; { delta_err = max_length } | |
pcmpeqd mm7,mm7 | |
psrlq mm7,32 | |
pand mm0,mm7 | |
pand mm1,mm7 | |
movq mm4,[Addr] | |
movq mm3,mm5 | |
psrld mm3,1 ; { error = delta_err / 2 } | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.log clear | |
.log "Coordinates logging:" | |
.log " YYYYYYYY_XXXXXXXX" | |
.log length | |
.canvas clear | |
.repeat ; { prepare for iterations } | |
.Step: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.log mm4 | |
movq mm6,[col] ; { load pixel-color } | |
punpcklwd mm6,mm0 ; { prepare for mix with x,y-pos } | |
movq mm7,mm4 ; { load x,y-position } | |
packusdw mm7,mm6 ; { pack the color with position } | |
.canvas mm7,width ; { set pixel to canvas } | |
paddd mm3,mm5 ; { error += delta_err } | |
movq mm6,mm3 ; { if error > length_min } | |
pcmpgtd mm6,mm2 | |
movq mm7,mm2 | |
pand mm7,mm6 | |
psubd mm3,mm7 ; { then error -= length_min } | |
punpckldq mm6,mm6 | |
pand mm6,mm1 | |
paddd mm4,mm6 ; { then y:x += slave:master } | |
paddd mm4,mm0 ; { y:x += master:slave } | |
.repeat length ; { repeats few times } | |
.Ready: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.log mm4 ; { y:x } | |
</script> | |
<script type='text/plain' subtitle="Bresenham's line to Pointer-array (mmx)"> | |
::mmx ; revision 20230323 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
x1: .equ 0x_00000029_00000022 ; y1 = 126, x1 = 64 | |
x2: .equ 0x_00000040_00000029 ; y2 = 100, x2 = 86 | |
col: .equ 0x_00000000_FFCCAA88 ; color | |
Addr: .equ 57680 ; Pixel pointer | |
width: .equ 1280 ; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
Line: movq mm1,[width] | |
punpckldq mm1,mm1 | |
movq mm2,[x2] ; { mm2 = y2:x2 } | |
psubd mm2,[x1] ; { mm2 -= y1:x1 } | |
pxor mm0,mm0 | |
pcmpgtd mm0,mm2 ; { y2:x2 < 0 } | |
pxor mm2,mm0 | |
psubd mm2,mm0 ; { abs(y2:x2 - y1:x1) } | |
pcmpeqd mm7,mm7 ; { -1:-1 } | |
pxor mm1,mm0 | |
psubd mm1,mm0 | |
psrlq mm1,32 | |
pslld mm0,1 | |
psubd mm0,mm7 ; { sgn(y2:x2 - y1:x1) } | |
; psrlq mm0,32 ; { mm0 = dx, mm5 = dy } | |
movq mm3,mm2 | |
psrlq mm3,32 | |
punpckldq mm3,mm2 | |
movq mm5,mm2 | |
pcmpgtd mm5,mm3 ; { master:slave mask } | |
punpckldq mm5,mm5 | |
movq mm4,mm5 | |
pand mm2,mm5 | |
pandn mm5,mm3 | |
por mm2,mm5 ; { length_max:length_min } | |
psrlq mm4,32 | |
punpckldq mm4,mm4 | |
movq mm7,mm4 | |
movq mm6,mm4 | |
movq mm5,mm4 | |
pandn mm4,mm1 ; { slave:master directions } | |
pandn mm6,mm0 | |
pand mm0,mm5 ; { master:slave directions } | |
por mm0,mm4 | |
pand mm1,mm7 | |
por mm1,mm6 | |
movq length,mm2 | |
movq mm5,mm2 | |
psrlq mm5,32 ; { delta_err = max_length } | |
pcmpeqd mm7,mm7 | |
psrlq mm7,32 | |
pand mm0,mm7 | |
pand mm1,mm7 | |
movq mm4,[Addr] | |
movq mm3,mm5 | |
psrld mm3,1 ; { error = delta_err / 2 } | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.log clear | |
.log "Coordinates logging:" | |
.log " YYYYYYYY_XXXXXXXX" | |
.log length | |
.canvas clear | |
.repeat ; { prepare for iterations } | |
.Step: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.log mm4 | |
movq mm6,[col] ; { load pixel-color } | |
punpckldq mm6,mm6 ; { prepare for mix with x,y-pos } | |
movq mm7,mm4 ; { load x,y-position } | |
punpckldq mm7,mm6 ; { pack the color with position } | |
.canvas mm7,width ; { set pixel to canvas } | |
paddd mm3,mm5 ; { error += delta_err } | |
movq mm6,mm3 ; { if error > length_min } | |
pcmpgtd mm6,mm2 | |
movq mm7,mm2 | |
pand mm7,mm6 | |
psubd mm3,mm7 ; { then error -= length_min } | |
punpckldq mm6,mm6 | |
pand mm6,mm1 | |
paddd mm4,mm6 ; { then y:x += slave:master } | |
paddd mm4,mm0 ; { y:x += master:slave } | |
.repeat length ; { repeats few times } | |
.Ready: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.log mm4 ; { y:x } | |
</script> | |
<script type='text/plain' subtitle="Bresenham's line to [x,y]-array (x86)"> | |
::x86 ; revision 20230323 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
Line: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
mov rax,0xFFBBCC9900000000 | |
mov eax,0x0005F000E ; eax = {y1:y1} | |
mov ecx,0x000590018 ; ecx = {y2:x2} | |
mov eax,[user_y1],[user_x1] | |
mov ecx,[user_y2],[user_x2] | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
add cx,ax | |
sub ecx,eax ; ecx{y2:x2} -= eax{y1:x1} | |
sbb ebx,ebx | |
sub cx,ax | |
sbb bx,bx | |
xor ecx,ebx | |
add cx,bx | |
sub ecx,ebx ; ecx{y2:x2} = abs(y2:x2) | |
or ebx,0x000010001 ; ebx{dy:dx} = sgn(dy:dx) | |
and ebx,0x07FFF7FFF | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
mov edx,ecx | |
ror edx,16 ; edx = abs(dx:dy) | |
mov edi,edx | |
add dx,cx | |
sub edx,ecx | |
sbb esi,esi | |
sub dx,cx | |
sbb si,si ; esi = abs(dx:dy) < abs(dy:dx) | |
movsx esi,si | |
and ecx,esi | |
not esi | |
and edi,esi | |
or ecx,edi ; ecx = {shorter:longer} | |
mov edx,ecx | |
shl ecx,16 | |
mov cx,dx ; ecx = {counter:longer} | |
shr dx,1 ; edx = {delta_err:error} | |
not si | |
mov length,cx | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.canvas clear | |
.log clear | |
.log length | |
.log " ????????_YYYY_XXXX" | |
.repeat | |
.Step: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.log RAX | |
.canvas rax | |
shld edi,edx,16 | |
add dx,di | |
cmp cx,dx | |
sbb edi,edi | |
and di,cx | |
sub dx,di | |
sar edi,16 | |
or edi,esi | |
and edi,ebx | |
add eax,edi | |
and eax,0x07FFF7FFF | |
sub ecx,0x000010000 | |
.repeat length | |
.log "Coordinates logging..." | |
</script> | |
<script type='text/plain' title="i8080 24-bits Multiplication test"> | |
::x86 ; revision 20230323 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.SHOW AUTO | |
LXI SP,075FFH | |
LXI H,0A009H | |
MVI A,014H ; AHL = 1351689 | |
MVI E,0FFH | |
;;;;;;;;;;;;;;;;;;;;;;; | |
; HLDE = AHL * 10 + E | |
;;;;;;;;;;;;;;;;;;;;;;; | |
MUL10: | |
PUSH PSW ; 10 | |
XRA A ; 4 | |
MOV D,A ; 5 | |
MOV B,H ; 5 | |
MOV C,L ; 5 | |
DAD H ; 11 | |
ADC A ; 4 AHL x= 2 | |
DAD H ; 11 | |
ADC A ; 4 AHL x= 4 | |
DAD B ; 11 | |
ADC D ; 7 AHL x= 5 | |
DAD H ; 11 | |
ADC A ; 4 AHL *= 10 | |
DAD D ; 11 | |
ADC D ; 4 AHL += E | |
XCHG ; 4 ADE = HL * 10 + E | |
POP H ; 11 | |
MOV L,H ; 5 | |
MVI H,000H ; 7 | |
MOV B,H ; 5 | |
MOV C,L ; 5 | |
DAD H ; 11 | |
DAD H ; 11 | |
DAD B ; 11 | |
DAD H ; 11 | |
MOV C,A ; 5 | |
MVI B,000H ; 7 | |
DAD B ; 11 = 208 | |
; L = 0xCE, D = 0x41, E = 0x59 | |
; LDE = 13517145 | |
</script> | |
<script> | |
const pExamples = Object.fromEntries(Array.from(document.querySelectorAll("script[type='text/plain'][title]")).map(script => [script.title, script.textContent])); | |
</script> | |
<script title='gists'> | |
var linkTo | |
= { | |
gist :{ | |
host :"https://gist.githubusercontent.com/Alikberov", | |
list :"/66bb9698f58765031522c600dda55260/raw/koy-mac-catalogue.txt" | |
} | |
}; | |
</script> | |
<script title='Hexadecimaler'> | |
Number.prototype.toHex = function(n) { | |
return (n < 0 ? "0x" : "") + ("0000000" + this.toString(16)).substr(-Math.abs(n)).toUpperCase(); | |
} | |
</script> | |
<script> | |
const hRefresh = setTimeout | |
(function() { | |
window.location = ""; | |
}, 30000); | |
window.addEventListener("mouseover", | |
function() { | |
clearTimeout(hRefresh); | |
} | |
); | |
if(window.location.protocol != "file:") | |
clearTimeout(hRefresh); | |
</script> | |
<script title='Interface Elements Handles'> | |
var hCaption; // Main Caption Bar | |
var hCaptionMenu; // Menu under Caption Bar | |
var hCaptionTopics; // | |
var hStatus; // Main Status Bar | |
var hListingRows; // Main Listing Lines numbers | |
var hListing; // Main Listing TextArea | |
var hFilesGists; // Gists list | |
var hFilesExamples; // Examples list | |
var hDebugger; | |
var hDisplay; | |
var hDisplay_Status; | |
var hScreen; | |
var hClock; | |
var hGraphic; | |
var hUserPad; | |
var hEmuDump; | |
var hEmuDis; | |
var hRegs_X80; | |
var hRegs_X64; | |
var hRegs_X86; | |
var hRegs_MMX; | |
var hRegs_SSE; | |
var hPseudos; | |
var hEmuLog; | |
var hProgressBar; | |
var hFiles; | |
var hImageFiles; | |
var hIteration; // Logging Slider | |
var nIteration = 0; | |
var editStatus = 0; | |
var hRefreshAssm = 0; | |
var hSliders; | |
function init() { | |
hCaption = document.getElementById("Caption"); | |
hCaptionMenu = document.getElementById("CaptionMenu"); | |
hCaptionTopics = document.getElementsByName("CaptionTopic"); | |
hFilesGists = document.getElementById("FilesGists"); | |
hFilesExamples = document.getElementById("FilesExamples"); | |
hStatus = document.getElementById("Status"); | |
hListingRows = document.getElementById("ListingRows"); | |
hListing = document.getElementById("Listing"); | |
hFiles = document.getElementById("Files"); | |
hDebugger = document.getElementById("Debugger"); | |
hUserPad = document.getElementById("UserPad"); | |
hSprites = document.getElementById("Sprites"); | |
hDisplay_Status = document.getElementById("Display_Status"); | |
hDisplay = document.getElementById("Display").getContext("2d"); | |
hScreen = document.getElementById("Screen").getContext("2d"); | |
hGraphic = hScreen.getImageData(0, 0, hScreen.canvas.width, hScreen.canvas.height); | |
hImageFiles = document.getElementById("ImageFiles"); | |
hProgressBar = document.getElementById("ProgressBar"); | |
hEmuDump = document.getElementById("EmuDump"); | |
hEmuDis = document.getElementById("EmuDis"); | |
hRegs_X80 = document.getElementById("Regs_X80"); | |
hRegs_X64 = document.getElementById("Regs_X64"); | |
hRegs_X86 = document.getElementById("Regs_X86"); | |
hRegs_MMX = document.getElementById("Regs_MMX"); | |
hRegs_SSE = document.getElementById("Regs_SSE"); | |
hPseudos = document.getElementById("Pseudos"); | |
hRegs_MMX.addEventListener("keydown", Ctx_KeyDown); | |
hRegs_MMX.addEventListener("keyup", Ctx_KeyUp); | |
hRegs_MMX.addEventListener("selectstart", Ctx_SelectStart); | |
hEmuLog = document.getElementById("EmuLog"); | |
hIteration = document.getElementById("Iteration"); | |
hEllipsys = document.getElementById("FilEllipsys"); | |
hMainMenu = document.getElementById("MenuBar"); | |
hStylers = document.getElementsByName("Styling"); | |
hSliders = document.getElementsByName("Sliders"); | |
for(var i = 0; i < hSliders.length; ++ i) { | |
if(("Slider" + i) in window.localStorage) | |
hSliders[i].value = Number(window.localStorage["Slider" + i]); | |
hSliders[i].dataset.index = i; | |
hSliders[i].addEventListener("input", (evt) => { window.localStorage["Slider" + evt.srcElement.dataset.index] = evt.srcElement.value; }); | |
hSliders[i].addEventListener("change", (evt) => { window.localStorage["Slider" + evt.srcElement.dataset.index] = evt.srcElement.value; Execute_Program(); }); | |
} | |
} | |
</script> | |
<script title='Draggable elements'> | |
function MakeDraggable(el, x, y) { | |
const position_suffix = "_Position"; | |
const header_suffix = "_Header"; | |
var last = {}, that = {}; | |
tmp = el.id + position_suffix; | |
if(el && (tmp in window.localStorage)) { | |
tmp = window.localStorage[tmp].split(","); | |
x = Number(tmp[0]), y = Number(tmp[1]); | |
if(x < 0) | |
x = 0; | |
else | |
if(x > window.innerWidth - el.offsetWidth) | |
x = window.innerWidth - el.offsetWidth; | |
if(y < hCaption.offsetHeight) | |
y = hCaption.offsetHeight; | |
else | |
if(y > window.innerHeight - hStatus.offsetHeight - el.offsetHeight) | |
y = window.innerHeight - hStatus.offsetHeight - el.offsetHeight; | |
el.style.top = y + "px"; | |
el.style.left = x + "px"; | |
} else | |
el.style.top = y + "px", | |
el.style.left = x + "px"; | |
if(tmp = el.getElementsByTagName("header")) | |
tmp[0].addEventListener("mousedown", StartDragging); | |
else | |
el.addEventListener("mousedown", StartDragging); | |
function StartDragging(e) { | |
e = e || window.event; | |
e.preventDefault(); | |
// get the mouse cursor position at startup:; | |
last = {x: e.clientX, y: e.clientY}; | |
if(e.srcElement.localName == "div") { | |
e.srcElement.parentElement.insertBefore(e.srcElement, e.srcElement.parentElement.children[e.srcElement.parentElement.children.length - 1].nextSibling); | |
} else { | |
e.srcElement.parentElement.parentElement.insertBefore(e.srcElement.parentElement, e.srcElement.parentElement.parentElement.children[e.srcElement.parentElement.parentElement.children.length - 1].nextSibling); | |
} | |
document.onmouseup = DragFinish; | |
// call a function whenever the cursor moves: | |
document.onmousemove = DragElement; | |
} | |
function DragElement(e) { | |
e = e || window.event; | |
e.preventDefault(); | |
// calculate the new cursor position: | |
that = {x: last.x - e.clientX, y: last.y - e.clientY}; | |
last = {x: e.clientX, y: e.clientY}; | |
// set the element's new position: | |
x = el.offsetLeft - that.x; | |
y = el.offsetTop - that.y; | |
if(x < 0) | |
x = 0; | |
else | |
if(x > window.innerWidth - el.offsetWidth) | |
x = window.innerWidth - el.offsetWidth; | |
if(y < hCaption.offsetHeight) | |
y = hCaption.offsetHeight; | |
else | |
if(y > window.innerHeight - hStatus.offsetHeight - el.offsetHeight) | |
y = window.innerHeight - hStatus.offsetHeight - el.offsetHeight; | |
el.style.top = y + "px"; | |
el.style.left = x + "px"; | |
window.localStorage[el.id + position_suffix] = [x, y].join(); | |
} | |
function DragFinish(e) { | |
e = e || window.event; | |
// stop moving when mouse button is released: | |
document.onmouseup = null; | |
document.onmousemove = null; | |
if(e.srcElement.localName == "div") | |
e.srcElement.style.zIndex = ""; | |
else | |
if(e.srcElement.parentElement) | |
e.srcElement.parentElement.style.zIndex = ""; | |
} | |
} | |
</script> | |
<script> | |
const Shell = { | |
CANVAS | |
:{ | |
X1 :() => { return Number(hDisplay.canvas.dataset.x1); }, | |
Y1 :() => { return Number(hDisplay.canvas.dataset.y1); }, | |
X2 :() => { return Number(hDisplay.canvas.dataset.x2); }, | |
Y2 :() => { return Number(hDisplay.canvas.dataset.y2); }, | |
}, | |
SLIDER1 :() => { return Number(document.getElementsByName("Sliders")[0].value); }, | |
SLIDER2 :() => { return Number(document.getElementsByName("Sliders")[1].value); }, | |
SLIDER3 :() => { return Number(document.getElementsByName("Sliders")[2].value); }, | |
SLIDER4 :() => { return Number(document.getElementsByName("Sliders")[3].value); }, | |
SLIDER5 :() => { return Number(document.getElementsByName("Sliders")[4].value); }, | |
SLIDER6 :() => { return Number(document.getElementsByName("Sliders")[5].value); }, | |
SLIDER7 :() => { return Number(document.getElementsByName("Sliders")[6].value); }, | |
SLIDER8 :() => { return Number(document.getElementsByName("Sliders")[7].value); } | |
} | |
</script> | |
<script> | |
const getters32 = { | |
right :function() { return 0x0F & this; }, | |
left :function() { return 0x0F & (this >> 4); }, | |
low :function() { return 0xFF & this; }, | |
high :function() { return 0xFF & (this >> 8); }, | |
isNum :function() { return (this & 15) <= 9; }, | |
isReg :function() { return (this & 15) >= 0xA && (this & 15) <= 0xD; }, | |
isDec :function() { return (this & 15) <= 9 && ((this >> 4) & 15) <= 9 && this > 0; } | |
}; | |
function get64_width(_) { | |
return this.WIDTH; | |
} | |
function get64_RAX(_) { | |
var n = BigInt(this[0]); n.WIDTH = 64; return n; | |
} | |
const getters64 = { | |
MASK_B :function() { return BigInt(0x7F7F7F7F7F7F7F7F); }, | |
MASK_W :function() { return BigInt(0x7FFF7FFF7FFF7FFF); }, | |
MASK_D :function() { return BigInt(0x7FFFFFFF7FFFFFFF); }, | |
MASK_Q :function() { return BigInt(0x7FFFFFFFFFFFFFFF); }, | |
width :get64_width//function() { return this.WIDTH; } | |
}; | |
const X64_getters = { | |
RAX :get64_RAX,//function() { var n = this[0]; n.WIDTH = 64; return n; }, | |
EAX :function() { return (this[0] & BigInt(0xFFFFFFFF)) | BigInt(this.SIGNED && (this[0] & BigInt(0x80000000)) ? 0xFFFFFFFF00000000n : 0); }, | |
AX :function() { return (this[0] & BigInt(0xFFFF)) | BigInt(this.SIGNED && (this[0] & BigInt(0x8000)) ? 0xFFFFFFFFFFFF0000n : 0); }, | |
PSW :function() { return ((this[0] & BigInt(0xFF)) << BigInt(8)) | (this[16] & BigInt(0xFF)); }, | |
AL :function() { return (this[0] & BigInt(0xFF)) | BigInt(this.SIGNED && (this[0] & BigInt(0x80)) ? 0xFFFFFFFFFFFFFF00n : 0); }, | |
A :function() { return (this[0] & BigInt(0xFF)) | BigInt(this.SIGNED && (this[0] & BigInt(0x80)) ? 0xFFFFFFFFFFFFFF00n : 0); }, | |
AH :function() { return ((this[0] >> BigInt(8)) & BigInt(0xFF)) | BigInt(this.SIGNED && (this[0] & BigInt(0x8000)) ? 0xFFFFFFFFFFFFFF00n : 0); }, | |
RBX :function() { return this[3]; }, | |
EBX :function() { return (this[3] & BigInt(0xFFFFFFFF)) | BigInt(this.SIGNED && (this[3] & BigInt(0x80000000)) ? 0xFFFFFFFF00000000n : 0); }, | |
BX :function() { return (this[3] & BigInt(0xFFFF)) | BigInt(this.SIGNED && (this[3] & BigInt(0x8000)) ? 0xFFFFFFFFFFFF0000n : 0); }, | |
HL :function() { return (this[3] & BigInt(0xFFFF)) | BigInt(this.SIGNED && (this[3] & BigInt(0x8000)) ? 0xFFFFFFFFFFFF0000n : 0); }, | |
BL :function() { return (this[3] & BigInt(0xFF)) | BigInt(this.SIGNED && (this[3] & BigInt(0x80)) ? 0xFFFFFFFFFFFFFF00n : 0); }, | |
L :function() { return (this[3] & BigInt(0xFF)) | BigInt(this.SIGNED && (this[3] & BigInt(0x80)) ? 0xFFFFFFFFFFFFFF00n : 0); }, | |
BH :function() { return ((this[3] >> BigInt(8)) & BigInt(0xFF)) | BigInt(this.SIGNED && (this[3] & BigInt(0x8000)) ? 0xFFFFFFFFFFFFFF00n : 0); }, | |
H :function() { return ((this[3] >> BigInt(8)) & BigInt(0xFF)) | BigInt(this.SIGNED && (this[3] & BigInt(0x8000)) ? 0xFFFFFFFFFFFFFF00n : 0); }, | |
RCX :function() { return this[1]; }, | |
ECX :function() { return (this[1] & BigInt(0xFFFFFFFF)) | BigInt(this.SIGNED && (this[1] & BigInt(0x80000000)) ? 0xFFFFFFFF00000000n : 0); }, | |
CX :function() { return (this[1] & BigInt(0xFFFF)) | BigInt(this.SIGNED && (this[1] & BigInt(0x8000)) ? 0xFFFFFFFFFFFF0000n : 0); }, | |
BC :function() { return (this[1] & BigInt(0xFFFF)) | BigInt(this.SIGNED && (this[1] & BigInt(0x8000)) ? 0xFFFFFFFFFFFF0000n : 0); }, | |
CL :function() { return (this[1] & BigInt(0xFF)) | BigInt(this.SIGNED && (this[1] & BigInt(0x80)) ? 0xFFFFFFFFFFFFFF00n : 0); }, | |
C :function() { return (this[1] & BigInt(0xFF)) | BigInt(this.SIGNED && (this[1] & BigInt(0x80)) ? 0xFFFFFFFFFFFFFF00n : 0); }, | |
CH :function() { return ((this[1] >> BigInt(8)) & BigInt(0xFF)) | BigInt(this.SIGNED && (this[1] & BigInt(0x8000)) ? 0xFFFFFFFFFFFFFF00n : 0); }, | |
B :function() { return ((this[1] >> BigInt(8)) & BigInt(0xFF)) | BigInt(this.SIGNED && (this[1] & BigInt(0x8000)) ? 0xFFFFFFFFFFFFFF00n : 0); }, | |
RDX :function() { return this[2]; }, | |
EDX :function() { return (this[2] & BigInt(0xFFFFFFFF)) | BigInt(this.SIGNED && (this[2] & BigInt(0x80000000)) ? 0xFFFFFFFF00000000n : 0); }, | |
DX :function() { return (this[2] & BigInt(0xFFFF)) | BigInt(this.SIGNED && (this[2] & BigInt(0x8000)) ? 0xFFFFFFFFFFFF0000n : 0); }, | |
DE :function() { return (this[2] & BigInt(0xFFFF)) | BigInt(this.SIGNED && (this[2] & BigInt(0x8000)) ? 0xFFFFFFFFFFFF0000n : 0); }, | |
DL :function() { return (this[2] & BigInt(0xFF)) | BigInt(this.SIGNED && (this[2] & BigInt(0x80)) ? 0xFFFFFFFFFFFFFF00n : 0); }, | |
E :function() { return (this[2] & BigInt(0xFF)) | BigInt(this.SIGNED && (this[2] & BigInt(0x80)) ? 0xFFFFFFFFFFFFFF00n : 0); }, | |
DH :function() { return ((this[2] >> BigInt(8)) & BigInt(0xFF)) | BigInt(this.SIGNED && (this[2] & BigInt(0x8000)) ? 0xFFFFFFFFFFFFFF00n : 0); }, | |
D :function() { return ((this[2] >> BigInt(8)) & BigInt(0xFF)) | BigInt(this.SIGNED && (this[2] & BigInt(0x8000)) ? 0xFFFFFFFFFFFFFF00n : 0); }, | |
RSP :function() { return this[4]; }, | |
ESP :function() { return (this[4] & BigInt(0xFFFFFFFF)) | BigInt(this.SIGNED && (this[4] & BigInt(0x80000000)) ? 0xFFFFFFFF00000000n : 0); }, | |
SP :function() { return (this[4] & BigInt(0xFFFF)) | BigInt(this.SIGNED && (this[4] & BigInt(0x8000)) ? 0xFFFFFFFFFFFF0000n : 0); }, | |
RBP :function() { return this[5]; }, | |
EBP :function() { return (this[5] & BigInt(0xFFFFFFFF)) | BigInt(this.SIGNED && (this[5] & BigInt(0x80000000)) ? 0xFFFFFFFF00000000n : 0); }, | |
BP :function() { return (this[5] & BigInt(0xFFFF)) | BigInt(this.SIGNED && (this[5] & BigInt(0x8000)) ? 0xFFFFFFFFFFFF0000n : 0); }, | |
RSI :function() { return this[6]; }, | |
ESI :function() { return (this[6] & BigInt(0xFFFFFFFF)) | BigInt(this.SIGNED && (this[6] & BigInt(0x80000000)) ? 0xFFFFFFFF00000000n : 0); }, | |
SI :function() { return (this[6] & BigInt(0xFFFF)) | BigInt(this.SIGNED && (this[6] & BigInt(0x8000)) ? 0xFFFFFFFFFFFF0000n : 0); }, | |
RDI :function() { return this[7]; }, | |
EDI :function() { return (this[7] & BigInt(0xFFFFFFFF)) | BigInt(this.SIGNED && (this[7] & BigInt(0x80000000)) ? 0xFFFFFFFF00000000n : 0); }, | |
DI :function() { return (this[7] & BigInt(0xFFFF)) | BigInt(this.SIGNED && (this[7] & BigInt(0x8000)) ? 0xFFFFFFFFFFFF0000n : 0); }, | |
R0 :function() { return this[0]; }, | |
R1 :function() { return this[1]; }, | |
R2 :function() { return this[2]; }, | |
R3 :function() { return this[3]; }, | |
R4 :function() { return this[4]; }, | |
R5 :function() { return this[5]; }, | |
R6 :function() { return this[6]; }, | |
R7 :function() { return this[7]; }, | |
R8 :function() { return this[8]; }, | |
R9 :function() { return this[9]; }, | |
R10 :function() { return this[10]; }, | |
R11 :function() { return this[11]; }, | |
R12 :function() { return this[12]; }, | |
R13 :function() { return this[13]; }, | |
R14 :function() { return this[14]; }, | |
R15 :function() { return this[15]; }, | |
RFX :function() { return this[16]; }, | |
MM0 :function() { return this[20]; }, | |
MM1 :function() { return this[21]; }, | |
MM2 :function() { return this[22]; }, | |
MM3 :function() { return this[23]; }, | |
MM4 :function() { return this[24]; }, | |
MM5 :function() { return this[25]; }, | |
MM6 :function() { return this[26]; }, | |
MM7 :function() { return this[27]; }, | |
SIGNED :function() { this.SIGNED = true; return this; } | |
}; | |
const X64_setters = { | |
RAX :function(x) { this[0] = BigInt(x); }, | |
EAX :function(x) { this[0] = (BigInt(this[0]) & BigInt(0xFFFFFFFF00000000n)) | (BigInt(0xFFFFFFFF) & BigInt(x)); }, | |
AX :function(x) { this[0] = (BigInt(this[0]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); }, | |
PSW :function(x) { this[16] = (BigInt(this[16]) & BigInt(0xFFFFFFFFFFFFFF00n)) | (BigInt(0x000000FF) & BigInt(x)); | |
this[0] = (BigInt(this[0]) & BigInt(0xFFFFFFFFFFFFFF00n)) | ((BigInt(0x0000FF00) & BigInt(x)) >> BigInt(8)); }, | |
AL :function(x) { this[0] = (BigInt(this[0]) & BigInt(0xFFFFFFFFFFFFFF00n)) | (BigInt(0x000000FF) & BigInt(x)); }, | |
A :function(x) { this[0] = (BigInt(this[0]) & BigInt(0xFFFFFFFFFFFFFF00n)) | (BigInt(0x000000FF) & BigInt(x)); }, | |
AH :function(x) { this[0] = (BigInt(this[0]) & BigInt(0xFFFFFFFFFFFF00FFn)) | ((BigInt(0x000000FF) & BigInt(x)) << BigInt(8)); }, | |
RBX :function(x) { this[3] = BigInt(x); }, | |
EBX :function(x) { this[3] = (BigInt(this[3]) & BigInt(0xFFFFFFFF00000000n)) | (BigInt(0xFFFFFFFF) & BigInt(x)); }, | |
BX :function(x) { this[3] = (BigInt(this[3]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); }, | |
HL :function(x) { this[3] = (BigInt(this[3]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); }, | |
BL :function(x) { this[3] = (BigInt(this[3]) & BigInt(0xFFFFFFFFFFFFFF00n)) | (BigInt(0x000000FF) & BigInt(x)); }, | |
L :function(x) { this[3] = (BigInt(this[3]) & BigInt(0xFFFFFFFFFFFFFF00n)) | (BigInt(0x000000FF) & BigInt(x)); }, | |
BH :function(x) { this[3] = (BigInt(this[3]) & BigInt(0xFFFFFFFFFFFF00FFn)) | ((BigInt(0x000000FF) & BigInt(x)) << BigInt(8)); }, | |
H :function(x) { this[3] = (BigInt(this[3]) & BigInt(0xFFFFFFFFFFFF00FFn)) | ((BigInt(0x000000FF) & BigInt(x)) << BigInt(8)); }, | |
RCX :function(x) { this[1] = BigInt(x); }, | |
ECX :function(x) { this[1] = (BigInt(this[1]) & BigInt(0xFFFFFFFF00000000n)) | (BigInt(0xFFFFFFFF) & BigInt(x)); }, | |
CX :function(x) { this[1] = (BigInt(this[1]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); }, | |
BC :function(x) { this[1] = (BigInt(this[1]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); }, | |
CL :function(x) { this[1] = (BigInt(this[1]) & BigInt(0xFFFFFFFFFFFFFF00n)) | (BigInt(0x000000FF) & BigInt(x)); }, | |
C :function(x) { this[1] = (BigInt(this[1]) & BigInt(0xFFFFFFFFFFFFFF00n)) | (BigInt(0x000000FF) & BigInt(x)); }, | |
CH :function(x) { this[1] = (BigInt(this[1]) & BigInt(0xFFFFFFFFFFFF00FFn)) | ((BigInt(0x000000FF) & BigInt(x)) << BigInt(8)); }, | |
B :function(x) { this[1] = (BigInt(this[1]) & BigInt(0xFFFFFFFFFFFF00FFn)) | ((BigInt(0x000000FF) & BigInt(x)) << BigInt(8)); }, | |
RDX :function(x) { this[2] = BigInt(x); }, | |
EDX :function(x) { this[2] = (BigInt(this[2]) & BigInt(0xFFFFFFFF00000000n)) | (BigInt(0xFFFFFFFF) & BigInt(x)); }, | |
DX :function(x) { this[2] = (BigInt(this[2]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); }, | |
DE :function(x) { this[2] = (BigInt(this[2]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); }, | |
DL :function(x) { this[2] = (BigInt(this[2]) & BigInt(0xFFFFFFFFFFFFFF00n)) | (BigInt(0x000000FF) & BigInt(x)); }, | |
E :function(x) { this[2] = (BigInt(this[2]) & BigInt(0xFFFFFFFFFFFFFF00n)) | (BigInt(0x000000FF) & BigInt(x)); }, | |
DH :function(x) { this[2] = (BigInt(this[2]) & BigInt(0xFFFFFFFFFFFF00FFn)) | ((BigInt(0x000000FF) & BigInt(x)) << BigInt(8)); }, | |
D :function(x) { this[2] = (BigInt(this[2]) & BigInt(0xFFFFFFFFFFFF00FFn)) | ((BigInt(0x000000FF) & BigInt(x)) << BigInt(8)); }, | |
RSP :function(x) { this[4] = BigInt(x); }, | |
ESP :function(x) { this[4] = (BigInt(this[4]) & BigInt(0xFFFFFFFF00000000n)) | (BigInt(0xFFFFFFFF) & BigInt(x)); }, | |
SP :function(x) { this[4] = (BigInt(this[4]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); }, | |
RBP :function(x) { this[5] = BigInt(x); }, | |
EBP :function(x) { this[5] = (BigInt(this[5]) & BigInt(0xFFFFFFFF00000000n)) | (BigInt(0xFFFFFFFF) & BigInt(x)); }, | |
BP :function(x) { this[5] = (BigInt(this[5]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); }, | |
RSI :function(x) { this[6] = BigInt(x); }, | |
ESI :function(x) { this[6] = (BigInt(this[6]) & BigInt(0xFFFFFFFF00000000n)) | (BigInt(0xFFFFFFFF) & BigInt(x)); }, | |
SI :function(x) { this[6] = (BigInt(this[6]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); }, | |
RDI :function(x) { this[7] = BigInt(x); }, | |
EDI :function(x) { this[7] = (BigInt(this[7]) & BigInt(0xFFFFFFFF00000000n)) | (BigInt(0xFFFFFFFF) & BigInt(x)); }, | |
DI :function(x) { this[7] = (BigInt(this[7]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); }, | |
R0 :function(x) { this[0] = BigInt(x); }, | |
R1 :function(x) { this[1] = BigInt(x); }, | |
R2 :function(x) { this[2] = BigInt(x); }, | |
R3 :function(x) { this[3] = BigInt(x); }, | |
R4 :function(x) { this[4] = BigInt(x); }, | |
R5 :function(x) { this[5] = BigInt(x); }, | |
R6 :function(x) { this[6] = BigInt(x); }, | |
R7 :function(x) { this[7] = BigInt(x); }, | |
R8 :function(x) { this[8] = BigInt(x); }, | |
R9 :function(x) { this[9] = BigInt(x); }, | |
R10 :function(x) { this[10] = BigInt(x); }, | |
R11 :function(x) { this[11] = BigInt(x); }, | |
R12 :function(x) { this[12] = BigInt(x); }, | |
R13 :function(x) { this[13] = BigInt(x); }, | |
R14 :function(x) { this[14] = BigInt(x); }, | |
R15 :function(x) { this[15] = BigInt(x); }, | |
RFX :function(x) { this[16] = BigInt(x); }, | |
MM0 :function(x) { this[20] = BigInt(x); }, | |
MM1 :function(x) { this[21] = BigInt(x); }, | |
MM2 :function(x) { this[22] = BigInt(x); }, | |
MM3 :function(x) { this[23] = BigInt(x); }, | |
MM4 :function(x) { this[24] = BigInt(x); }, | |
MM5 :function(x) { this[25] = BigInt(x); }, | |
MM6 :function(x) { this[26] = BigInt(x); }, | |
MM7 :function(x) { this[27] = BigInt(x); }, | |
}; | |
for(var fn in getters32) | |
Number.prototype.__defineGetter__(fn, getters32[fn]); | |
for(var fn in getters64) | |
BigInt.prototype.__defineGetter__(fn, getters64[fn]); | |
for(var fn in X64_getters) | |
BigUint64Array.prototype.__defineGetter__(fn, X64_getters[fn]); | |
for(var fn in X64_setters) | |
BigUint64Array.prototype.__defineSetter__(fn, X64_setters[fn]); | |
BigUint64Array.prototype.GET = function(id) { | |
switch(id.toUpperCase()) { | |
case "RAX" :return this[0]; | |
case "EAX" :return this[0] & BigInt(0xFFFFFFFF); | |
case "AX" :return this[0] & BigInt(0xFFFF); | |
case "AL" : | |
case "A" :return this[0] & BigInt(0xFF); | |
case "AH" :return (this[0] >> BigInt(8)) & BigInt(0xFF); | |
case "RBX" :return this[3]; | |
case "EBX" :return this[3] & BigInt(0xFFFFFFFF); | |
case "BX" : | |
case "HL" :return this[3] & BigInt(0xFFFF); | |
case "BL" : | |
case "L" :return this[3] & BigInt(0xFF); | |
case "BH" : | |
case "H" :return (this[3] >> BigInt(8)) & BigInt(0xFF); | |
case "RCX" :return this[1]; | |
case "ECX" :return this[1] & BigInt(0xFFFFFFFF); | |
case "CX" : | |
case "BC" :return this[1] & BigInt(0xFFFF); | |
case "CL" : | |
case "C" :return this[1] & BigInt(0xFF); | |
case "CH" : | |
case "B" :return (this[1] >> BigInt(8)) & BigInt(0xFF); | |
case "RDX" :return this[2]; | |
case "EDX" :return this[2] & BigInt(0xFFFFFFFF); | |
case "DX" : | |
case "DE" :return this[2] & BigInt(0xFFFF); | |
case "DL" : | |
case "E" :return this[2] & BigInt(0xFF); | |
case "DH" : | |
case "D" :return (this[2] >> BigInt(8)) & BigInt(0xFF); | |
case "RSP" :return this[4]; | |
case "ESP" :return this[4] & BigInt(0xFFFFFFFF); | |
case "SP" :return this[4] & BigInt(0xFFFF); | |
case "RBP" :return this[5]; | |
case "EBP" :return this[5] & BigInt(0xFFFFFFFF); | |
case "BP" :return this[5] & BigInt(0xFFFF); | |
case "RSI" :return this[6]; | |
case "ESI" :return this[6] & BigInt(0xFFFFFFFF) | |
case "SI" :return this[6] & BigInt(0xFFFF); | |
case "RDI" :return this[7]; | |
case "EDI" :return this[7] & BigInt(0xFFFFFFFF); | |
case "DI" :return this[7] & BigInt(0xFFFF); | |
} | |
}; | |
BigUint64Array.prototype.SET = function(id, x) { | |
switch(id.toUpperCase()) { | |
case "RAX" :this[0] = BigInt(x); break; | |
case "EAX" :this[0] = (BigInt(this[0]) & BigInt(0xFFFFFFFF00000000n)) | (BigInt(0xFFFFFFFF) & BigInt(x)); break; | |
case "AX" :this[0] = (BigInt(this[0]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); break; | |
case "AL" : | |
case "A" :this[0] = (BigInt(this[0]) & BigInt(0xFFFFFFFFFFFFFF00n)) | (BigInt(0x000000FF) & BigInt(x)); break; | |
case "AH" :this[0] = (BigInt(this[0]) & BigInt(0xFFFFFFFFFFFF00FFn)) | ((BigInt(0x000000FF) & BigInt(x)) << BigInt(8)); break; | |
case "RBX" :this[3] = BigInt(x); break; | |
case "EBX" :this[3] = (BigInt(this[3]) & BigInt(0xFFFFFFFF00000000n)) | (BigInt(0xFFFFFFFF) & BigInt(x)); break; | |
case "BX" : | |
case "HL" :this[3] = (BigInt(this[3]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); break; | |
case "BL" : | |
case "L" :this[3] = (BigInt(this[3]) & BigInt(0xFFFFFFFFFFFFFF00n)) | (BigInt(0x000000FF) & BigInt(x)); break; | |
case "BH" : | |
case "H" :this[3] = (BigInt(this[3]) & BigInt(0xFFFFFFFFFFFF00FFn)) | ((BigInt(0x000000FF) & BigInt(x)) << BigInt(8)); break; | |
case "RCX" :this[1] = BigInt(x); break; | |
case "ECX" :this[1] = (BigInt(this[1]) & BigInt(0xFFFFFFFF00000000n)) | (BigInt(0xFFFFFFFF) & BigInt(x)); break; | |
case "CX" : | |
case "BC" :this[1] = (BigInt(this[1]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); break; | |
case "CL" : | |
case "C" :this[1] = (BigInt(this[1]) & BigInt(0xFFFFFFFFFFFFFF00n)) | (BigInt(0x000000FF) & BigInt(x)); break; | |
case "CH" : | |
case "B" :this[1] = (BigInt(this[1]) & BigInt(0xFFFFFFFFFFFF00FFn)) | ((BigInt(0x000000FF) & BigInt(x)) << BigInt(8)); break; | |
case "RDX" :this[2] = BigInt(x); break; | |
case "EDX" :this[2] = (BigInt(this[2]) & BigInt(0xFFFFFFFF00000000n)) | (BigInt(0xFFFFFFFF) & BigInt(x)); break; | |
case "DX" : | |
case "DE" :this[2] = (BigInt(this[2]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); break; | |
case "DL" : | |
case "E" :this[2] = (BigInt(this[2]) & BigInt(0xFFFFFFFFFFFFFF00n)) | (BigInt(0x000000FF) & BigInt(x)); break; | |
case "DH" : | |
case "D" :this[2] = (BigInt(this[2]) & BigInt(0xFFFFFFFFFFFF00FFn)) | ((BigInt(0x000000FF) & BigInt(x)) << BigInt(8)); break; | |
case "RSP" :this[4] = BigInt(x); break; | |
case "ESP" :this[4] = (BigInt(this[4]) & BigInt(0xFFFFFFFF00000000n)) | (BigInt(0xFFFFFFFF) & BigInt(x)); break; | |
case "SP" :this[4] = (BigInt(this[4]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); break; | |
case "RBP" :this[5] = BigInt(x); break; | |
case "EBP" :this[5] = (BigInt(this[5]) & BigInt(0xFFFFFFFF00000000n)) | (BigInt(0xFFFFFFFF) & BigInt(x)); break; | |
case "BP" :this[5] = (BigInt(this[5]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); break; | |
case "RSI" :this[6] = BigInt(x); break; | |
case "ESI" :this[6] = (BigInt(this[6]) & BigInt(0xFFFFFFFF00000000n)) | (BigInt(0xFFFFFFFF) & BigInt(x)); break; | |
case "SI" :this[6] = (BigInt(this[6]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); break; | |
case "RDI" :this[7] = BigInt(x); break; | |
case "EDI" :this[7] = (BigInt(this[7]) & BigInt(0xFFFFFFFF00000000n)) | (BigInt(0xFFFFFFFF) & BigInt(x)); break; | |
case "DI" :this[7] = (BigInt(this[7]) & BigInt(0xFFFFFFFFFFFF0000n)) | (BigInt(0x0000FFFF) & BigInt(x)); break; | |
} | |
}; | |
BigUint64Array.prototype.DIGITS = function(id) { | |
if(id.match(/^(MM[0-7])$/i)) | |
return 64; | |
else | |
if(id.match(/^(R([A-D]X|[SB]P|[SD]I|[89]|1[0-5]))$/i)) | |
return 64; | |
else | |
if(id.match(/^(E([A-D]X|[SB]P|[SD]I))$/i)) | |
return 32; | |
else | |
if(id.match(/^([A-D]X|[SB]P|[SD]I)$/i)) | |
return 16; | |
else | |
if(id.match(/^([A-D][HL])$/i)) | |
return 8; | |
else | |
return 0; | |
}; | |
BigUint64Array.prototype.ADD = function(id, y) { | |
var r = this.GET(id); | |
var x = r; | |
this.SET(id, x + BigInt(y)); | |
r = this.GET(id); | |
this[16] = BigInt(r < x ? 1n : 0n); | |
if(r === BigInt(0n)) | |
this[16] |= BigInt(64n); | |
switch(this.DIGITS(id)) { | |
case 64: | |
if(r & BigInt(0x8000000000000000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 32: | |
if(r & BigInt(0x80000000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 16: | |
if(r & BigInt(0x8000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 8: | |
if(r & BigInt(0x80n)) | |
this[16] |= BigInt(128n); | |
break; | |
} | |
}; | |
BigUint64Array.prototype.ADC = function(id, y) { | |
var r = this.GET(id); | |
var x = r; | |
this.SET(id, x + BigInt(y) + (this[16] & BigInt(1n))); | |
r = this.GET(id); | |
this[16] = BigInt(r < x ? 1n : 0n); | |
if(r === BigInt(0n)) | |
this[16] |= BigInt(64n); | |
switch(this.DIGITS(id)) { | |
case 64: | |
if(r & BigInt(0x8000000000000000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 32: | |
if(r & BigInt(0x80000000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 16: | |
if(r & BigInt(0x8000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 8: | |
if(r & BigInt(0x80n)) | |
this[16] |= BigInt(128n); | |
break; | |
} | |
}; | |
BigUint64Array.prototype.CMP = function(id, y) { | |
var r = this.GET(id); | |
var x = r; | |
this.SET(id, x - BigInt(y)); | |
r = this.GET(id); | |
this.SET(id, x); | |
this[16] = BigInt(r > x ? 1n : 0n); | |
if(r === BigInt(0n)) | |
this[16] |= BigInt(64n); | |
switch(this.DIGITS(id)) { | |
case 64: | |
if(r & BigInt(0x8000000000000000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 32: | |
if(r & BigInt(0x80000000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 16: | |
if(r & BigInt(0x8000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 8: | |
if(r & BigInt(0x80n)) | |
this[16] |= BigInt(128n); | |
break; | |
} | |
}; | |
BigUint64Array.prototype.SUB = function(id, y) { | |
var r = this.GET(id); | |
var x = r; | |
this.SET(id, x - BigInt(y)); | |
r = this.GET(id); | |
this[16] = BigInt(r > x ? 1n : 0n); | |
if(r === BigInt(0n)) | |
this[16] |= BigInt(64n); | |
switch(this.DIGITS(id)) { | |
case 64: | |
if(r & BigInt(0x8000000000000000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 32: | |
if(r & BigInt(0x80000000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 16: | |
if(r & BigInt(0x8000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 8: | |
if(r & BigInt(0x80n)) | |
this[16] |= BigInt(128n); | |
break; | |
} | |
}; | |
BigUint64Array.prototype.SBB = function(id, y) { | |
var r = this.GET(id); | |
var x = r; | |
this.SET(id, x - BigInt(y) - (this[16] & BigInt(1n))); | |
r = this.GET(id); | |
this[16] = BigInt(r > x ? 1n : 0n); | |
if(r === BigInt(0n)) | |
this[16] |= BigInt(64n); | |
switch(this.DIGITS(id)) { | |
case 64: | |
if(r & BigInt(0x8000000000000000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 32: | |
if(r & BigInt(0x80000000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 16: | |
if(r & BigInt(0x8000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 8: | |
if(r & BigInt(0x80n)) | |
this[16] |= BigInt(128n); | |
break; | |
} | |
}; | |
BigUint64Array.prototype.XOR = function(id, y) { | |
var r = this.GET(id); | |
var x = r; | |
this.SET(id, x ^ BigInt(y)); | |
r = this.GET(id); | |
this[16] = BigInt(0n); | |
if(r === BigInt(0n)) | |
this[16] |= BigInt(64n); | |
switch(this.DIGITS(id)) { | |
case 64: | |
if(r & BigInt(0x8000000000000000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 32: | |
if(r & BigInt(0x80000000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 16: | |
if(r & BigInt(0x8000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 8: | |
if(r & BigInt(0x80n)) | |
this[16] |= BigInt(128n); | |
break; | |
} | |
}; | |
BigUint64Array.prototype.AND = function(id, y) { | |
var r = this.GET(id); | |
var x = r; | |
this.SET(id, x & BigInt(y)); | |
r = this.GET(id); | |
this[16] = BigInt(0n); | |
if(r === BigInt(0n)) | |
this[16] |= BigInt(64n); | |
switch(this.DIGITS(id)) { | |
case 64: | |
if(r & BigInt(0x8000000000000000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 32: | |
if(r & BigInt(0x80000000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 16: | |
if(r & BigInt(0x8000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 8: | |
if(r & BigInt(0x80n)) | |
this[16] |= BigInt(128n); | |
break; | |
} | |
}; | |
BigUint64Array.prototype.OR = function(id, y) { | |
var r = this.GET(id); | |
var x = r; | |
this.SET(id, x | BigInt(y)); | |
r = this.GET(id); | |
this[16] = BigInt(0n); | |
if(r === BigInt(0n)) | |
this[16] |= BigInt(64n); | |
switch(this.DIGITS(id)) { | |
case 64: | |
if(r & BigInt(0x8000000000000000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 32: | |
if(r & BigInt(0x80000000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 16: | |
if(r & BigInt(0x8000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 8: | |
if(r & BigInt(0x80n)) | |
this[16] |= BigInt(128n); | |
break; | |
} | |
}; | |
BigUint64Array.prototype.SAR = function(id, y) { | |
var r = this.GET(id); | |
var x = r; | |
this.SET(id, x >> BigInt(y)); | |
r = this.GET(id); | |
this[16] = BigInt(0n); | |
if(r === BigInt(0n)) | |
this[16] |= BigInt(64n); | |
switch(this.DIGITS(id)) { | |
case 64: | |
if(x & BigInt(0x8000000000000000n)) | |
this.SET(id, r | (BigInt(0xFFFFFFFFFFFFFFFFn) << (BigInt(64n) - BigInt(y)))); | |
if(r & BigInt(0x8000000000000000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 32: | |
if(x & BigInt(0x80000000n)) | |
this.SET(id, r | (BigInt(0xFFFFFFFFFFFFFFFFn) << (BigInt(32n) - BigInt(y)))); | |
if(r & BigInt(0x80000000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 16: | |
if(x & BigInt(0x8000n)) | |
this.SET(id, r | (BigInt(0xFFFFFFFFFFFFFFFFn) << (BigInt(16n) - BigInt(y)))); | |
if(r & BigInt(0x8000n)) | |
this[16] |= BigInt(128n); | |
break; | |
case 8: | |
if(x & BigInt(0x80n)) | |
this.SET(id, r | (BigInt(0xFFFFFFFFFFFFFFFFn) << (BigInt(8n) - BigInt(y)))); | |
if(r & BigInt(0x80n)) | |
this[16] |= BigInt(128n); | |
break; | |
} | |
}; | |
BigUint64Array.prototype.MOVSX = function(idx, idy) { | |
var r = this.GET(idy); | |
this.SET(idx, r); | |
switch(this.DIGITS(idy)) { | |
case 32: | |
if((r & BigInt(0x80000000n)) > BigInt(0n)) | |
this.SET(idx, r | BigInt(0xFFFFFFFF00000000n)); | |
break; | |
case 16: | |
if((r & BigInt(0x8000n)) > BigInt(0n)) | |
this.SET(idx, r | BigInt(0xFFFFFFFFFFFF0000n)); | |
break; | |
case 8: | |
if((r & BigInt(0x80n)) > BigInt(0n)) | |
this.SET(idx, r | BigInt(0xFFFFFFFFFFFFFF00n)); | |
break; | |
} | |
}; | |
BigUint64Array.prototype.PUSHW = function(y) { | |
var sp = this.SP; | |
this.SP = sp - 2; | |
}; | |
/*Number.prototype.__defineGetter__("right", | |
function() { | |
return this & 15; | |
} | |
); | |
Number.prototype.__defineGetter__("left", | |
function() { | |
return (this >> 4) & 15; | |
} | |
); | |
Number.prototype.__defineGetter__("low", | |
function() { | |
return this & 255; | |
} | |
); | |
Number.prototype.__defineGetter__("high", | |
function() { | |
return (this >> 8) & 255; | |
} | |
); | |
Number.prototype.__defineGetter__("isNum", | |
function() { | |
return this <= 9; | |
} | |
); | |
Number.prototype.__defineGetter__('isReg", | |
function() { | |
return this >= 0xA && this <= 0xD; | |
} | |
);*/ | |
</script> | |
<script> | |
var i; | |
var MMX_R = new BigUint64Array(67); | |
MMX_R[0] = 0x0000000000000000n; | |
MMX_R[1] = 0x0000000000000001n; | |
MMX_R[2] = 0x0000000000000002n; | |
MMX_R[3] = 0x0000000000000003n; | |
MMX_R[4] = 0x9ABCDE0F12345678n; | |
MMX_R[5] = 0x2D098CBE756431FAn; | |
MMX_R[6] = 0x0000000000000006n; | |
MMX_R[7] = 0x0000000000000007n; | |
MMX_R[8] = 0x7F7F7F7F7F7F7F7Fn; | |
MMX_R[9] = 0x8080808080808080n; | |
MMX_R[10] = 7n; | |
MMX_R[11] = 0xFFn; | |
MMX_R[16] = 0x7FFF7FFF7FFF7FFFn; | |
MMX_R[17] = 0x8000800080008000n; | |
MMX_R[18] = 15n; | |
MMX_R[19] = 0xFFFFn; | |
MMX_R[32] = 0x7FFFFFFF7FFFFFFFn; | |
MMX_R[33] = 0x8000000080000000n; | |
MMX_R[34] = 31n; | |
MMX_R[35] = 0xFFFFFFFFn; | |
MMX_R[64] = 0x7FFFFFFFFFFFFFFFn; | |
MMX_R[65] = 0x8000000000000000n; | |
MMX_R[66] = 63n; | |
MMX_R[67] = 0xFFFFFFFFFFFFFFFFn; | |
BigInt.prototype.__defineGetter__("U", function() { this.UNSIGNED = true; return this; } ); | |
BigInt.prototype.__defineGetter__("S", function() { this.SATURATED = true; return this; } ); | |
BigInt.prototype.__defineGetter__("L", function() { this.LOWER = true; return this; } ); | |
BigInt.prototype.__defineGetter__("H", function() { this.HIGHER = true; return this; } ); | |
BigInt.prototype.__defineGetter__("B", function() { this.BYTE = true; this.MASK = BigInt(0x7F7F7F7F7F7F7F7Fn); return this; } ); | |
BigInt.prototype.__defineGetter__("W", function() { this.WORD = true; this.MASK = BigInt(0x7FFF7FFF7FFF7FFFn); return this; } ); | |
BigInt.prototype.__defineGetter__("D", function() { this.DWORD = true; this.MASK = BigInt(0x7FFFFFFF7FFFFFFFn); return this; } ); | |
BigInt.prototype.__defineGetter__("Q", function() { this.QWORD = true; this.MASK = BigInt(0x7FFFFFFFFFFFFFFFn); return this; } ); | |
BigInt.prototype.__defineGetter__("PTEST", function() { | |
return (function(n) { | |
console.log(this.UNSIGNED ? "UNSIGNED" : "SIGNED"); | |
console.log(this.SATURATED ? "SATURATED" : "LOOPED" ); | |
console.log(this.LOWER ? "LOWER" : this.HIGHER ? "HIGHER" : "WHOLE"); | |
console.log(this.BYTE ? "BYTE" : this.WORD ? "WORD" : this.DWORD ? "DWORD" : this.QWORD ? "QWORD" : "AUTO"); | |
console.log(n); | |
return this; | |
}).bind(this); | |
}); | |
BigInt.prototype.__defineGetter__ | |
("Show", function(){ | |
alert(this.TEST); | |
return this; | |
} | |
); | |
BigInt.prototype.toHex = function(n) { | |
return (n < 0 ? "0x" : "") + ( | |
("0000000" + ((this >> BigInt(32n)) & BigInt(0xFFFFFFFFn)).toString(16)).substr(-8) + | |
("0000000" + (this & BigInt(0xFFFFFFFFn)).toString(16)).substr(-8)).substr(-Math.abs(n)).toUpperCase(); | |
} | |
var test = BigInt(65000); | |
//console.log(test.B.W.MASK.toHex(16)); | |
Number.prototype.__defineGetter__ | |
("ME", function() { | |
this.PERSON = "Me"; | |
return this; | |
}); | |
Number.prototype.__defineGetter__ | |
("HERE", function() { | |
this.PLACE = "Here"; | |
return this; | |
}); | |
var Man = new Number(1536); | |
var Logs = []; | |
try { | |
Logs.push(`Man: ${Man}`); | |
} catch(e) {} | |
try { | |
Logs.push(`Man.ME: ${Man.ME}`); | |
// Почему тут не число 1536, а [object.Window]? | |
} catch(e) {} | |
try { | |
Logs.push(`Man.HERE: ${Man.HERE}`); | |
// Почему тут не число 1536, а [object.Window]? | |
} catch(e) {} | |
try { | |
Logs.push(`Man.ME.HERE: ${Man.ME.HERE}`); | |
// Почему тут не число 1536, а [object.Window]? | |
} catch(e) {} | |
try { | |
Logs.push(`Man.HERE.ME: ${Man.HERE.ME}`); | |
// Почему тут не число 1536, а [object.Window]? | |
} catch(e) {} | |
try { | |
Logs.push(`Man.ME.PERSON: ${Man.ME.PERSON}`); | |
// Работает | |
} catch(e) {} | |
try { | |
Logs.push(`Man.HERE.PLACE: ${Man.HERE.PLACE}`); | |
// Работает | |
} catch(e) {} | |
try { | |
Logs.push(`Man.ME.HERE.PLACE: ${Man.ME.HERE.PLACE}`); | |
// Почему накопление свойств не работает? | |
} catch(e) {} | |
try { | |
Logs.push(`Man.HERE.ME.PLACE: ${Man.HERE.ME.PLACE}`); | |
// Почему накопление свойств не работает? | |
} catch(e) {} | |
try { | |
Logs.push(`Man.ME.HERE.PERSON: ${Man.ME.HERE.PERSON}`); | |
// Почему накопление свойств не работает? | |
} catch(e) {} | |
try { | |
Logs.push(`Man.HERE.ME.PERSON: ${Man.HERE.ME.PERSON}`); | |
// Почему накопление свойств не работает? | |
} catch(e) {} | |
//console.log(Logs.join("\n")); | |
//alert(Logs.join("\n")); | |
/*BigInt.prototype.PADD = function(n, mask) { | |
return (((this & mask) + (n & mask))) ^ ((this ^ n) & ~mask); | |
}*/ | |
BigInt.prototype.PADD = function(n, mask) { | |
var _this = BigInt(this)|0n; | |
'use asm'; | |
_this = _this|0n; | |
n = n|0n; | |
mask = mask|0n; | |
return ((((_this & mask) + (n & mask))) ^ ((_this ^ n) & ~mask))|0n; | |
} | |
//0x1234n.PADD(0xEF5Dn, 0x7777n) | |
/*BigInt.prototype.PSUB = function(n, mask) { | |
return (((this | ~mask) - (n & mask)) & mask) | ((this - n) & ~mask); | |
}*/ | |
BigInt.prototype.PSUB = function(n, mask) { | |
var _this = BigInt(this); | |
'use asm'; | |
_this = _this|0n; | |
n = n|0n; | |
mask = mask|0n; | |
return (((_this | ~mask) - (n & mask)) & mask) | ((_this - n) & ~mask)|0n; | |
} | |
BigInt.prototype.PCMPGT = function(n, digits) { | |
/*var x = 0x1234; | |
var y = 0x8623; | |
var m = MMX_R[digits]; | |
var n = ~MMX_R[digits];*/ | |
var lo = this & BigInt(0xFFFFFFFFn); | |
var hi = (this >> BigInt(32n)) & BigInt(0xFFFFFFFFn); | |
var nlo = n & BigInt(0xFFFFFFFFn); | |
var nhi = (n >> BigInt(32n)) & BigInt(0xFFFFFFFFn); | |
var zlo = ((lo | MMX_R[digits + 1]) - (nlo & MMX_R[digits])) & (MMX_R[digits] | MMX_R[digits + 1]); | |
var zhi = ((hi | MMX_R[digits + 1]) - (nhi & MMX_R[digits])) & (MMX_R[digits] | MMX_R[digits + 1]); | |
var zlo1 = (lo ^ nlo) & MMX_R[digits + 1]; | |
var zhi1 = (hi ^ nhi) & MMX_R[digits + 1]; | |
var zlo2 = (((zlo ^ zlo1) & MMX_R[digits + 1]) >> MMX_R[digits + 2]) * (MMX_R[digits + 3]); | |
var zhi2 = (((zhi ^ zhi1) & MMX_R[digits + 1]) >> MMX_R[digits + 2]) * (MMX_R[digits + 3]); | |
return BigInt(BigInt(zlo2) + (BigInt(zhi2) << BigInt(32))); | |
} | |
BigInt.prototype.PCMPEQB = function(n) { | |
var d1 = BigInt(0xFF) & this; | |
var d2 = BigInt(0xFF) & (this >> BigInt(8)); | |
var d3 = BigInt(0xFF) & (this >> BigInt(16)); | |
var d4 = BigInt(0xFF) & (this >> BigInt(24)); | |
var d5 = BigInt(0xFF) & (this >> BigInt(32)); | |
var d6 = BigInt(0xFF) & (this >> BigInt(40)); | |
var d7 = BigInt(0xFF) & (this >> BigInt(48)); | |
var d8 = BigInt(0xFF) & (this >> BigInt(56)); | |
var n1 = BigInt(0xFF) & n; | |
var n2 = BigInt(0xFF) & (n >> BigInt(8)); | |
var n3 = BigInt(0xFF) & (n >> BigInt(16)); | |
var n4 = BigInt(0xFF) & (n >> BigInt(24)); | |
var n5 = BigInt(0xFF) & (n >> BigInt(32)); | |
var n6 = BigInt(0xFF) & (n >> BigInt(40)); | |
var n7 = BigInt(0xFF) & (n >> BigInt(48)); | |
var n8 = BigInt(0xFF) & (n >> BigInt(56)); | |
var r1 = BigInt(d1 == n1 ? 0xFF : 0x00); | |
var r2 = BigInt(d2 == n2 ? 0xFF : 0x00) << BigInt(8); | |
var r3 = BigInt(d3 == n3 ? 0xFF : 0x00) << BigInt(16); | |
var r4 = BigInt(d4 == n4 ? 0xFF : 0x00) << BigInt(24); | |
var r5 = BigInt(d5 == n5 ? 0xFF : 0x00) << BigInt(32); | |
var r6 = BigInt(d6 == n6 ? 0xFF : 0x00) << BigInt(40); | |
var r7 = BigInt(d7 == n7 ? 0xFF : 0x00) << BigInt(48); | |
var r8 = BigInt(d8 == n8 ? 0xFF : 0x00) << BigInt(56); | |
return r8 | r7 | r6 | r5 | r4 | r3 | r2 | r1; | |
} | |
BigInt.prototype.PCMPEQW = function(n) { | |
var d1 = BigInt(0xFFFF) & this; | |
var d2 = BigInt(0xFFFF) & (this >> BigInt(16)); | |
var d3 = BigInt(0xFFFF) & (this >> BigInt(32)); | |
var d4 = BigInt(0xFFFF) & (this >> BigInt(48)); | |
var n1 = BigInt(0xFFFF) & n; | |
var n2 = BigInt(0xFFFF) & (n >> BigInt(16)); | |
var n3 = BigInt(0xFFFF) & (n >> BigInt(32)); | |
var n4 = BigInt(0xFFFF) & (n >> BigInt(48)); | |
var r1 = BigInt(d1 == n1 ? 0xFFFF : 0x0000); | |
var r2 = BigInt(d2 == n2 ? 0xFFFF : 0x0000) << BigInt(16); | |
var r3 = BigInt(d3 == n3 ? 0xFFFF : 0x0000) << BigInt(32); | |
var r4 = BigInt(d4 == n4 ? 0xFFFF : 0x0000) << BigInt(48); | |
return r4 | r3 | r2 | r1; | |
} | |
BigInt.prototype.PCMPEQD = function(n) { | |
var d1 = BigInt(0xFFFFFFFF) & this; | |
var d2 = BigInt(0xFFFFFFFF) & (this >> BigInt(32)); | |
var n1 = BigInt(0xFFFFFFFF) & n; | |
var n2 = BigInt(0xFFFFFFFF) & (n >> BigInt(32)); | |
var r1 = BigInt(d1 == n1 ? 0xFFFFFFFF : 0x00000000); | |
var r2 = BigInt(d2 == n2 ? 0xFFFFFFFF : 0x00000000) << BigInt(32); | |
return r2 | r1; | |
} | |
BigInt.prototype.PCMPGTB = function(n) { | |
var d1 = BigInt(0xFF) & this; | |
var d2 = BigInt(0xFF) & (this >> BigInt(8)); | |
var d3 = BigInt(0xFF) & (this >> BigInt(16)); | |
var d4 = BigInt(0xFF) & (this >> BigInt(24)); | |
var d5 = BigInt(0xFF) & (this >> BigInt(32)); | |
var d6 = BigInt(0xFF) & (this >> BigInt(40)); | |
var d7 = BigInt(0xFF) & (this >> BigInt(48)); | |
var d8 = BigInt(0xFF) & (this >> BigInt(56)); | |
var n1 = BigInt(0xFF) & n; | |
var n2 = BigInt(0xFF) & (n >> BigInt(8)); | |
var n3 = BigInt(0xFF) & (n >> BigInt(16)); | |
var n4 = BigInt(0xFF) & (n >> BigInt(24)); | |
var n5 = BigInt(0xFF) & (n >> BigInt(32)); | |
var n6 = BigInt(0xFF) & (n >> BigInt(40)); | |
var n7 = BigInt(0xFF) & (n >> BigInt(48)); | |
var n8 = BigInt(0xFF) & (n >> BigInt(56)); | |
var r1 = BigInt(BigInt(0x80n) ^ d1 > BigInt(0x80n) ^ n1 ? 0xFF : 0x00); | |
var r2 = BigInt(BigInt(0x80n) ^ d2 > BigInt(0x80n) ^ n2 ? 0xFF : 0x00) << BigInt(8); | |
var r3 = BigInt(BigInt(0x80n) ^ d3 > BigInt(0x80n) ^ n3 ? 0xFF : 0x00) << BigInt(16); | |
var r4 = BigInt(BigInt(0x80n) ^ d4 > BigInt(0x80n) ^ n4 ? 0xFF : 0x00) << BigInt(24); | |
var r5 = BigInt(BigInt(0x80n) ^ d5 > BigInt(0x80n) ^ n5 ? 0xFF : 0x00) << BigInt(32); | |
var r6 = BigInt(BigInt(0x80n) ^ d6 > BigInt(0x80n) ^ n6 ? 0xFF : 0x00) << BigInt(40); | |
var r7 = BigInt(BigInt(0x80n) ^ d7 > BigInt(0x80n) ^ n7 ? 0xFF : 0x00) << BigInt(48); | |
var r8 = BigInt(BigInt(0x80n) ^ d8 > BigInt(0x80n) ^ n8 ? 0xFF : 0x00) << BigInt(56); | |
return r8 | r7 | r6 | r5 | r4 | r3 | r2 | r1; | |
} | |
BigInt.prototype.PCMPGTW = function(n) { | |
var d1 = BigInt(0xFFFF) & this; | |
var d2 = BigInt(0xFFFF) & (this >> BigInt(16)); | |
var d3 = BigInt(0xFFFF) & (this >> BigInt(32)); | |
var d4 = BigInt(0xFFFF) & (this >> BigInt(48)); | |
var n1 = BigInt(0xFFFF) & n; | |
var n2 = BigInt(0xFFFF) & (n >> BigInt(16)); | |
var n3 = BigInt(0xFFFF) & (n >> BigInt(32)); | |
var n4 = BigInt(0xFFFF) & (n >> BigInt(48)); | |
var r1 = BigInt(BigInt(0x8000n) ^ d1 > BigInt(0x8000n) ^ n1 ? 0xFFFF : 0x0000); | |
var r2 = BigInt(BigInt(0x8000n) ^ d2 > BigInt(0x8000n) ^ n2 ? 0xFFFF : 0x0000) << BigInt(16); | |
var r3 = BigInt(BigInt(0x8000n) ^ d3 > BigInt(0x8000n) ^ n3 ? 0xFFFF : 0x0000) << BigInt(32); | |
var r4 = BigInt(BigInt(0x8000n) ^ d4 > BigInt(0x8000n) ^ n4 ? 0xFFFF : 0x0000) << BigInt(48); | |
return r4 | r3 | r2 | r1; | |
} | |
BigInt.prototype.PCMPGTD = function(n) { | |
var d1 = BigInt(0xFFFFFFFF) & BigInt(this); | |
var d2 = BigInt(0xFFFFFFFF) & BigInt(this >> BigInt(32)); | |
var n1 = BigInt(0xFFFFFFFF) & BigInt(n); | |
var n2 = BigInt(0xFFFFFFFF) & (BigInt(n) >> BigInt(32)); | |
var r1 = BigInt((BigInt(0x80000000n) ^ BigInt(d1)) > (BigInt(0x80000000n) ^ BigInt(n1)) ? 0xFFFFFFFF : 0x00000000); | |
var r2 = BigInt((BigInt(0x80000000n) ^ BigInt(d2)) > (BigInt(0x80000000n) ^ BigInt(n2)) ? 0xFFFFFFFF : 0x00000000) << BigInt(32); | |
return r2 | r1; | |
} | |
BigInt.prototype.PACKUSDW = function(n) { | |
var d1 = BigInt(0xFFFFFFFF) & BigInt(this); | |
var d2 = BigInt(0xFFFFFFFF) & BigInt(this >> BigInt(32)); | |
var n1 = BigInt(0xFFFFFFFF) & BigInt(n); | |
var n2 = BigInt(0xFFFFFFFF) & (BigInt(n) >> BigInt(32)); | |
var r1 = d1 > BigInt(65535) ? BigInt(65535) : d1; | |
var r2 = d2 > BigInt(65535) ? BigInt(65535) : d2; | |
var r3 = n1 > BigInt(65535) ? BigInt(65535) : n1; | |
var r4 = n2 > BigInt(65535) ? BigInt(65535) : n2; | |
// console.log(this.toHex(16), n.toHex(16), d1,d1,n1,n2,r1,r2,r3,r4); | |
return r1 | (r2 << BigInt(16)) | (r3 << BigInt(32)) | (r4 << BigInt(48)); | |
} | |
/* | |
BigInt.prototype.PUNPCKLDQ = function(n) { | |
return (this & BigInt(0x00000000FFFFFFFFn)) | (n << BigInt(32n)); | |
}*/ | |
BigInt.prototype.PUNPCKLDQ = function(n) { | |
var _this = this; | |
'use asm'; | |
_this = _this|0n; | |
n = n|0n; | |
return ((_this & 0x00000000FFFFFFFFn) | (n << 32n))|0n; | |
} | |
/*BigInt.prototype.PUNPCKLWD = function(n) { | |
var d1 = BigInt(0xFFFF) & BigInt(this); | |
var d2 = BigInt(0xFFFF) & BigInt(this >> BigInt(16)); | |
var n1 = BigInt(0xFFFF) & BigInt(n); | |
var n2 = BigInt(0xFFFF) & BigInt(n >> BigInt(16)); | |
return d1 | (n1 << BigInt(16n)) | (d2 << BigInt(32n)) | (n2 << BigInt(48n)); | |
}*/ | |
BigInt.prototype.PUNPCKLWD = function(n) { | |
var _this = this; | |
var d1, d2, n1, n2; | |
'use asm'; | |
_this = _this|0n; | |
n = n|0n; | |
d1 = (0xFFFFn & _this)|0n; | |
d2 = (0xFFFFn & (_this >> 16n))|0n; | |
n1 = (0xFFFFn & n)|0n; | |
n2 = (0xFFFFn & (n >> 16n))|0n; | |
return (d1 | (n1 << 16n) | (d2 << 32n) | (n2 << 48n))|0n; | |
} | |
BigInt.prototype.PSLLD = function(n) { | |
var d1 = BigInt(this); | |
var n1 = parseInt(n); | |
var i; | |
for(i = 1; i <= n1; ++ i) { | |
d1 <<= BigInt(1); | |
d1 &= BigInt(0xFFFFFFFEFFFFFFFEn); | |
} | |
return d1; | |
} | |
BigInt.prototype.PSLLQ = function(n) { | |
var d1 = BigInt(this); | |
var n1 = parseInt(n); | |
var i; | |
for(i = 1; i <= n1; ++ i) { | |
d1 <<= BigInt(1); | |
d1 &= BigInt(0xFFFFFFFFFFFFFFFEn); | |
} | |
return d1; | |
} | |
BigInt.prototype.PSRLD = function(n) { | |
var d1 = BigInt(this); | |
var n1 = parseInt(n); | |
var i; | |
for(i = 1; i <= n1; ++ i) { | |
d1 >>= BigInt(1); | |
d1 &= BigInt(0x7FFFFFFF7FFFFFFFn); | |
} | |
return d1; | |
} | |
BigInt.prototype.PSRLQ = function(n) { | |
var d1 = BigInt(this); | |
var n1 = parseInt(n); | |
var i; | |
for(i = 1; i <= n1; ++ i) { | |
d1 >>= BigInt(1); | |
d1 &= BigInt(0x7FFFFFFFFFFFFFFFn); | |
} | |
return d1; | |
} | |
</script> | |
<script> | |
var KOY | |
= function() { | |
this.cps = 1; // Cycles Per Second | |
this.is_peek = false; | |
this.cycles = 0; | |
this.ticks = 0; | |
this.classic = false; | |
this.prefix = false; | |
this.prefixes = 0; | |
this.marginal = 0; // Vector's prefixes margins | |
this.address = 0; // Vector's indexing accumulator | |
this.offset = 0; // Vector's offset value | |
this.pairs = 0; // Vector's using pairs flags | |
this.id = 0; | |
this.dis_pointer = 0; | |
this.dis_address = 0x0000; | |
this.dis_lines = 16; | |
this.dis_line_letters = 24; | |
this.dis_line_bytes = 4; | |
this.dis_line_lettersingle = 30; | |
this.dis_line_bytesingle = 2; | |
this.dis_lines_points = []; | |
this.dis_points_lines = []; | |
this.dis_lines_tables = []; | |
this.snaps_offset = []; | |
this.images = []; | |
////////////////////////////////////////////////////////////////////// | |
this.program = []; | |
this.labels = []; | |
this.Views = ""; | |
////////////////////////////////////////////////////////////////////// | |
this.MMX_R = new BigUint64Array(8); | |
this.MMX_R[0] = 0x416C696B6265726Fn; | |
this.MMX_R[1] = 0x53696D756C61746Fn; | |
this.MMX_R[2] = 0x56657273696F6E31n; | |
this.MMX_R[3] = 0x0000000000000003n; | |
this.MMX_R[4] = 0x9ABCDE0F12345678n; | |
this.MMX_R[5] = 0x2D098CBE756431FAn; | |
this.MMX_R[6] = 0x0000000000000006n; | |
this.MMX_R[7] = 0x0765676567656765n; | |
////////////////////////////////////////////////////////////////////// | |
this.SSE_R = new BigUint64Array(16); | |
this.SSE_R[0] = 0x0123456765432109n; | |
this.SSE_R[1] = 0x0000000000000001n; | |
this.SSE_R[2] = 0x0000000000000002n; | |
this.SSE_R[3] = 0x0000000000000003n; | |
this.SSE_R[4] = 0x9ABCDE0F12345678n; | |
this.SSE_R[5] = 0x2D098CBE756431FAn; | |
this.SSE_R[6] = 0x0000000000000006n; | |
this.SSE_R[7] = 0x0765676567656765n; | |
this.SSE_R[8] = 0x0123456765432109n; | |
this.SSE_R[9] = 0x0000000000000001n; | |
this.SSE_R[10] = 0x0000000000000002n; | |
this.SSE_R[11] = 0x0000000000000003n; | |
this.SSE_R[12] = 0x9ABCDE0F12345678n; | |
this.SSE_R[13] = 0x2D098CBE756431FAn; | |
this.SSE_R[14] = 0x0000000000000006n; | |
this.SSE_R[15] = 0x0765676567656765n; | |
////////////////////////////////////////////////////////////////////// | |
this.X64_R = new BigUint64Array(256); | |
this.X64_R[0] = 0x0123456765432109n; | |
this.X64_R[1] = 0x0000000000000001n; | |
this.X64_R[2] = 0x0000000000000002n; | |
this.X64_R[3] = 0x0000000000000003n; | |
this.X64_R[4] = 0x9ABCDE0F12345678n; | |
this.X64_R[5] = 0x2D098CBE756431FAn; | |
this.X64_R[6] = 0x0000000000000006n; | |
this.X64_R[7] = 0x0765676567656765n; | |
this.X64_R[8] = 0x0123456765432109n; | |
this.X64_R[9] = 0x0000000000000001n; | |
this.X64_R[10] = 0x0000000000000002n; | |
this.X64_R[11] = 0x0000000000000003n; | |
this.X64_R[12] = 0x9ABCDE0F12345678n; | |
this.X64_R[13] = 0x2D098CBE756431FAn; | |
this.X64_R[14] = 0x0000000000000006n; | |
this.X64_R[15] = 0x0765676567656765n; | |
this.X64_R[16] = 0x0765676567656765n; | |
////////////////////////////////////////////////////////////////////// | |
this.snaps = []; | |
this.logging = []; | |
this.limit = 1000; | |
this.format = ""; | |
this.draft = null; | |
////////////////////////////////////////////////////////////////////// | |
this.devices | |
= { | |
i8255 :{ | |
init : | |
function() { | |
this.state = []; | |
for(var i = 0; i < 256; ++ i) | |
this.state[i] = [0x00, 0x00, 0x00, 0x00]; | |
} | |
, | |
clock : | |
function() { | |
} | |
, | |
read : | |
function(index, port) { | |
return this.state[index][port & 3]; | |
} | |
, | |
write : | |
function(index, port, data) { | |
this.state[index][port & 3] = data & 0xFF; | |
} | |
}, | |
i8279 :{ | |
init : | |
function() { | |
this.state = []; | |
this.mode = []; | |
this.freq = []; | |
for(var i = 0; i < 256; ++ i) { | |
this.state[i] = 0; | |
this.mode[i] = 0; | |
this.freq[i] = 0; | |
} | |
} | |
, | |
clock : | |
function() { | |
} | |
, | |
read : | |
function(index, port) { | |
switch(port) { | |
case 0x00: | |
if(!this._this.is_peek) { | |
if(hUserPad.selectionEnd == hUserPad.selectionStart + 1) { | |
hUserPad.selectionStart ++; | |
hUserPad.selectionEnd ++; | |
if(hUserPad.selectionStart >= hUserPad.value.length) { | |
tmp = hUserPad.value.indexOf("$run "); | |
if(tmp >= 0) { | |
hUserPad.selectionStart = tmp + 5; | |
hUserPad.selectionEnd = hUserPad.selectionStart + 1; | |
} | |
} | |
} | |
} | |
return hUserPad.value.charCodeAt(hUserPad.selectionStart) & 0xFF; | |
} | |
return 0xFF; | |
} | |
, | |
write : | |
function(index, port, data) { | |
switch(port) { | |
case 0x01: | |
if((port & 0xE0) == 0x00) | |
// 0_0_0_D_D_K_K_K | |
// 0 0 -------> 8×8 character display - left entry | |
// 0 1 -------> 16×8 character display - left entry | |
// 1 0 -------> 8×8 character display - right entry | |
// 1 1 -------> 16×8 character display - right entry | |
// 0 0 0 -> Encoded Scan Keyboard - 2-Key Lock-out | |
// 0 0 1 -> Decoded Scan Keyboard - 2-Key Lock-out | |
// 0 1 0 -> Encoded Scan Keyboard - N-Key Roll-over | |
// 0 1 1 -> Decoded Scan Keyboard - N-Key Roll-over | |
// 1 0 0 -> Encoded Scan Sensor Matrix | |
// 1 0 1 -> Decoded Scan Sensor Matrix | |
// 1 1 0 -> Strobed Input. Encoded Display Scan | |
// 1 1 1 -> Strobed Input. Decoded Display Scan | |
this.mode[index] = data & 0x1F; | |
if((port & 0xE0) == 0x20) | |
this.freq[index] = data & 0x1F; | |
break; | |
} | |
} | |
}, | |
i82C0 :{ | |
init : | |
function() { | |
} | |
, | |
clock : | |
function() { | |
} | |
, | |
read : | |
function(index, port) { | |
return this.state[index][port & 3]; | |
} | |
, | |
write : | |
function(index, port, data) { | |
if(data == 0x00) | |
hEmuLog.textContent = ""; | |
else | |
hEmuLog.textContent += String.fromCharCode(data); | |
} | |
}, | |
i82CB :{ | |
init : | |
function() { | |
this.buffer = new Uint8Array(256 * 8); | |
} | |
, | |
clock : | |
function() { | |
} | |
, | |
read : | |
function(index, port) { | |
return 0; | |
} | |
, | |
write : | |
function(index, port, data) { | |
var addr = (index & 0xFF) << 3; | |
var x = (index & 0x0F) << 3; | |
var y = (index & 0xF0) >> 1; | |
var pixels; | |
var alfa = 0; | |
this.buffer[addr + (port & 7)] = data & 0xFF; | |
} | |
}, | |
i82CD :{ | |
init : | |
function() { | |
this.buffer = new Uint8Array(256 * 8); | |
} | |
, | |
clock : | |
function() { | |
} | |
, | |
read : | |
function(index, port) { | |
return 0; | |
} | |
, | |
write : | |
function(index, port, data) { | |
var addr = (index & 0xFF) << 3; | |
var x = (index & 0x0F) << 3; | |
var y = (index & 0xF0) >> 1; | |
var pixels; | |
var alfa = 0; | |
this.buffer[addr + (port & 7)] = data & 0xFF; | |
if((this.buffer[addr] | this.buffer[addr + 1] | |
| this.buffer[addr + 2] | this.buffer[addr + 3] | |
| this.buffer[addr + 4] | this.buffer[addr + 5] | |
| this.buffer[addr + 6] | this.buffer[addr + 7]) != 0) | |
alfa = 255; | |
for(var h = 0; h < 8; ++ h) { | |
pixels = hDisplay.getImageData(x + h, y, 1, 8); | |
data = this.buffer[addr + h]; | |
for(var i = 0; i < 8; ++ i) { | |
pixels.data[i * 4 + 0] = data & 1 ? 0xFF : 0x00; | |
pixels.data[i * 4 + 1] = data & 1 ? 0xFF : 0x00; | |
pixels.data[i * 4 + 2] = data & 1 ? 0xFF : 0x00; | |
pixels.data[i * 4 + 3] = alfa; | |
data >>= 1; | |
} | |
hDisplay.putImageData(pixels, x + h, y); | |
} | |
} | |
} | |
}; | |
////////////////////////////////////////////////////////////////////// | |
this.ram = new Uint8Array(65536); | |
////////////////////////////////////////////////////////////////////// | |
this.rams | |
= new Proxy | |
(new Array(65536), | |
{ | |
get: function(target, name) { | |
if(0x00D0 <= name && name <= 0x00D9) { | |
if(name <= 0x00D7) { | |
if(("i82" + target[0x00D9].toHex(2)) in target.devices) { | |
return target.devices["i82" + target[0x00D9].toHex(2)].read(target[0x00D8], (+name & 0x7)); | |
} | |
} | |
} | |
return target[name]; | |
}, | |
set: function(target, name, data) { | |
if(0x00D0 <= name && name <= 0x00D9) { | |
if(name <= 0x00D7) { | |
target[0xD000 + +target[0x00D9] * 16 + (+name & 0x000F)] = data; | |
if(("i82" + target[0x00D9].toHex(2)) in target.devices) { | |
target.devices["i82" + target[0x00D9].toHex(2)].write(target[0x00D8], (+name & 0x7), +data); | |
} | |
} else | |
if(name == 0x00D8) | |
target[0xD000 + +target[0x00D9] * 16 + (+name & 0x000F)] = data; | |
else { | |
if(data == 0xCB) | |
hScreen.canvas.style.zoom = 1; | |
target[0x00D9] = data; | |
} | |
/* switch(target[0x00D9]) { | |
case 0xC0: | |
switch(+name) { | |
case 0x00D0: | |
if(data == 0x00) | |
hEmuLog.textContent = ""; | |
else | |
hEmuLog.textContent += String.fromCharCode(data); | |
} | |
break; | |
default: | |
}*/ | |
} | |
if(name >= 0x7000 && 0x9FFF >= name) { | |
var addr = +name - 0x7000; | |
var x = addr % 120; | |
var y = (addr - x) / 120; | |
hGraphic.data[addr * 16 + 0] = +data; | |
hGraphic.data[addr * 16 + 1] = +data; | |
hGraphic.data[addr * 16 + 2] = +data; | |
hGraphic.data[addr * 16 + 3] = 0xFF; | |
hGraphic.data[addr * 16 + 4] = +data; | |
hGraphic.data[addr * 16 + 5] = +data; | |
hGraphic.data[addr * 16 + 6] = +data; | |
hGraphic.data[addr * 16 + 7] = 0xFF; | |
hGraphic.data[addr * 16 + 8] = +data; | |
hGraphic.data[addr * 16 + 9] = +data; | |
hGraphic.data[addr * 16 + 10] = +data; | |
hGraphic.data[addr * 16 + 11] = 0xFF; | |
hGraphic.data[addr * 16 + 12] = +data; | |
hGraphic.data[addr * 16 + 13] = +data; | |
hGraphic.data[addr * 16 + 14] = +data; | |
hGraphic.data[addr * 16 + 15] = 0xFF; | |
hScreen.putImageData(hGraphic, 0, 0); | |
//hScreen.fillStyle = "#" + (+data * 0x010101).HEX(6); | |
//hScreen.fillRect(x * 2, y * 2, 2, 2); | |
} | |
return target[name] = data; | |
} | |
} | |
); | |
////////////////////////////////////////////////////////////////////// | |
this.ram.base = 0x0000; | |
this.ctx = new Array(0xFFF + 1); | |
for(i = 0; i < this.ctx.length; ++ i) | |
this.ctx[i] = 0; | |
this.ctx.devices = this.devices; | |
for(i = 0; i < 8; ++ i) { | |
Object.defineProperty(this.ctx, 0xD0 + i, | |
{ | |
set: ( | |
function(data) { | |
var id = this._this.ctx[0xD9]; | |
var name = `i82${id.toHex(2)}`; | |
if(name in this._this.devices) | |
this._this.devices[name].write(this._this.ctx[0xD8], this.index, data); | |
else | |
this._this.ctx[0xE0 + id] = data; | |
} | |
).bind( | |
{ | |
_this :this, | |
index :i | |
} | |
), | |
get: ( | |
function() { | |
var id = this._this.ctx[0xD9]; | |
var name = `i82${id.toHex(2)}`; | |
if(name in this._this.devices) | |
return this._this.devices[name].read(this._this.ctx[0xD8], this.index); | |
return this._this.ctx[0xE0 + id]; | |
} | |
).bind( | |
{ | |
_this :this, | |
index :i | |
} | |
) | |
} | |
); | |
} | |
////////////////////////////////////////////////////////////////////// | |
this.ctx.receiver | |
= function(data) { | |
var vector = this[this[0x00AE] | 0x0F]; | |
if(isFinite(data)) | |
this[vector] = data.low; | |
else | |
if(typeof data == "string") | |
return vector.toHex(2).toLowerCase() + data; | |
return this[vector]; | |
} | |
////////////////////////////////////////////////////////////////////// | |
this.ctx.translator | |
= function(data) { | |
var vector = this[(this[0x00AE].right << 4) | 0x000F]; | |
if(isFinite(data)) | |
this[vector] = data.low; | |
else | |
if(typeof data == "string") | |
return vector.toHex(2).toLowerCase() + data; | |
return this[vector]; | |
} | |
////////////////////////////////////////////////////////////////////// | |
this.ctx.state | |
= function(data) { | |
if(isFinite(data)) | |
this[0x00A0] = (data & 0xFF ? 0 : 1) | (data & 0x100 ? 2 : 0) | (data & 0x80 ? 8 : 0); | |
return this[0x00A0]; | |
} | |
////////////////////////////////////////////////////////////////////// | |
this.ctx.pointer | |
= function(index, address) { | |
if(typeof address == "string") | |
return (0x0BC0 | index).toHex(3) + address; | |
else | |
if(isFinite(address)) { | |
this[this.base | index] = address.high; | |
this[(this.base | index) + 0x10] = address.low; | |
} | |
return (this[this.base | index] << 8) | this[(this.base | index) + 0x10]; | |
} | |
////////////////////////////////////////////////////////////////////// | |
this.ram.toDump | |
= function(address, width) { | |
var i; | |
var n = address.low; | |
var row, data; | |
var dump = []; | |
address &= 0xFF00; | |
for(i = 0; i < 256; ++ i) { | |
if(i.right == 0) | |
row = [(address + i).toHex(4) + ":"]; | |
data = this[address + i]; | |
if(isFinite(data)) | |
data = data.toHex(2); | |
else | |
data = "--"; | |
row.push( | |
(i == n ? "<span class=ActiveByte>" + data + "</span>": | |
(i > n && i <= n + width - 1 ? "<span class=ActiveByte>" + data + "</span>" : data) | |
)); | |
if(i.right == 15) | |
dump.push(row.join(" ")); | |
} | |
return dump; | |
} | |
////////////////////////////////////////////////////////////////////// | |
this.ram.set | |
= function(data) { | |
var address; | |
var ram = this; | |
// | |
if("string" == typeof data) { | |
data | |
.split(/\r?\n/) | |
.forEach | |
(function(row) { | |
row | |
.split(/\s+|\t+/) | |
.forEach | |
(function(chars) { | |
data = chars.match(/[0-9A-F]{2,4}/); | |
if(data) | |
switch(data[0].length) { | |
case 4: | |
address = parseInt(data[0], 16); | |
break; | |
case 2: | |
ram[address ++] = parseInt(data[0], 16); | |
break; | |
} | |
else | |
if(chars.match(/'./)) | |
ram[address ++] = chars.charCodeAt(1) & 0xFF; | |
}); | |
}); | |
} else | |
address = this.length; | |
while(address -- > 0) | |
this[address] = isFinite(data) ? data : 0; | |
return this; | |
} | |
////////////////////////////////////////////////////////////////////// | |
this.context | |
= function(snap) { | |
if(!snap) | |
return new BigUint64Array(this.X64_R); | |
var i; | |
var x80 = []; | |
var x64 = []; | |
var x86 = []; | |
var mmx = []; | |
var flags = this.ctx[0xA0]; | |
var regs = "RAX RCX RDX RBX RSP RBP RSI RDI R8_ R9_ R10 R11 R12 R13 R14 R15 RFX".split(/\s+/); | |
/*text.push(`[${(" " + this.marginal.toString(10)).substr(-4)}#${this.id<160?"D"+(this.id>>4):" "}+${this.address.toHex(4)}+${this.offset.toHex(4)}]${this.prefixes}`); | |
text.push(`PC:${this.ctx.pointer(0x00BE).toHex(4)} TICKS:${this.ticks}`); | |
text.push(`AF:${flags & 0x08 ? "AF(Is Among)" : "NA(No Among)"}`); | |
text.push(`BF:${flags & 0x04 ? "BF(Is ???)" : "NB(No ???)"}`); | |
text.push(`CF:${flags & 0x02 ? "CF(Is Carry)" : "NC(No Carry)"}`); | |
text.push(`DF:${flags & 0x01 ? "DF(Is Duplex)" : "ND(No Duplex)"}`);*/ | |
this.is_peek = true; | |
x80.push(`BC:${snap.BC.toHex(4)}`); | |
x80.push(`DE:${snap.DE.toHex(4)}`); | |
x80.push(`HL:${snap.HL.toHex(4)}`); | |
x80.push(`AF:${snap.PSW.toHex(4)}`); | |
x80.push(`SP:${snap.SP.toHex(4)}`); | |
x80.push(`+0:${(this.ram[snap.SP] + this.ram[snap.SP + 1n] * 256).toHex(4)}`); | |
x80.push(`+2:${(this.ram[snap.SP + 2n] + this.ram[snap.SP + 3n] * 256).toHex(4)}`); | |
x80.push(`+4:${(this.ram[snap.SP + 4n] + this.ram[snap.SP + 5n] * 256).toHex(4)}`); | |
x80.push(`+6:${(this.ram[snap.SP + 6n] + this.ram[snap.SP + 7n] * 256).toHex(4)}`); | |
x80.push(`+8:${(this.ram[snap.SP + 8n] + this.ram[snap.SP + 9n] * 256).toHex(4)}`); | |
for(i = 0; i <= 7; ++ i) { | |
x86.push(`${regs[i].replace("R", "E")}:${snap[i].toHex(8)}`); | |
mmx.push(`MM${i}:${snap["MM" + i].toHex(16)}`); | |
} | |
for(i = 0; i <= 16; ++ i) { | |
x64.push(`${regs[i]}:${snap[i].toHex(16)}`); | |
} | |
x86.push(`${regs[16].replace("R", "E")}:${snap[16].toHex(8)}`); | |
this.is_peek = false; | |
return { | |
mmx: mmx.join("\r\n"), | |
x80: x80.join("\r\n"), | |
x64: x64.join("\r\n"), | |
x86: x86.join("\r\n") | |
}; | |
} | |
////////////////////////////////////////////////////////////////////// | |
this.prepareImage | |
= function(im) { | |
var pScr = []; | |
var hSrc = document.createElement("canvas").getContext("2d"); | |
hSrc.canvas.width = im.width; | |
hSrc.canvas.height = im.height; | |
hSrc.canvas.setAttribute("crossOrigin", ""); | |
hSrc.imageSmoothingEnabled = false; | |
hSrc.drawImage(im, 0, 0); | |
var imdt = hSrc.getImageData(0, 0, hSrc.canvas.width, hSrc.canvas.height); | |
var data = imdt.data; | |
var len = data.length; | |
var i, bytes, code = 0; | |
var bc, gc, rc; | |
var sprite = false; | |
var flag, index; | |
var paper, sprite, indexes, output; | |
var rrggbb; | |
// | |
for(i = 0; i < len; i += 4) { | |
paper = { | |
b: (data[i] & 0x30) << 2, | |
g: (data[i + 1] & 0x30) << 2, | |
r: (data[i + 2] & 0x30) << 2 | |
}; | |
sprite = { | |
b: (data[i] & 0xC0), | |
g: (data[i + 1] & 0xC0), | |
r: (data[i + 2] & 0xC0) | |
}; | |
indexes = { | |
b: (data[i] & 0x0C) << 4, | |
g: (data[i + 1] & 0x0C) << 4, | |
r: (data[i + 2] & 0x0C) << 4 | |
}; | |
flag = paper.r == sprite.r && paper.g == sprite.g && paper.b == sprite.b; | |
if(flag) { | |
output = { | |
r: paper.r & 0xC0, | |
g: paper.g & 0xC0, | |
b: paper.b & 0xC0 | |
}; | |
} else { | |
output = { | |
r: sprite.r & 0xC0, | |
g: sprite.g & 0xC0, | |
b: sprite.b & 0xC0 | |
}; | |
} | |
data[i] = output.b; | |
data[i + 1] = output.g; | |
data[i + 2] = output.r; | |
code = ((indexes.r & 0xC0) >> 2) | ((indexes.g & 0xC0) >> 4) | ((indexes.b & 0xC0) >> 6); | |
output_rrggbb = (output.r >> 2) | (output.g >> 4) | (output.b >> 6); | |
paper_rrggbb = (paper.r >> 2) | (paper.g >> 4) | (paper.b >> 6); | |
sprite_rrggbb = (sprite.r >> 2) | (sprite.g >> 4) | (sprite.b >> 6); | |
if(index != code) { | |
index = code; | |
pScr.push(index); | |
pScr.push(128 + paper_rrggbb); | |
} else { | |
pScr.push(128 + 64 + sprite_rrggbb); | |
pScr.push(128 + 0 + paper_rrggbb); | |
} | |
} | |
// | |
pScr.width = hSrc.canvas.width; | |
pScr.height = hSrc.canvas.height; | |
return pScr; | |
} | |
////////////////////////////////////////////////////////////////////// | |
this.render | |
= function(hCnv, pScr) { | |
if(hCnv.canvas.width != pScr.width || hCnv.canvas.height != pScr.height) { | |
hCnv.canvas.width = pScr.width * 2; | |
hCnv.canvas.height = pScr.height * 2; | |
} | |
var imdt = hCnv.getImageData(0, 0, hCnv.canvas.width, hCnv.canvas.height); | |
var data = imdt.data; | |
var r = 0, g = 0, b = 0; | |
var len = data.length / 3; | |
var dup = hCnv.canvas.width * 4; | |
var i = 0, bytes, index = 0, shift = 0; | |
var d, x, y; | |
var s = 0; | |
var mask = this.devices.i82CB.buffer.slice(0x0, 0x08); | |
var rn, gn, bn, noisel = 0; | |
// | |
for(y = 0; y < hCnv.canvas.height; ++ y) { | |
for(x = 0; x < hCnv.canvas.width; ++ x) { | |
if(-- noisel < 0) { | |
noisel = Math.floor(Math.random() * 64 * this.render.noise / 100) + 8; | |
rn = Math.floor(Math.random() * 256 * this.render.noise / 100); | |
gn = Math.floor(Math.random() * 256 * this.render.noise / 100); | |
bn = Math.floor(Math.random() * 256 * this.render.noise / 100); | |
} | |
d = pScr[s ++]; | |
if(d & 128) { | |
if(((d >> 6) & 1) == ((mask[index] >> shift) & 1)) { | |
b = ((d & 3) << 6) ^ bn; | |
g = ((d & 12) << 4) ^ gn; | |
r = ((d & 48) << 2) ^ rn; | |
} | |
} else { | |
index = (d >> 3) & 15; | |
shift = d & 7; | |
} | |
data[i] = b; | |
data[i + 1] = g; | |
data[i + 2] = r; | |
data[i + 3] = 255; | |
data[i + dup] = b; | |
data[i + dup + 1] = g; | |
data[i + dup + 2] = r; | |
data[i + dup + 3] = 255; | |
i += 4; | |
if(x == hCnv.canvas.width - 1) | |
i += dup; | |
} | |
} | |
hCnv.putImageData(imdt, 0, 0); | |
} | |
////////////////////////////////////////////////////////////////////// | |
function parse_vector(text) { | |
var j; | |
var base; | |
var product = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | |
var offset = 0, sign = 1; | |
var scan = 0; | |
var immediate = text.match(/\$[-+]?/); | |
var mode = 0; | |
var parts; | |
var codes = [], code; | |
var uses, used; | |
var using, usings; | |
if(text.match(/\$\+D/i) || text.match(/\$\+\d/)) | |
mode = 1, | |
parts = text.replace(/\$\+/, "").match(/(D\d)|(\+\d*D\d)|([-+]\d+)/gi); | |
else | |
if(text.match(/[1-9]+#/)) | |
mode = Number(text.match(/(\d+)/)[1]), | |
parts = text.replace(/\d+#/, "").match(/(D\d)|(\+\d*D\d)|([-+]\d+)/gi); | |
else | |
parts = text.match(/(D\d)|(\+\d*\*?D\d)|([-+]?\d+)/gi); | |
if(parts) { | |
if(parts[0].match(/^D\d$/i)) | |
base = Number(parts[0].substr(-1)); | |
else | |
if(parts[0].match(/[-+]\d+/)) | |
offset = Number(parts[0].substr(1)), | |
base = 9; | |
for(i = 1; i < parts.length; ++ i) { | |
if(parts[i].match(/\+\d*D\d/i)) { | |
product[Number(parts[i].substr(-1))] += isFinite(parseInt(parts[i].substr(1))) ? parseInt(parts[i].substr(1)) : 1; | |
} else | |
if(parts[i].match(/[-+]\d+/)) { | |
if(parts[i].match(/-\d+/)) | |
sign = -1; | |
offset = Number(parts[i].substr(1)); | |
} | |
} | |
for(i = 0; i <= 9; ++ i) { | |
j = -1; | |
while((product[i] >> (j + 1)) > 0) | |
++ j; | |
if(scan < j) | |
scan = j; | |
} | |
used = 0; | |
usings = []; | |
usings.push(base); | |
while(scan >= 0) { | |
uses = 0; | |
using = []; | |
i = usings.pop(); | |
code = []; | |
if((product[i] >> scan) > 0) { | |
product[i] -= 1 << scan; | |
uses |= 1 << i; | |
code.push(i); | |
if(scan > 0 && ((product[i] >> (scan - 1)) & 1) > 0) | |
using.push(String(i)); | |
} | |
for(i = 0; i <= 9; ++ i) { | |
if((product[i] >> scan) > 0) { | |
uses |= 1 << i; | |
code.push(String(i)); | |
if(scan > 0 && ((product[i] >> (scan - 1)) & 1) > 0) | |
using.push(i); | |
} | |
} | |
if((used & uses) == 0) | |
codes.push(String(base)); | |
codes = codes.concat(code); | |
for(i = 0; i <= 9; ++ i) { | |
if((product[i] >> scan) > 0) | |
product[i] -= 1 << scan; | |
} | |
-- scan; | |
used = uses; | |
usings = [base].concat(using); | |
} | |
} | |
i = codes.length; | |
while(-- i >= 0) { | |
codes[i] += String(offset % 10); | |
offset = Math.floor(offset / 10); | |
} | |
while(offset > 0) { | |
codes.unshift(String(base) + String(offset % 10)); | |
offset = Math.floor(offset / 10); | |
} | |
if(immediate) | |
codes.unshift(String(base) + "0"), | |
codes.unshift(String(base) + "0"); | |
if(sign < 0) | |
codes.unshift(String(base) + "0"); | |
if(typeof mode != "number") | |
mode = mode ? Number(mode[1]) : 0; | |
while(mode > 0) { | |
codes.unshift(String(mode % 10) + "0"); | |
codes.unshift(String(mode % 10) + "0"); | |
mode = Math.floor(mode / 10); | |
} | |
return codes.join(" "); | |
} | |
////////////////////////////////////////////////////////////////////// | |
function show_vector(codes) { | |
var mul = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | |
var sep = -1; | |
var offset = 0; | |
var hi, lo, i; | |
var exp = [""]; | |
var last = -1; | |
var nulls = 0; | |
var mode = 0; | |
var key = 0; | |
var flag; | |
var sign = "+"; | |
var pairs = 0; | |
var marginal = 0; | |
console.log(codes.join(" ")); | |
codes | |
.forEach | |
/* this.offset += this.offset << 2; | |
this.offset <<= 1; | |
this.offset += ic.right; | |
if(this.offset == 0 && ic.left == this.id.left && this.pairs == (1 << this.id.left)) | |
this.marginal = this.marginal * 10 + ic.left, | |
this.id = 160, | |
this.pairs = 0; | |
else | |
if(((this.pairs >> ic.left) & 1) > 0) { | |
this.address <<= 1, | |
this.pairs = (1 << ic.left); | |
if(this.id < 160) | |
this.pairs |= (1 << this.id.left); | |
if(ic.left != this.id.left && this.id < 160) | |
this.address += this.ctx.pointer(0x00B0 | ic.left); | |
} else | |
if(this.id < 160) { | |
this.pairs |= (1 << ic.left); | |
++ this.prefixes; | |
this.address += this.ctx.pointer(0x00B0 | ic.left); | |
} else | |
//if(this.offset == 0 && this.prefixes % 2 == 0) | |
this.id = ic, | |
this.pairs |= (1 << this.id.left), | |
this.address = 0; | |
ic = this.ram[++ ip]; | |
if(this.pairs == 0) | |
++ this.prefixes; | |
*/ (function(data) { | |
if(data.length > 1 && isFinite(data.substr(0, 2))) { | |
hi = Math.floor(Number(data.substr(0, 2)) / 10); | |
lo = Number(data.substr(0, 2)) % 10; | |
offset = Number(offset) * 10 + lo; | |
if(offset == 0 && hi == sep && pairs == 0) { | |
console.log(sep); | |
marginal = marginal * 10 + hi, | |
sep = -1, | |
pairs = 0; | |
} else | |
if(((pairs >> hi) & 1) > 0 || hi == sep) { | |
for(i = 0; i < 10; ++ i) | |
mul[i] <<= 1; | |
pairs = (1 << hi); | |
if(sep >= 0) | |
pairs |= (1 << sep); | |
if(hi != sep && sep >= 0) | |
mul[hi] ++; | |
} else | |
if(sep >= 0) | |
pairs |= (1 << hi), | |
mul[hi] ++; | |
else | |
sep = hi, | |
mul[0] = mul[1] = mul[2] = mul[3] = mul[4] = mul[5] = mul[6] = mul[7] = mul[8] = mul[9] = 0; | |
/* if(offset == 0 && hi == sep && lo == 0) { | |
key = key * 10 + sep, | |
sep = -1; | |
} else | |
if(sep < 0) | |
sep = hi; | |
else | |
if(sep == hi || (mul[hi] & 1) > 0) { | |
flag = true; | |
for(i = 0; i < 10; ++ i) { | |
if(mul[i] > 0) | |
flag = false; | |
mul[i] <<= 1; | |
} | |
if(sep != hi) | |
mul[hi] ++; | |
else | |
if(flag) { | |
mode ++; | |
/*if((mode > 0) && (mode % 2) == 0) | |
key = key * 10 + sep, | |
sep = -1;*//* | |
} | |
} else { | |
if(sep == last) | |
for(i = 0; i < 10; ++ i) | |
mul[i] <<= 1; | |
mul[hi] ++; | |
} | |
last = hi;*/ | |
} | |
}); | |
for(i = 0; i < 10; ++ i) { | |
if(sep != i && mul[i] > 0) | |
exp.push("+" + mul[i] + "*D" + i); | |
} | |
//key = mode; | |
if(offset == 0) | |
offset = ""; | |
else | |
offset = String(offset); | |
return (marginal == "" ? "" : `${marginal}#`) + "D" + sep + exp.join("") + (offset != "" ? "+" + offset : ""); | |
switch(marginal % 10) { | |
case 0: | |
case 1: return "$" + exp.join("") + "+" + offset; | |
case 2: return `BC${sep}` + exp.join("") + (offset != "" ? "+" + offset : ""); | |
case 3: return `BC${sep}` + exp.join("") + (offset != "" ? "-" + offset : ""); | |
case 4: return `BC${sep}` + "++" + exp.join("") + (offset != "" ? "+" + offset : ""); | |
case 5: return `BC${sep}` + "--" + exp.join("") + (offset != "" ? "+" + offset : ""); | |
case 6: return "++" + `BC${sep}` + exp.join("") + (offset != "" ? "+" + offset : ""); | |
case 7: return "--" + `BC${sep}` + exp.join("") + (offset != "" ? "+" + offset : ""); | |
case 8: return `BC${sep}` + exp.join("") + (offset != "" ? "+" + offset : ""); | |
case 9: return `BC${sep}` + exp.join("") + (offset != "" ? "-" + offset : ""); | |
//case 0: case 1: return "D" + sep + exp.join("") + sign + offset; | |
//case 2: case 3: return "$" + exp.join("") + sign + offset; | |
default: return "???"; | |
} | |
} | |
////////////////////////////////////////////////////////////////////// | |
this.Do_Snaps = (line) => { | |
if(this.snaps.length <= line) | |
this.snaps[line] = [this.context()]; | |
else | |
this.snaps[line].push(this.context()); | |
} | |
////////////////////////////////////////////////////////////////////// | |
this.Canvas_Directive = function(_this, part3, part4) { | |
if(part3 && part3.match(/^([ER][A-D]X|[ER][BS]P|[ER][DS]I|R[89]|R1[0-5])$/i)) { | |
tmp = _this.X64_R[part3.toUpperCase()].toHex(16); | |
var x = parseInt(tmp.substr(12, 4), 16); | |
var y = parseInt(tmp.substr(8, 4), 16); | |
var rgba = parseInt(tmp.substr(0, 8), 16); | |
if(part4 && part4.toUpperCase() in this.labels) { | |
tmp = parseInt(tmp.substr(8, 8), 16); | |
var pitch = parseInt(this.labels[part4.toUpperCase()].toHex(16), 16); | |
x = tmp % pitch; | |
y = (tmp - x) / pitch; | |
} | |
_this.images.push({x: x, y: y, rgba: rgba}); | |
return; | |
tmp = hDisplay.getImageData(x % hDisplay.canvas.width - 1, y % hDisplay.canvas.height - 1, 3, 3); | |
tmp.data[3] = 255; | |
tmp.data[7] = 255; | |
tmp.data[11] = 255; | |
tmp.data[15] = 255; | |
tmp.data[16] = (rgba & 255); | |
tmp.data[17] = (rgba >> 8) & 255; | |
tmp.data[18] = (rgba >> 16) & 255; | |
tmp.data[19] = (rgba >> 24) & 255; | |
tmp.data[23] = 255; | |
tmp.data[27] = 255; | |
tmp.data[31] = 255; | |
tmp.data[35] = 255; | |
hDisplay.putImageData(tmp, x % hDisplay.canvas.width - 1, y % hDisplay.canvas.height - 1); | |
//hDisplay.canvas.style.display = "block"; | |
if(true || review >= 0) { | |
//if(/*(dbg_loop_start > 0 && dbg_loop_count > 0 && _this.images.length <= dbg_loop_count) || */_this.images.length < 1) | |
_this.images.push(new Image(hDisplay.canvas.width, hDisplay.canvas.height)); | |
_this.images[_this.images.length - 1].src = hDisplay.canvas.toDataURL("image/png"); | |
} | |
} else | |
if(part3 && part3.match(/^MM[0-7]$/i)) { | |
tmp = _this.X64_R[part3.toUpperCase()].toHex(16); | |
var x = parseInt(tmp.substr(12, 4), 16); | |
var y = parseInt(tmp.substr(8, 4), 16); | |
var rgba = parseInt(tmp.substr(0, 8), 16); | |
if(part4 && part4.toUpperCase() in this.labels) { | |
tmp = parseInt(tmp.substr(8, 8), 16); | |
var pitch = parseInt(this.labels[part4.toUpperCase()].toHex(16), 16); | |
x = tmp % pitch; | |
y = (tmp - x) / pitch; | |
} | |
_this.images.push({x: x, y: y, rgba: rgba}); | |
return; | |
tmp = hDisplay.getImageData(x % hDisplay.canvas.width - 1, y % hDisplay.canvas.height - 1, 3, 3); | |
tmp.data[3] = 255; | |
tmp.data[7] = 255; | |
tmp.data[11] = 255; | |
tmp.data[15] = 255; | |
tmp.data[16] = (rgba & 255); | |
tmp.data[17] = (rgba >> 8) & 255; | |
tmp.data[18] = (rgba >> 16) & 255; | |
tmp.data[19] = (rgba >> 24) & 255; | |
tmp.data[23] = 255; | |
tmp.data[27] = 255; | |
tmp.data[31] = 255; | |
tmp.data[35] = 255; | |
hDisplay.putImageData(tmp, x % hDisplay.canvas.width - 1, y % hDisplay.canvas.height - 1); | |
//hDisplay.canvas.style.display = "block"; | |
if(true || review > 0) { | |
//if((/*dbg_loop_start > 0 && dbg_loop_count > 0 && _this.images.length <= dbg_loop_count*/true) || _this.images.length < 1) | |
_this.images.push(new Image(hDisplay.canvas.width, hDisplay.canvas.height)); | |
_this.images[_this.images.length - 1].src = hDisplay.canvas.toDataURL("image/png"); | |
} | |
} else | |
if(part3 && part3.match(/CLEAR/i)) { | |
hDisplay.imageSmoothingEnabled = false; | |
hDisplay.canvas.style.imageRendering = "pixelated"; | |
Display_Line(+hDisplay.canvas.dataset.x1, +hDisplay.canvas.dataset.y1, +hDisplay.canvas.dataset.x2, +hDisplay.canvas.dataset.y2); | |
_this.images = []; | |
return; | |
if(true || review >= 0) { | |
//if((/*dbg_loop_start > 0 && dbg_loop_count > 0 && _this.images.length <= dbg_loop_count*/true) || _this.images.length < 1) | |
_this.images.push(new Image(hDisplay.canvas.width, hDisplay.canvas.height)); | |
_this.images[_this.images.length - 1].src = hDisplay.canvas.toDataURL("image/png"); | |
} | |
} | |
} | |
////////////////////////////////////////////////////////////////////// | |
this.Log_Directive = function(i, ...part) { | |
if(part[0] && part[0].match(/CLEAR/i)) { | |
this.logging = []; | |
hEmuDump.textContent = ""; | |
return; | |
} | |
if(part[3]) { | |
if(part[3].substr(1, part[3].length - 2).indexOf("_") > 0) | |
this.format = part[3];//.substr(1, part[3].length - 2); | |
if(!part[0] && !part[1] && !part[2]) | |
this.logging.push(part[3]);//.substr(1, part[3].length - 2)); | |
} | |
var digits = this.format.replace(/_/g, "").replace(/^\s+/, "").length; | |
for(j = 0; j <= 2; ++ j) { | |
if(part[j] && part[j].match(/^(R([A-D]X|[SB]P|[SD]I|[89]|1[0-5])|E?([A-D]X|[BS]P|[DS]I)|[A-D][HL]|MM[0-7])$/i)) { | |
tmp = this.format; | |
this.logging.push( | |
(part[j] + ":" + this.X64_R[part[j].toUpperCase()].toHex(digits) | |
).replace(/./g, (s) => { | |
while(tmp.charAt(0) == "_") | |
s = "_" + s, | |
tmp = tmp.substr(1); | |
tmp = tmp.substr(1); | |
return s; | |
} | |
) + " " + this.label.join(".") + " #" + (i + 1) + | |
(this.limit > 0 ? "/" + this.limit : "")); | |
} | |
} | |
} | |
////////////////////////////////////////////////////////////////////// | |
this.label = []; | |
this.assembly | |
= function(text, head) { | |
var _this = this; | |
var rows = text.split(/\r?\n/); | |
var i, j; | |
var ri, ti; | |
var part, text; | |
var curLabel = ""; | |
var address = 0x0000; | |
var command, code; | |
var group, no_carry; // Group of command and add/sub vs adc/sbb | |
var codes; | |
var rcv = "X", trs = "X"; | |
var regs = {A:0xA0, B:0xB0, C:0xC0, D:0xD0}; | |
var alu = { | |
ADD:10, ADC:10, INC:10, | |
DEC:11, SBB:11, SUB:11, | |
AND:12, CLR:12, CON:12, | |
DIS:13, OR:13, SET:13, | |
EOR:14, NOT:14, XOR:14, | |
FOR:15, MOV:15 | |
}; | |
var defs = {}; | |
this.labels = []; | |
var review = 0; | |
var usr; | |
var vector, offset; | |
var __, _; | |
var arg, prefixes; | |
var inf; | |
var logging; | |
var dbg_loop_start = -1; | |
var dbg_loop_count = -1; | |
var dbg_loop_snaps = -1; | |
var dbg_loop_snappy = -1; | |
const Log_Program = (code) => { | |
if(code.substr(-1) == ";" || "{" == code.substr(-1)) | |
this.program.push("/*" + String(i + 1) + "*/\t" + code + " this.Do_Snaps(" + String(i) + ");"); | |
else | |
this.program.push("this.Do_Snaps(" + String(i) + ");//" + String(i + 1) + "\t" + rows[i]); | |
} | |
head = isFinite(head) ? head : 0; | |
// | |
do { | |
this.label = []; | |
this.program = []; | |
this.MMX_R[0] = 0x0123456765432109n; | |
this.MMX_R[1] = 0x0000000000000001n; | |
this.MMX_R[2] = 0x0000000000000002n; | |
this.MMX_R[3] = 0x0000000000000003n; | |
this.MMX_R[4] = 0x9ABCDE0F12345678n; | |
this.MMX_R[5] = 0x2D098CBE756431FAn; | |
this.MMX_R[6] = 0x0000000000000006n; | |
this.MMX_R[7] = 0x0765676567656765n; | |
this.X64_R[0] = 0x0000000000000000n; | |
this.X64_R[1] = 0x0000000000000000n; | |
this.X64_R[2] = 0x0000000000000000n; | |
this.X64_R[3] = 0x0000000000000000n; | |
this.X64_R[4] = 0x0000000000000000n; | |
this.X64_R[5] = 0x0000000000000000n; | |
this.X64_R[6] = 0x0000000000000000n; | |
this.X64_R[7] = 0x0000000000000000n; | |
this.X64_R[8] = 0x0000000000000000n; | |
this.X64_R[9] = 0x0000000000000000n; | |
this.X64_R[10] = 0x0000000000000000n; | |
this.X64_R[11] = 0x0000000000000000n; | |
this.X64_R[12] = 0x0000000000000000n; | |
this.X64_R[13] = 0x0000000000000000n; | |
this.X64_R[14] = 0x0000000000000000n; | |
this.X64_R[15] = 0x0000000000000000n; | |
this.X64_R[16] = 0x0000000000000000n; | |
this.snaps = []; | |
this.snaps_offset = []; | |
this.logging = []; | |
format = ""; | |
this.images = []; | |
for(i = 0; i < rows.length; ++ i) { | |
/* tmp = this.context();// + " #" + (i + head); | |
if(dbg_loop_snaps < 0) { | |
this.snaps.push([tmp]); | |
} else { | |
//tmp += "/" + dbg_loop_count; | |
if(this.snaps.length <= dbg_loop_snappy) | |
this.snaps.push([tmp]); | |
else | |
this.snaps[dbg_loop_snappy].push(tmp); | |
dbg_loop_snappy ++; | |
}*/ | |
codes = []; | |
this.dis_lines_points[i + head] = address; | |
this.dis_points_lines[address] = i + head; | |
part = /([^:;"'`\s]*(?::))?(?:\s)*([^\s;]*)(?:\s*)([^\s,;"'`]*)(?:[,\s]*)?([^\s,;"'`]*)?(?:[,\s]*)?([^\s,;"'`]*)(?:[,\s]*)?(?:(?:("(?:\\.|.)*?")|('(?:\\.|.)*?')|(`(?:\\.|.)*?`)|[^;"'`]*)*)*(\.*)/.exec(rows[i].replace(/(\d[0-9A-F]*)h/gi, "0x$1")); | |
if(part[1]) { | |
switch(part[2].toUpperCase()) { | |
case ".DEF": | |
defs[part[1].toUpperCase()] = { bytes: 0, code: parseInt(part[3])}; | |
this.dis_lines_points[i + head] = parseInt(part[3]) << 8; | |
break; | |
case ".DEFB": | |
defs[part[1].toUpperCase()] = { bytes: 1, code: parseInt(part[3])}; | |
this.dis_lines_points[i + head] = parseInt(part[3]) << 8; | |
break; | |
case ".DEFW": | |
defs[part[1].toUpperCase()] = { bytes: 2, code: parseInt(part[3])}; | |
this.dis_lines_points[i + head] = parseInt(part[3]) << 8; | |
break; | |
default: | |
if(part[2] && part[2].toUpperCase() == ".MMXEQU") | |
break; | |
part[1] = part[1].replace(/[ :]$/, ""); | |
tmp = part[1].replace(/:/g, "..").match(/(\.*)(.*)/); | |
this.label = this.label.slice(0, tmp[1].length).concat(tmp[2].split(".")); | |
part[1] = this.label.join("."); | |
if(this.labels[part[1]] != address) | |
delete this.labels[this.labels[part[1].toUpperCase()]]; | |
this.labels[address] = part[1]; | |
this.labels[part[1].toUpperCase()] = address; | |
break; | |
} | |
} | |
/* if(part[2].toUpperCase() == ".DEF") { | |
rcv = "X", trs = "X"; | |
regs.A = 0xFA; | |
regs.B = 0xFB; | |
regs.C = 0xFC; | |
regs.D = 0xFD; | |
if(part[3].toUpperCase() in defs) | |
address = defs[part[3].toUpperCase()].code << 8; | |
this.dis_lines_points[i + head] = address; | |
this.dis_points_lines[address] = i + head; | |
} else*/ | |
if(part[2].charAt(0) == ".") { | |
switch(part[2].toUpperCase()) { | |
/* case ".DBG_BYTES": | |
this.dis_line_bytes = parseInt(part[3]); | |
if(part[4]) | |
this.dis_line_bytesingle = parseInt(part[4]); | |
else | |
this.dis_line_bytesingle = parseInt(part[3]); | |
break; | |
case ".DBG_CHARS": | |
this.dis_line_letters = parseInt(part[3]); | |
if(part[4]) | |
this.dis_line_lettersingle = parseInt(part[4]); | |
else | |
this.dis_line_lettersingle = parseInt(part[3]); | |
break;*/ | |
case ".HIDE": | |
switch(part[3].toUpperCase()) { | |
case "ALL": | |
this.Views = "-"; | |
break; | |
} | |
break; | |
case ".SHOW": | |
this.Views = part[3].toUpperCase(); | |
break; | |
case ".REPEAT": | |
if(part[3] && !isFinite(part[3]) && part[3].toUpperCase() in this.labels) { | |
Log_Program(/*`console.log(this.labels.${part[3].toUpperCase().replace(/\[|\]/g, "")});*/`} while(this.limit ++ < 1000 && -- this.labels.${part[3].toUpperCase().replace(/\[|\]/g, "")} > 0); hIteration.max = this.limit - 1;`); | |
continue; | |
if(dbg_loop_start > 0 && dbg_loop_count >= 0) { | |
for(var lpp = 1; lpp <= Number(parseInt(this.labels[part[3].toUpperCase()].toHex(16).substr(-2), 16)); ++ lpp) { | |
eval(this.program.slice(dbg_loop_start, i).join("\r\n")); | |
/* tmp = this.context();// + " #" + (i + head); | |
//tmp += "/" + dbg_loop_count; | |
if(this.snaps.length <= dbg_loop_snappy) | |
this.snaps.push([tmp]); | |
else | |
this.snaps[dbg_loop_snappy].push(tmp);*/ | |
dbg_loop_snappy ++; | |
hIteration.max = ++ dbg_loop_count; | |
} | |
dbg_loop_snaps = -1; | |
dbg_loop_start = -1; | |
dbg_loop_count = -1; | |
/*if(dbg_loop_count < Number(parseInt(labels[part[3].toUpperCase()].toHex(16).substr(-2), 16))) { | |
hIteration.max = ++ dbg_loop_count; | |
i = dbg_loop_start; | |
dbg_loop_snappy = dbg_loop_snaps; | |
} else { | |
dbg_loop_snaps = -1; | |
dbg_loop_start = -1; | |
dbg_loop_count = -1; | |
}*/ | |
} | |
} else | |
if(isFinite(part[3]) && Number(part[3])) { | |
Log_Program(/*`console.log(this.labels.${part[3].toUpperCase().replace(/\[|\]/g, "")});*/`} while(++ this.limit < Number(${part[3]})); hIteration.max = this.limit - 1;`); | |
continue; | |
if(dbg_loop_start > 0 && dbg_loop_count >= 0) { | |
if(dbg_loop_count < Number(part[3])) { | |
hIteration.max = ++ dbg_loop_count; | |
i = dbg_loop_start; | |
dbg_loop_snappy = dbg_loop_snaps; | |
} else { | |
dbg_loop_snaps = -1; | |
dbg_loop_start = -1; | |
dbg_loop_count = -1; | |
} | |
} | |
} else { | |
dbg_loop_start = i; | |
dbg_loop_count = 0; | |
dbg_loop_snappy = this.snaps.length; | |
dbg_loop_snaps = this.snaps.length; | |
hIteration.max = 0; | |
Log_Program(`this.limit = 0; do {`); | |
} | |
continue; | |
case ".LOG": | |
if(part[3]) { | |
if(part[3].toUpperCase() in this.labels) | |
part[3] = "`${this.labels." + part[3].toUpperCase() + "}`"; | |
else | |
part[3] = "`" + part[3] + "`"; | |
} | |
if(part[4]) { | |
if(part[4].toUpperCase() in this.labels) | |
part[4] = "`${this.labels." + part[4].toUpperCase() + "}`"; | |
else | |
part[4] = "`" + part[4] + "`"; | |
} | |
if(part[5]) { | |
if(part[5].toUpperCase() in this.labels) | |
part[5] = "`${this.labels." + part[5].toUpperCase() + "}`"; | |
else | |
part[5] = "`" + part[5] + "`"; | |
} | |
if(part[6]) { | |
Log_Program(`this.Log_Directive(${i}, ${part[3] ? part[3] : undefined}, ${part[4] ? part[4] : undefined}, ${part[5] ? part[5] : undefined}, ${part[6]});`); | |
} else | |
if(part[5]) | |
Log_Program(`this.Log_Directive(${i}, ${part[3] ? part[3] : undefined}, ${part[4] ? part[4] : undefined}, ${part[5]});`); | |
else | |
if(part[4]) | |
Log_Program(`this.Log_Directive(${i}, ${part[3] ? part[3] : undefined}, ${part[4]});`); | |
else | |
if(part[3]) | |
Log_Program(`this.Log_Directive(${i}, ${part[3]});`); | |
continue; | |
case ".ORG": | |
rcv = "X", trs = "X"; | |
regs.A = 0xFA; | |
regs.B = 0xFB; | |
regs.C = 0xFC; | |
regs.D = 0xFD; | |
if(part[3].toUpperCase() in defs) | |
address = defs[part[3].toUpperCase()].code << 8; | |
else | |
address = parseInt(part[3]); | |
this.dis_lines_points[i + head] = address; | |
this.dis_points_lines[address] = i + head; | |
Log_Program(""); | |
continue; | |
case ".MMXEQU": | |
if(part[3] && part[3].match(/^MM[0-7]$/i)) { | |
this.labels[part[1].toUpperCase().replace(/[ :]/g, "")] = BigInt(this.MMX_R[part[3].substr(-1)]); | |
Log_Program(`this.labels.${part[1].toUpperCase().replace(/[ :]/g, "")}] = BigInt(this.MMX_R[${part[3].substr(-1)}]);`); | |
} else | |
Log_Program(""); | |
continue; | |
case ".EQU": | |
this.labels[part[1].toUpperCase()] = BigInt(part[3].replace(/_/g, "")); | |
this.dis_lines_points[i + head] = BigInt(part[3].replace(/_/g, "")); | |
Log_Program(""); | |
continue; | |
case ".DB": | |
if(part[5] && (part[5].charAt(0) == '"')) { | |
this.dis_lines_points[i + head] = address; | |
part[5].substr(1, part[5].length - 2) | |
.replace(/\\0/g, "\0") | |
.replace(/\\n/g, "\n") | |
.replace(/\\r/g, "\r") | |
.replace(/\\t/g, "\t") | |
.split("") | |
.forEach | |
(function(ascii) { | |
if(review > 0) | |
_this.dis_lines_tables[address] = true; | |
_this.dis_points_lines[address] = i + head; | |
_this.ram[address ++] = ascii.charCodeAt(0); | |
return 0; | |
}); | |
} else { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[3]); | |
} | |
Log_Program(""); | |
continue; | |
case ".DW": | |
code = parseInt(part[3]); | |
this.dis_lines_points[i + head] = address; | |
this.dis_points_lines[address] = i + head; | |
if(review > 0) | |
this.dis_lines_tables[address] = true; | |
this.ram[address ++] = code.low; | |
this.dis_points_lines[address] = i + head; | |
if(review > 0) | |
this.dis_lines_tables[address] = true; | |
this.ram[address ++] = code.high; | |
Log_Program(""); | |
continue; | |
/* case ".CLR": | |
rcv = "X", trs = "X"; | |
Log_Program(""); | |
continue; | |
case ".DEF": | |
if(!part[1]) | |
this.dis_lines_points[i + head] = parseInt(part[4]) << 8, | |
defs[part[3].toUpperCase()] = { bytes: 0, code: parseInt(part[4])}; | |
break; | |
case ".DEFB": | |
if(!part[1]) | |
this.dis_lines_points[i + head] = parseInt(part[4]) << 8, | |
defs[part[3].toUpperCase()] = { bytes: 1, code: parseInt(part[4])}; | |
break; | |
case ".DEFW": | |
if(!part[1]) | |
this.dis_lines_points[i + head] = parseInt(part[4]) << 8, | |
defs[part[3].toUpperCase()] = { bytes: 2, code: parseInt(part[4])}; | |
break;*/ | |
case ".IMGUR": | |
hSprites.src = "https://i.imgur.com/" + part[3]; | |
Log_Program(""); | |
continue; | |
case ".CANVAS": | |
this.Views = this.Views.replace(/CANVAS\s?/, "").replace("AUTO", "CANVAS AUTO"), | |
/* if(part[3].match(/clear/i)) | |
Log_Program(`this.pBitMap = new Uint32Array(hDisplay.getImageData(0, 0, ${hDisplay.canvas.width}, ${hDisplay.canvas.height}));`); | |
else | |
Log_Program(`this.pBitMap[Number((_.${part[3].toUpperCase()} & 0xFFFFn) % ${hDisplay.canvas.width}n + ((_.${part[3].toUpperCase()} >> 16n) & 0xFFFFn) * ${hDisplay.canvas.height}n)] = Number(0xFF000000n | (_.${part[3].toUpperCase()} >> 32n)); this.images.push(new Image()); this.images[this.images.length - 1].src = hDisplay.canvas.toDataURL("image/png");`); | |
continue; | |
*/ | |
this.Canvas_Directive(this, part[3], part[4]); | |
if(part[4]) | |
Log_Program(`this.Canvas_Directive(this, "${part[3]}", "${part[4]}");`); | |
else | |
if(part[3]) | |
Log_Program(`this.Canvas_Directive(this, "${part[3]}");`); | |
else | |
Log_Program(`this.Canvas_Directive(this);`); | |
continue; | |
} | |
} | |
for(j = 3; j <= 5; ++ j) { | |
if(part[j]) | |
part[j] = part[j].replace(/(\.*)([A-Z_a-z][A-Z_a-z.0-9]*)/g, function(str, nest, tag) { | |
var tmp; | |
if(_this.label && _this.labels.length) { | |
tmp = _this.labels[_this.label.slice(0, nest.length).concat(tag.split(".")).join(".").toUpperCase()]; | |
if(!tmp && tag && nest.length == 0) { | |
var segs = tag.toUpperCase().split("."); | |
if(segs[0] in Shell) | |
if(segs[1] && segs[1] in Shell[segs[0]]) | |
if(segs[2] && segs[2] in Shell[segs[0]][segs[1]]) | |
if(segs[3] && segs[3] in Shell[segs[0]][segs[1]][segs[2]]) | |
if("function" == typeof Shell[segs[0]][segs[1]][segs[2]][segs[3]]) | |
return "Shell." + tag.toUpperCase() + "()"; | |
else | |
return Shell[segs[0]][segs[1]][segs[2]][segs[3]]; | |
else | |
if("function" == typeof Shell[segs[0]][segs[1]][segs[2]]) | |
return "Shell." + tag.toUpperCase() + "()"; | |
else | |
return Shell[segs[0]][segs[1]][segs[2]]; | |
else | |
if("function" == typeof Shell[segs[0]][segs[1]]) | |
return "Shell." + tag.toUpperCase() + "()"; | |
else | |
return Shell[segs[0]][segs[1]]; | |
else | |
if("function" == typeof Shell[segs[0]]) | |
return "Shell." + tag.toUpperCase() + "()"; | |
else | |
return Shell[segs[0]]; | |
else | |
return str; | |
} | |
try { | |
if(isFinite(tmp)) | |
return String(Number(tmp)); | |
} catch(e) { | |
} | |
try { | |
if(BigInt(tmp)) | |
return String(BigInt(tmp)); | |
} catch(e) { | |
} | |
try { | |
if("function" == typeof tmp) | |
return String(nest + tag + "()"); | |
} catch(e) { | |
} | |
return nest + tag; | |
} | |
return str; | |
}); | |
} | |
/* if(part[4]) | |
part[4] = part[4].replace(/(\.*)([A-Z_a-z][A-Z_a-z.0-9]*)/g, function(str, nest, tag) { | |
var tmp; | |
if(label && labels.length) { | |
tmp = labels[label.slice(0, nest.length).concat(tag.split(".")).join(".").toUpperCase()]; | |
try { | |
if(isFinite(tmp)) | |
return String(Number(tmp)); | |
} catch(e) { | |
} | |
try { | |
if(BigInt(tmp)) | |
return String(BigInt(tmp)); | |
} catch(e) { | |
} | |
return nest + tag; | |
} | |
return str; | |
}); | |
if(part[5]) | |
part[5] = part[5].replace(/(\.*)([A-Z_a-z][A-Z_a-z.0-9]*)/g, function(str, nest, tag) { | |
var tmp; | |
if(label && labels.length) { | |
tmp = labels[label.slice(0, nest.length).concat(tag.split(".")).join(".").toUpperCase()]; | |
try { | |
if(isFinite(tmp)) | |
return String(Number(tmp)); | |
} catch(e) { | |
} | |
try { | |
if(BigInt(tmp)) | |
return String(BigInt(tmp)); | |
} catch(e) { | |
} | |
return nest + tag; | |
} | |
return str; | |
});*/ | |
command = (part[2] + " " + part[3] + (part[4] ? "," + part[4] + (part[5] ? "," + part[5] : "") : "")).toUpperCase(); | |
/*if(part[2].toUpperCase() in defs) { | |
usr = defs[part[2].toUpperCase()]; | |
switch(usr.bytes) { | |
case 0: | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = usr.code; | |
break; | |
case 1: | |
if(part[3].match(/[ABC]\d/i)) { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[3], 16); | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = usr.code; | |
this.dis_lines_tables[address] = true; | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[4]); | |
} else { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = usr.code; | |
this.dis_points_lines[address] = i + head; | |
this.dis_lines_tables[address] = true; | |
this.ram[address ++] = parseInt(part[3]); | |
} | |
rcv = "X", trs = "X"; | |
regs.A = 0xFA; | |
regs.B = 0xFB; | |
regs.C = 0xFC; | |
regs.D = 0xFD; | |
break; | |
case 2: | |
if(part[3].match(/BC\d/i)) { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[3].charAt(0) + part[3].charAt(2), 16); | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[3].substr(1), 16); | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = usr.code; | |
this.dis_points_lines[address] = i + head; | |
this.dis_lines_tables[address] = true; | |
this.ram[address ++] = parseInt(part[4]).low; | |
this.dis_points_lines[address] = i + head; | |
this.dis_lines_tables[address] = true; | |
this.ram[address ++] = parseInt(part[4]).high; | |
} else { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = usr.code; | |
this.dis_points_lines[address] = i + head; | |
this.dis_lines_tables[address] = true; | |
this.ram[address ++] = parseInt(part[3]).low; | |
this.dis_points_lines[address] = i + head; | |
this.dis_lines_tables[address] = true; | |
this.ram[address ++] = parseInt(part[3]).high; | |
} | |
rcv = "X", trs = "X"; | |
regs.A = 0xFA; | |
regs.B = 0xFB; | |
regs.C = 0xFC; | |
regs.D = 0xFD; | |
break; | |
} | |
}*/ | |
/*****************************************************************************/ | |
arg = []; | |
inf = []; | |
_ = []; | |
var encode = ""; | |
var X8_16 = { | |
H: "HL", | |
D: "DE", | |
B: "BC", | |
SP: "SP", | |
HL: "HL", | |
DE: "DE", | |
BC: "BC", | |
PSW: "PSW", | |
AF: "AF" | |
}; | |
group = part[2] | |
//.replace(/^(ADC|ADD|AND|CON|DIS|EOR|OR|SBB|SUB|MOV)$/i, "ALU") | |
;//.replace(/^(CLR|DEC|INC|NOT|SET)$/i, "UNA"); | |
no_carry = (part[2].match(/^(ADD|SUB)$/i)) ? "CE " : ""; | |
if(part[2].toUpperCase() in alu) | |
encode = alu[part[2].toUpperCase()]; | |
prefixes = []; | |
if(part[4]=='cx') | |
console.log(2); | |
for(j = 3; j <= 5 && j < part.length; ++ j) { | |
if(part[j] && part[j] != "") { | |
if(part[j].match(/^\[\d+\]$/gi)) { | |
_.push("@"); | |
if(part[j].match(/\[(\d+)\]/i)[1]) { | |
prefixes.push(part[j].match(/\[(.+)\]/i)[1]); | |
arg.push(prefixes[prefixes.length - 1]); | |
} else | |
arg.push(0); | |
} else | |
if(part[j].match(/[A-Z][A-Z_0-9\.]*\(\)/i)) { | |
_.push("@"); | |
arg.push(part[j].replace(/\[|\]/g, "")); | |
} else { | |
if(part[j].match(/^(MM[0-7])$/i)) | |
this.Views = this.Views.replace(/MMX\s?/, "").replace("AUTO", "MMX AUTO"), | |
_.push("MMX"), | |
arg.push(part[j].toUpperCase()); | |
else | |
if(part[j].match(/^(R([A-D]X|[SB]P|[SD]I|[89]|1[0-5]))$/i)) | |
this.Views = this.Views.replace(/X64\s?/, "").replace("AUTO", "X64 AUTO"), | |
_.push("R64"), | |
arg.push(part[j].toUpperCase()); | |
else | |
if(part[j].match(/^(E([A-D]X|[SB]P|[SD]I))$/i)) | |
this.Views = this.Views.replace(/X86\s?/, "").replace("AUTO", "X86 AUTO"), | |
_.push("R32"), | |
arg.push(part[j].toUpperCase()); | |
else | |
if(part[j].match(/^([A-D]X|[SB]P|[SD]I)$/i) && part[2].toUpperCase() != "LXI") | |
this.Views = this.Views.replace(/X86\s?/, "").replace("AUTO", "X86 AUTO"), | |
_.push("R16"), | |
arg.push(part[j].toUpperCase()); | |
else | |
if(part[j].match(/^([A-E]|[HL]|PSW|AF|SP)$/i)) | |
this.Views = this.Views.replace(/X80\s?/, "").replace("AUTO", "X80 AUTO"), | |
_.push("R80"), | |
arg.push(part[j].toUpperCase()); | |
else | |
if(part[j].match(/^\[?[A-Z][A-Z_0-9\.]*\]?$/i)) { | |
_.push("@"); | |
arg.push(part[j].replace(/\[|\]/g, "")); | |
} else { | |
_.push("&"); | |
arg.push(part[j]); | |
} | |
} | |
} else | |
arg.push(""); | |
} | |
if((_[1] + _[2]) == "@@") { | |
switch(_[0]) { | |
case "R64": | |
case "MMX": | |
arg[1] = `(BigInt(${arg[1]}) << BigInt(32)) | BigInt(${arg[2]})`; | |
_.pop(); | |
break; | |
case "R32": | |
arg[1] = `(BigInt(${arg[1]}) << BigInt(16)) | BigInt(${arg[2]})`; | |
_.pop(); | |
break; | |
case "R16": | |
break; | |
} | |
} else | |
if(prefixes.length > 1) | |
tmp = (BigInt(prefixes[0]) << BigInt(32)) | BigInt(prefixes[1]), | |
tmp32 = (BigInt(prefixes[0]) << BigInt(16)) | BigInt(prefixes[1]); | |
else | |
if(prefixes.length > 0) | |
tmp = BigInt(prefixes[0]), | |
tmp32 = (BigInt(prefixes[0]) << BigInt(16)) | (BigInt(prefixes[0]) & BigInt(0xFFFF)); | |
else | |
tmp = BigInt(0), | |
tmp32 = BigInt(0); | |
inf.push(0); | |
__ = part[2].toUpperCase() + (_.length > 0 ? " " + _.join() : ""); | |
_ = group + (_.length > 0 ? " " + _.join() : ""); | |
//Log_Program(__ + " // " + arg.join()); | |
__ = __.search.bind(__); | |
_ = _.search.bind(_); | |
switch(0) { | |
case _(/MOV R80,R80$/i): | |
Log_Program(`_.${arg[0]} = _.${arg[1]};`); | |
break; | |
case _(/MVI R80,(&)$/i): | |
Log_Program(`_.${arg[0]} = BigInt(${arg[1]});`); | |
break; | |
case _(/MVI R80,@$/i): | |
Log_Program(`_.${arg[0]} = BigInt(${arg[1]});`); | |
break; | |
case _(/LXI R80,(&)$/i): | |
case _(/LXI SP,(&)$/i): | |
Log_Program(`_.${X8_16[arg[0]]} = BigInt(${arg[1]});`); | |
break; | |
case _(/LXI R80,@$/i): | |
case _(/LXI SP,@$/i): | |
Log_Program(`_.${X8_16[arg[0]]} = BigInt(${arg[1]});`); | |
break; | |
case _(/XCHG$/i): | |
Log_Program(`$_ = _.HL; _.HL = _.DE; _.DE = $_;`); | |
break; | |
case _(/ADC R80$/i): | |
this.X64_R.ADC("A", this.X64_R.GET(arg[0])); | |
Log_Program(`_.ADC("A", _.${arg[0]});`); | |
break; | |
case _(/ACI (&)$/i): | |
this.X64_R.ADD("A", BigInt(arg[0])); | |
Log_Program(`_.ADD("A", BigInt(arg[0]));`); | |
break; | |
case _(/ADD R80$/i): | |
this.X64_R.ADD("A", this.X64_R.GET(arg[0])); | |
Log_Program(`_.ADD("A", _.${arg[0]});`); | |
break; | |
case _(/ADI (&)$/i): | |
this.X64_R.ADD("A", BigInt(arg[0])); | |
Log_Program(`_.ADD("A", BigInt(arg[0]));`); | |
break; | |
case _(/ANA R80$/i): | |
this.X64_R.AND("A", this.X64_R.GET(arg[0])); | |
Log_Program(`_.AND("A", _.${arg[0]});`); | |
break; | |
case _(/ANI (&)$/i): | |
this.X64_R.AND("A", BigInt(arg[0])); | |
Log_Program(`_.AND("A", BigInt(${arg[0]}));`); | |
break; | |
case _(/ORA R80$/i): | |
this.X64_R.OR("A", this.X64_R.GET(arg[0])); | |
Log_Program(`_.OR("A", _.${arg[0]});`); | |
break; | |
case _(/ORI (&)$/i): | |
this.X64_R.OR("A", BigInt(arg[0])); | |
Log_Program(`_.OR("A", BigInt(${arg[0]}));`); | |
break; | |
case _(/SBB R80$/i): | |
this.X64_R.SBB("A", this.X64_R.GET(arg[0])); | |
Log_Program(`_.SBB("A", _.${arg[0]});`); | |
break; | |
case _(/SBI (&)$/i): | |
this.X64_R.SBB("A", BigInt(arg[0])); | |
Log_Program(`_.SBB("A", BigInt(arg[0]));`); | |
break; | |
case _(/SUB R80$/i): | |
this.X64_R.SUB("A", this.X64_R.GET(arg[0])); | |
Log_Program(`_.SUB("A", _.${arg[0]});`); | |
break; | |
case _(/SUI (&)$/i): | |
this.X64_R.SUB("A", BigInt(arg[0])); | |
Log_Program(`_.SUB("A", BigInt(arg[0]));`); | |
break; | |
case _(/XRA R80$/i): | |
this.X64_R.XOR("A", this.X64_R.GET(arg[0])); | |
Log_Program(`_.XOR("A", _.${arg[0]});`); | |
break; | |
case _(/XRI (&)$/i): | |
this.X64_R.XOR("A", BigInt(arg[0])); | |
Log_Program(`_.XOR("A", BigInt(arg[0]));`); | |
break; | |
case _(/CMP R80$/i): | |
this.X64_R.CMP("A", this.X64_R.GET(arg[0])); | |
Log_Program(`_.CMP("A", _.${arg[0]});`); | |
break; | |
case _(/CPI (&)$/i): | |
this.X64_R.CMP("A", BigInt(arg[0])); | |
Log_Program(`_.CMP("A", BigInt(arg[0]));`); | |
break; | |
case _(/DAD R80$/i): | |
this.X64_R.ADD("HL", this.X64_R.GET(X8_16[arg[0]])); | |
Log_Program(`_.ADD("HL", _.${X8_16[arg[0]]});`); | |
break; | |
/*********************************************************************/ | |
case _(/PUSH R80$/i): | |
this.X64_R.SP = this.X64_R.SP - 2n; | |
this.ram[this.X64_R.SP] = this.X64_R.GET(X8_16[arg[0]]); | |
Log_Program(`_.SP -= 2n; this.ram[Number(_.SP)] = Number(_.${X8_16[arg[0]]}); this.ram[Number(_.SP + 1n)] = Number(_.${X8_16[arg[0]]}) >> 8;`); | |
break; | |
case _(/POP R80$/i): | |
this.X64_R.SET(X8_16[arg[0]], this.ram[this.X64_R.SP] || 0n); | |
this.X64_R.SP = this.X64_R.SP + 2n; | |
Log_Program(`_.${X8_16[arg[0]]} = this.ram[Number(_.SP)] + (this.ram[Number(_.SP + 1n)] * 256); _.SP += 2n;`); | |
break; | |
case _(/XTHL$/i): | |
tmp = this.ram[Number(this.X64_R.SP & 0xFFFFn)] + (this.ram[Number((this.X64_R.SP + 1n) & 0xFFFFn)] << 8); | |
this.ram[Number(this.X64_R.SP & 0xFFFFn)] = Number(this.X64_R.L); | |
this.ram[Number((this.X64_R.SP + 1n) & 0xFFFFn)] = Number(this.X64_R.H); | |
this.X64_R.HL = BigInt(tmp); | |
/*Log_Program(`$_ = this.ram[Number(_.SP & 0xFFFFn)] + (this.ram[Number((_.SP + 1n) & 0xFFFFn)] << 8); | |
this.ram[Number(_.SP & 0xFFFFn] = Number(_.L); | |
this.ram[Number((_.SP + 1n) & 0xFFFFn)] = Number(_.H); | |
_.HL = BigInt($_);`);*/ | |
break; | |
/*********************************************************************/ | |
case _(/MOV R64,@$/i): | |
this.X64_R.SET(arg[0], BigInt(tmp)); | |
Log_Program(`_.${arg[0]} = BigInt(${tmp});`); | |
break; | |
case _(/MOV R32,@$/i): | |
this.X64_R.SET(arg[0], BigInt(tmp32)); | |
Log_Program(`_.${arg[0]} = ${arg[1]};`); | |
break; | |
case _(/MOVSX (R64|R32|R16),(R32|R16|R8)$/i): | |
this.X64_R.MOVSX(arg[0], arg[1]); | |
Log_Program(`_.${arg[0]} = _.SIGNED.${arg[1]};`); | |
break; | |
case _(/MOVZX (R64|R32|R16),(R32|R16|R8)$/i): | |
case _(/MOV (R64|R32|R16|R8),(R32|R16|R8)$/i): | |
this.X64_R.SET(arg[0], this.X64_R.GET(arg[1])); | |
Log_Program(`_.${arg[0]} = _.${arg[1]};`); | |
break; | |
case _(/LXI (R80|R16),&$/i): | |
case _(/MOV (R64|R32|R16|R8),&$/i)://(\d+|0x[0-9A-F]+)$/i): | |
this.X64_R.SET(arg[0], BigInt(arg[1])); | |
Log_Program(`_.${arg[0]} = BigInt(${arg[1]});`); | |
break; | |
case _(/MOV @,(R64|R32|R16|R8)$/i): | |
this.labels[arg[0].toUpperCase()] = this.X64_R.GET(arg[1]); | |
Log_Program(`this.labels.${arg[0].toUpperCase().replace(/\[|\]/g, "")} = _.${arg[1]};`);// & BigInt(255);`); | |
break; | |
case _(/ADD (R64|R32|R16|R8),(R64|R32|R16|R8)$/i): | |
this.X64_R.ADD(arg[0], this.X64_R.GET(arg[1])); | |
Log_Program(`_.ADD("${arg[0]}", _.${arg[1]});`); | |
break; | |
case _(/AND (R64|R32|R16|R8),(R64|R32|R16|R8)$/i): | |
this.X64_R.AND(arg[0], this.X64_R.GET(arg[1])); | |
Log_Program(`_.AND("${arg[0]}", _.${arg[1]});`); | |
break; | |
case _(/AND (R64|R32|R16|R8),(&)$/i): | |
this.X64_R.AND(arg[0], BigInt(arg[1])); | |
Log_Program(`_.AND("${arg[0]}", BigInt(${arg[1]}));`); | |
break; | |
case _(/OR (R64|R32|R16|R8),(R64|R32|R16|R8)$/i): | |
this.X64_R.OR(arg[0], this.X64_R.GET(arg[1])); | |
Log_Program(`_.OR("${arg[0]}", _.${arg[1]});`); | |
break; | |
case _(/OR (R64|R32|R16|R8),(&)$/i): | |
this.X64_R.OR(arg[0], BigInt(arg[1])); | |
Log_Program(`_.OR("${arg[0]}", BigInt(${arg[1]}));`); | |
break; | |
case _(/SBB (R64|R32|R16|R8),(R64|R32|R16|R8)$/i): | |
this.X64_R.SBB(arg[0], this.X64_R.GET(arg[1])); | |
Log_Program(`_.SBB("${arg[0]}", _.${arg[1]});`); | |
break; | |
case _(/SUB (R64|R32|R16|R8),(R64|R32|R16|R8)$/i): | |
this.X64_R.SUB(arg[0], this.X64_R.GET(arg[1])); | |
Log_Program(`_.SUB("${arg[0]}", _.${arg[1]});`); | |
break; | |
case _(/SUB (R64|R32|R16|R8),(&)$/i): | |
this.X64_R.SUB(arg[0], BigInt(arg[1])); | |
Log_Program(`_.SUB("${arg[0]}", BigInt(${arg[1]}));`); | |
break; | |
case _(/XOR (R64|R32|R16|R8),(R64|R32|R16|R8)$/i): | |
this.X64_R.XOR(arg[0], this.X64_R.GET(arg[1])); | |
Log_Program(`_.XOR("${arg[0]}", _.${arg[1]});`); | |
break; | |
case _(/CMP (R64|R32|R16|R8),(R64|R32|R16|R8)$/i): | |
this.X64_R.CMP(arg[0], this.X64_R.GET(arg[1])); | |
Log_Program(`_.CMP("${arg[0]}", _.${arg[1]});`); | |
break; | |
case _(/NOT (R64|R32|R16|R8)$/i): | |
this.X64_R.SET(arg[0], ~this.X64_R.GET(arg[0])); | |
Log_Program(`_.${arg[0]} = ~_.${arg[0]};`); | |
break; | |
case _(/ROR (R32),(&)$/i): | |
this.X64_R.SET(arg[0], (this.X64_R.GET(arg[0]) >> BigInt(arg[1])) | (this.X64_R.GET(arg[0]) << BigInt(32 - arg[1]))); | |
Log_Program(`_.${arg[0]} = (_.${arg[0]} >> BigInt(${arg[1]})) | (_.${arg[0]} << BigInt(${32 - arg[1]}));`); | |
break; | |
case _(/SAR (R64|R32|R16|R8),(&)$/i): | |
this.X64_R.SAR(arg[0], BigInt(arg[1])); | |
Log_Program(`_.SAR("${arg[0]}", BigInt(${arg[1]}));`); | |
break; | |
case _(/SHL (R64|R32|R16|R8),(&)$/i): | |
this.X64_R.SET(arg[0], this.X64_R.GET(arg[0]) << BigInt(arg[1])); | |
Log_Program(`_.${arg[0]} = _.${arg[0]} << BigInt(${arg[1]});`); | |
break; | |
case _(/SHLD (R32),(R32),(&)$/i): | |
this.X64_R.SET(arg[0], (this.X64_R.GET(arg[0]) << BigInt(arg[2])) | (this.X64_R.GET(arg[1]) >> BigInt(32 - arg[2]))); | |
Log_Program(`_.${arg[0]} = (_.${arg[0]} << BigInt(${arg[2]})) | (_.${arg[1]} >> BigInt(${32 - arg[2]}));`); | |
break; | |
case _(/SHR (R64|R32|R16|R8),(&)$/i): | |
this.X64_R.SET(arg[0], this.X64_R.GET(arg[0]) >> BigInt(arg[1])); | |
Log_Program(`_.${arg[0]} = _.${arg[0]} >> BigInt(${arg[1]});`); | |
break; | |
/*********************************************************************/ | |
case _(/MOVQ R(32|64),MMX$/i): | |
this.X64_R.SET(arg[0], this.MMX_R[arg[1].substr(-1)]); | |
Log_Program(`_.${arg[0]} = _.${arg[1]};`); | |
break; | |
/*********************************************************************/ | |
case _(/MOVQ MMX,@(,@)?$/i): | |
this.MMX_R[arg[0].substr(-1)] = BigInt(tmp); | |
Log_Program(`_.${arg[0]} = ${arg[1]};`); | |
break; | |
case _(/MOVQ MMX,MMX$/i): | |
this.MMX_R[arg[0].substr(-1)] = this.MMX_R[arg[1].substr(-1)]; | |
Log_Program(`_.${arg[0]} = _.${arg[1]};`); | |
break; | |
case _(/MOVQ .+,MMX$/i): | |
this.labels[arg[0].toUpperCase()] = this.MMX_R[arg[1].substr(-1)]; | |
Log_Program(`this.labels.${arg[0].toUpperCase()} = _.${arg[1]} & BigInt(65535);`); | |
break; | |
case _(/PACKUSDW MMX,@(,@)?/i): | |
this.MMX_R[arg[0].substr(-1)] = this.MMX_R[arg[0].substr(-1)].PACKUSDW(BigInt(tmp)); | |
Log_Program(`_.${arg[0]} = _.${arg[0]}.PACKUSDW(${arg[1]});`); | |
break; | |
case _(/PACKUSDW MMX,MMX/i): | |
this.MMX_R[arg[0].substr(-1)] = this.MMX_R[arg[0].substr(-1)].PACKUSDW(this.MMX_R[arg[1].substr(-1)]); | |
Log_Program(`_.${arg[0]} = _.${arg[0]}.PACKUSDW(_.${arg[1]});`); | |
break; | |
case _(/PADDD MMX,@(,@)?$/i): | |
this.MMX_R[arg[0].substr(-1)] = this.MMX_R[arg[0].substr(-1)].PADD(BigInt(tmp), MMX_R[32]); | |
Log_Program(`_.${arg[0]} = _.${arg[0]}.PADD(${arg[1]}, BigInt(${MMX_R[32]}n));`); | |
break; | |
case _(/PADDD MMX,MMX$/i): | |
this.MMX_R[arg[0].substr(-1)] = this.MMX_R[arg[0].substr(-1)].PADD(this.MMX_R[arg[1].substr(-1)], MMX_R[32]); | |
Log_Program(`_.${arg[0]} = _.${arg[0]}.PADD(_.${arg[1]}, BigInt(${MMX_R[32]}n));`); | |
break; | |
case _(/PCMPEQD MMX,MMX$/i): | |
this.MMX_R[arg[0].substr(-1)] = this.MMX_R[arg[0].substr(-1)].PCMPEQD(this.MMX_R[arg[1].substr(-1)]); | |
Log_Program(`_.${arg[0]} = _.${arg[0]}.PCMPEQD(_.${arg[1]});`); | |
break; | |
case _(/PCMPGTD MMX,MMX$/i): | |
this.MMX_R[arg[0].substr(-1)] = this.MMX_R[arg[0].substr(-1)].PCMPGTD(this.MMX_R[arg[1].substr(-1)]); | |
Log_Program(`_.${arg[0]} = _.${arg[0]}.PCMPGTD(_.${arg[1]});`); | |
break; | |
case _(/PSUBD MMX,@(,@)?$/i): | |
this.MMX_R[arg[0].substr(-1)] = this.MMX_R[arg[0].substr(-1)].PSUB(BigInt(tmp), MMX_R[32]); | |
Log_Program(`_.${arg[0]} = _.${arg[0]}.PSUB(${arg[1]}, BigInt(${MMX_R[32]}n));`); | |
break; | |
case _(/PSUBD MMX,MMX$/i): | |
this.MMX_R[arg[0].substr(-1)] = this.MMX_R[arg[0].substr(-1)].PSUB(this.MMX_R[arg[1].substr(-1)], MMX_R[32]); | |
Log_Program(`_.${arg[0]} = _.${arg[0]}.PSUB(_.${arg[1]}, BigInt(${MMX_R[32]}n));`); | |
break; | |
case _(/PAND MMX,MMX$/i): | |
this.MMX_R[arg[0].substr(-1)] &= this.MMX_R[arg[1].substr(-1)]; | |
Log_Program(`_.${arg[0]} &= _.${arg[1]};`); | |
break; | |
case _(/PANDN MMX,MMX$/i): | |
this.MMX_R[arg[0].substr(-1)] = ~this.MMX_R[arg[0].substr(-1)] & this.MMX_R[arg[1].substr(-1)]; | |
Log_Program(`_.${arg[0]} = ~_.${arg[0]} & _.${arg[1]};`); | |
break; | |
case _(/POR MMX,MMX$/i): | |
this.MMX_R[arg[0].substr(-1)] |= this.MMX_R[arg[1].substr(-1)]; | |
Log_Program(`_.${arg[0]} |= _.${arg[1]};`); | |
break; | |
case _(/PSLLD MMX,&$/i): | |
this.MMX_R[arg[0].substr(-1)] = this.MMX_R[arg[0].substr(-1)].PSLLD(arg[1]); | |
Log_Program(`_.${arg[0]} = _.${arg[0]}.PSLLD(${arg[1]});`); | |
break; | |
case _(/PSLLQ MMX,&$/i): | |
this.MMX_R[arg[0].substr(-1)] = this.MMX_R[arg[0].substr(-1)].PSLLQ(arg[1]); | |
Log_Program(`_.${arg[0]} = _.${arg[0]}.PSLLQ(${arg[1]});`); | |
break; | |
case _(/PSRLD MMX,&$/i): | |
this.MMX_R[arg[0].substr(-1)] = this.MMX_R[arg[0].substr(-1)].PSRLD(arg[1]); | |
Log_Program(`_.${arg[0]} = _.${arg[0]}.PSRLD(${arg[1]});`); | |
break; | |
case _(/PSRLQ MMX,&$/i): | |
this.MMX_R[arg[0].substr(-1)] = this.MMX_R[arg[0].substr(-1)].PSRLQ(arg[1]); | |
Log_Program(`_.${arg[0]} = _.${arg[0]}.PSRLQ(${arg[1]});`); | |
break; | |
case _(/PUNPCKLDQ MMX,@(,@)?/i): | |
this.MMX_R[arg[0].substr(-1)] = this.MMX_R[arg[0].substr(-1)].PUNPCKLDQ(BigInt(tmp)); | |
Log_Program(`_.${arg[0]} = _.${arg[0]}.PUNPCKLDQ(${arg[1]});`); | |
break; | |
case _(/PUNPCKLDQ MMX,MMX/i): | |
this.MMX_R[arg[0].substr(-1)] = this.MMX_R[arg[0].substr(-1)].PUNPCKLDQ(this.MMX_R[arg[1].substr(-1)]); | |
Log_Program(`_.${arg[0]} = _.${arg[0]}.PUNPCKLDQ(_.${arg[1]});`); | |
break; | |
case _(/PUNPCKLWD MMX,@(,@)?/i): | |
this.MMX_R[arg[0].substr(-1)] = this.MMX_R[arg[0].substr(-1)].PUNPCKLWD(BigInt(tmp)); | |
Log_Program(`_.${arg[0]} = _.${arg[0]}.PUNPCKLWD(${arg[1]});`); | |
break; | |
case _(/PUNPCKLWD MMX,MMX/i): | |
this.MMX_R[arg[0].substr(-1)] = this.MMX_R[arg[0].substr(-1)].PUNPCKLWD(this.MMX_R[arg[1].substr(-1)]); | |
Log_Program(`_.${arg[0]} = _.${arg[0]}.PUNPCKLWD(_.${arg[1]});`); | |
break; | |
case _(/PXOR MMX,MMX$/i): | |
this.MMX_R[arg[0].substr(-1)] ^= this.MMX_R[arg[1].substr(-1)]; | |
Log_Program(`_.${arg[0]} ^= _.${arg[1]};`); | |
break; | |
default: | |
Log_Program(""); | |
if(part[2] && part[2] != "") | |
this.logging.push(`Line ${i}: "${part[2]} ${part.splice(3, 3).join()}" "${arg.join()}"???`); | |
codes = ""; break; | |
} | |
/*if(codes != "") { | |
codes = codes | |
.replace(/::/g, prefixes) | |
.replace(/~/g, no_carry) | |
.replace(/_/g, encode.toString(16).toUpperCase()) | |
.replace(/X/g, arg[0].charAt(0).toUpperCase()) | |
.replace(/x/g, arg[0].charAt(1).toUpperCase()) | |
.replace(/Y/g, arg[1].charAt(0).toUpperCase()) | |
.replace(/y/g, arg[1].charAt(1).toUpperCase()) | |
.replace(/Z/g, arg[2].charAt(0).toUpperCase()) | |
.replace(/z/g, arg[2].charAt(1).toUpperCase()) | |
.split(/\s/); | |
if(codes[0].match(/[ABCD][ABCD]/) && codes[0] != rcv + trs) { | |
rcv = codes[0].charAt(0), trs = codes[0].charAt(1); | |
this.ram[address ++] = parseInt(rcv + trs, 16); | |
} | |
if(codes.length > 2 && codes[1].match(/[ABCD][0-9]/)) { | |
if(regs[codes[1].charAt(0)] != parseInt(codes[1], 16)) { | |
regs[codes[1].charAt(0)] = parseInt(codes[1], 16); | |
this.ram[address ++] = parseInt(codes[1], 16); | |
} | |
} | |
if(codes.length > 3 && codes[2].match(/[ABCD][0-9]/)) { | |
if(regs[codes[2].charAt(0)] != parseInt(codes[2], 16)) { | |
regs[codes[2].charAt(0)] = parseInt(codes[2], 16); | |
this.ram[address ++] = parseInt(codes[2], 16); | |
} | |
} | |
for(j = 0; j < codes.length - 1; ++ j) { | |
if(codes[j].match(/[0-9][0-9]/) && parseInt(codes[j], 16) > 0) | |
this.ram[address ++] = parseInt(codes[j], 16); | |
} | |
this.ram[address ++] = parseInt(codes[j], 16); | |
}*/ | |
/*****************************************************************************/ | |
/* | |
if(command.match(/REG BC\d/)) { | |
code = parseInt(part[3].charAt(2), 16); | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = 0xB0 + code; | |
regs.B = 0xB0 + code; | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = 0xC0 + code; | |
regs.C = 0xC0 + code; | |
} else | |
if(command.match(/REG [ABCD]\d/)) { | |
code = parseInt(part[3], 16); | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = code; | |
regs[part[3].charAt(0).toUpperCase()] = code; | |
} | |
if(command.match(/ARG [ABCD]\d?,[ABCD]\d?/)) { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[3].charAt(0) + part[4].charAt(0), 16); | |
if(part[3].length == 2) { | |
code = parseInt(part[3], 16); | |
regs[part[3].charAt(0).toUpperCase()] = code; | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = code; | |
rcv = part[3].charAt(0).toUpperCase(); | |
} | |
if(part[4].length == 2) { | |
code = parseInt(part[4], 16); | |
regs[part[4].charAt(0).toUpperCase()] = code; | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = code; | |
trs = part[4].charAt(0).toUpperCase(); | |
} | |
} | |
if(tmp = command.match(/MOV \[BC(\d+)\+(\d+)\],([ABCD]\d)/)) { | |
vector = tmp[1].padEnd(tmp[2].length, tmp[1].charAt(0)); | |
offset = parseInt(tmp[2]); | |
while(vector != "") { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(vector.charAt(0)) * 16 + Math.floor(offset / Math.pow(10, vector.length - 1)) % 10; | |
vector = vector.substr(1); | |
} | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(tmp[3], 16); | |
} else | |
if(tmp = command.match(/LEA BC(\d),\[BC(\d+)\+(\d+)\]/)) { | |
vector = tmp[2].padEnd(tmp[3].length, tmp[2].charAt(0)); | |
offset = parseInt(tmp[3]); | |
while(vector != "") { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(vector.charAt(0)) * 16 + Math.floor(offset / Math.pow(10, vector.length - 1)) % 10; | |
vector = vector.substr(1); | |
} | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = 0xDD; | |
} else | |
if(command.match(/ADD BC\d\,BC\d/)) { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[3].charAt(2) + part[4].charAt(2), 16); | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = 0xDD; | |
} else | |
if(command.match(/SWP [ABC]\d,[ABC]\d/)) { | |
ri = parseInt(part[3].charAt(1)); | |
ti = parseInt(part[4].charAt(1)); | |
if(ri < ti) { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[3].charAt(1) + part[4].charAt(1), 16); | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[3].charAt(0) + part[4].charAt(0), 16); | |
} else { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[4].charAt(1) + part[3].charAt(1), 16); | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[4].charAt(0) + part[3].charAt(0), 16); | |
} | |
} else | |
if(command.match(/DIV BC\d/)) { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[3].charAt(2), 16) * 0x11; | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = 0xAA; | |
} else | |
if(command.match(/MIL BC\d/)) { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[3].charAt(2), 16) * 0x11; | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = 0xBB; | |
} else | |
if(command.match(/MUL BC\d/)) { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[3].charAt(2), 16) * 0x11; | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = 0xCC; | |
} else | |
if(tmp = command.match(/(ADD|ADC|SUB|SBB|AND|CON|OR|DIS|XOR|EOR|MOV|FOR) ([ABCD]\d?,)?\[BC(\d+)(\+\d+)?(\+[ABCD]\d)?\]/)) { | |
var cmd = tmp[1]; | |
var dst = tmp[2]; | |
vector = tmp[3].padEnd((tmp[4] || "+").length - 1, tmp[3].charAt(0)); | |
offset = parseInt(tmp[4]) || 0; | |
var idx = parseInt(tmp[5], 16); | |
if(dst) { | |
if(rcv != dst.charAt(0) || (tmp[5] ? trs != tmp[5].charAt(1) : false)) { | |
rcv = dst.charAt(0); | |
if(idx) | |
trs = tmp[5].charAt(1); | |
if(trs == "X") | |
trs = rcv; | |
codes.unshift(parseInt(rcv + trs, 16)); | |
} | |
code = parseInt(dst, 16); | |
if(code != regs[rcv] && code >= 0xA0) { | |
this.dis_points_lines[address] = i + head; | |
codes.unshift(code); | |
regs[rcv] = code; | |
} | |
while(codes.length > 0) { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = codes.shift(); | |
} | |
} | |
while(vector != "") { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(vector.charAt(0)) * 16 + Math.floor(offset / Math.pow(10, vector.length - 1)) % 10; | |
vector = vector.substr(1); | |
} | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = +(tmp[5] ? +tmp[5].charAt(2) : 0) * 16 + alu[cmd]; | |
} else | |
if(command.match(/(ADD|ADC|SUB|SBB|AND|CON|OR|DIS|XOR|EOR|MOV|FOR) ([ABCD]\d?,)?[ABCD]?\d/)) { | |
if(!part[4]) { | |
if(isFinite(part[3])) { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = +part[3] * 16 + alu[part[2]]; | |
} else { | |
if(trs != part[3].charAt(0).toUpperCase()) { | |
trs = part[3].charAt(0).toUpperCase(); | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(rcv + trs, 16); | |
} | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = +(part[3].charAt(1)) * 16 + alu[part[2].toUpperCase()]; | |
} | |
} else { | |
if(rcv != part[3].charAt(0).toUpperCase() || trs != part[4].charAt(0).toUpperCase()) { | |
if(part[4].match(/^[ABCD]/)) { | |
rcv = part[3].charAt(0).toUpperCase(); | |
trs = part[4].charAt(0).toUpperCase(); | |
codes.unshift(parseInt(rcv + trs, 16)); | |
} | |
} | |
if(parseInt(part[3], 16) != regs[part[3].charAt(0).toUpperCase()]) { | |
code = parseInt(part[3], 16); | |
if(code >= 0xA0) { | |
codes.unshift(code); | |
regs[part[3].charAt(0).toUpperCase()] = parseInt(part[3], 16); | |
} | |
} | |
while(codes.length > 0) { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = codes.shift(); | |
} | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = (+(part[4].charAt(1)) || 0) * 16 + alu[part[2].toUpperCase()]; | |
} | |
} | |
if(command.match(/^(CMA|CMB|CMC|CMD|AF|BF|CF|DF)/)) { | |
if(part[2].length == 2) { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[2], 16); | |
} else { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[2].charAt(2) + "F", 16); | |
} | |
} | |
if(command.match(/(JAE|JBE|JCE|JDE) BC\d\+\d/)) { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[3].charAt(2) + part[3].charAt(4), 16); | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[2].charAt(1) + "E", 16); | |
} else | |
if(command.match(/(JAF|JBF|JCF|JND|JDF) BC\d\+\d/)) { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[3].charAt(2) + part[3].charAt(4), 16); | |
if(part[2].charAt(1) == "N") { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[2].charAt(2) + "F", 16); | |
} else { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[2].charAt(1) + "F", 16); | |
} | |
} else | |
if(command.match(/(JAE|JBE|JCE|JDE)/)) { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = parseInt(part[2].charAt(1) + "E", 16); | |
} | |
if(command.match(/(INT) ([0-9A-F]{2}){1,2}/)) { | |
code = parseInt(part[3], 16); | |
if(part[3].length > 2) { | |
if(code.low) { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = code.low; | |
} | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = code.high; | |
} else { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = code.low; | |
} | |
rcv = "X", trs = "X"; | |
regs.A = 0xFA; | |
regs.B = 0xFB; | |
regs.C = 0xFC; | |
regs.D = 0xFD; | |
} | |
if(command.match(/HLT|HALT/)) { | |
this.dis_points_lines[address] = i + head; | |
this.ram[address ++] = 0x00; | |
} | |
*/ | |
} | |
} while(review ++ < 2); | |
Log_Program(`hEmuDump.textContent = this.logging.join("\\r\\n");`); | |
try { | |
this.draft = (new Function("_", /*"'use asm';\r\n" + */this.program.join("\r\n"))).bind(this); | |
this.draft(this.X64_R); | |
} catch(err) { | |
this.draft = null; | |
this.logging.push(`${err}`); | |
} | |
hEmuDump.textContent = this.logging.join("\\r\\n"); | |
} | |
////////////////////////////////////////////////////////////////////// | |
i = (function() { | |
var arr = new Array(256, 0x00); | |
var i; | |
arr._this = this.ram; | |
for(i = 0xD0; i <= 0xD8; ++ i) { | |
Object.defineProperty(arr, i, | |
{ | |
set() { | |
this._this.devices[this[0xD9]](this._this.ram[0xD900], i & 15, data); | |
} | |
} | |
); | |
} | |
return arr; | |
})(); | |
////////////////////////////////////////////////////////////////////// | |
var dis | |
= { | |
addr :0, | |
read | |
:function(address) { | |
var ic; // Instruction Code | |
var id; // Instruction Data (Prefix) | |
var is_id; | |
// | |
do { | |
ic = this.ram[address ++]; | |
is_id = (ic.left.isNum && ic.right.isNum && ic > 0); | |
if(is_id && this.classic) | |
return true; | |
id = (id << 8) | ic; | |
} while(is_id); | |
} | |
}; | |
////////////////////////////////////////////////////////////////////// | |
this.disassm | |
= function(pc) { | |
var i; | |
var address, offset; | |
var ic; // Instruction Code | |
var id = 0; // Instruction Data / Prefix | |
var ip = isFinite(pc) ? pc : this.ctx.pointer(0x00BE); | |
var ctx = this.ctx;//this.ram.slice(this.base, 256); | |
var pointer; | |
var pointers; | |
var bytes; | |
var rows; | |
var text; | |
var dis_line_bytes = this.classic ? this.dis_line_bytesingle : this.dis_line_bytes; | |
var dis_line_letters = this.classic ? this.dis_line_lettersingle : this.dis_line_letters; | |
var color; | |
var active = 0; | |
var prefix, receiver, args; | |
var vector; | |
var source; | |
var marginal, base, indexers, pairs; | |
var arg = ctx[0x00AE]; | |
var reg = { | |
0x0F: "??", | |
0xAF: ctx[0x00AF] ? ctx[0x00AF].toHex(2) : "A?", | |
0xBF: ctx[0x00BF] ? ctx[0x00BF].toHex(2) : "B?", | |
0xCF: ctx[0x00CF] ? ctx[0x00CF].toHex(2) : "C?", | |
0xDF: ctx[0x00DF] ? ctx[0x00DF].toHex(2) : "D?" | |
}; | |
if(arg == 0) | |
arg = 0xAA; | |
// | |
if(this.dis_address > ip) | |
this.dis_address = ip; | |
do { | |
pointer = this.dis_address; | |
this.dis_pointer = pointer; | |
rows = []; | |
pointers = []; | |
i = this.dis_lines; | |
id = 0; | |
marginal = ""; | |
base = ""; | |
indexers = ""; | |
vector = ""; | |
pairs = 0; | |
do { | |
bytes = []; | |
text = ""; | |
if(!this.classic) | |
id = 0; | |
pointers.push(pointer); | |
if(!id) { | |
offset = 0; | |
address = pointer; | |
} | |
while(this.dis_lines_tables[pointer]) { | |
bytes.push(this.ram[pointer].toHex(2)); | |
pointer ++; | |
text = "...DATA..."; | |
color = "Data"; | |
} | |
if(text == "") | |
do { | |
if(pointer == ip) | |
active = this.dis_lines - i; | |
ic = this.ram[pointer ++]; | |
if(!isFinite(ic)) | |
ic = 0; | |
bytes.push(ic.toHex(2)); | |
if(this.classic && ic.left.isNum && ic.right.isNum && ic != 0x00) { | |
offset = offset * 10 + ic.right; | |
if(base == "") | |
id = ic.left << 4, | |
base = /*(marginal == "" ? "" : marginal + "#") + */"BC" + ic.left, | |
indexers = "", | |
pairs = 0; | |
else | |
if(id == ic && indexers == "") { | |
marginal += "" + ic.left; | |
id = 0; | |
base = "", | |
pairs = 0; | |
} else { | |
if(indexers == "") | |
indexers = "D" + ic.left; | |
else | |
if(id.left == ic.left) | |
indexers = indexers.length > 2 ? "2(" + indexers + ")" : "2" + indexers, | |
pairs = 0; | |
else | |
if(((pairs >> ic.left) & 1) > 0) | |
indexers = "2(" + indexers + ")+D" + ic.left, | |
pairs |= 1 << ic.left; | |
else | |
indexers += "+D" + ic.left, | |
pairs |= 1 << ic.left; | |
} | |
text = marginal + (marginal == "" ? "" : "#"); | |
text += base + (indexers != "" ? "+" + indexers + (offset != 0 ? "+" + offset : "") : ""); | |
vector = text; | |
color = "Data"; | |
//if(bytes.length < dis_line_bytes - 1) | |
bytes.push("++"); | |
} else | |
if(this.classic) { | |
if(id > 0) | |
bytes.unshift("++"); | |
} else { | |
var vv = []; | |
while(ic.left.isNum && ic.right.isNum && ic != 0x00) { | |
vv.push(ic.toHex(2)), | |
ic = this.ram[pointer ++]; | |
bytes.push(ic.toHex(2)); | |
} | |
/*if(vv.length > 0) | |
bytes.push(ic.toHex(2));*/ | |
if(vv.length > 0) | |
vector = show_vector(vv), color = "Data"; | |
/*while(ic.left.isNum && ic.right.isNum && ic != 0x00) { | |
if(id == 0) { | |
id = ic; | |
vector = "";//this.ctx.pointer(id.left, ""); | |
} else | |
if(id.left != ic.left) | |
vector += "" + ic.left; | |
offset = offset * 10 + ic.right; | |
if(pointer == ip) | |
active = this.dis_lines - i; | |
ic = this.ram[pointer ++]; | |
if(!isFinite(ic)) | |
ic = 0; | |
bytes.push(ic.toHex(2)); | |
}*/ | |
} | |
/*if(id > 0 && !this.classic) | |
vector += "+" + offset;*/ | |
/*if(ic.left.isReg && ic.right.isNum) { | |
if(id > 0) | |
text = "MOV [" + vector + "]," + ic.toHex(2), | |
color = "CPU_Group_F"; | |
else { | |
if(this.classic) | |
text = "REG " + ic.toHex(2), | |
color = "CPU_Group_E", | |
bytes.push("--", "--", "--"); | |
reg[ic | 0x0F] = ic.toHex(2); | |
} | |
}*/ | |
/*if(ic.left.isReg && ic.right.isReg && vector == "") { | |
if(this.classic) | |
text = "ARG " + ic.left.toHex(1) + "," + ic.right.toHex(1), | |
color = "CPU_Group_E", | |
bytes.push("--", "--"); | |
arg = ic; | |
} else | |
if(ic.left.isReg && ic.right.isNum && vector == "") { | |
if(this.classic) | |
text = "REG " + ic.toHex(2), | |
color = "CPU_Group_E", | |
bytes.push("--", "--", "--"); | |
reg[ic | 0x0F] = ic.toHex(2); | |
} else */if(text == "") { | |
bytez = arg.toHex(2) + " " + | |
reg[arg | 0x0F] + " " + | |
ic.toHex(2); | |
/********************************************************************/ | |
var $ALU = ["ADD", "SUB", "AND", "OR", "EOR", "MOV"]; | |
var $END = ["REA", "REB", "REC", "RED", "RET", "?F?"]; | |
var $INF = ["?A?", "?B?", "?C?", "?D?", "?E?", "INF"]; | |
var $OUF = ["?A?", "?B?", "?C?", "?D?", "?E?", "OUF"]; | |
var $UNO = ["INC", "DEC", "CLR", "SET", "NOT", "?F?"]; | |
var Pattern; | |
var x; | |
bytez = bytez.split(/\s+/); | |
x = parseInt(bytez[bytez.length - 1].charAt(1), 16); | |
if(x >= 10) | |
x -= 10; | |
$R = bytez[0].charAt(0) + bytez[1].charAt(1); | |
$T = bytez[0].charAt(1) + bytez[bytez.length - 1].charAt(0); | |
$r = "B" + $R.charAt(1) + "C" + $R.charAt(1); | |
$th = "B" + $T.charAt(1); | |
$tl = "C" + $T.charAt(1); | |
$t = $th + $tl; | |
Pattern = $R == $T ? "E" : "N"; | |
Pattern += vector != "" ? "M" : "R"; | |
Pattern += $R; | |
Pattern += $T; | |
Pattern += bytez[bytez.length - 1].charAt(1); | |
$IC = ic.toHex(2); | |
$A = $ALU[x]; | |
$E = $END[x]; | |
$I = $INF[x]; | |
$O = $OUF[x]; | |
$U = $UNO[x]; | |
$V = "[" + vector + "]"; | |
$X = $IC.charAt(0); | |
$Y = $IC.charAt(1); | |
text = (function (_) { | |
switch(0) { | |
case _(/.R...[A-D][A-D]/): | |
arg = ic; | |
if(this.classic) { | |
bytes.push("--"); | |
return "X;ARG " + $X + "," + $Y; | |
} else | |
return ""; | |
//color = "CPU_Group_E", | |
case _(/.R...[A-D][0-9]/): | |
reg[ic | 0x0F] = ic.toHex(2); | |
if(this.classic) { | |
bytes.push("--"); | |
return "X;REG " + $IC; | |
} else | |
return ""; | |
//color = "CPU_Group_E", | |
case _(/.M...00/): return `B;JMP ${$V}`; | |
case _(/.R...00/): return `C;HLT`; | |
case _(/.M...[A-D][0-9]/): return `F;MOV ${$V},${$IC}`; | |
case _(/.M...[A-D]E/): return `B;DO ${$V},${$IC}`; | |
case _(/.M...[A-D]F/): return `B;DO ${$V},${$IC}`; | |
case _(/.M...[A-D][A-D]/): return `B;DO ${$V},${$X}F,${$Y}F`; | |
case _(/.MA0A0F/): return `F;${$A} ${$R},${$V};Load FLAGS from Memory`; | |
case _(/.MA0A0./): return `A;${$U} ${$V};Unar operation with Memory`; | |
case _(/.RA0A0F/): return `Z;${$A} ???;Reserved (Forth DUP ???)`; | |
case _(/.RA0A0E/): return `Z;${$A} ???;Reserved (Forth ${$A} ??? EXI (Enable eXternal Interruptions))`; | |
case _(/.RA0A0./): return `Z;${$A} ???;Reserved (Forth ${$A} ???)`; | |
case _(/.MA0D.F/): return `E;SWP ${$V},${$T};Swap Memory with 16-bit Register ${$t}`; | |
case _(/.MA0D../): return `D;${$A} ${$V},${$T};${$A} Memory with 16-bit Register ${$t}`; | |
case _(/.RA0D.F/): return `C;INF ${$T};Try Input from Port ${$T} and set FLAGS`; | |
case _(/.RA0D0C/): return `C;${$U} ${$T};${$U} 16-bit ${$t} / EHI (Enable Hardware Interruptions)`; | |
case _(/.RA0D../): return `A;${$U} ${$T};Unconditional unar operation with 16-bit ${$t}`; | |
case _(/.MA0..F/): return `E;SWP ${$V},${$T};Swap 8-bit Register and Memory`; | |
case _(/.MA0.../): return `A;${$A} ${$V},${$T};${$A} Memory with 8-bit Register`; | |
case _(/.RA0..F/): return `F;${$A} ${$R},${$T};Load FLAGS from 8-bit Register`; | |
case _(/.RA0.../): return `A;${$U} ${$T};Unconditional unar 8-bit operation`; | |
case _(/.MD.A0./): return `D;${$A} ${$R},${$V};${$A} 16-bit Register ${$r} with Memory`; | |
case _(/.RD.A0F/): return `C;OUF ${$R};Try Output to port ${$R} and set FLAGS`; | |
case _(/.RD.A0./): return `D;${$U} ${$R},CF;Unar operation with 16-bit ${$r} if set CF`; | |
case _(/.M..A0./): return `A;${$A} ${$R},${$V};${$A} 8-bit Register with Memory`; | |
case _(/.R..A0F/): return `F;${$A} ${$R};Load FLAGS to Register`; | |
case _(/.R..A0./): return `A;${$U} ${$R},CF;Unar 8-bit operation if set CF`; | |
case _(/EMD...F/): return `D;LEA ${$R},${$V};Load Effective Address to 16-bit ${$r}`; | |
case _(/NMD.D.F/): return `D;ORD ${$V},${$R},${$T};16-bit Sort: MIN(${$V})..MID(${$r})..MAX(${$t})`; | |
case _(/.MD.D../): return `D;${$A} ${$R},${$V},${$T};16-bit ${$r}=${$A}(Memory,${$t})`; | |
case _(/ERA...F/): return `Z;??? ${$R},${$T};Reserved (??? #A: ${$t}=${$t}/${$R}, ${$R}=${$t}%${$R} ???)`; | |
case _(/ERB...F/): return `Z;??? ${$R},${$T};Reserved (??? #B)`; | |
case _(/ERC...F/): return `Z;??? ${$R},${$T};Reserved (??? #C)`; | |
case _(/ERD...F/): return `Z;??? ${$R},${$T};Reserved (Forth OVER ??? ${$t}=${$th}*${$tl} ???)`; | |
case _(/.RD.D../): return `D;${$A} ${$R},${$T};${$A} with 16-bit Registers ${$r} and ${$t}`; | |
case _(/.MD...F/): return `D;LEX ${$R},${$V},${$T};16-bit Lexicon: ${$r}=${$V}[${$T}*2]`; | |
case _(/.MD..../): return `D;${$A} ${$R},${$V},${$T};16-bit ${$r}=${$A}(${$V},sign expanded ${$T})`; | |
case _(/.RD...F/): return `C;OUT ${$R},${$T};Output ${$T} to Port ${$R}`; | |
case _(/.RD..../): return `D;${$A} ${$R},${$T};16-bit ${$r}=${$A}(${$r},sign expanded ${$T})`; | |
case _(/.M..D.F/): return `Z;??? ${$R},${$V},${$T};Reserved`; | |
case _(/.M..D../): return `A;${$A} ${$R},${$V},${$T};8-bit ${$R}=${$A}(Memory,Port ${$T})`; | |
case _(/.R..D../): return `A;${$A} ${$R},${$T};${$A} with 8-bit Register and Port ${$T}`; | |
case _(/EM....F/): return `F;LEX ${$R},${$V},${$T};8-bit Lexicon: ${$R}=${$V}[${$T} (x86-XLAT)`; | |
case _(/NM....F/): return `E;ORD ${$V},${$R},${$T};8-bit Sort: MIN(${$V})..MID(${$R})..MAX(${$T})`; | |
case _(/.M...../): return `A;${$A} ${$R},${$V},${$T};8-bit ${$R}=${$A}(Memory,${$T})`; | |
case _(/.R...../): return `A;${$A} ${$R},${$T};${$A} with 8-bit Registers`; | |
default: return "Z;???"; | |
} | |
}).bind({classic: this.classic})(Pattern.search.bind(Pattern)); | |
if(text != "") { | |
color = "CPU_Group_" + text.split(";")[0], | |
text = /*Pattern+';'+*/text.split(";")[1], | |
vector = "", | |
id = 0, | |
base = "", | |
marginal = ""; | |
//if(!this.classic) | |
// bytes.push(ic.toHex(2)); | |
} | |
/********************************************************************/ | |
} | |
/* if(ic == 0x00) { | |
if(id == 0) | |
text = "HLT", | |
color = "CPU_Group_C"; | |
else | |
text = "RET " + vector, | |
color = "CPU_Group_C"; | |
} | |
if(ic.left.isNum && ic.right >= 0xA) { | |
if(ctx[0x00F9].left == 0xD) { | |
if(arg > 0) | |
source = ((arg.right << 4) | ic.left).toHex(2); | |
else | |
source = "?" + ic.left.toHex(1); | |
if(id > 0) | |
text = "MOV " + reg[arg | 0x0F] + ",[" + vector + "+" + source + "]", | |
color = "CPU_Group_F"; | |
else | |
if(ic.right == 0xF) | |
text = "MOV " + reg[arg | 0x0F] + "," + source, | |
color = "CPU_Group_F"; | |
else | |
text = "??? " + reg[arg | 0x0F] + "," + source, | |
color = "CPU_Group_X"; | |
} else | |
if(ctx[0x00F9].right == 0xD && id > 0) { | |
} else { | |
text = "ADD SUB AND OR EOR MOV".split(/\s+/)[ic.right - 0xA]; | |
text += " " + reg[arg | 0x0F] + ","; | |
if(arg > 0) | |
source = ((arg.right << 4) | ic.left).toHex(2); | |
else | |
source = "?" + ic.left.toHex(1); | |
if(id > 0) { | |
if(ic.left > 0) | |
text += "[" + vector + "+" + source + "]"; | |
else | |
text += "[" + vector + "]"; | |
} else | |
text += source; | |
color = "CPU_Group_A"; | |
} | |
} | |
if(ic.left.isReg && ic.right.isNum) { | |
if(id > 0) | |
text = "MOV [" + vector + "]," + ic.toHex(2), | |
color = "CPU_Group_F"; | |
else { | |
if(this.classic) | |
text = "REG " + ic.toHex(2), | |
color = "CPU_Group_E", | |
bytes.push("--", "--", "--"); | |
reg[ic | 0x0F] = ic.toHex(2); | |
} | |
} | |
if(ic.left.isReg && ic.right.isReg) { | |
if(id > 0) { | |
if(ic == 0xDD) { | |
text = "ADD " + this.ctx.pointer(id.left, ",") + this.ctx.pointer(id.right, ""), | |
color = "CPU_Group_D"; | |
} else { | |
if(ic.left == ic.right && id.left == id.right) { | |
switch(ic) { | |
case 0xAA: | |
text = "DIV " + this.ctx.pointer(id.left, `,A${id.right}`); | |
break; | |
case 0xBB: | |
text = "MIL " + this.ctx.pointer(id.left, `,B${id.right},C${id.right}`); | |
break; | |
case 0xCC: | |
text = "MUL " + this.ctx.pointer(id.left, `,B${id.right},C${id.right}`); | |
break; | |
} | |
} else { | |
if(id.left < id.right) | |
text = "SWP " + ((ic.left << 4) | id.left).toHex(2) +"," + ((ic.right << 4) | id.right).toHex(2); | |
else | |
text = "??? " + ((ic.left << 4) | id.left).toHex(2) +"," + ((ic.right << 4) | id.right).toHex(2), | |
color = "CPU_Group_X"; | |
} | |
} | |
} else { | |
if(ic == 0xDD) | |
text = "DBG"; | |
else { | |
if(this.classic) | |
text = "ARG " + ic.left.toHex(1) + "," + ic.right.toHex(1), | |
color = "CPU_Group_E", | |
bytes.push("--", "--"); | |
arg = ic; | |
} | |
} | |
} | |
if(ic.left.isReg && ic.right == 0xE) { | |
if(id > 0) { | |
text = "JCE JDE JAE JBE".split(/\s+/)[ic.left & 3] + " " + vector; | |
} else | |
text = "JCE JDE JAE JBE".split(/\s+/)[ic.left & 3]; | |
color = "CPU_Group_B"; | |
} | |
if(ic.left.isReg && ic.right == 0xF) { | |
if(id > 0) { | |
text = "JCF JDF JAF JBF".split(/\s+/)[ic.left & 3] + " " + vector; | |
} else | |
text = "CMC CMD CMA CMB".split(/\s+/)[ic.left & 3]; | |
color = "CPU_Group_B"; | |
} | |
if(ic >= 0xE0) { | |
text = "INT " + ((ic << 8) | id).toHex(-4); | |
color = "CPU_Group_C"; | |
}*/ | |
//vector = ""; | |
} while(text == ""); | |
/*if(this.classic && (base ) | |
id = 0;*/ | |
while(bytes.length < dis_line_bytes) | |
bytes.unshift("--"); | |
if(bytes.length > dis_line_bytes) { | |
do { | |
tmp = address.toHex(4) + " " + bytes.slice(0, dis_line_bytes).join(" ") + "|" + text; | |
if(bytes.length <= dis_line_bytes && tmp.length <= dis_line_letters + 3 * dis_line_bytes) { | |
rows.push(address.toHex(4) + " " + bytes.slice(0, dis_line_bytes).join(" ") + "|" + `<span class=${color}>` + text.padEnd(dis_line_letters, " ") + "</span>"); | |
text = ""; | |
} else | |
if(bytes.length == dis_line_bytes + 1) | |
rows.push((address.toHex(4) + " " + bytes.join(" ")).padEnd(dis_line_letters, " ")), | |
tmp = ""; | |
else | |
rows.push((address.toHex(4) + " " + bytes.slice(0, dis_line_bytes).join(" ") + (bytes.length > dis_line_bytes ? "+" : "")).padEnd(dis_line_letters, " ")), | |
tmp = ""; | |
address += dis_line_bytes; | |
bytes.splice(0, dis_line_bytes); | |
if(bytes.length > 1) | |
while(bytes.length < dis_line_bytes) | |
bytes.splice(bytes.length - 1, 0, "--"); | |
} while(bytes.length > 1 && -- i > 0); | |
if(text != "" && -- i > 0) | |
rows.push(`${address.toHex(4)}${tmp}|<span class=${color}>${text.padEnd(dis_line_letters, " ").substr(0, dis_line_letters + 3 * dis_line_bytes)}` + "</span>"); | |
} else | |
rows.push(address.toHex(4) + " " + bytes.join(" ") + `|<span class=${color}>` + text.padEnd(dis_line_letters, " ") + "</span>"); | |
if(this.classic) | |
address ++; | |
} while(-- i > 0); | |
if(pointer - 1 < ip) { | |
this.dis_address = ip; | |
if(pointers.length >= this.dis_lines) | |
this.dis_address = pointers[pointers.length - (this.dis_lines - 1)]; | |
continue; | |
} | |
} while(false); | |
return { | |
active :active, | |
content :rows.join("\r\n").replace(/^(.+)$/gm, "<span>$1</span>") | |
} | |
} | |
////////////////////////////////////////////////////////////////////// | |
this.init | |
= function() { | |
this.render.noise = 25; | |
} | |
////////////////////////////////////////////////////////////////////// | |
this.reset | |
= function() { | |
this.ctx.pointer(0x00B0, 0x0000); | |
this.ctx.pointer(0x00B1, 0x0001); | |
this.ctx.pointer(0x00B2, 0x0002); | |
this.ctx.pointer(0x00B3, 0x0003); | |
this.ctx.pointer(0x00BE, 0x0000); | |
this.ticks = 0; | |
this.marginal = 0; | |
this.address = 0; | |
this.offset = 0; | |
this.pairs = 0; | |
this.id = 0; | |
for(var dev in this.devices) { | |
try { | |
this.devices[dev]._this = this; | |
this.devices[dev].init(); | |
} catch(e) { | |
console.log(e); | |
} | |
} | |
} | |
////////////////////////////////////////////////////////////////////// | |
this.step | |
= function() { | |
const apr = this.ram.base | 0x00F0; | |
var address; | |
var x, y, z; | |
var flags; | |
var hollow; // Hollow command | |
var ic; // Instruction Code | |
var ip = this.ctx.pointer(0x00BE); | |
// | |
do { | |
if(!this.classic || !this.prefix) | |
this.id = 160, | |
this.offset = 0, | |
this.prefixes = 0, | |
this.marginal = 0, | |
this.pairs = 0, | |
this.address = this.ctx.pointer(0x00B0); | |
if(this.id >= 160) | |
this.address = 0, | |
this.offset = 0, | |
this.pairs = 0; | |
hollow = false; | |
this.ticks ++; | |
ic = this.ram[ip]; | |
while(ic.left.isNum && ic.right.isNum && ic != 0x00) { | |
// 01..99 | |
this.offset += this.offset << 2; | |
this.offset <<= 1; | |
this.offset += ic.right; | |
if(this.offset == 0 && ic.left == this.id.left && this.pairs == 0)//(1 << this.id.left)) | |
this.marginal = this.marginal * 10 + ic.left, | |
this.id = 160, | |
this.pairs = 0; | |
else | |
if(((this.pairs >> ic.left) & 1) > 0 || ic.left == this.id.left) { | |
this.address <<= 1, | |
this.pairs = (1 << ic.left); | |
if(this.id < 160) | |
this.pairs |= (1 << this.id.left); | |
if(ic.left != this.id.left && this.id < 160) | |
this.address += this.ctx.pointer(0x00B0 | ic.left); | |
} else | |
if(this.id < 160) { | |
this.pairs |= (1 << ic.left); | |
++ this.prefixes; | |
this.address += this.ctx.pointer(0x00B0 | ic.left); | |
} else | |
//if(this.offset == 0 && this.prefixes % 2 == 0) | |
this.id = ic, | |
this.pairs |= (1 << this.id.left), | |
this.address = 0; | |
ic = this.ram[++ ip]; | |
if(this.pairs == 0) | |
++ this.prefixes; | |
this.prefix = true; | |
if(this.classic) { | |
this.ctx.pointer(0x00BE, ip); | |
return true; | |
} | |
} | |
/*while(ic.left.isNum && ic.right.isNum && ic != 0x00) { | |
// 01..99 | |
this.offset += this.offset << 2; | |
this.offset <<= 1; | |
this.offset += ic.right; | |
if(ic.left != this.id.left || this.prefixes == 0) | |
this.address = (this.prefixes > 0 ? this.address : 0) + this.ctx.pointer(0x00B0 | ic.left); | |
if(this.prefixes == 0) | |
this.id = ic; | |
ic = this.ram[++ ip]; | |
++ this.prefixes; | |
this.prefix = true; | |
if(this.classic) { | |
this.ctx.pointer(0x00BE, ip); | |
return true; | |
} | |
}*/ | |
this.prefix = false; | |
if(this.id < 160 && this.classic) | |
this.address += this.ctx.pointer(0x00B0 | this.id.left); | |
this.address += this.offset; | |
this.address &= 0xFFFF; | |
this.id = 160; | |
if(ic == 0x00) { | |
if(this.pairs == 0) { | |
// HLT | |
this.ctx.pointer(0x00B0, ip); | |
this.ctx.pointer(0x00BE, 0x0000); | |
} else { | |
// HLT vector | |
this.ctx.pointer(0x00B0, ip); | |
this.ctx.pointer(0x00BE, this.address); | |
} | |
return false; | |
} | |
if(ic.left.isNum && ic.right >= 0xA) { | |
// ALU Rn,Ti | |
//y = this.ram.translator(); | |
if(this.prefixes > 0 && ic.left == 0) | |
y = 0; | |
else | |
y = this.ctx[(this.ctx[0xAE].right << 4) | ic.left]; | |
x = this.ctx.receiver(); | |
if(this.prefixes > 0) { | |
// ALU Rn,[BCi+k+Tm] | |
y = this.ram[this.address + y]; | |
} | |
switch(ic.right) { | |
case 0xA: // ADD / ADC | |
x += y + ((this.ctx.state() >> 1) & 1); | |
this.ctx.state(x); | |
break; | |
case 0xB: // SUB / SBB | |
x -= y + ((this.ctx.state() >> 1) & 1); | |
this.ctx.state(x); | |
break; | |
case 0xC: // CON / AND | |
x &= y; | |
this.ctx.state(x); | |
break; | |
case 0xD: // DIS / OR | |
x |= y; | |
this.ctx.state(x); | |
break; | |
case 0xE: // EOR / XOR | |
x ^= y; | |
this.ctx.state(x); | |
break; | |
case 0xF: // FOR / MOV | |
x = y; | |
break; | |
} | |
this.ctx.receiver(x); | |
ip ++; | |
} | |
if(ic.left.isReg && ic.right.isNum) { | |
if(this.prefixes > 0) { | |
// MOV [BCi+k],Rn | |
this.ram[this.address] = this.ctx[ic]; | |
} else { | |
// REG Rn | |
this.ctx[ic | 0x0F] = ic; | |
hollow = !this.classic; | |
} | |
ip ++; | |
} | |
if(ic.left.isReg && ic.right.isReg) { | |
if(this.prefixes > 1) { | |
// Has few prefixes | |
return false; | |
} else | |
if(this.prefixes == 1) { | |
// Has one prefix | |
if(ic == 0xDD) { | |
// ADD BCi,BCk | |
x = this.ctx.pointer(0x00B0 | this.id.left); | |
y = this.ctx.pointer(0x00B0 | this.id.right); | |
this.address = x + y + ((this.ctx[0x00A0] >> 1) & 1); | |
this.ctx.pointer(0x00B0 | this.id.left, this.address); | |
this.ctx[0xA0] = (this.ctx[0xA0] & 0xFD) | ((this.address >> 15) & 2); | |
} else { | |
if(ic.left == ic.right && this.id.left == this.id.right) { | |
switch(ic) { | |
case 0xAA: | |
// DIV BCi,Ak | |
x = this.ctx.pointer(0x00B0 | this.id.left); | |
y = this.ctx[0x0A0 | this.id.left]; | |
if(y == 0) | |
y = 256; | |
this.ctx.pointer(0x00B0 | this.id.left, Math.floor(x / y)); | |
this.ctx[0x0A0 | this.id.left] = (x % y).low; | |
break; | |
case 0xBB: | |
x = this.ctx.pointer(0x00B0 | this.id.left); | |
y = x.high; | |
x = x.low; | |
y -= (y & 128) << 1; | |
x -= (x & 128) << 1; | |
x *= y; | |
this.ctx.pointer(0x00B0 | this.id.left, x >= 0 ? x : x + 65536); | |
break; | |
case 0xCC: | |
x = this.ctx.pointer(0x00B0 | this.id.left); | |
y = x.high; | |
x = x.low; | |
this.ctx.pointer(0x00B0 | this.id.left, x * y); | |
break; | |
} | |
} else { | |
if(this.id.left < this.id.right) { | |
// SWP Ri,Tk | |
x = this.ctx[(ic & 0xF0) | this.id.left]; | |
y = this.ctx[(ic.right << 4) | this.id.right]; | |
this.ctx[(ic & 0xF0) | this.id.left] = y; | |
this.ctx[(ic.right << 4) | this.id.right] = x; | |
} else { | |
// ??? Ri,Tk | |
return false | |
} | |
} | |
} | |
ip ++; | |
} else { | |
/*if(ic == 0xDD) { | |
// DBG | |
this.ctx.pointer(0x00B0, ip); | |
ip = (ic << 8); | |
this.dis_address = ip; | |
} else */{ | |
// ARG R,T | |
this.ctx[0xAE] = ic; | |
ip ++; | |
hollow = !this.classic; | |
} | |
} | |
} | |
if(ic.left.isReg && ic.right == 0xE) { | |
if(this.ctx.state() & [2, 1, 8, 4][ic.left & 3]) { | |
// AE / BE / CE / DE / JA / JB / JC / JD | |
this.ctx.pointer(0x00B0, ip); | |
ip = this.address; | |
this.dis_address = ip; | |
} else | |
ip ++; | |
} | |
if(ic.left.isReg && ic.right == 0xF) { | |
if(this.prefixes > 0) { | |
if(!(this.ctx.state() & [2, 1, 8, 4][ic.left & 3])) { | |
// JAF / JBF / JCF / JDF / JNA / JNB / JNC / JND | |
this.ctx.pointer(0x00B0, ip); | |
ip = this.address; | |
this.dis_address = ip; | |
} else | |
ip ++; | |
} else { | |
// AF / BF / CF / DF | CMA / CMB / CMC / CMD | |
this.ctx[0xA0] ^= [2, 1, 8, 4][ic.left & 3]; | |
ip ++; | |
} | |
} | |
if(ic >= 0xE0) { | |
// E000..FF99 | CALL 0xE000..0xFF99 | |
this.ctx.pointer(this.process | 0x00B0, ip); | |
ip = (ic << 8) | this.id; | |
this.dis_address = ip; | |
} | |
this.ctx.pointer(0x00BE, ip); | |
} while(hollow); | |
return true; | |
} | |
} | |
</script> | |
<script> | |
var cpu = new KOY(); | |
function showState(addr, is_edit) { | |
try { | |
var ip = isFinite(addr) ? addr : cpu.ctx.pointer(0x00BE); | |
var ic; | |
i = 0; | |
do { | |
ic = cpu.ram[ip + i ++]; | |
} while(ic > 0 && ic.left.isNum && ic.right.isNum); | |
/*hEmuDump.innerHTML = cpu.ram.toDump(ip, i).join("\r\n");*/ | |
// tmp = cpu.disassm(ip + 1);//.join("\r\n"); | |
// tmp = cpu.disassm(ip);//.join("\r\n"); | |
if(!isFinite(addr) && isFinite(cpu.dis_points_lines[cpu.dis_pointer]) && !is_edit) { | |
hListing.scrollTop = cpu.dis_points_lines[cpu.dis_pointer] * (hListing.scrollHeight / (hListing.value.split(/\r?\n/).length)); | |
var line = cpu.dis_points_lines[ip]; | |
var lines = hListing.value.split(/\r?\n/); | |
hListing.focus(); | |
hListing.selectionStart = lines.slice(0, line).join().length + 1; | |
hListing.selectionEnd = lines.slice(0, line + 1).join().length; | |
} | |
hEmuDis.innerHTML = tmp.content; | |
hEmuDis.className = "line" + tmp.active; | |
hRegs_MMX.textContent = cpu.context().mmx; | |
hRegs_X64.textContent = cpu.context().x64; | |
if(Number(hIteration.value) < cpu.images.length) { | |
Draw_Pixels(); | |
} | |
} catch(e) {} | |
} | |
HTMLTextAreaElement.prototype.insertAtCursor | |
= function(szChar) { | |
//IE support | |
if(document.selection) { | |
this.focus(); | |
sel = document.selection.createRange(); | |
sel.text = szChar; | |
} else | |
//MOZILLA and others | |
if(this.selectionStart || this.selectionStart == '0') { | |
var startPos = this.selectionStart; | |
var endPos = this.selectionEnd; | |
this.value = this.value.substring(0, startPos) | |
+ szChar | |
+ this.value.substring(endPos, this.value.length); | |
this.selectionStart = startPos + szChar.length; | |
this.selectionEnd = this.selectionStart; | |
} else | |
this.value += szChar; | |
} | |
function onListing_RefreshState(e) { | |
window.localStorage.listingSelection = [hListing.selectionStart, hListing.selectionEnd, hListing.scrollTop, hIteration.value].join(); | |
showState(cpu.dis_lines_points[hListing.value.substr(0, hListing.selectionStart).split(/\r?\n/).length - 1], true); | |
var row = hListing.value.substr(0, hListing.selectionStart).split(/\r?\n/).length; | |
var col = hListing.value.substr(0, hListing.selectionEnd).split(/\r?\n/).pop().length + 1; | |
hListingRows.scrollTop = hListing.scrollTop; | |
hEmuLog.textContent = `${row}:${col}`; | |
hPseudos.textContent = cpu.program.join("\r\n").replace(/(^this.Do_Snaps\(\d+\);)|(this.Do_Snaps\(\d+\);$)/gm, ""); | |
if(col == 1) | |
editStatus = -1; | |
else | |
if(col == hListing.value.split(/\r?\n/)[row - 1].length + 1) | |
editStatus = +1; | |
else | |
editStatus = 0; | |
if(row < cpu.snaps.length) { | |
var tmp = cpu.snaps[row - 1]; | |
tmp = cpu.context(tmp[Number(hIteration.value) < tmp.length ? Number(hIteration.value) : 0]); | |
hRegs_X80.textContent = tmp.x80; | |
hRegs_X86.textContent = tmp.x86; | |
hRegs_X64.textContent = tmp.x64, | |
hRegs_MMX.textContent = tmp.mmx; | |
} | |
Draw_Pixels(); | |
return true; | |
} | |
function Draw_Pixels() { | |
var tmp; | |
if(Number(hIteration.value) < cpu.images.length) { | |
var n = Number(hIteration.value); | |
if(nIteration > n) { | |
hDisplay.clearRect(0, 0, hDisplay.canvas.width, hDisplay.canvas.height); | |
Display_Line(+hDisplay.canvas.dataset.x1, +hDisplay.canvas.dataset.y1, +hDisplay.canvas.dataset.x2, +hDisplay.canvas.dataset.y2, true); | |
} | |
for(var i = nIteration < n ? nIteration : 0; i <= n; ++ i) { | |
var x = cpu.images[i].x, y = cpu.images[i].y, rgba = cpu.images[i].rgba; | |
tmp = hDisplay.getImageData(x % hDisplay.canvas.width - 1, y % hDisplay.canvas.height - 1, 3, 3); | |
tmp.data[3] = 255; | |
tmp.data[7] = 255; | |
tmp.data[11] = 255; | |
tmp.data[15] = 255; | |
tmp.data[16] = (rgba & 255); | |
tmp.data[17] = (rgba >> 8) & 255; | |
tmp.data[18] = (rgba >> 16) & 255; | |
tmp.data[19] = (rgba >> 24) & 255; | |
tmp.data[23] = 255; | |
tmp.data[27] = 255; | |
tmp.data[31] = 255; | |
tmp.data[35] = 255; | |
hDisplay.putImageData(tmp, x % hDisplay.canvas.width - 1, y % hDisplay.canvas.height - 1); | |
} | |
nIteration = n; | |
Display_Line(+hDisplay.canvas.dataset.x1, +hDisplay.canvas.dataset.y1, +hDisplay.canvas.dataset.x2, +hDisplay.canvas.dataset.y2, false); | |
} | |
} | |
function onResize() { | |
hListingRows.style.paddingLeft = "0px"; | |
hListing.rows = Math.floor((window.innerHeight - hStatus.offsetHeight - hCaption.offsetHeight) / (hListing.offsetHeight / hListing.rows)); | |
hListing.cols = Math.floor((window.innerWidth) / ((hListing.offsetWidth + hListingRows.offsetWidth) / hListing.cols)); | |
hListingRows.style.paddingLeft = (window.innerWidth - (hListing.offsetWidth + hListingRows.offsetWidth)) + "px"; | |
hListingRows.rows = hListing.rows; | |
var els = document.querySelectorAll("div.Information"); | |
var x = window.innerWidth; | |
if(els) | |
els | |
.forEach | |
(function(el) { | |
if(el.offsetLeft + el.offsetWidth >= window.innerWidth) | |
el.style.left = (x - el.offsetWidth) + "px", | |
x -= 64; | |
if(el.offsetTop + el.offsetHeight >= window.innerHeight) | |
el.style.top = (window.innerHeight - hStatus.offsetHeight - hCaption.offsetHeight - el.offsetHeight) + "px"; | |
}); | |
} | |
function TryStyle(css) { | |
// for(var i = 0; i < document.documentElement.classList.length; ++ i) | |
// document.documentElement.classList.toggle(document.documentElement.classList[i], false); | |
const stylesheet = new CSSStyleSheet(); | |
// Add some CSS | |
stylesheet.replaceSync(css.text) | |
// OR stylesheet.replace, which returns a Promise instead | |
// Tell the document to adopt your new stylesheet. | |
// Note that this also works with Shadow Roots. | |
document.adoptedStyleSheets = [stylesheet]; | |
} | |
function onListing_RefreshRows() { | |
var nRows = hListing.value.split(/\r?\n/g).length; | |
var rows = []; | |
if(nRows != hListingRows.value.split(/\r?\n/).length) { | |
for(var i = 0; i <= nRows; ++ i) | |
rows.push(i + 1); | |
hListingRows.textContent = rows.join("\r\n"); | |
} | |
hListingRows.scrollTop = hListing.scrollTop; | |
} | |
function Listing_ParseSections() { | |
var time = hIteration.value; | |
var sections = {}; | |
var regexp = /^::[\W\w][\r\n\W\w]+?(?=^::)/igm; | |
var ma = (hListing.value + "\r\n::").matchAll(regexp); | |
var m = ma.next(); | |
while(!m.done) { | |
if(!m.done){ | |
tmp = m.value[0].split(/\r?\n/); | |
sections[tmp[0].split(/\s|\t/)[0].replace(/[^A-Z]/gi, "").toUpperCase()] = { | |
name :tmp[0].substr(2), | |
text :[].concat(tmp.splice(1)).join("\n") | |
}; | |
} | |
m = ma.next(); | |
} | |
if(sections.X) { | |
switch(sections.X.name.split(/\s/)[0].toUpperCase()) { | |
case "X86": | |
case "X64": | |
case "I8080": | |
cpu.assembly("\r\n" + sections.X.text); | |
if(cpu.Views.match(/AUTO|-/)) { | |
var Checkers = document.getElementsByName("View_Windows"); | |
for(var el of Checkers) { | |
el.checked = cpu.Views.indexOf(el.dataset.show) >= 0; | |
document.getElementById(el.dataset.window).style.display = el.checked ? "block" : "none"; | |
} | |
/* | |
document.getElementById("Window_Graphics").style | |
<li><label><input name=View_Windows type=checkbox checked data-window=Window_History />History</label></li> | |
<hr /><li><label><input name=View_Windows type=checkbox data-window=Window_X80 />CPU:i8080/z80</label></li> | |
<li><label><input name=View_Windows type=checkbox checked data-window=Window_X86 />CPU:x86</label></li> | |
<li><label><input name=View_Windows type=checkbox checked data-window=Window_X64 />CPU:x64</label></li> | |
<li><label><input name=View_Windows type=checkbox checked data-window=Window_MMX />CPU:MMX</label></li> | |
<li><label><input name=View_Windows type=checkbox data-window=Window_SSE />CPU:SSE</label></li> | |
<li><label><input name=View_Windows type=checkbox data-window=Window_Sliders />User Sliders</label></li> | |
<li><label><input name=View_Windows type=checkbox data-window=Window_Pseudos */ | |
} | |
Execute_Program(); | |
break; | |
} | |
} else | |
if(sections.MMX) { | |
cpu.assembly("\r\n" + sections.MMX.text); | |
Execute_Program(); | |
} | |
if(sections.STYLE) { | |
if(sections.STYLE.text == "") { | |
var css = document.querySelector("style"); | |
var found = css.textContent.replace(/(})([^{]+)/gm,"$1~~~$2").split("~~~"); | |
if(!("CustomStyle" in window.localStorage)) | |
window.localStorage.CustomStyle = found[0].replace(/:[^{]+/, ":root.Style10\r\n"); | |
hListing.value += "\r\n" + window.localStorage.CustomStyle; | |
for(var id in found) { | |
if((new RegExp(sections.STYLE.name, "ig")).test(found[id])) { | |
hListing.value = "::" + sections.STYLE.name + "\r\n" + found[id]; | |
break; | |
} | |
} | |
} else { | |
window.localStorage.CustomStyle = sections.STYLE.text; | |
TryStyle(sections.STYLE); | |
document.documentElement.classList.toggle("Style" + 10, true), | |
hStylers[10].checked = true; | |
} | |
} | |
hCaption.disabled = false; | |
hProgressBar.style.display = "none"; | |
hIteration.value = time; | |
onListing_RefreshState(hListing); | |
hListing.focus(); | |
onListing_RefreshRows(); | |
} | |
function onListing_Input(e, time) { | |
clearTimeout(hRefresh); | |
clearTimeout(hRefreshAssm); | |
onResize(); | |
// | |
if(e) | |
window.localStorage.listing = hListing.value; | |
hProgressBar.style.display = "inline"; | |
hRefreshAssm = setTimeout(Listing_ParseSections, time && isFinite(time) ? time : 3000); | |
onListing_RefreshRows(); | |
window.localStorage.listingSelectAt = hListing.selectionStart; | |
window.localStorage.listingSelectTo = hListing.selectionEnd; | |
} | |
var pVideo; | |
function check_status(resp) { | |
if(!resp.ok) { | |
throw new Error(`HTTP ${resp.status} - ${resp.statusText}`); | |
} | |
return resp; | |
} | |
// | |
function load_gist(el, id) { | |
var f; | |
if(id) | |
f = fetch(linkTo.gist.host + id, {redirect: "follow"}); | |
else | |
f = fetch(linkTo.gist.host + linkTo.gist.list, {redirect: "follow"}); | |
console.log(`Load Gist...`); | |
f | |
.then(response => | |
check_status(response) | |
) | |
.then(response => | |
{ | |
console.log(response); | |
return response.arrayBuffer() | |
} | |
) | |
.then((function(buffer) | |
{ | |
var text = String.fromCharCode.apply(null, new Uint8Array(buffer)); | |
var index = 1; | |
if(this.is_list) { | |
text.split(/\r?\n/) | |
.forEach( | |
function(items) { | |
var item = items.split(/\t+/); | |
var li = document.createElement("li"); | |
li.addEventListener("click", | |
(function(e) { | |
load_gist(null, this.url); | |
}).bind({ | |
url :item[0] | |
}) | |
); | |
li.textContent = index ++ + ". " + item[1]; | |
li.className = "File"; | |
hFilesGists.appendChild(li); | |
} | |
); | |
} else { | |
hListing.value = text; | |
onListing_Input(); | |
hListing.focus(); | |
/*cpu.ram.set(0).set(hListing.value.split(".assm")[0]); | |
cpu.assembly(hListing.value.split(".assm")[1], hListing.value.split(".assm")[0].split(/\r?\n/).length - 1); | |
cpu.reset(); | |
showState();*/ | |
} | |
}) | |
.bind({ | |
el :el, | |
is_list :id ? false : true | |
}) | |
) | |
.catch(error => | |
console.log(error) | |
); | |
} | |
// | |
function load_assembly(url) { | |
//url = "https://pastebin.com/raw/AqHSN1B9"; | |
fetch(url, { | |
redirect: "follow" | |
}) | |
.then(response => | |
check_status(response) | |
) | |
.then(response => | |
{ | |
console.log(response); | |
return response.arrayBuffer() | |
} | |
) | |
.then(buffer => | |
{ | |
hListing.value = String.fromCharCode.apply(null, new Uint8Array( buffer)); | |
onListing_Input(); | |
hListing.focus(); | |
/*cpu.ram.set(0).set(hListing.value.split(".assm")[0]); | |
cpu.assembly(hListing.value.split(".assm")[1], hListing.value.split(".assm")[0].split(/\r?\n/).length - 1); | |
cpu.reset(); | |
showState();*/ | |
} | |
) | |
.catch(error => | |
console.log(error) | |
); | |
} | |
////////////////////////////////////////////////// | |
function cycle() { | |
setTimeout(cycle, 1000.0 / cpu.cps); | |
if((hUserPad.value.indexOf("$run ") > 0 || hUserPad.value.indexOf("$go") > 0) | |
&& (hUserPad.selectionEnd == hUserPad.selectionStart + 1) | |
&& (hUserPad.selectionEnd > hUserPad.value.replace(";$go ", ";$run ").indexOf("$run "))) { | |
while(cpu.step()) {} | |
showState(cpu.ctx.pointer(0x00B0)); | |
showState(cpu.ctx.pointer(0x00B0)); | |
if(hUserPad.value.indexOf(";$run") < 0) | |
hDebugger.style.display = "block"; | |
} else | |
hDebugger.style.display = "block"; | |
} | |
////////////////////////////////////////////////////////// | |
function do_run(speed, let_go) { | |
var tmp = hUserPad.value.replace(";$go ", ";$run "); | |
if(tmp.indexOf(";$run ") < 0) { | |
if(tmp.indexOf(";") < 0) { | |
tmp += ";$run Test for keyboard stroke..."; | |
} else { | |
tmp = tmp.replace(";", ";$run "); | |
} | |
hUserPad.value = tmp; | |
} | |
if(let_go) | |
hDebugger.style.display = "block", | |
hUserPad.value = hUserPad.value.replace(";$run ", ";$go "); | |
else | |
hDebugger.style.display = "none", | |
hUserPad.value = hUserPad.value.replace(";$go ", ";$run "); | |
if(hUserPad.selectionEnd < tmp.indexOf("$run ") | |
|| hUserPad.selectionEnd >= hUserPad.value.length) { | |
hUserPad.selectionStart = tmp.indexOf("$run ") + 5; | |
} | |
hUserPad.selectionEnd = hUserPad.selectionStart + 1; | |
hUserPad.focus(); | |
cpu.cps = speed; | |
} | |
////////////////////////////////////////////////////////// | |
function do_console(e) { | |
var text = hUserPad.value; | |
var pos = text.indexOf(";"); | |
var assm; | |
if(pos > 0 && hUserPad.selectionStart < pos) { | |
assm = hUserPad.value.split(" ")[0]; | |
if(assm.length == 4) { | |
cpu.assembly([ | |
"\t.ORG\t0x" + assm, | |
hUserPad.value.substr(assm.length), | |
".DW\t0x0000", | |
".DW\t0x0000", | |
".DW\t0x0000" | |
].join("\r\n\t")); | |
showState(parseInt(assm, 16)); | |
showState(parseInt(assm, 16)); | |
} | |
} else { | |
if(tmp = text.match(/([0-9A-F]{2}):([0-9A-F]{2})/i)) { | |
cpu.ctx[parseInt(tmp[1], 16)] = parseInt(tmp[2], 16); | |
showState(); | |
showState(); | |
} else | |
if(tmp = text.match(/([0-9A-F]{2})([0-9A-F]{2})([0-9A-F])#([0-9A-F]{2})/i)) { | |
cpu.ctx[0xD9] = parseInt(tmp[1], 16); | |
cpu.ctx[0xD8] = parseInt(tmp[2], 16); | |
cpu.ctx[0xD0 + parseInt(tmp[3], 16)] = parseInt(tmp[4], 16); | |
showState(); | |
showState(); | |
} | |
} | |
} | |
////////////////////////////////////////////////////////// | |
function FullScreen_OnOff(el) { | |
if(el.title == "Restore") { | |
el.title = "Expand"; | |
el.classList.toggle("Caption_Maxi", true); | |
el.classList.toggle("Caption_Maximal", false); | |
if(document.exitFullscreen) | |
document.exitFullscreen(); | |
else | |
if(document.mozCancelFullScreen) | |
document.mozCancelFullScreen(); | |
else | |
if(document.webkitExitFullscreen) | |
document.webkitExitFullscreen(); | |
else | |
if (document.msExitFullscreen) | |
document.msExitFullscreen(); | |
} else { | |
el.title = "Restore"; | |
el.classList.toggle("Caption_Maxi", false); | |
el.classList.toggle("Caption_Maximal", true); | |
if (document.body.requestFullScreen) | |
document.body.requestFullScreen(); | |
else | |
if(document.body.mozRequestFullScreen) | |
document.body.mozRequestFullScreen(); | |
else | |
if(document.body.webkitRequestFullScreen) | |
document.body.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT); | |
else | |
if (document.body.msRequestFullscreen) | |
document.body.msRequestFullscreen(); | |
} | |
} | |
////////////////////////////////////////////////////////// | |
function Ctx_KeyDown(evt) { | |
var keyCode = evt.keyCode || evt.which; | |
var el = evt.srcElement; | |
var hSelection = document.getSelection(); | |
var hRange = document.createRange(); | |
hRange.setStart(el, 0); | |
hRange.setEnd(hSelection.focusNode, hSelection.focusOffset); | |
var txt = hRange.toString(); | |
var ascii = el.textContent.charCodeAt(txt.length); | |
var rows = txt.split(/\r?\n/); | |
var columns = rows[rows.length - 1]; | |
hEmuLog.textContent = `${columns.length}:${rows.length}:"${ascii.toHex(2)}"`; | |
switch(keyCode) { | |
case 37: // Left | |
if(txt.length < 1 || !el.textContent.charAt(txt.length - 1).match(/[0-9A-F]/i)) | |
evt.preventDefault(); | |
break; | |
case 38: // Up | |
if(rows.length < 2) | |
evt.preventDefault(); | |
break; | |
case 39: // Right | |
if(ascii == 13) | |
evt.preventDefault(); | |
break; | |
case 40: // Down | |
if(rows.length == el.textContent.split(/\r?\n/).length) | |
evt.preventDefault(); | |
break; | |
case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: | |
case 65: case 66: case 67: case 68: case 69: case 70: | |
if(txt.length == el.textContent.length || ascii == 13) { | |
evt.preventDefault(); | |
break; | |
} | |
var textNode = el.childNodes[0]; //text node is the first child node of a span | |
var r = document.createRange(); | |
var startIndex = r.toString().length; | |
var endIndex = startIndex + 1; | |
r.setStart(textNode, txt.length); | |
r.setEnd(textNode, txt.length + 1); | |
var s = window.getSelection(); | |
s.removeAllRanges(); | |
s.addRange(r); | |
break; | |
default: | |
evt.preventDefault(); | |
} | |
} | |
function Ctx_KeyUp(evt) { | |
var keyCode = evt.keyCode || evt.which; | |
var el = evt.srcElement; | |
var hSelection = document.getSelection(); | |
var hRange = document.createRange(); | |
hRange.setStart(el, 0); | |
hRange.setEnd(hSelection.focusNode, hSelection.focusOffset); | |
var txt = hRange.toString(); | |
var ascii = el.textContent.charCodeAt(txt.length); | |
var rows = txt.split(/\r?\n/); | |
var columns = rows[rows.length - 1]; | |
hEmuLog.textContent = `${columns.length}:${rows.length}:"${ascii.toHex(2)}"`; | |
} | |
function Ctx_SelectStart(evt) { | |
selection = document.getSelection(); | |
childOffset = selection.focusOffset; | |
var range = document.createRange(); | |
eDiv = hRegs_MMX; | |
range.setStart(eDiv, 0); | |
range.setEnd(selection.focusNode, childOffset); | |
var txt = range.toString().split(/\r?\n/); | |
hEmuLog.textContent = txt[txt.length - 1].length + ":" + txt.length; | |
var e = hRegs_MMX; | |
var textNode = e.childNodes[0]; //text node is the first child node of a span | |
var r = document.createRange(); | |
var startIndex = range.toString().length; | |
var endIndex = startIndex + 1; | |
r.setStart(textNode, startIndex); | |
r.setEnd(textNode, endIndex); | |
var s = window.getSelection(); | |
s.removeAllRanges(); | |
s.addRange(r); | |
// | |
// | |
return; let sel = window.getSelection(); | |
let offset = sel.focusOffset; | |
let focus = sel.focusNode; | |
sel1 = document.selection.createRange(); | |
sel1.moveStart('character', 15); | |
sel.select(); | |
range = document.createRange(); | |
range.selectNode(focus); | |
range.setStart(focus, offset); | |
range.collapse(true); | |
sel.removeAllRanges(); | |
sel.addRange(range); | |
return; | |
sel = window.getSelection(); | |
offset = sel.focusOffset; | |
focus = sel.focusNode; | |
focus.textContent += "\""; //setting div's innerText directly creates new | |
//nodes, which invalidate our selections, so we modify the focusNode directly | |
range = document.createRange(); | |
range.selectNode(focus); | |
range.setStart(focus, offset); | |
range.collapse(true); | |
sel.removeAllRanges(); | |
sel.addRange(range); | |
} | |
////////////////////////////////////////////////////////// | |
function ShowHide(el) { | |
if(typeof el == "string") | |
document.getElementById(el).style.display = document.getElementById(el).style.display != "none" ? "none" : "block"; | |
else | |
if(el.dataset) | |
document.getElementById(el.dataset.window).style.display = el.checked ? "block" : "none"; | |
else | |
document.getElementById(el.srcElement.dataset.window).style.display = el.srcElement.checked ? "block" : "none"; | |
return false; | |
} | |
////////////////////////////////////////////////////////// | |
function prepareMenu(hLabel) { | |
var hTopics = hLabel.children; | |
var i, el; | |
if(hTopics && hTopics.length > 0) { | |
for(i in hTopics) { | |
el = hTopics[i]; | |
console.log(el); | |
} | |
} | |
for(i = 0; i < hCaptionTopics.length; ++ i) { | |
hCaptionTopics[i].addEventListener("click", | |
function(evt) { | |
if(hCaptionMenu.checked) { | |
for(var i = 0; i < hCaptionTopics.length; ++ i) { | |
if(hCaptionTopics[i].checked) { | |
window.localStorage.MenuTopic = i; | |
return; | |
} | |
} | |
} | |
} | |
); | |
} | |
hCaptionMenu.addEventListener("change", | |
function(evt) { | |
if(!evt.srcElement.checked) | |
window.localStorage.MenuTopic = ""; | |
} | |
); | |
if("MenuTopic" in window.localStorage) { | |
i = window.localStorage.MenuTopic; | |
if(i != "") | |
hCaptionMenu.checked = true, | |
hCaptionTopics[i].checked = true; | |
} | |
} | |
////////////////////////////////////////////////////////// | |
function onFileNew() { | |
var WindowStyle = "WindowStyle" in window.localStorage ? window.localStorage.WindowStyle : ""; | |
var CustomStyle = "CustomStyle" in window.localStorage ? window.localStorage.CustomStyle : ""; | |
window.localStorage.clear(); | |
if(WindowStyle != "") | |
window.localStorage.WindowStyle = WindowStyle; | |
if(CustomStyle != "") | |
window.localStorage.CustomStyle = CustomStyle; | |
window.location=""; | |
} | |
////////////////////////////////////////////////////////// | |
function Execute_Program() { | |
var n = hIteration.value; | |
var m = hIteration.max; | |
if("function" == typeof cpu.draft) | |
try { | |
cpu.draft(cpu.X64_R); | |
if(m < hIteration.max) { | |
nIteration = hIteration.max + 1; | |
hIteration.value = hIteration.max; | |
Draw_Pixels(); | |
} else { | |
nIteration = n + 1; | |
hIteration.value = n; | |
Draw_Pixels(); | |
} | |
} catch(err) { | |
console.log(err); | |
} | |
} | |
////////////////////////////////////////////////////////// | |
function Display_onMouseDown(evt) { | |
if(evt.buttons != 1) | |
return; | |
evt.srcElement.dataset.x1 = Math.floor(evt.offsetX / evt.srcElement.style.zoom), | |
evt.srcElement.dataset.y1 = Math.floor(evt.offsetY / evt.srcElement.style.zoom); | |
} | |
function Display_onMouseUp(evt) { | |
window.localStorage.Canvas_X1 = evt.srcElement.dataset.x1; | |
window.localStorage.Canvas_Y1 = evt.srcElement.dataset.y1; | |
window.localStorage.Canvas_X2 = evt.srcElement.dataset.x2; | |
window.localStorage.Canvas_Y2 = evt.srcElement.dataset.y2; | |
Execute_Program(); | |
Draw_Pixels(); | |
// onListing_Input(hListing, 1); | |
// setTimeout("hListing.focus()", 100); | |
} | |
function Display_onMouseMove(evt) { | |
if(evt.buttons != 1) | |
return; | |
evt.srcElement.dataset.x2 = Math.floor(evt.offsetX / evt.srcElement.style.zoom), | |
evt.srcElement.dataset.y2 = Math.floor(evt.offsetY / evt.srcElement.style.zoom); | |
Display_Line(+evt.srcElement.dataset.x1, +evt.srcElement.dataset.y1, +evt.srcElement.dataset.x2, +evt.srcElement.dataset.y2, true); | |
hDisplay_Status.textContent = `:: ${evt.srcElement.dataset.x1}:${evt.srcElement.dataset.y1} - ${evt.srcElement.dataset.x2}x${evt.srcElement.dataset.y2}`; | |
} | |
function Display_Line(x1, y1, x2, y2, flag) { | |
if(flag) | |
hDisplay.clearRect(0, 0, hDisplay.canvas.width, hDisplay.canvas.height); | |
hDisplay.strokeStyle = "magenta"; | |
hDisplay.beginPath(); | |
hDisplay.moveTo(x1, y1 - 4); | |
hDisplay.lineTo(x1, y1 + 4); | |
hDisplay.moveTo(x1 - 4, y1); | |
hDisplay.lineTo(x1 + 4, y1); | |
hDisplay.stroke(); | |
hDisplay.strokeStyle = "cyan"; | |
hDisplay.beginPath(); | |
hDisplay.moveTo(x2, y2 - 4); | |
hDisplay.lineTo(x2, y2 + 4); | |
hDisplay.moveTo(x2 - 4, y2); | |
hDisplay.lineTo(x2 + 4, y2); | |
hDisplay.stroke(); | |
if(!flag) | |
return; | |
hDisplay.strokeStyle = "black"; | |
hDisplay.beginPath(); | |
hDisplay.moveTo(x1, y1); | |
hDisplay.lineTo(x2, y2); | |
hDisplay.stroke(); | |
} | |
////////////////////////////////////////////////////////// | |
function main() { | |
init(); | |
hDisplay.canvas.addEventListener("mousedown", Display_onMouseDown); | |
hDisplay.canvas.addEventListener("mousemove", Display_onMouseMove); | |
hDisplay.canvas.addEventListener("mouseup", Display_onMouseUp); | |
if("Canvas_X1" in window.localStorage) | |
hDisplay.canvas.dataset.x1 = window.localStorage.Canvas_X1; | |
if("Canvas_Y1" in window.localStorage) | |
hDisplay.canvas.dataset.y1 = window.localStorage.Canvas_Y1; | |
if("Canvas_X2" in window.localStorage) | |
hDisplay.canvas.dataset.x2 = window.localStorage.Canvas_X2; | |
if("Canvas_Y2" in window.localStorage) | |
hDisplay.canvas.dataset.y2 = window.localStorage.Canvas_Y2; | |
prepareMenu(hMainMenu); | |
if("CustomStyle" in window.localStorage) | |
TryStyle({text: window.localStorage.CustomStyle.replace(/^::.*$/, "")}); | |
for(var i = 0; i < hStylers.length; ++ i) { | |
hStylers[i].addEventListener("change", | |
(function(evt) { | |
for(var i = 0; i < document.documentElement.classList.length; ++ i) | |
document.documentElement.classList.toggle(document.documentElement.classList[i], false); | |
if(this.styleId >= 10 && ("CustomStyle" in window.localStorage)) | |
TryStyle({text: window.localStorage.CustomStyle.replace(/^::.*$/, "")}); | |
document.documentElement.classList.toggle("Style" + this.styleId); | |
window.localStorage.WindowStyle = this.styleId; | |
}).bind({ | |
styleId :i | |
}) | |
); | |
hStylers[i].parentElement.addEventListener("dblclick", (function(evt) { | |
evt.preventDefault(); | |
hListing.value = "::Style" + this.index; | |
onListing_Input(null, 0); | |
}).bind({index: i})); | |
if("WindowStyle" in window.localStorage) { | |
if(i == window.localStorage.WindowStyle) | |
document.documentElement.classList.toggle("Style" + i, true), | |
hStylers[i].checked = true; | |
} else | |
if(hStylers[i].checked) | |
document.documentElement.classList.toggle("Style" + i, true); | |
} | |
/* function(evt) { | |
SelectText1(); | |
evt.preventDefault(); | |
return; | |
setTimeout( | |
(function() { | |
var selection; | |
try { | |
selection = document.getSelection(); | |
} catch(e) {return;} | |
childOffset = selection.focusOffset; | |
var range = document.createRange(); | |
eDiv = hEmuCtx; | |
range.setStart(eDiv, 0); | |
range.setEnd(selection.focusNode, childOffset); | |
var txt = range.toString().split(/\r?\n/); | |
hEmuLog.textContent = txt[txt.length - 1].length + ":" + txt.length; | |
var rnge = document.createRange(hEmuCtx, 15, 25); | |
selection = window.getSelection(); | |
selection.removeAllRanges(); | |
selection.addRange(rnge); | |
/* var rng = document.getSelection().getRangeAt(0).cloneRange(); | |
// rng.setStart(evt.srcElement, 0); | |
// do not use 'this' sel anymore since the selection has changed | |
const content = window.getSelection().toString(); | |
const text = JSON.stringify(content); | |
const lines = (text.match(/\\n/g) || []).length + 1; | |
// clear selection | |
window.getSelection().collapseToEnd(); | |
alert(`${text.length}/${lines}`);*/ | |
/* rng.setStart(evt.srcElement, 23); | |
rng.setEnd(evt.srcElement, 26);* / | |
}), 1); | |
} | |
);*/ | |
/////////////////////////////////////////////////////////////////////// | |
document | |
.getElementsByName("View_Windows") | |
.forEach( | |
function(el) { | |
if(el.dataset.window) { | |
el.addEventListener("change", ShowHide); | |
ShowHide(el); | |
} | |
} | |
); | |
/////////////////////////////////////////////////////////////////////// | |
i = 1; | |
/*Array.prototype.slice.call(document.getElementsByTagName("TextArea")) | |
.forEach | |
(function(el) { | |
if(el.style.display == "none" && el.title != "") { | |
var li = document.createElement("li"); | |
li.textContent = el.title; | |
li.addEventListener("click", | |
(function(e) { | |
hListing.value = this.fromTextArea.value; | |
onListing_Input(); | |
}).bind({ | |
fromTextArea: el | |
}) | |
); | |
li.accessKey = "" + (i ++); | |
hFilesExamples.appendChild(li); | |
//hEllipsys.parentNode.insertBefore(li, hEllipsys.nextSibling); | |
} | |
});*/ | |
for(var title in pExamples) { | |
var li = document.createElement("li"); | |
li.textContent = title; | |
li.addEventListener("click", | |
(function(evt) { | |
hListing.value = this.text; | |
onListing_Input(); | |
}).bind({ | |
text: pExamples[title].trim() | |
}) | |
); | |
hFilesExamples.appendChild(li); | |
//hEllipsys.parentNode.insertBefore(li, hEllipsys.nextSibling); | |
} | |
document.body.style.paddingTop = hCaption.offsetHeight; | |
document.body.style.visibility = "visible"; | |
// | |
hIteration.addEventListener("change", function(e) { | |
onListing_RefreshState(hListing); | |
} | |
); | |
hIteration.addEventListener("input", function(e) { | |
onListing_RefreshState(hListing); | |
} | |
); | |
hImageFiles.addEventListener("change", function(e) { | |
if(e.srcElement.files[0]) { | |
var reader = new FileReader(); | |
reader.onload = function() { | |
var dataUrl = reader.result; | |
var base64 = dataUrl.split(',')[1]; | |
hSprites.style.height = ""; | |
hSprites.style.width = ""; | |
hSprites.src = dataUrl; | |
}; | |
reader.readAsDataURL(e.srcElement.files[0]); | |
e.srcElement.style.display = "none"; | |
} | |
} | |
); | |
/* hUserPad.addEventListener("focus", function(e) { | |
if(hClock) | |
clearInterval(hClock); | |
hClock = setInterval("while(cpu.step()) {} showState();", 1000 / cpu.cps); | |
hDebugger.style.display = "none"; | |
} | |
); | |
hUserPad.addEventListener("blur", function(e) { | |
if(hClock) | |
clearInterval(hClock); | |
hClock = null; | |
hDebugger.style.display = "block"; | |
} | |
);*/ | |
hSprites.src = hSprites.src; | |
hSprites.addEventListener("load", | |
function(e) { | |
e.srcElement.style.display = "inline"; | |
pVideo = cpu.prepareImage(e.srcElement); | |
setInterval("cpu.render(hScreen, pVideo)" , 40); | |
} | |
); | |
window.addEventListener("resize", function() {onResize(); setTimeout(onResize(), 20)}); | |
hListing.addEventListener("input", onListing_Input); | |
hListing.addEventListener("scroll", | |
function(e) { | |
var el = e.srcElement; | |
hListingRows.scrollTop = el.scrollTop; | |
} | |
); | |
hListing.addEventListener("mousedown", onListing_RefreshState); | |
hListing.addEventListener("keyup", onListing_RefreshState); | |
hListing.addEventListener("keydown", | |
function(e) { | |
var keyCode = e.keyCode || e.which; | |
if(keyCode === 0x09) { | |
document.execCommand('insertText', false, '\t'.repeat(1)); | |
e.preventDefault(); | |
} else | |
if(keyCode === 0x23) { // End | |
if(editStatus > 0) | |
hIteration.value = Number(hIteration.value) + 1; | |
} else | |
if(keyCode === 0x24) { // Home | |
if(editStatus < 0) | |
hIteration.value = Number(hIteration.value) - 1; | |
} | |
onListing_RefreshState(e); | |
} | |
); | |
/* hUserPad.addEventListener("keydown", | |
function(e) { | |
var keyCode = e.keyCode || e.which; | |
if(keyCode === 0x09) { | |
document.execCommand('insertText', false, '\t'.repeat(1)); | |
e.preventDefault(); | |
} else | |
if(keyCode == 0x0D) { | |
cpu.step(); | |
showState(undefined, true); | |
} | |
} | |
); | |
hUserPad.addEventListener("input", do_console);*/ | |
cpu.init(); | |
if(window.location.href.match(/classic/i)) | |
cpu.classic = true; | |
if(tmp = window.location.href.match(/gist=(http.*\.asm)/)) | |
load_assembly(tmp[1]); | |
else | |
if("listing" in window.localStorage && (window.localStorage.listing.indexOf("::style") >= 0 || window.localStorage.listing.indexOf("20230323") > 0)) { | |
hListing.value = window.localStorage.listing; | |
hListing.focus(); | |
onListing_Input(); | |
} else | |
if("listing" in window.localStorage) { | |
if(confirm("Latest revision is inactual. Reload anyway?")) { | |
hListing.value = window.localStorage.listing; | |
hListing.focus(); | |
onListing_Input(); | |
} | |
} | |
if("listingSelection" in window.localStorage) { | |
var selection = window.localStorage.listingSelection; | |
if(selection) | |
hListing.selectionStart = selection.split(",")[0], | |
hListing.selectionEnd = selection.split(",")[1], | |
hListing.scrollTop = selection.split(",")[2], | |
hIteration.value = selection.split(",")[3]; | |
hListingRows.scrollTop = hListing.scrollTop; | |
}/* else | |
if(!window.location.href.match(/debug/)) | |
load_assembly("https://gist.githubusercontent.com/Alikberov/0a9ed1f8bca71b6e0bc957485497311b/raw/koy-mac-slalom.asm");*/ | |
onResize(); | |
onResize(); | |
load_gist(hFiles); | |
//cpu.ram.set(0).set(hListing.value.split(".assm")[0]); | |
//cpu.assembly(hListing.value.split(".assm")[1], hListing.value.split(".assm")[0].split(/\r?\n/).length - 1); | |
//cpu.reset(); | |
//showState(); | |
onListing_Input(null, 1); | |
tmp = window.location.href.match(/autorun-?(\d*)(\.)?/i) | |
if(tmp) { | |
do_run(tmp[1] || 1, tmp[2]); | |
clearTimeout(hRefresh); | |
} | |
//cycle(); | |
} | |
setTimeout(main, 1000); | |
</script> | |
<style> | |
body | |
{ | |
visibility :hidden; | |
background-color:var(--button-face); | |
color :grey; | |
padding-bottom :0px; | |
margin-bottom :0px; | |
padding-right :0px; | |
margin-right :0px; | |
padding-left :0px; | |
margin-left :0px; | |
padding-top :0px; | |
margin-top :0px; | |
overfrow-x :hidden; | |
overfrow-y :hidden; | |
} | |
hr | |
{ | |
padding-bottom :0px; | |
margin-bottom :0px; | |
padding-right :0px; | |
margin-right :0px; | |
padding-left :0px; | |
margin-left :0px; | |
padding-top :0px; | |
margin-top :0px; | |
} | |
input#UserPad | |
{ | |
width :100%; | |
} | |
pre#EmuLog | |
{ | |
background-color:var(--menu);/*Menu;*/ | |
color :var(--menu-text);/*MenuText;*/ | |
border :thin inset var(--button-edge);/*ButtonFace*/ | |
display :inline-block; | |
font-family :Courier New; | |
font-size :12px; | |
margin :0px 0px 0px 0px; | |
resize :none; | |
padding :0px 0px 0px 0px; | |
display:inline-block; | |
position:fixed; | |
right:0%; | |
text-align:right; | |
} | |
textarea#ListingRows { | |
background :var(--textrows); | |
text-shadow :var(--textrows-claw); | |
color :var(--textrows-text); | |
border-bottom :thin inset var(--textarea-edge);/*ButtonFace*/ | |
border-left :thin inset var(--textarea-edge);/*ButtonFace*/ | |
border-top :thin inset var(--textarea-edge);/*ButtonFace*/ | |
border-right :thin dashed var(--textarea-text); | |
cursor :default; | |
display :inline-block; | |
font-family :Courier New; | |
font-size :12px; | |
/*white-space :nowrap;*/ | |
font-weight :normal; | |
margin :0px 0px 0px 0px; | |
padding :0px 0px 0px 0px; | |
overflow-y :hidden; | |
resize :none; | |
text-align :right; | |
} | |
textarea#Listing | |
{ | |
background :var(--textarea); | |
text-shadow :var(--textarea-claw); | |
color :var(--textarea-text); | |
border-left :none; | |
border-top :thin inset var(--textarea-edge);/*ButtonFace*/ | |
border-right :thin inset var(--textarea-edge);/*ButtonFace*/ | |
border-bottom :thin inset var(--textarea-edge);/*ButtonFace*/ | |
display :inline-block; | |
font-family :Courier New; | |
font-size :12px; | |
margin-left :0px; | |
resize :none; | |
padding :0px 0px 0px 0px; | |
} | |
textarea#Listing:focus, | |
textarea#ListingRows:focus | |
{ | |
outline :none; | |
} | |
pre#EmuDis, pre#EmuDump, | |
pre#Regs_MMX, pre#Regs_SSE, pre#Regs_x64, pre#Regs_x86 | |
{ | |
border :thin inset var(--button-face);/*ButtonFace*/ | |
display :block; | |
font-family :Courier New; | |
font-size :12px; | |
} | |
span.ActiveByte | |
{ | |
color :white; | |
font-weight :bolder; | |
} | |
pre#EmuDis { | |
background-color:darkgreen; | |
color :lightgreen; | |
font-family :Courier New; | |
font-size :12px; | |
} | |
pre#EmuDis.line0 > span:nth-child(1), | |
pre#EmuDis.line1 > span:nth-child(2), | |
pre#EmuDis.line2 > span:nth-child(3), | |
pre#EmuDis.line3 > span:nth-child(4), | |
pre#EmuDis.line4 > span:nth-child(5), | |
pre#EmuDis.line5 > span:nth-child(6), | |
pre#EmuDis.line6 > span:nth-child(7), | |
pre#EmuDis.line7 > span:nth-child(8), | |
pre#EmuDis.line8 > span:nth-child(9), | |
pre#EmuDis.line9 > span:nth-child(10), | |
pre#EmuDis.line10 > span:nth-child(11), | |
pre#EmuDis.line11 > span:nth-child(12), | |
pre#EmuDis.line12 > span:nth-child(13), | |
pre#EmuDis.line13 > span:nth-child(14), | |
pre#EmuDis.line14 > span:nth-child(15), | |
pre#EmuDis.line15 > span:nth-child(16) { | |
background-color:green; | |
} | |
tr | |
{ | |
border-top :none; | |
padding-top :0px; | |
margin-top :0px; | |
} | |
table#Caption | |
{ | |
border :none; | |
z-index :1000; | |
} | |
label#MenuBar | |
{ | |
background :var(--menu);/*Menu*/ | |
color :var(--menu-text);/*MenuText*/ | |
text-shadow :var(--menu-claw); | |
display :block; | |
} | |
label input#CaptionMenu | |
{ | |
display :none; | |
} | |
label input#CaptionMenu ~ menu li menu::before | |
{ | |
left :-1em; | |
position :absolute; | |
content :'\25B6'; | |
visibility :visible; | |
display :inline-block; | |
} | |
label input#CaptionMenu ~ menu li menu | |
{ | |
left:100%; | |
position :absolute; | |
} | |
label input#CaptionMenu ~ menu | |
{ | |
background :inherit; | |
color :inherit; | |
border :none; | |
padding :1px 9px 1px 9px; | |
margin :0 0 0 0; | |
display :inline-block; | |
} | |
label input#CaptionMenu ~ input { | |
display :none; | |
} | |
label input#CaptionMenu ~ menu:hover | |
{ | |
border :1px outset var(--menu-over-edge); | |
background :var(--menu-over); | |
text-shadow :var(--menu-over-claw); | |
color :var(--menu-over-text); | |
padding :0px 8px 0px 8px; | |
} | |
label input#CaptionMenu:checked ~ input:checked + menu | |
{ | |
border :1px inset var(--menu-open-edge); | |
background :var(--menu-open); | |
color :var(--menu-open-text); | |
text-shadow :var(--menu-open-claw); | |
padding :0px 8px 0px 8px; | |
} | |
label input#CaptionMenu ~ menu:active, | |
label input#CaptionMenu:checked ~ input:checked + menu:active | |
{ | |
border :1px inset var(--menu-push-edge); | |
background :var(--menu-push); | |
color :var(--menu-push-text); | |
text-shadow :var(--menu-push-claw); | |
padding :0px 8px 0px 8px; | |
} | |
label input#CaptionMenu ~ menu ol, | |
label input#CaptionMenu ~ menu ul | |
{ | |
color :inherit; | |
position :absolute; | |
border :1px outset; | |
display :none; | |
list-style-type :none; | |
list-style-type :none; | |
list-style-position :outside; | |
} | |
label input#CaptionMenu ~ li | |
{ | |
background :inherit; | |
color :inherit; | |
} | |
label input#CaptionMenu:checked ~ menu:hover ol, | |
label input#CaptionMenu:checked ~ menu:hover ul | |
{ | |
background :var(--item); | |
color :var(--item-text); | |
display :block; | |
padding :0px 0em 0px 0px; | |
margin :0px 0px 0px 0px; | |
text-shadow :var(--item-claw); | |
width:auto; | |
} | |
label input#CaptionMenu:checked ~ input:checked + menu > ol, | |
label input#CaptionMenu:checked ~ input:checked + menu > ul | |
{ | |
background :var(--item); | |
color :var(--item-text); | |
display :block; | |
padding :0px 0em 0px 0px; | |
margin :0px 0px 0px 0px; | |
text-shadow :var(--item-claw); | |
width:auto; | |
} | |
label input#CaptionMenu:checked ~ menu li label | |
{ | |
display:inline; | |
} | |
label input#CaptionMenu:checked ~ menu:hover ol li::after, | |
label input#CaptionMenu:checked ~ menu:hover ul li::after, | |
label input#CaptionMenu:checked ~ input:checked + menu > ol li::after, | |
label input#CaptionMenu:checked ~ input:checked + menu > ul li::after | |
{ | |
display :inline; | |
padding :0px 1em 0px 0px; | |
margin :0px 0px 0px 0px; | |
white-space :textarea; | |
text-shadow :none; | |
content :' '; | |
} | |
label input#CaptionMenu:checked ~ menu:hover li:hover, | |
label input#CaptionMenu:checked ~ menu:hover li label:hover | |
{ | |
background :var(--item-over);/*Highlight*/ | |
text-shadow :var(--item-over-claw); | |
border :var(--item-over-edge); | |
color :var(--item-over-text);/*HighlightText*/ | |
width :100%; | |
} | |
label input#CaptionMenu:checked ~ menu:hover li menu, | |
label input#CaptionMenu:checked ~ input:checked + menu li menu | |
{ | |
padding :0px 0px 0px 0px; | |
margin :0px 0px 0px 0px; | |
width :100%; | |
} | |
label input#CaptionMenu:checked ~ menu:hover li menu ol::before, | |
label input#CaptionMenu:checked ~ menu:hover li menu ul::before, | |
label input#CaptionMenu:checked ~ input:checked + menu li menu, | |
label input#CaptionMenu:checked ~ input:checked + menu li menu ol, | |
label input#CaptionMenu:checked ~ input:checked + menu li menu ul, | |
label input#CaptionMenu:checked ~ input:checked + menu li menu ol, | |
label input#CaptionMenu:checked ~ input:checked + menu li menu ul | |
{ | |
-background-color:red; | |
visibility :visible; | |
display :block; | |
} | |
label input#CaptionMenu:checked ~ input:checked + menu li menu ol li:hover, | |
label input#CaptionMenu:checked ~ input:checked + menu li menu ul li:hover | |
{ | |
background :var(--item-over);/*Highlight*/ | |
text-shadow :var(--item-over-claw); | |
border :var(--item-over-edge); | |
color :var(--item-over-text);/*HighlightText*/ | |
} | |
label input#CaptionMenu:checked ~ input:checked + menu li menu/* ol, | |
label input#CaptionMenu:checked ~ input:checked + menu li menu ul*/ | |
{ | |
left:100%; | |
width:auto; | |
display:inline-block; | |
} | |
label input#CaptionMenu:checked ~ input:checked + menu li menu ol li, | |
label input#CaptionMenu:checked ~ input:checked + menu li menu ul li | |
{ | |
display:none; | |
white-space :pre; | |
} | |
label input#CaptionMenu:checked ~ input:checked + menu li menu ul::before | |
{ | |
left:-1em; | |
width:auto; | |
visibility:visible; | |
display:inline-block; | |
} | |
label input#CaptionMenu:checked ~ menu:hover li menu ol, | |
label input#CaptionMenu:checked ~ menu:hover li menu ul, | |
label input#CaptionMenu:checked ~ input:checked + menu li menu ol, | |
label input#CaptionMenu:checked ~ input:checked + menu li menu ul | |
{ | |
border :none; | |
left :10%; | |
color :var(--item-text);/*MenuText*/ | |
-display :none; | |
width :auto; | |
} | |
label input#CaptionMenu:checked ~ menu:hover li:hover menu ol, | |
label input#CaptionMenu:checked ~ menu:hover li:hover menu ul | |
{ | |
left :100%; | |
border :1px outset; | |
visibility:visible; | |
} | |
label input#CaptionMenu:checked ~ menu:hover li:hover menu ol li, | |
label input#CaptionMenu:checked ~ menu:hover li:hover menu ul li | |
{ | |
color :var(--item-text);/*MenuText*/ | |
display :inline-block; | |
} | |
li.File | |
{ | |
white-space :nowrap; | |
} | |
table#Caption | |
{ | |
width :100%; | |
position :fixed; | |
left :0px; | |
top :0px; | |
background-color:var(--caption);/*ActiveCaption*/ | |
color :var(--caption-text);/*CaptionText*/ | |
background :var(--caption); | |
} | |
table#Caption:disabled tr, | |
table#Caption[disabled] tr, | |
table#Caption[readonly] tr | |
{ | |
color :var(--wait-text);/*CaptionText*/ | |
background :red;/*var(--wait-bg);*/ | |
} | |
table#Status | |
{ | |
background :var(--status);/*Menu*/ | |
text-shadow :var(--status-claw); | |
color :var(--status-text);/*MenuText*/ | |
width :100%; | |
position :fixed; | |
left :0px; | |
bottom :0px; | |
} | |
table#Caption tr td:nth-child(2), | |
table#Status tr | |
{ | |
font-family :Courier New; | |
width :100%; | |
/*color :grey;*/ | |
} | |
table#Status td | |
{ | |
border :thin inset var(--menu);/*Menu*/ | |
} | |
table#Caption tr td:nth-child(3) | |
{ | |
white-space :nowrap; | |
} | |
table#Caption tr td:nth-child(3) button | |
{ | |
font-family :Marlett; | |
} | |
input#ImageFiles | |
{ | |
display :none; | |
} | |
@keyframes canvasChecks { | |
from { | |
background-position: 0px 0px, 10px 10px; | |
} | |
to { | |
background-position: 40px 20px, 50px 30px; | |
} | |
} | |
canvas#Display | |
{ | |
/*position :absolute;*/ | |
animation-duration: 3s; | |
animation-timing-function: linear; | |
animation-name :canvasChecks; | |
animation-iteration-count: infinite; | |
background-position: 0px 0px, 10px 10px; | |
background-size :20px 20px; | |
background-image:var(--display-bg); | |
} | |
span.CPU_Group_A { | |
background-color: #772; <!-- ALU - AND/XOR/CMP 772--> | |
} | |
span.CPU_Group_B { | |
background-color: #764; <!-- Branching - Ccnd/Jcnd 752--> | |
} | |
span.CPU_Group_C { | |
background-color: #888; <!-- Controls - HLT/NOP 888--> | |
} | |
span.CPU_Group_D { | |
background-color: #663; <!-- Dubbed/Pair - INC/DEC 552--> | |
} | |
span.CPU_Group_E { | |
background-color: #363; <!-- Xchg/Stack - POP/PUSH 262--> | |
} | |
span.CPU_Group_F { | |
background-color: #367; <!-- Flip-Flop - MOV 257--> | |
} | |
span.CPU_Group_X { | |
background-color: #437; <!-- X-Code - --- 437--> | |
} | |
span.CPU_Group_Z { | |
background-color: #444; <!-- X-Code - --- 437--> | |
} | |
div.About | |
{ | |
display :none; | |
background-color:var(--button-face);/*ButtonFace*/ | |
opacity :90%; | |
position :fixed; | |
bottom :10%; | |
right :10%; | |
left :10%; | |
top :10%; | |
} | |
div.About h1 | |
{ | |
background-color:blue;/*ActiveCaption*/ | |
border :thick inset grey;/*InActiveCaption*/ | |
margin :0px 0px 0px 0px; | |
text-align :center; | |
} | |
button.Caption_Mini | |
{ | |
background :var(--mini); | |
border :outset var(--mini-edge); | |
border-radius :var(--radius); | |
} | |
button.Caption_Mini:active | |
{ | |
border :inset var(--mini-edge); | |
} | |
button.Caption_Mini:after | |
{ | |
content :var(--mini-sign); | |
visibility :visible; | |
} | |
button.Caption_Maxi, | |
button.Caption_Maximal | |
{ | |
background :var(--maxi); | |
border :outset var(--maxi-edge); | |
border-radius :var(--radius); | |
} | |
button.Caption_Maxi:active | |
{ | |
border :inset var(--maxi-edge); | |
} | |
button.Caption_Maxi:after | |
{ | |
content :var(--maxi-sign); | |
visibility :visible; | |
} | |
button.Caption_Maximal:after | |
{ | |
content :var(--maximal-sign); | |
visibility :visible; | |
} | |
button.Caption_Quit | |
{ | |
background :var(--quit); | |
border :outset var(--quit-edge); | |
border-radius :var(--radius); | |
} | |
button.Caption_Quit:active | |
{ | |
border :inset var(--quit-edge); | |
} | |
button.Caption_Quit:after | |
{ | |
content :var(--quit-sign); | |
visibility :visible; | |
} | |
</style> | |
<style> | |
div.Information | |
{ | |
color :black; | |
opacity :var(--float-opacity); | |
position :absolute; | |
border :thin outset var(--float-edge); | |
resize :vertical; | |
} | |
div.Information > header | |
{ | |
background :var(--caption);/*ActiveCaption;*/ | |
border-top :thin outset var(--button-edge);/*InActiveCaption;*/ | |
border-left :thin outset var(--button-edge); | |
border-right :thin outset var(--button-edge); | |
margin :0px 0px 0px 0px; | |
text-align :center; | |
color :var(--caption-text); | |
cursor :Move; | |
--visibility :hidden; | |
} | |
div.Information:hover > header | |
{ | |
visibility :visible; | |
} | |
div.Information textarea | |
{ | |
overflow :auto; | |
resize :none; | |
} | |
div.Information pre | |
{ | |
border :thick outset var(--float-edge);/*ActiveCaption;*/ | |
background :var(--float);/*ActiveCaption;*/ | |
color :var(--float-text); | |
margin :0px 0px 0px 0px; | |
overflow :auto; | |
resize :none; | |
} | |
</style> | |
</head> | |
<body> | |
<div id=Info class=About onclick='this.style.display="none"'><h1>Koyaanisqatsi::Info</h1><hr /> | |
KISC - is Koyaanisqatsi Instruction Set Computing<hr /> | |
CPS - Cycles Per Second: Programm cycle until HALT<br /> | |
Classic Mode: Native Koyaanisqatsi operating<br /> | |
DF - Duplex Flag: Alias for ZF, when compare identical operands<br /> | |
Do n CPS: Run until end of terminal line</div> | |
<div id=Help class=About onclick='this.style.display="none"'><h1>Koyaanisqatsi::Help</h1><hr /> | |
<ul> | |
<li><a href='https://gistpreview.github.io/?cff9df3bc1901d33f5c055682721240a#gist=https://gist.githubusercontent.com/Alikberov/0a9ed1f8bca71b6e0bc957485497311b/raw/koy-mac-slalom.asm'>Autoload listing</a></li> | |
<li><a href='https://gistpreview.github.io/?cff9df3bc1901d33f5c055682721240a#autorun-gist=https://gist.githubusercontent.com/Alikberov/0a9ed1f8bca71b6e0bc957485497311b/raw/koy-mac-slalom.asm'>Autorun listing</a></li> | |
<li><a href='https://gistpreview.github.io/?cff9df3bc1901d33f5c055682721240a#classic-gist=https://gist.githubusercontent.com/Alikberov/0a9ed1f8bca71b6e0bc957485497311b/raw/koy-mac-slalom.asm'>Classic mnemonic</a></li> | |
<li><a href='https://gistpreview.github.io/?cff9df3bc1901d33f5c055682721240a#autorun-classic-gist=https://gist.githubusercontent.com/Alikberov/0a9ed1f8bca71b6e0bc957485497311b/raw/koy-mac-slalom.asm'>Autorun listing with classic</a></li> | |
</ul> | |
Context - Set | |
<button onclick='hUserPad.value = "B5:3F"; do_console()'>B5=3F</button> | |
<button onclick='hUserPad.value = "B5:CD"; do_console()'>B5=CD</button> | |
<button onclick='hUserPad.value = "C6:5B"; do_console()'>C6=5B</button> | |
<button onclick='hUserPad.value = "A0:01"; do_console()'>A0=01</button> | |
<button onclick='hUserPad.value = "A0:02"; do_console()'>A0=02</button> | |
<button onclick='hUserPad.value = "A0:08"; do_console()'>A0=08</button><br /> | |
Device#CB:Part#00 - Set | |
CB:00.1=<button onclick='hUserPad.value = "CB001#3F"; do_console()'>3F</button> | |
<button onclick='hUserPad.value = "CB001#06"; do_console()'>06</button> | |
<button onclick='hUserPad.value = "CB001#5B"; do_console()'>5B</button> | |
<button onclick='hUserPad.value = "CB001#4F"; do_console()'>4F</button> | |
<button onclick='hUserPad.value = "CB001#66"; do_console()'>66</button> | |
<button onclick='hUserPad.value = "CB001#6D"; do_console()'>6D</button> | |
<button onclick='hUserPad.value = "CB001#7D"; do_console()'>7D</button> | |
<button onclick='hUserPad.value = "CB001#07"; do_console()'>07</button> | |
<button onclick='hUserPad.value = "CB001#7F"; do_console()'>7F</button> | |
<button onclick='hUserPad.value = "CB001#6F"; do_console()'>6F</button><br /> | |
Device#CD:Part#00 - Set | |
CD:12.3=<button onclick='hUserPad.value = "CD123#00"; do_console()'>00</button> | |
<button onclick='hUserPad.value = "CD123#55"; do_console()'>55</button> | |
<button onclick='hUserPad.value = "CD123#FF"; do_console()'>FF</button> | |
CD:12.5=<button onclick='hUserPad.value = "CD125#AA"; do_console()'>AA</button> | |
<button onclick='hUserPad.value = "CD125#55"; do_console()'>55</button> | |
<button onclick='hUserPad.value = "CD125#FF"; do_console()'>FF</button> | |
CD:39.1=<button onclick='hUserPad.value = "CD391#AA"; do_console()'>AA</button> | |
<button onclick='hUserPad.value = "CD391#55"; do_console()'>55</button> | |
<button onclick='hUserPad.value = "CD391#FF"; do_console()'>FF</button><br /> | |
</div> | |
<div id=About class=About onclick='this.style.display="none"'><h1>Koyaanisqatsi::About</h1><hr /> | |
MMX/SSE/AVX Simulator<br /> | |
by Alikberov</div> | |
<table id=Caption cellPadding=0 cellSpacing=0 border=0> | |
<tr onselectstart='window.event.preventDefault()'> | |
<td><blink><b style=color:red>MMX</b></blink></td> | |
<td> Simulator v1.01</td> | |
<td><button class=Caption_Mini></button><button class=Caption_Maxi onclick='FullScreen_OnOff(this)' title='Expand'></button><button class=Caption_Quit></button></td> | |
<!--td><button>0</button><button>2</button><button>r</button></td--> | |
</tr> | |
<tr> | |
<td colSpan=3> | |
<label id=MenuBar> | |
<input id=CaptionMenu type=checkbox /> | |
<input name=CaptionTopic type=radio onmouseover='this.checked=true' /> | |
<menu onmousemove='this.previousSibling.previousSibling.click()'>File<ul> | |
<li onclick='onFileNew();'>New</li> | |
<li style=display:none onclick='return false'><menu>Load<ol id=Files> | |
</ol></menu></li> | |
<li onclick='hImageFiles.click()'>Load local</li> | |
<li onclick='return false'>Gists<menu><ul id=FilesGists></ul></menu></li> | |
<li onclick='return false'>Examples<menu><ul id=FilesExamples></ul></menu></li> | |
<hr /></li> | |
<li id=FilEllipsys>… … …</li> | |
</ul> | |
</menu> | |
<input name=CaptionTopic type=radio onmouseover='this.checked=true' /> | |
<menu onmousemove='this.previousSibling.previousSibling.click()'>Edit<ul> | |
<li onclick='hListing.focus(); document.execCommand("cut", false)'>Cut</li> | |
<li onclick='hListing.focus(); document.execCommand("copy", false)'>Copy</li> | |
<li onclick='hListing.focus(); document.execCommand("selectAll", false)'>Select all</li> | |
</ul> | |
</menu> | |
<input name=CaptionTopic type=radio onmouseover='this.checked=true' /> | |
<menu style=display:none onmousemove='this.previousSibling.previousSibling.click()'>Debug<ul> | |
<li style=display:none onclick='cpu.step(); showState(); return false' accesskey=s>Step</li> | |
<li style=display:none onclick='while(cpu.step()) {} showState(); return false'>Do</li> | |
</ul> | |
</menu> | |
<input name=CaptionTopic type=radio onmouseover='this.checked=true' /> | |
<menu style=display:none onmousemove='this.previousSibling.previousSibling.checked=true;'>CPU<ul> | |
<li style=display:none onclick='cpu.reset(); showState()' accesskey=r>Reset</li> | |
<li style=display:none onclick='cpu.classic = !cpu.classic; showState(); return false' accesskey=c>Classic</li> | |
<li style=display:none onclick='do_run(1)'>Run 1 CPS</li> | |
<li style=display:none onclick='do_run(10)'>Run 10 CPS</li> | |
<li style=display:none onclick='do_run(100)'>Run 100 CPS</li> | |
<li style=display:none onclick='do_run(1, true)'>Do 1 CPS</li> | |
<li style=display:none onclick='do_run(10, true)'>Do 10 CPS</li> | |
<li style=display:none onclick='do_run(100, true)'>Do 100 CPS</li> | |
</ul> | |
</menu> | |
<input name=CaptionTopic type=radio onmouseover='this.checked=true' /> | |
<menu onmousemove='this.previousSibling.previousSibling.click()'>View<ul> | |
<li><label><input name=View_Windows type=checkbox checked data-window=Window_Graphics data-show=CANVAS />Canvas</label></li> | |
<li><label><input name=View_Windows type=checkbox checked data-window=Window_History data-show=HISTORY />History</label></li> | |
<hr /><li><label><input name=View_Windows type=checkbox data-window=Window_X80 data-show=X80 />CPU:i8080/z80</label></li> | |
<li><label><input name=View_Windows type=checkbox checked data-window=Window_X86 data-show=X86 />CPU:x86</label></li> | |
<li><label><input name=View_Windows type=checkbox checked data-window=Window_X64 data-show=X64 />CPU:x64</label></li> | |
<li><label><input name=View_Windows type=checkbox checked data-window=Window_MMX data-show=MMX />CPU:MMX</label></li> | |
<li><label><input name=View_Windows type=checkbox data-window=Window_SSE data-show=SSE />CPU:SSE</label></li> | |
<li><label><input name=View_Windows type=checkbox data-window=Window_Sliders />User Sliders</label></li> | |
<li><label><input name=View_Windows type=checkbox data-window=Window_Pseudos />Pseudo Code</label></li> | |
</ul> | |
</menu> | |
<input name=CaptionTopic type=radio onmouseover='this.checked=true' /> | |
<menu onmousemove='this.previousSibling.previousSibling.click()'>Window<ul> | |
<li><label><input name=Styling type=radio />Style "Chromed"</label></li> | |
<li><label><input name=Styling type=radio />Style #1 (VisualBasic)</label></li> | |
<li><label><input name=Styling type=radio />Style #2 (Macintosh)</label></li> | |
<li><label><input name=Styling type=radio />Style #3 (Windows'3.1 - Classic)</label></li> | |
<li><label><input name=Styling type=radio />Style #4 (Windows'3.1 - Dark)</label></li> | |
<li><label><input name=Styling type=radio />Style #5 (Windows'95 - Classic)</label></li> | |
<li><label><input name=Styling type=radio />Style #6 (Windows'95 - Dark)</label></li> | |
<li><label><input name=Styling type=radio />Style #7 (TurboPascal'7)</label></li> | |
<li><label><input name=Styling type=radio />Style #8 (Windows'98 - Classic)</label></li> | |
<li><label><input name=Styling type=radio checked />Style #9 (Windows'98 - Dark)</label></li> | |
<li><label title='Double click for Edit'><input name=Styling type=radio />Style #10 (User Defined Style)</label></li> | |
<li style=display:none onclick='return false'><menu>Render<ul> | |
<li style=display:none onclick='cpu.render.noise = 0; return false'>Clean</li> | |
<li style=display:none onclick='cpu.render.noise = 25; return false'>Noised</li> | |
<li style=display:none onclick='cpu.render.noise = 50; return false'>Dirty</li> | |
</ul></menu></li> | |
<li style=display:none onclick='hRegs_MMX.style.display = hRegs_MMX.style.display != "none" ? "none" : "block"; return false'>Context</li> | |
<li style=display:none onclick='hEmuDis.style.display = hEmuDis.style.display != "none" ? "none" : "block"; return false'>Disassembly</li> | |
<li style=display:none onclick='hListingRows.style.display = hListing.style.display = hListing.style.display != "none" ? "none" : "block"; return false'>Listing</li> | |
<li style=display:none onclick='hEmuDump.style.display = hEmuDump.style.display != "none" ? "none" : "block"; return false'>Memory</li> | |
</ul></menu> | |
<input name=CaptionTopic type=radio onmouseover='this.checked=true' /> | |
<menu onmousemove='this.previousSibling.previousSibling.click()'>Help<ul> | |
<li style=display:none onclick='document.getElementById("Info").style.display="block"'>Info</li> | |
<li style=display:none onclick='document.getElementById("Help").style.display="block"'>Help</li> | |
<li onclick='document.getElementById("About").style.display="block"'>About</li> | |
<li style=display:none><a href='https://gistpreview.github.io/?9a3cb1276bf066814f9a551a74052ff7' target=_blank>LCD-Editor</a></li> | |
<li style=display:none><a href='https://github.com/Alikberov/Koyaanisqatsi'>GitHub</a></li> | |
</ul></menu><pre id=EmuLog>Status</pre></label> | |
</td> | |
</tr> | |
</table> | |
<table id=Status cellPadding=0 cellSpacing=0 border=0 onselectstart='window.event.preventDefault()'> | |
<tr> | |
<td>Status Bar | |
<progress id=ProgressBar /></td> | |
<!--td><button>0</button><button>2</button><button>r</button></td--> | |
</tr> | |
</table> | |
<span id=State></span> | |
<input id=UserPad accesskey=k type=text style=display:none placeholder='User input Terminal' value=';0000 LEA D1,[D1+2D2+3D3+4D4+5D5] ; Uncomment this' /> | |
<hr /> | |
<table id=Debugger cellspacing=0 cellpadding=0> | |
<tr> | |
<td> | |
<pre id=EmuDis style=display:none> | |
</pre> | |
</td> | |
<td><textarea id=ListingRows cols=4 disabled></textarea></td> | |
<td><textarea id=Listing accesskey=a rows=30 cols=80 spellcheck=false> | |
::x86 ; revision 20230323 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; by Alikberov | |
.show - | |
Line: | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Check <View> >> <User Sliders> | |
mov eax,[Slider1] ; Load Slider #1 | |
mov ebx,[Slider2] ; Load Slider #2 | |
mov ecx,[Slider3] ; Load Slider #3 | |
mov edx,[Slider4] ; Load Slider #4 | |
mov esp,[Slider5] ; Load Number #5 | |
mov ebp,[Slider6] ; Load Number #6 | |
mov esi,[Slider7] ; Load Number #7 | |
mov edi,[Slider8] ; Load Number #8 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
mov rax,0xFFBBCC9900000000 ; Color | |
mov eax,[Canvas.y1],[Canvas.x1] ; Canvas Line x1,y1 | |
mov ecx,[Canvas.y2],[Canvas.x2] ; Canvas Line x2,y2 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
add cx,ax | |
sub ecx,eax ; ecx{y2:x2} -= eax{y1:x1} | |
sbb ebx,ebx | |
sub cx,ax | |
sbb bx,bx | |
xor ecx,ebx | |
add cx,bx | |
sub ecx,ebx ; ecx{y2:x2} = abs(y2:x2) | |
or ebx,0x000010001 ; ebx{dy:dx} = sgn(dy:dx) | |
and ebx,0x07FFF7FFF | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
mov edx,ecx | |
ror edx,16 ; edx = abs(dx:dy) | |
mov edi,edx | |
add dx,cx | |
sub edx,ecx | |
sbb esi,esi | |
sub dx,cx | |
sbb si,si ; esi = abs(dx:dy) < abs(dy:dx) | |
movsx esi,si | |
and ecx,esi | |
not esi | |
and edi,esi | |
or ecx,edi ; ecx = {shorter:longer} | |
mov edx,ecx | |
shl ecx,16 | |
mov cx,dx ; ecx = {counter:longer} | |
shr dx,1 ; edx = {delta_err:error} | |
not si | |
mov length,cx | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.canvas clear | |
.log clear | |
.log length | |
.log "Coordinates logging..." | |
.log " YYYY_XXXX" | |
.repeat | |
.Step: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.log EAX | |
.canvas rax | |
shld edi,edx,16 ; di = HI(edx) | |
add dx,di | |
cmp cx,dx | |
sbb edi,edi | |
and di,cx | |
sub dx,di | |
sar edi,16 | |
or edi,esi | |
and edi,ebx | |
add eax,edi | |
and eax,0x07FFF7FFF | |
sub ecx,0x000010000 | |
.repeat length</textarea> | |
<textarea style=display:none> | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; (C) Alikberov - 2021.07.09 ; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.IMGUR OysxF9E.png ; Load LCD-Sprites | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
CALL .DEFW 0xFE ; CALL LABEL | |
RET .DEF 0xE9 ; RETURN | |
JC .DEFW 0xEC ; JUMP IF CARRY | |
JNC .DEFW 0xED ; JUMP IF NO CARRY | |
JZ .DEFW 0xEE ; JUMP IF ZERO | |
JNZ .DEFW 0xEF ; JUMP IF NO ZERO | |
SHR .DEF 0xF9 ; SHIFT RIGHT | |
LDA .DEFB 0xFA ; LOAD A | |
LDB .DEFB 0xFB ; LOAD B | |
LDC .DEFB 0xFC ; LOAD C | |
LOAD .DEFW 0xFD ; LOAD BC | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
STACK .EQU 0x00A0 ; STACK BASE | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; CALL ADDRESS | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.DEF CALL | |
OR A9,A9 ; CLC | |
ADD BC4,BC9 ; ADC SP,-1 | |
CMC ; CMC | |
ADD BC4,BC9 ; ADC SP,-1 | |
MOV C8,[BC0+1] | |
MOV B8,[BC0+2] | |
ADD BC0,BC1 | |
ADD BC0,BC1 | |
MOV [BC4+0],C0 ; MOV [SP],C0 | |
MOV [BC4+1],B0 ; MOV [SP+1],B0 | |
JCF BC8+0 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; RET | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.DEF RET | |
MOV B0,[BC4+1] | |
MOV C0,[BC4+0] | |
OR C0,C0 | |
ADD BC4,BC1 | |
ADD BC4,BC1 | |
CMC | |
JCE | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; JC ADDRESS | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.DEF JC | |
JCF BC0+3 ; Is Carry - False? | |
MOV A0,[BC0+1] | |
MOV B0,[BC0+2] | |
MOV C0,A0 | |
JCE | |
CMC | |
JCE | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; JNC ADDRESS | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.DEF JNC | |
JCE BC0+3 ; Is Carry - Exist? | |
MOV A0,[BC0+1] | |
MOV B0,[BC0+2] | |
MOV C0,A0 | |
JCE | |
CMC | |
JCE | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; JZ ADDRESS | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.DEF JZ | |
JDF BC0+3 ; Is Duplex - False? | |
MOV A0,[BC0+1] | |
MOV B0,[BC0+2] | |
MOV C0,A0 | |
JDE | |
CMD | |
JDE | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; JNZ ADDRESS | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.DEF JNZ | |
JDE BC0+3 ; Is Duplex - Exist? | |
MOV A0,[BC0+1] | |
MOV B0,[BC0+2] | |
MOV C0,A0 | |
JDE | |
CMD | |
JDE | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; SHR | |
; SHIFT RIGHT A9 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.DEF SHR | |
ADD A9,A9 | |
ADD A9 | |
ADD A9 | |
ADD A9 | |
ADD A9 | |
ADD A9 | |
ADD A9 | |
ADD A9 | |
ADD A9 | |
ADD A9 | |
ADD A9 | |
ADD A9 | |
ADD A9 | |
ADD A9 | |
ADD A9 | |
ADD A9 | |
ADD A9 | |
JAE BC0+1 | |
JAF BC0+1 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; LOAD A,DATA | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.DEF LDA | |
MOV A,[BC0+1] | |
JAE BC0+2 | |
JAF BC0+2 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; LOAD B,DATA | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.DEF LDB | |
MOV B,[BC0+1] | |
JAE BC0+2 | |
JAF BC0+2 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; LOAD C,DATA | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.DEF LDC | |
MOV C,[BC0+1] | |
JAE BC0+2 | |
JAF BC0+2 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; LOAD BC,ADDRESS | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
.DEF LOAD | |
MOV C,[BC0+1] | |
MOV B,[BC0+2] | |
JAE BC0+3 | |
JAF BC0+3 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; BC1 = +1 | |
; BC9 = -1 | |
; BC6 = GLASS DATA | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
STACK .EQU 0x1000 | |
.ORG 0 | |
TETRIS | |
OR C0,B0 | |
JZ TETRINI | |
CALL SCORED | |
CALL GLASSED | |
CALL CHECK | |
HALT | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
TETRINI | |
LOAD BC1,1 ; BC1 = +1 | |
LOAD BC9,65535 ; BC9 = -1 | |
LOAD BC6,GLASS | |
LOAD BC5,NUMBERS | |
LOAD BC4,STACK | |
LDA A9,0xCB | |
MOV D9,A9 | |
HALT | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
SCORED | |
LOAD BC8,0 | |
LDA A5,10 | |
MOV A9,[BC6+65535] | |
.DIV10 ARG A,A | |
MOV A8,A9 | |
OR A9,A9 | |
SUB A5 | |
JC .DIV1 | |
ADD BC8,BC1 | |
JNZ .DIV10 | |
.DIV1 MOV D0,[BC5+0+A8] | |
MOV D1,[BC5+0+C8] | |
MOV D2,[BC6+0] | |
MOV D3,[BC6+1] | |
MOV D4,[BC6+2] | |
MOV D5,[BC6+3] | |
MOV D6,[BC6+4] | |
MOV D7,[BC6+5] | |
RET | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
CHECK | |
LDA A9,5 | |
MOV C7,C6 | |
MOV B7,B6 | |
.LOOP | |
MOV A8,[BC7+0] | |
OR A8 | |
SUB C9 | |
JZ .ERASE | |
CMC | |
ADD BC7,BC1 | |
SUB A9,C1 | |
JNC .LOOP | |
RET | |
.ERASE | |
MOV A8,[BC7+1] | |
MOV [BC7+0],A8 | |
OR A9,A9 | |
ADD BC7,BC1 | |
SUB C1 | |
JNZ .ERASE | |
HALT | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
GLASSED | |
RET | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
SCORE .DB 25 | |
GLASS .DB 0xFD | |
.DB 0xFF | |
.DB 0xCF | |
.DB 0xE1 | |
.DB 0x00 | |
.DB 0x00 | |
NUMBERS .DB 0x7E ; 0 | |
.DB 0x0C ; 1 | |
.DB 0xB6 ; 2 | |
.DB 0x9E ; 3 | |
.DB 0xCC ; 4 | |
.DB 0xDA ; 5 | |
.DB 0xFA ; 6 | |
.DB 0x0E ; 7 | |
.DB 0xFE ; 8 | |
.DB 0xDE ; 9 | |
</textarea> | |
<!-- | |
____ .0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .A .B .C .D .E .F | |
0000 B4 C4 EE A0 00 B1 C1 EE 01 00 B9 C9 EE FF FF B5 | |
0010 C5 EE C0 C0 D9 DC 5F EC 'H 'E 'L 'L 'O 20 'W 'O | |
0020 'R 'L 'D 21 00 | |
EC00 BB B5 0F CC C5 0F 10 EC 51 CE CF 51 CE | |
EC10 AA A9 9E 09 DD 9E 51 DD 50 9D 02 DE D0 DA 9F DF | |
EC20 DE | |
EE00 CC 01 8F BB 02 8F 03 CE 03 CF | |
.assm--> | |
<code style=display:none> | |
Experimental x86-Research | |
========================= | |
REP AAA ; REP ADD [EDI],[ESI] | |
REP AAD ; REP DIV [EDI],[ESI] | |
REP AAM ; REP MUL [EDI],[ESI] | |
REP AAS ; REP SUB [EDI],[ESI] | |
REP XLAT ; REP XLAT [EDI],EBX | |
REP WAIT ; REP WAIT | |
</code> | |
</td> | |
<td valign=top> | |
</td> | |
</tr> | |
</table> | |
<hr /> | |
<canvas id=Screen style=display:none width=128 height=128></canvas> | |
<img id=Sprites style=display:none crossorigin='' src5='https://i.imgur.com/OysxF9E.png' src4='https://i.imgur.com/kUeYpDl.png' src3='https://i.imgur.com/AKvx7ER.png' src2='https://i.imgur.com/xPIE14m.png' src1='https://i.imgur.com/MQ1x2Bf.png' /> | |
<input id=ImageFiles type=file accesskey=f accept='image/png' /> | |
<!-- Information Panels --> | |
<!--div style='position:absolute; top: 25%; left: 60%'--> | |
<div id=Window_Graphics class=Information> | |
<header>Graphics Display<span id=Display_Status></span></header> | |
<canvas id=Display data-x1=14 data-y1=189 data-x2=24 data-y2=89 width=640 height=480 style=zoom:1></canvas> | |
</div> | |
<div id=Window_History class=Information> | |
<header>Simulation History</header> | |
<input id=Iteration type=range min=0 value=0 style=width:100% /> | |
<pre id=EmuDump style='max-height:256px; overflow:auto'> | |
</pre></div> | |
<div id=Window_SSE class=Information style=display:none> | |
<header>SSE</header> | |
<pre id=Regs_SSE contenteditable=false spellcheck=false> | |
XMM0_:00044444444444444444444444444000 | |
XMM1_:00700000000000000000000000000200 | |
XMM2_:07000000000000000000000000000020 | |
XMM3_:10004440000000000000000004440001 | |
XMM4_:10040004000000000000000040004001 | |
XMM5_:10000000000000000000000000000001 | |
XMM6_:10000000000000000000000000000001 | |
XMM7_:10000000000000FACE00000000000001 | |
XMM8_:10000000000000000000000000000001 | |
XMM9_:10000000000000000000000000000001 | |
XMM10:10100000000000000000000000000101 | |
XMM11:10010000000000000000000000001001 | |
XMM12:10004444444444444444444444440001 | |
XMM13:02000000000000000000000000000070 | |
XMM14:00200000000000000000000000000700 | |
XMM15:00033333333333333333333333333000 | |
</pre></div> | |
<div id=Window_X86 class=Information> | |
<header>x86</header> | |
<pre id=Regs_X86 contenteditable=false spellcheck=false> | |
</pre></div> | |
<div id=Window_X80 class=Information> | |
<header>x80</header> | |
<pre id=Regs_X80 contenteditable=false spellcheck=false> | |
</pre></div> | |
<div id=Window_X64 class=Information> | |
<header>x64</header> | |
<pre id=Regs_X64 contenteditable=false spellcheck=false> | |
</pre></div> | |
<div id=Window_MMX class=Information> | |
<header>MMX</header> | |
<pre id=Regs_MMX contenteditable=false spellcheck=false> | |
</pre></div> | |
<div id=Window_Pseudos class=Information> | |
<header>Pseudo Code</header> | |
<pre id=Pseudos contenteditable=false spellcheck=false style='max-height:256px; overflow:auto; resize:auto'> | |
</pre></div> | |
<div id=Window_Sliders class=Information> | |
<header>Sliders</header> | |
<input type=range name=Sliders min=0 max=255 value=128 /><br /> | |
<input type=range name=Sliders min=0 max=255 value=128 /><br /> | |
<input type=range name=Sliders min=0 max=255 value=128 /><br /> | |
<input type=range name=Sliders min=0 max=255 value=128 /><hr /> | |
<input type=number name=Sliders min=0 max=255 value=128 /><br /> | |
<input type=number name=Sliders min=0 max=255 value=128 /><br /> | |
<input type=number name=Sliders min=0 max=255 value=128 /><br /> | |
<input type=number name=Sliders min=0 max=255 value=128 /> | |
</div> | |
<!--/div--> | |
<script> | |
setTimeout | |
(function() { | |
var x = Math.floor(hCaption.offsetWidth / 3); | |
var y = hCaption.offsetHeight; | |
var els = document.querySelectorAll("div.Information"); | |
if(els) | |
els | |
.forEach | |
(function(el) { | |
MakeDraggable(el, x, y); | |
x += hCaption.offsetWidth >> 3; | |
y += 48; | |
}); | |
}, 1000); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment