[
  {
    "path": ".gitignore",
    "content": "# Created by https://www.gitignore.io\n\n### JetBrains ###\n# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm\n\n*.iml\n\n## Directory-based project format:\n.idea/\n# if you remove the above rule, at least ignore the following:\n\n# User-specific stuff:\n# .idea/workspace.xml\n# .idea/tasks.xml\n# .idea/dictionaries\n\n# Sensitive or high-churn files:\n# .idea/dataSources.ids\n# .idea/dataSources.xml\n# .idea/sqlDataSources.xml\n# .idea/dynamic.xml\n# .idea/uiDesigner.xml\n\n# Gradle:\n# .idea/gradle.xml\n# .idea/libraries\n\n# Mongo Explorer plugin:\n# .idea/mongoSettings.xml\n\n## File-based project format:\n*.ipr\n*.iws\n\n## Plugin-specific files:\n\n# IntelliJ\n/out/\n\n# mpeltonen/sbt-idea plugin\n.idea_modules/\n\n# JIRA plugin\natlassian-ide-plugin.xml\n\n# Crashlytics plugin (for Android Studio and IntelliJ)\ncom_crashlytics_export_strings.xml\ncrashlytics.properties\ncrashlytics-build.properties\n\n\n### OSX ###\n.DS_Store\n.AppleDouble\n.LSOverride\n\n# Icon must end with two \\r\nIcon\n\n\n# Thumbnails\n._*\n\n# Files that might appear in the root of a volume\n.DocumentRevisions-V100\n.fseventsd\n.Spotlight-V100\n.TemporaryItems\n.Trashes\n.VolumeIcon.icns\n\n# Directories potentially created on remote AFP share\n.AppleDB\n.AppleDesktop\nNetwork Trash Folder\nTemporary Items\n.apdisk\n\n# ignored bower components\nbower_components"
  },
  {
    "path": "CNAME",
    "content": "y86.js.org\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2016 Parabola\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# Y86 Emulator\n\n[![](https://img.shields.io/website-up-down-green-red/http/y86.js.org.svg?label=y86.js.org)](http://y86.js.org)\n\n[y86.js.org](http://y86.js.org) is a JavaScript powered, Y86 pipeline CPU emulator with a sci-fi UI (Y86 is a classic project in book CS:APP3e).\n\n![screenshot](screenshot.png)\n\n## Details\n\n1. Only supports .yo code\n2. Using Angular + Angular-route\n3. move.js for CSS3 animations\n4. Implemented a simple CommonJS module loader and a canvas CPI curve graph plotter\n\n## Notes\n\n1. All dependencies are included. So I can use `gh-pages` as the main branch.\n2. To open it locally, please host the static files under a HTTP server. The `file://` protocol won't work.\n\n## Acknowledgement\n\n- Author: Shu Ding\n- Special thanks: Linghao Zhang, Yifu Yu.\n- License: the MIT license\n"
  },
  {
    "path": "bower.json",
    "content": "{\n  \"name\": \"Y86\",\n  \"version\": \"0.0.1\",\n  \"authors\": [\n    \"quietshu <ds303077135@gmail.com>\"\n  ],\n  \"description\": \"Y86-Simulator for Fudan ICS 2015\",\n  \"main\": \"index.html\",\n  \"keywords\": [\n    \"Y86\"\n  ],\n  \"license\": \"MIT\",\n  \"ignore\": [\n    \"**/.*\",\n    \"node_modules\",\n    \"bower_components\",\n    \"test\",\n    \"tests\"\n  ],\n  \"dependencies\": {\n    \"angular-route\": \"~1.4.0\",\n    \"requirejs\": \"~2.1.18\",\n    \"angular\": \"~1.4.0\",\n    \"move.js\": \"~0.3.3\"\n  }\n}\n"
  },
  {
    "path": "index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\" ng-app=\"y86\">\n<head>\n\n  <meta charset=\"UTF-8\">\n  <meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no\">\n  <title>Y86 Emulator</title>\n\n  <base href=\"src/\">\n\n  <script src=\"../lib/angular.min.js\"></script>\n  <script src=\"../lib/angular-route.min.js\"></script>\n\n  <script src=\"script/kernels/main.js\"></script>\n\n  <script src=\"script/controllers/main.js\"></script>\n\n  <script src=\"script/directives/board.js\"></script>\n  <script src=\"script/directives/register.js\"></script>\n  <script src=\"script/directives/stack.js\"></script>\n  <script src=\"script/directives/clock.js\"></script>\n  <script src=\"script/directives/condition.js\"></script>\n  <script src=\"script/directives/control.js\"></script>\n  <script src=\"script/directives/cpi.js\"></script>\n  <script src=\"script/directives/code.js\"></script>\n  <script src=\"script/directives/pipe.js\"></script>\n\n  <link rel=\"stylesheet\" href=\"../lib/font-awesome.min.css\">\n\n  <link rel=\"stylesheet\" href=\"style/main.css\">\n  <link rel=\"stylesheet\" href=\"style/board.css\">\n  <link rel=\"stylesheet\" href=\"style/register.css\">\n  <link rel=\"stylesheet\" href=\"style/stack.css\">\n  <link rel=\"stylesheet\" href=\"style/clock.css\">\n  <link rel=\"stylesheet\" href=\"style/condition.css\">\n  <link rel=\"stylesheet\" href=\"style/control.css\">\n  <link rel=\"stylesheet\" href=\"style/cpi.css\">\n  <link rel=\"stylesheet\" href=\"style/code.css\">\n  <link rel=\"stylesheet\" href=\"style/pipe.css\">\n\n</head>\n<body ng-controller=\"mainCtrl\" style=\"-webkit-font-smoothing: auto\">\n\n  <board class=\"top-line\">\n\n    <flex-container class=\"rot-top\">\n\n      <control-container>\n        <frequency-label hz=\"player.hz\" style=\"left: {{ player.hz * 4 + 20 }}px\"></frequency-label>\n        <div>\n          <prev fn=\"prev()\"></prev>\n          <play-pause icon=\"state.icons[state.icon]\" fn=\"play()\"></play-pause>\n          <next fn=\"next()\"></next>\n          <reset fn=\"reset()\"></reset>\n        </div>\n        <frequency hz=\"player.hz\"></frequency>\n      </control-container>\n\n      <cpi-container style=\"-webkit-flex:1;flex:1;-webkit-flex-grow:1;flex-grow:1\"></cpi-container>\n\n      <h1>Y86 Emulator<br/>\n        <small>Source code: <a href=\"https://github.com/shuding/y86\" target=\"_blank\">GitHub</a>, by <a href=\"https://github.com/shuding\" target=\"_blank\">@shuding</a></small>\n      </h1>\n\n    </flex-container>\n\n    <flex-container class=\"top-line flex-grow\">\n      <div class=\"top-dotted tool-sidebar\">\n        <clock-container class=\"container container-line container-left rot-left\">\n          <clock data=\"clock.data\"></clock>\n        </clock-container>\n\n        <register-container class=\"container container-line container-left flex-grow rot-left\">\n          <register ng-repeat=\"(key, value) in registers\" reg-name=\"key\" reg-data=\"value | toHex: 8\"></register>\n        </register-container>\n      </div>\n\n      <code-container class=\"container container-line top-dotted\" style=\"-webkit-flex-grow:1;flex-grow:1\">\n        <code-line-indicator style=\"top: {{ code.current * 1.2 }}em\"></code-line-indicator>\n        <code-line ng-repeat=\"line in code.lines track by $index\" line-number=\"$index+1\" line-content=\"line\"></code-line>\n      </code-container>\n\n      <div class=\"top-dotted tool-sidebar\">\n        <condition-container class=\"container container-line container-right rot-right\">\n          <condition ng-repeat=\"(key, value) in conditions\" cond-name=\"key\" cond-data=\"value\"></condition>\n        </condition-container>\n\n        <stack-container class=\"container container-line container-right flex-grow rot-right\">\n          <stack ng-repeat=\"data in memory.data track by $index\"><span>{{ $index * 4 | toHex: 4 }}</span><span>{{ data[0] | toHex: 2 }}{{ data[1] | toHex: 2 }}{{ data[2] | toHex: 2 }}{{ data[3] | toHex: 2 }}</span></stack>\n        </stack-container>\n      </div>\n    </flex-container>\n\n    <flex-container class=\"top-line shadow-bg\" style=\"-webkit-flex-direction: column\">\n      <fetch>\n        <pipe-attr pipe-name=\"'predPC'\" pipe-data=\"parser.CPU.Input.F_predPC | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'instructions'\" pipe-data=\"parser.CPU.instruction\"></pipe-attr>\n        <pipe-attr pipe-name=\"'CPI'\" pipe-data=\"parser.CPU.cpi[parser.CPU.cycle] | round\"></pipe-attr>\n      </fetch>\n      <decode>\n        <pipe-attr pipe-name=\"'stat'\" pipe-data=\"constantMap.stat[parser.CPU.Input.D_stat]\"></pipe-attr>\n        <pipe-attr pipe-name=\"'icode'\" pipe-data=\"constantMap.icode[parser.CPU.Input.D_icode]\"></pipe-attr>\n        <pipe-attr pipe-name=\"'ifun'\" pipe-data=\"parser.CPU.Input.D_ifun\"></pipe-attr>\n        <pipe-attr pipe-name=\"'rA'\" pipe-data=\"constantMap.reg[parser.CPU.Input.D_rA]||'R_NONE'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'rB'\" pipe-data=\"constantMap.reg[parser.CPU.Input.D_rB]||'R_NONE'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'valC'\" pipe-data=\"parser.CPU.Input.D_valC | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'valP'\" pipe-data=\"parser.CPU.Input.D_valP | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n      </decode>\n      <execute>\n        <pipe-attr pipe-name=\"'stat'\" pipe-data=\"constantMap.stat[parser.CPU.Input.E_stat]\"></pipe-attr>\n        <pipe-attr pipe-name=\"'icode'\" pipe-data=\"constantMap.icode[parser.CPU.Input.E_icode]\"></pipe-attr>\n        <pipe-attr pipe-name=\"'ifun'\" pipe-data=\"parser.CPU.Input.E_ifun\"></pipe-attr>\n        <pipe-attr pipe-name=\"'valC'\" pipe-data=\"parser.CPU.Input.E_valC | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'valA'\" pipe-data=\"parser.CPU.Input.E_valA | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'valB'\" pipe-data=\"parser.CPU.Input.E_valB | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'dstE'\" pipe-data=\"constantMap.reg[parser.CPU.Input.E_dstE]||'R_NONE'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'dstM'\" pipe-data=\"constantMap.reg[parser.CPU.Input.E_dstM]||'R_NONE'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'srcA'\" pipe-data=\"constantMap.reg[parser.CPU.Input.E_srcA]||'R_NONE'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'srcB'\" pipe-data=\"constantMap.reg[parser.CPU.Input.E_srcB]||'R_NONE'\"></pipe-attr>\n      </execute>\n      <memory>\n        <pipe-attr pipe-name=\"'stat'\" pipe-data=\"constantMap.stat[parser.CPU.Input.M_stat]\"></pipe-attr>\n        <pipe-attr pipe-name=\"'icode'\" pipe-data=\"constantMap.icode[parser.CPU.Input.M_icode]\"></pipe-attr>\n        <pipe-attr pipe-name=\"'valE'\" pipe-data=\"parser.CPU.Input.M_valE | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'valA'\" pipe-data=\"parser.CPU.Input.M_valA | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'dstE'\" pipe-data=\"constantMap.reg[parser.CPU.Input.M_dstE]||'R_NONE'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'dstM'\" pipe-data=\"constantMap.reg[parser.CPU.Input.M_dstM]||'R_NONE'\"></pipe-attr>\n      </memory>\n      <write-back>\n        <pipe-attr pipe-name=\"'stat'\" pipe-data=\"constantMap.stat[parser.CPU.Input.W_stat]\"></pipe-attr>\n        <pipe-attr pipe-name=\"'icode'\" pipe-data=\"constantMap.icode[parser.CPU.Input.W_icode]\"></pipe-attr>\n        <pipe-attr pipe-name=\"'valE'\" pipe-data=\"parser.CPU.Input.W_valE | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'valM'\" pipe-data=\"parser.CPU.Input.W_valM | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'dstE'\" pipe-data=\"constantMap.reg[parser.CPU.Input.W_dstE]||'R_NONE'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'dstM'\" pipe-data=\"constantMap.reg[parser.CPU.Input.W_dstM]||'R_NONE'\"></pipe-attr>\n      </write-back>\n    </flex-container>\n\n  </board>\n\n  <script src=\"../lib/move.min.js\"></script>\n\n</body>\n</html>\n"
  },
  {
    "path": "src/font/Jura/OFL.txt",
    "content": "Copyright (c) 2009, 2010, 2011 Daniel Johnson (<il.basso.buffo@gmail.com>).\r\nThis Font Software is licensed under the SIL Open Font License, Version 1.1.\r\nThis license is copied below, and is also available with a FAQ at:\r\nhttp://scripts.sil.org/OFL\r\n\r\n\r\n-----------------------------------------------------------\r\nSIL OPEN FONT LICENSE Version 1.1 - 26 February 2007\r\n-----------------------------------------------------------\r\n\r\nPREAMBLE\r\nThe goals of the Open Font License (OFL) are to stimulate worldwide\r\ndevelopment of collaborative font projects, to support the font creation\r\nefforts of academic and linguistic communities, and to provide a free and\r\nopen framework in which fonts may be shared and improved in partnership\r\nwith others.\r\n\r\nThe OFL allows the licensed fonts to be used, studied, modified and\r\nredistributed freely as long as they are not sold by themselves. The\r\nfonts, including any derivative works, can be bundled, embedded, \r\nredistributed and/or sold with any software provided that any reserved\r\nnames are not used by derivative works. The fonts and derivatives,\r\nhowever, cannot be released under any other type of license. The\r\nrequirement for fonts to remain under this license does not apply\r\nto any document created using the fonts or their derivatives.\r\n\r\nDEFINITIONS\r\n\"Font Software\" refers to the set of files released by the Copyright\r\nHolder(s) under this license and clearly marked as such. This may\r\ninclude source files, build scripts and documentation.\r\n\r\n\"Reserved Font Name\" refers to any names specified as such after the\r\ncopyright statement(s).\r\n\r\n\"Original Version\" refers to the collection of Font Software components as\r\ndistributed by the Copyright Holder(s).\r\n\r\n\"Modified Version\" refers to any derivative made by adding to, deleting,\r\nor substituting -- in part or in whole -- any of the components of the\r\nOriginal Version, by changing formats or by porting the Font Software to a\r\nnew environment.\r\n\r\n\"Author\" refers to any designer, engineer, programmer, technical\r\nwriter or other person who contributed to the Font Software.\r\n\r\nPERMISSION & CONDITIONS\r\nPermission is hereby granted, free of charge, to any person obtaining\r\na copy of the Font Software, to use, study, copy, merge, embed, modify,\r\nredistribute, and sell modified and unmodified copies of the Font\r\nSoftware, subject to the following conditions:\r\n\r\n1) Neither the Font Software nor any of its individual components,\r\nin Original or Modified Versions, may be sold by itself.\r\n\r\n2) Original or Modified Versions of the Font Software may be bundled,\r\nredistributed and/or sold with any software, provided that each copy\r\ncontains the above copyright notice and this license. These can be\r\nincluded either as stand-alone text files, human-readable headers or\r\nin the appropriate machine-readable metadata fields within text or\r\nbinary files as long as those fields can be easily viewed by the user.\r\n\r\n3) No Modified Version of the Font Software may use the Reserved Font\r\nName(s) unless explicit written permission is granted by the corresponding\r\nCopyright Holder. This restriction only applies to the primary font name as\r\npresented to the users.\r\n\r\n4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font\r\nSoftware shall not be used to promote, endorse or advertise any\r\nModified Version, except to acknowledge the contribution(s) of the\r\nCopyright Holder(s) and the Author(s) or with their explicit written\r\npermission.\r\n\r\n5) The Font Software, modified or unmodified, in part or in whole,\r\nmust be distributed entirely under this license, and must not be\r\ndistributed under any other license. The requirement for fonts to\r\nremain under this license does not apply to any document created\r\nusing the Font Software.\r\n\r\nTERMINATION\r\nThis license becomes null and void if any of the above conditions are\r\nnot met.\r\n\r\nDISCLAIMER\r\nTHE FONT SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\r\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF\r\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT\r\nOF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE\r\nCOPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\r\nINCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL\r\nDAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r\nFROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM\r\nOTHER DEALINGS IN THE FONT SOFTWARE.\r\n"
  },
  {
    "path": "src/gulpfile.js",
    "content": "var gulp = require('gulp'),\n    usemin = require('gulp-usemin'),\n    wrap = require('gulp-wrap'),\n    connect = require('gulp-connect'),\n    ngannotate = require('gulp-ng-annotate'),\n    watch = require('gulp-watch'),\n    minifyCss = require('gulp-minify-css'),\n    minifyJs = require('gulp-uglify'),\n    concat = require('gulp-concat'),\n    less = require('gulp-less'),\n    rename = require('gulp-rename'),\n    minifyHTML = require('gulp-minify-html');\n\nvar paths = {\n    scripts: 'src/script/**/*.*',\n    styles: 'src/style/**/*.*',\n    images: 'src/image/**/*.*',\n    templates: 'src/template/**/*.html',\n    index: 'src/index.html',\n    fonts: 'src/font/**/*.{ttf,woff,woff2,eof,svg}'\n};\n\n/**\n * Handle bower components from index\n */\ngulp.task('usemin', function() {\n    return gulp.src(paths.index)\n        .pipe(usemin({\n            //js: [/* ngannotate(), minifyJs(), */'concat'],\n            css: [/*minifyCss({keepSpecialComments: 0}), */'concat'],\n        }))\n        .pipe(gulp.dest('dist/'));\n});\n\n/**\n * Copy assets\n */\ngulp.task('build-assets', ['copy-fonts']);\n\ngulp.task('copy-fonts', function() {\n    return gulp.src(paths.fonts)\n        .pipe(rename({\n            dirname: '/fonts'\n        }))\n        .pipe(gulp.dest('dist/'));\n});\n\n/**\n * Handle custom files\n */\ngulp.task('build-custom', ['custom-images', 'custom-js', 'custom-css', 'custom-templates']);\n\ngulp.task('custom-images', function() {\n    return gulp.src(paths.images)\n        .pipe(gulp.dest('dist/img'));\n});\n\ngulp.task('custom-js', function() {\n    return gulp.src(paths.scripts)\n        .pipe(ngannotate())\n        .pipe(minifyJs())\n        .pipe(concat('dashboard.min.js'))\n        .pipe(gulp.dest('dist/js'));\n});\n\ngulp.task('custom-css', function() {\n    return gulp.src(paths.styles)\n        //.pipe(minifyCss())\n        .pipe(concat('dashboard.min.css'))\n        .pipe(gulp.dest('dist/css'));\n});\n\ngulp.task('custom-templates', function() {\n    return gulp.src(paths.templates)\n        .pipe(minifyHTML())\n        .pipe(gulp.dest('dist/templates'));\n});\n\n/**\n * Watch custom files\n */\ngulp.task('watch', function() {\n    gulp.watch([paths.images], ['custom-images']);\n    gulp.watch([paths.styles], ['custom-css']);\n    gulp.watch([paths.scripts], ['custom-js']);\n    gulp.watch([paths.templates], ['custom-templates']);\n    gulp.watch([paths.index], function () {\n        return gulp.src(paths.index)\n            .pipe(usemin({\n                js: ['concat'], // do not minify!!!!!!\n                css: ['concat'],\n            }))\n            .pipe(gulp.dest('dist/'));\n    });//['usemin']);\n});\n\n/**\n * Live reload server\n */\ngulp.task('webserver', function() {\n    connect.server({\n        root: 'dist',\n        livereload: true,\n        port: 8888\n    });\n});\n\ngulp.task('livereload', function() {\n    gulp.src(['dist/**/*.*'])\n        .pipe(watch())\n        .pipe(connect.reload());\n});\n\n/**\n * Gulp tasks\n */\ngulp.task('build', ['usemin', 'build-assets', 'build-custom']);\n// do not usemin with livereload\ngulp.task('default', ['usemin', 'build-assets', 'build-custom', 'webserver', 'livereload', 'watch']);"
  },
  {
    "path": "src/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\" ng-app=\"y86\">\n<head>\n\n  <meta charset=\"UTF-8\">\n  <meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no\">\n  <title>Y86 Simulator</title>\n\n  <script src=\"../bower_components/angular/angular.min.js\"></script>\n  <script src=\"../bower_components/angular-route/angular-route.min.js\"></script>\n\n  <script src=\"script/kernels/main.js\"></script>\n\n  <script src=\"script/controllers/main.js\"></script>\n\n  <script src=\"script/directives/board.js\"></script>\n  <script src=\"script/directives/register.js\"></script>\n  <script src=\"script/directives/stack.js\"></script>\n  <script src=\"script/directives/clock.js\"></script>\n  <script src=\"script/directives/condition.js\"></script>\n  <script src=\"script/directives/control.js\"></script>\n  <script src=\"script/directives/cpi.js\"></script>\n  <script src=\"script/directives/code.js\"></script>\n  <script src=\"script/directives/pipe.js\"></script>\n\n  <link rel=\"stylesheet\" href=\"../bower_components/font-awesome/css/font-awesome.min.css\">\n\n  <link rel=\"stylesheet\" href=\"style/main.css\">\n  <link rel=\"stylesheet\" href=\"style/board.css\">\n  <link rel=\"stylesheet\" href=\"style/register.css\">\n  <link rel=\"stylesheet\" href=\"style/stack.css\">\n  <link rel=\"stylesheet\" href=\"style/clock.css\">\n  <link rel=\"stylesheet\" href=\"style/condition.css\">\n  <link rel=\"stylesheet\" href=\"style/control.css\">\n  <link rel=\"stylesheet\" href=\"style/cpi.css\">\n  <link rel=\"stylesheet\" href=\"style/code.css\">\n  <link rel=\"stylesheet\" href=\"style/pipe.css\">\n\n</head>\n<body ng-controller=\"mainCtrl\" style=\"-webkit-font-smoothing: auto\">\n\n  <board class=\"top-line\">\n\n    <flex-container>\n\n      <control-container>\n        <frequency-label hz=\"player.hz\" style=\"left: {{ player.hz * 4 + 20 }}px\"></frequency-label>\n        <div>\n          <prev fn=\"prev()\"></prev>\n          <play-pause icon=\"state.icons[state.icon]\" fn=\"play()\"></play-pause>\n          <next fn=\"next()\"></next>\n          <reset fn=\"reset()\"></reset>\n        </div>\n        <frequency hz=\"player.hz\"></frequency>\n      </control-container>\n\n      <cpi-container style=\"-webkit-flex:1;flex:1;-webkit-flex-grow:1;flex-grow:1\"></cpi-container>\n\n    </flex-container>\n\n    <flex-container class=\"top-line\">\n      <div class=\"top-dotted\">\n        <clock-container class=\"container container-line container-left\">\n          <clock data=\"clock.data\"></clock>\n        </clock-container>\n\n        <register-container class=\"container container-line container-left\">\n          <register ng-repeat=\"(key, value) in registers\" reg-name=\"key\" reg-data=\"value | toHex: 8\"></register>\n        </register-container>\n      </div>\n\n      <code-container class=\"container container-line top-dotted\" style=\"-webkit-flex-grow:1;flex-grow:1\">\n        <code-line-indicator style=\"top: {{ code.current * 1.2 }}em\"></code-line-indicator>\n        <code-line ng-repeat=\"line in code.lines track by $index\" line-number=\"$index+1\" line-content=\"line\"></code-line>\n      </code-container>\n\n      <div class=\"top-dotted\">\n        <condition-container class=\"container container-line container-right\">\n          <condition ng-repeat=\"(key, value) in conditions\" cond-name=\"key\" cond-data=\"value\"></condition>\n        </condition-container>\n\n        <stack-container class=\"container container-line container-right\">\n          <stack ng-repeat=\"data in memory.data track by $index\"><span>{{ $index * 4 | toHex: 4 }}</span><span>{{ data[0] | toHex: 2 }}{{ data[1] | toHex: 2 }}{{ data[2] | toHex: 2 }}{{ data[3] | toHex: 2 }}</span></stack>\n        </stack-container>\n      </div>\n    </flex-container>\n\n    <flex-container class=\"top-line\" style=\"-webkit-flex-direction: column\">\n      <fetch>\n        <pipe-attr pipe-name=\"'predPC'\" pipe-data=\"parser.CPU.Input.F_predPC | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'instructions'\" pipe-data=\"parser.CPU.instruction\"></pipe-attr>\n        <pipe-attr pipe-name=\"'CPI'\" pipe-data=\"parser.CPU.cpi[parser.CPU.cycle] | round\"></pipe-attr>\n        <pipe-attr></pipe-attr>\n        <pipe-attr></pipe-attr>\n        <pipe-attr></pipe-attr>\n        <pipe-attr></pipe-attr>\n        <pipe-attr></pipe-attr>\n        <pipe-attr></pipe-attr>\n        <pipe-attr></pipe-attr>\n      </fetch>\n      <decode>\n        <pipe-attr pipe-name=\"'stat'\" pipe-data=\"constantMap.stat[parser.CPU.Input.D_stat]\"></pipe-attr>\n        <pipe-attr pipe-name=\"'icode'\" pipe-data=\"constantMap.icode[parser.CPU.Input.D_icode]\"></pipe-attr>\n        <pipe-attr pipe-name=\"'ifun'\" pipe-data=\"parser.CPU.Input.D_ifun\"></pipe-attr>\n        <pipe-attr pipe-name=\"'rA'\" pipe-data=\"constantMap.reg[parser.CPU.Input.D_rA]||'R_NONE'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'rB'\" pipe-data=\"constantMap.reg[parser.CPU.Input.D_rB]||'R_NONE'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'valC'\" pipe-data=\"parser.CPU.Input.D_valC | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'valP'\" pipe-data=\"parser.CPU.Input.D_valP | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr></pipe-attr>\n        <pipe-attr></pipe-attr>\n        <pipe-attr></pipe-attr>\n      </decode>\n      <execute>\n        <pipe-attr pipe-name=\"'stat'\" pipe-data=\"constantMap.stat[parser.CPU.Input.E_stat]\"></pipe-attr>\n        <pipe-attr pipe-name=\"'icode'\" pipe-data=\"constantMap.icode[parser.CPU.Input.E_icode]\"></pipe-attr>\n        <pipe-attr pipe-name=\"'ifun'\" pipe-data=\"parser.CPU.Input.E_ifun\"></pipe-attr>\n        <pipe-attr pipe-name=\"'valC'\" pipe-data=\"parser.CPU.Input.E_valC | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'valA'\" pipe-data=\"parser.CPU.Input.E_valA | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'valB'\" pipe-data=\"parser.CPU.Input.E_valB | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'dstE'\" pipe-data=\"constantMap.reg[parser.CPU.Input.E_dstE]||'R_NONE'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'dstM'\" pipe-data=\"constantMap.reg[parser.CPU.Input.E_dstM]||'R_NONE'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'srcA'\" pipe-data=\"constantMap.reg[parser.CPU.Input.E_srcA]||'R_NONE'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'srcB'\" pipe-data=\"constantMap.reg[parser.CPU.Input.E_srcB]||'R_NONE'\"></pipe-attr>\n      </execute>\n      <memory>\n        <pipe-attr pipe-name=\"'stat'\" pipe-data=\"constantMap.stat[parser.CPU.Input.M_stat]\"></pipe-attr>\n        <pipe-attr pipe-name=\"'icode'\" pipe-data=\"constantMap.icode[parser.CPU.Input.M_icode]\"></pipe-attr>\n        <pipe-attr pipe-name=\"'valE'\" pipe-data=\"parser.CPU.Input.M_valE | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'valA'\" pipe-data=\"parser.CPU.Input.M_valA | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'dstE'\" pipe-data=\"constantMap.reg[parser.CPU.Input.M_dstE]||'R_NONE'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'dstM'\" pipe-data=\"constantMap.reg[parser.CPU.Input.M_dstM]||'R_NONE'\"></pipe-attr>\n        <pipe-attr></pipe-attr>\n        <pipe-attr></pipe-attr>\n        <pipe-attr></pipe-attr>\n        <pipe-attr></pipe-attr>\n      </memory>\n      <write-back>\n        <pipe-attr pipe-name=\"'stat'\" pipe-data=\"constantMap.stat[parser.CPU.Input.W_stat]\"></pipe-attr>\n        <pipe-attr pipe-name=\"'icode'\" pipe-data=\"constantMap.icode[parser.CPU.Input.W_icode]\"></pipe-attr>\n        <pipe-attr pipe-name=\"'valE'\" pipe-data=\"parser.CPU.Input.W_valE | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'valM'\" pipe-data=\"parser.CPU.Input.W_valM | toHex: 8\" pipe-pref=\"'0x'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'dstE'\" pipe-data=\"constantMap.reg[parser.CPU.Input.W_dstE]||'R_NONE'\"></pipe-attr>\n        <pipe-attr pipe-name=\"'dstM'\" pipe-data=\"constantMap.reg[parser.CPU.Input.W_dstM]||'R_NONE'\"></pipe-attr>\n        <pipe-attr></pipe-attr>\n        <pipe-attr></pipe-attr>\n        <pipe-attr></pipe-attr>\n        <pipe-attr></pipe-attr>\n      </write-back>\n    </flex-container>\n\n  </board>\n\n  <script src=\"../bower_components/move.js/move.min.js\"></script>\n\n</body>\n</html>\n"
  },
  {
    "path": "src/script/controllers/main.js",
    "content": "angular.module('y86', ['ngRoute']).controller('mainCtrl', ['$scope', mainCtrl]).filter(\"toHex\", function () {\n    return function (input, digest) {\n        if (typeof input == 'undefined' || input === null) {\n            return '';\n        }\n        if (input < 0) {\n            input = 0xFFFFFFFF + input + 1;\n        }\n        var ret = input.toString(16);\n        while (ret.length < digest) {\n            ret = '0' + ret;\n        }\n        return ret;\n    };\n}).filter(\"round\", function () {\n    return function (input) {\n        return Math.round(input * 1000) / 1000 || 0;\n    };\n});\n\nfunction mainCtrl($scope) {\n    var Constant = require('script/kernels/constant');\n    var Parser   = require('script/kernels/parser');\n\n    $scope.constantMap = {\n        stat:  {\n            0: 'STAT_BUB',\n            1: 'STAT_AOK',\n            2: 'STAT_HLT',\n            3: 'STAT_ADR',\n            4: 'STAT_INS',\n            5: 'STAT_PIP'\n        },\n        icode: {\n            0:   'I_HALT',\n            1:   'I_NOP',\n            2:   'I_RRMOVL',\n            3:   'I_IRMOVL',\n            4:   'I_RMMOVL',\n            5:   'I_MRMOVL',\n            6:   'I_OPL',\n            7:   'I_JXX',\n            8:   'I_CALL',\n            9:   'I_RET',\n            0xa: 'I_PUSHL',\n            0xb: 'I_POPL',\n            0xc: 'I_IADDL',\n            0xd: 'I_LEAVE'\n        },\n        reg: {\n            0: 'R_EAX',\n            1: 'R_ECX',\n            2: 'R_EDX',\n            3: 'R_EBX',\n            4: 'R_ESP',\n            5: 'R_EBP',\n            6: 'R_ESI',\n            7: 'R_EDI',\n            15: 'R_NONE'\n        }\n    };\n\n    $scope.$safeApply = function () {\n        if ($scope.$root.$$phase != '$apply' && $scope.$root.$$phase != '$digest') {\n            $scope.$apply();\n        }\n    };\n\n    $scope.state = {\n        icons:  ['play', 'pause'],\n        icon:   0,\n        loaded: 0\n    };\n\n    $scope.registers = {\n        eax: 0,\n        ecx: 0,\n        edx: 0,\n        ebx: 0,\n        esp: 0,\n        ebp: 0,\n        esi: 0,\n        edi: 0\n    };\n\n    $scope.memory = {\n        data:  [],\n        block: []\n    };\n\n    $scope.conditions = {\n        zf: 0,\n        sf: 0,\n        of: 0\n    };\n\n    $scope.clock = {\n        data: 0\n    };\n\n    $scope.code = {\n        current:      0,\n        height:       0,\n        scrollTop:    0,\n        scrollHeight: 0,\n        lineHeight:   14 * 1.2,\n        currentTab:   0,\n        tabs:         ['asum', 'List_Sum', 'Forward'],\n        tabFiles:     ['test/asum.yo', 'test/List_Sum.yo', 'test/Forward.yo'],\n        fileCache:    ['', '', '']\n    };\n\n    $scope.player = {\n        hz: 10\n    };\n\n    // Functions\n\n    $scope.initParser = function (parser) {\n        if ($scope.parser && $scope.parser !== parser)\n            delete $scope.parser;\n\n        $scope.parser      = parser;\n        $scope.code.lines  = parser.syntaxs;\n        $scope.clock.data  = parser.CPU.cycle;\n        $scope.memory.data = parser.CPU.Memory.data;\n\n        // Clock Cycle\n        $scope.$watch('parser.CPU.cycle', function (clock) {\n            $scope.clock.data = clock;\n        });\n\n        // Registers\n        $scope.$watch('parser.CPU.Register[' + Constant['R_EAX'] + ']', function (value) {\n            $scope.registers['eax'] = value;\n        });\n        $scope.$watch('parser.CPU.Register[' + Constant['R_ECX'] + ']', function (value) {\n            $scope.registers['ecx'] = value;\n        });\n        $scope.$watch('parser.CPU.Register[' + Constant['R_EDX'] + ']', function (value) {\n            $scope.registers['edx'] = value;\n        });\n        $scope.$watch('parser.CPU.Register[' + Constant['R_EBX'] + ']', function (value) {\n            $scope.registers['ebx'] = value;\n        });\n        $scope.$watch('parser.CPU.Register[' + Constant['R_ESP'] + ']', function (value) {\n            $scope.registers['esp'] = value;\n        });\n        $scope.$watch('parser.CPU.Register[' + Constant['R_EBP'] + ']', function (value) {\n            $scope.registers['ebp'] = value;\n        });\n        $scope.$watch('parser.CPU.Register[' + Constant['R_ESI'] + ']', function (value) {\n            $scope.registers['esi'] = value;\n        });\n        $scope.$watch('parser.CPU.Register[' + Constant['R_EDI'] + ']', function (value) {\n            $scope.registers['edi'] = value;\n        });\n\n        // PC\n        $scope.$watch('parser.CPU.Input.F_predPC', function (value) {\n            $scope.code.current = $scope.parser.map[value] || $scope.code.current;\n        });\n\n        // Condition Codes\n        $scope.$watch('parser.CPU.ALU.data.ZF', function (value) {\n            $scope.conditions.zf = value;\n        });\n        $scope.$watch('parser.CPU.ALU.data.SF', function (value) {\n            $scope.conditions.sf = value;\n        });\n        $scope.$watch('parser.CPU.ALU.data.OF', function (value) {\n            $scope.conditions.of = value;\n        });\n\n        $scope.$watch('code.current', function (value) {\n            var cursorPos = value * $scope.code.lineHeight;\n            while (cursorPos >= $scope.code.height + $scope.code.scrollTop) {\n                $scope.code.scrollTop += $scope.code.height;\n            }\n            while (cursorPos <= $scope.code.scrollTop) {\n                $scope.code.scrollTop -= $scope.code.height;\n            }\n            $scope.code.scrollTop = Math.min($scope.code.scrollTop, $scope.code.scrollHeight - $scope.code.height);\n            $scope.code.scrollTop = Math.max($scope.code.scrollTop, 0);\n        });\n    };\n\n    $scope.loadTab = function (index) {\n        $scope.code.currentTab = index;\n        $scope.reset();\n    };\n\n    $scope.newTab = function (files) {\n        var readFile = function (index) {\n            if (!files[index])\n                return;\n            if (files[index].name.split('.')[1] !== 'yo') {\n                alert('File type is not supported!');\n                return;\n            }\n            $scope.code.tabs.push(files[index].name.split('.')[0]);\n            var reader = new FileReader();\n            reader.onload = function(event) {\n                $scope.code.fileCache.push(event.target.result);\n                $scope.$safeApply();\n                readFile(index + 1);\n            };\n            reader.readAsText(files[index]);\n        };\n        readFile(0);\n    };\n\n    $scope.prev = function () {\n        if (!$scope.parser) {\n            return false;\n        }\n        if ($scope.state.icon) {\n            // Pause here\n            $scope.play();\n        }\n        $scope.parser.CPU.backword();\n    };\n\n    $scope.next = function () {\n        if (!$scope.parser) {\n            return false;\n        }\n        try {\n            $scope.parser.CPU.forward();\n        } catch (err) {\n            return false;\n        }\n        return true;\n    };\n\n    $scope.setInterval = function () {\n        if (!$scope.state.icon) {\n            return false;\n        }\n        if (!$scope.next()) {\n            $scope.state.icon = 0;\n            $scope.$safeApply();\n            return false;\n        }\n        $scope.$safeApply();\n        setTimeout($scope.setInterval, 1000 / $scope.player.hz);\n        return true;\n    };\n\n    $scope.play = function () {\n        $scope.state.icon ^= 1;\n\n        if ($scope.state.icon) {\n            if (!$scope.parser) {\n                // test\n                var parser = new Parser($scope.code.fileCache[$scope.code.currentTab] || ($scope.code.fileCache[$scope.code.currentTab] = xhrGETSync($scope.code.tabFiles[$scope.code.currentTab])));\n\n                $scope.initParser(parser);\n                $scope.setInterval();\n            } else {\n                $scope.setInterval();\n            }\n        }\n    };\n\n    $scope.reset = function () {\n        if ($scope.state.icon) {\n            // Pause here\n            $scope.play();\n        }\n\n        var parser = new Parser($scope.code.fileCache[$scope.code.currentTab] || ($scope.code.fileCache[$scope.code.currentTab] = xhrGETSync($scope.code.tabFiles[$scope.code.currentTab])));\n\n        $scope.initParser(parser);\n    };\n\n    // Initialization\n\n    setTimeout(function () {\n        $scope.reset();\n        $scope.$safeApply();\n    }, 0);\n\n    move.select = function (element) {\n        return element;\n    };\n}\n"
  },
  {
    "path": "src/script/directives/board.js",
    "content": "/**\n * Created by shuding on 6/4/15.\n * <ds303077135@gmail.com>\n */\nangular\n    .module('y86')\n    .directive('board', function () {\n        return {\n            restrict:   'E',\n            transclude: true,\n            template:   '<div ng-transclude=\"true\"></div>'\n        }\n    })\n    .directive('flex-container', function () {\n        return {\n            restrict:   'E',\n            transclude: true\n        }\n    });\n"
  },
  {
    "path": "src/script/directives/clock.js",
    "content": "/**\n * Created by shuding on 6/4/15.\n * <ds303077135@gmail.com>\n */\nangular\n    .module('y86')\n    .directive('clockContainer', function () {\n        return {\n            restrict:   'E',\n            transclude: true,\n            template:   '<h3>CLOCK</h3>' +\n                        '<div ng-transclude=\"true\"></div>'\n        }\n    })\n    .directive('clock', function () {\n        return {\n            restrict: 'E',\n            scope: {\n                data: '='\n            },\n            template: '<div>{{ data }}</div>',\n            link: function($scope, elem) {\n                $scope.$watch('data', function () {\n                    move(elem[0])\n                        .set('color', '#0B0B0B')\n                        .set('background-color', '#37F3FF')\n                        .duration('0s')\n                        .delay('0s')\n                        .then()\n                            .set('color', '#37F3FF')\n                            .set('background-color', '#0B0B0B')\n                            .duration('.2s')\n                            .delay('.1s')\n                        .pop()\n                        .end();\n                });\n            }\n        }\n    });\n"
  },
  {
    "path": "src/script/directives/code.js",
    "content": "/**\n * Created by shuding on 6/5/15.\n * <ds303077135@gmail.com>\n */\nangular\n    .module('y86')\n    .directive('codeContainer', function () {\n        return {\n            restrict:   'E',\n            scope:      true,\n            transclude: true,\n            template:   '<h2 ng-repeat=\"tab in code.tabs\" ng-class=\"{active: $index == code.currentTab}\" ng-click=\"loadTab($index)\"><span class=\"tab\"></span>{{ tab }}</h2><h2><span class=\"tab\"></span><input type=\"file\">+</h2>' +\n                        '<pre><code ng-transclude=\"true\"></code></pre><span class=\"info\">WRITE ASSEMBLY CODE HERE</span>',\n            link:       function ($scope, elem) {\n                var pre = elem.find('pre')[0];\n                $scope.$watch(function () {\n                    $scope.code.height = pre.offsetHeight;\n                    $scope.code.scrollHeight = pre.scrollHeight;\n                });\n                $scope.$watch('code.scrollTop', function () {\n                    pre.scrollTop = $scope.code.scrollTop;\n                });\n\n                var file = elem.find('input');\n                file.bind('change', function (event) {\n                    $scope.newTab(event.target.files);\n                });\n            }\n        }\n    }).directive('codeLine', function () {\n        return {\n            restrict:   'E',\n            transclude: true,\n            scope:      {\n                lineNumber:  '=',\n                lineContent: '='\n            },\n            template:   '<span class=\"line-number\">{{ lineNumber }}</span><span>{{ lineContent }}</span>'\n        }\n    }).directive('codeLineIndicator', function () {\n        return {\n            restrict: 'E'\n        }\n    });\n"
  },
  {
    "path": "src/script/directives/condition.js",
    "content": "/**\n * Created by shuding on 6/4/15.\n * <ds303077135@gmail.com>\n */\nangular\n    .module('y86')\n    .directive('conditionContainer', function () {\n        return {\n            restrict:   'E',\n            transclude: true,\n            template:   '<h3>CONDITIONS</h3>' +\n                        '<div ng-transclude=\"true\"></div>'\n        }\n    })\n    .directive('condition', function () {\n        return {\n            restrict: 'E',\n            scope: {\n                condName: '=',\n                condData: '='\n            },\n            template: '<span>{{ condName | uppercase }}={{ condData }}</span>',\n            link: function($scope, elem) {\n                $scope.$watch('condData', function () {\n                    move(elem[0])\n                        .set('color', '#0B0B0B')\n                        .set('background-color', '#37F3FF')\n                        .duration('0s')\n                        .delay('0s')\n                        .then()\n                            .set('color', '#37F3FF')\n                            .set('background-color', '#0B0B0B')\n                            .duration('.2s')\n                            .delay('.1s')\n                        .pop()\n                        .end();\n                });\n            }\n        }\n    });\n"
  },
  {
    "path": "src/script/directives/control.js",
    "content": "/**\n * Created by shuding on 6/4/15.\n * <ds303077135@gmail.com>\n */\nangular\n    .module('y86')\n    .directive('controlContainer', function () {\n        return {\n            restrict:   'E',\n            transclude: true,\n            template:   '<div ng-transclude=\"true\"></div>'\n        }\n    }).directive('frequency', function () {\n        return {\n            restrict: 'E',\n            transclude: true,\n            scope:    {\n                hz: '='\n            },\n            template: '1 Hz <input id=\"frequency-input\" type=\"range\" min=\"1\" max=\"50\" value=\"10\" step=\".1\" ng-model=\"hz\"> 50 Hz'\n        }\n    }).directive('frequencyLabel', function () {\n        return {\n            restrict: 'E',\n            scope:    {\n                hz: '='\n            },\n            template: '<span>{{ hz }}</span>'\n        }\n    }).directive('playPause', function () {\n        return {\n            restrict: 'E',\n            scope:    {\n                fn:   '&',\n                icon: '='\n            },\n            template: '<button ng-click=\"fn()\"><i class=\"fa fa-fw fa-{{ icon }}\"></i></button>'\n        }\n    }).directive('prev', function () {\n        return {\n            restrict: 'E',\n            scope:    {\n                fn: '&'\n            },\n            template: '<button ng-click=\"fn()\"><i class=\"fa fa-caret-left\"></i></button>'\n        }\n    }).directive('next', function () {\n        return {\n            restrict: 'E',\n            scope:    {\n                fn: '&'\n            },\n            template: '<button ng-click=\"fn()\"><i class=\"fa fa-caret-right\"></i></button>'\n        }\n    }).directive('reset', function () {\n        return {\n            restrict: 'E',\n            scope:    {\n                fn: '&'\n            },\n            template: '<button ng-click=\"fn()\"><i class=\"fa fa-fw fa-undo\"></i> Reset</button>'\n        }\n    });\n"
  },
  {
    "path": "src/script/directives/cpi.js",
    "content": "/**\n * Created by shuding on 6/11/15.\n * <ds303077135@gmail.com>\n */\nangular.module('y86').directive('cpiContainer', function () {\n    return {\n        restrict:   'E',\n        scope:      true,\n        transclude: true,\n        template:   '<h6>CPI Curve</h6><div><input id=\"cpi-input\" type=\"range\" min=\"0\" max=\"{{ parser.CPU.cpi.length - 1 }}\" value=\"0\" step=\"1\" ng-model=\"getterAndSetterCycle\"><canvas id=\"graph\" width=\"1000\" height=\"50\"></div>',\n        link: function ($scope, elem) {\n            var canvas = elem.find('canvas')[0];\n            var context = canvas.getContext('2d');\n            var lastPoint = [[0, 0], [0, 0]];\n            context.strokeStyle = '#37F3FF';\n            context.lineWidth = 2;\n\n            function draw(dataset) {\n                // Clear\n                context.fillStyle = 'black';\n                context.fillRect(0, 0, 1000, 50);\n\n                if (!dataset || dataset.length < 2)\n                    return;\n\n                var eachPadding = 1000 / (dataset.length - 1);\n                var maxY = .1;\n\n                dataset.forEach(function (y) {\n                    maxY = Math.max(maxY, y - 1);\n                });\n\n                context.beginPath();\n                context.moveTo(0, 49);\n\n                // Render dataset\n                dataset.forEach(function (y, x) {\n                    var px = x * eachPadding;\n                    var py = (1 - (y - 1) / maxY) * 48 + 1;\n                    context.fillStyle = '#30F4FE';\n                    context.fillRect(px - 1, py - 3, 2, 5);\n\n                    if (x > 1) {\n                        context.quadraticCurveTo(lastPoint[1][0], lastPoint[1][1], (px + lastPoint[1][0]) / 2, (py + lastPoint[1][1]) / 2);\n                    }\n\n                    lastPoint[0] = lastPoint[1];\n                    lastPoint[1] = [px, py];\n                });\n\n                context.quadraticCurveTo(lastPoint[0][0], lastPoint[0][1], lastPoint[1][0], lastPoint[1][1]);\n\n                context.stroke();\n                context.closePath();\n            }\n\n            $scope.$watch('parser.CPU.cpi.length', function () {\n                if ($scope.parser)\n                    draw($scope.parser.CPU.cpi);\n            });\n\n            $scope.$watch('parser.CPU.cycle', function (value) {\n                $scope.getterAndSetterCycle = value;\n            });\n\n            $scope.$watch('getterAndSetterCycle', function (value) {\n                if ($scope.parser)\n                    $scope.parser.CPU.goto(value);\n            });\n\n            elem.find('#cpi-input');\n        }\n    }\n});\n"
  },
  {
    "path": "src/script/directives/pipe.js",
    "content": "/**\n * Created by shuding on 6/10/15.\n * <ds303077135@gmail.com>\n */\nangular.module('y86').directive('fetch', function () {\n        return {\n            restrict:   'E',\n            scope:      true,\n            transclude: true,\n            template:   '<h3>FETCH</h3>' + '<div ng-transclude=\"true\"></div>'\n        }\n    }).directive('decode', function () {\n        return {\n            restrict:  'E',\n            scope:     true,\n            transclude: true,\n            template:  '<h3>DECODE</h3>' + '<div ng-transclude=\"true\"></div>'\n        }\n    }).directive('execute', function () {\n        return {\n            restrict:  'E',\n            scope:     true,\n            transclude: true,\n            template:  '<h3>EXECUTE</h3>' + '<div ng-transclude=\"true\"></div>'\n        }\n    }).directive('memory', function () {\n        return {\n            restrict:  'E',\n            scope:     true,\n            transclude: true,\n            template:  '<h3>MEMORY</h3>' + '<div ng-transclude=\"true\"></div>'\n        }\n    }).directive('writeBack', function () {\n        return {\n            restrict:  'E',\n            scope:     true,\n            transclude: true,\n            template:  '<h3>WRITE BACK</h3>' + '<div ng-transclude=\"true\"></div>'\n        }\n    }).directive('pipeAttr', function () {\n        return {\n            restrict: 'E',\n            scope: {\n                pipeName: '=',\n                pipeData: '=',\n                pipePref: '='\n            },\n            transclude: true,\n            template: '<h6>{{ pipeName }}</h6><p>{{ pipePref }}{{ pipeData }}</p>',\n            link: function($scope, elem) {\n                $scope.$watch('pipeData', function () {\n                    move(elem[0])\n                        .set('color', '#0B0B0B')\n                        .set('background-color', '#37F3FF')\n                        .duration('0s')\n                        .delay('0s')\n                        .then()\n                        .set('color', '#37F3FF')\n                        .set('background-color', '#0B0B0B')\n                        .duration('.2s')\n                        .delay('.1s')\n                        .pop()\n                        .end();\n                });\n            }\n        }\n    });\n"
  },
  {
    "path": "src/script/directives/register.js",
    "content": "/**\n * Created by shuding on 6/4/15.\n * <ds303077135@gmail.com>\n */\nangular\n    .module('y86')\n    .directive('registerContainer', function () {\n        return {\n            restrict:   'E',\n            transclude: true,\n            template:   '<h3>REGISTERS</h3>' +\n                        '<div ng-transclude=\"true\"></div>'\n        }\n    }).directive('register', function () {\n        return {\n            restrict: 'E',\n            scope:    {\n                regName: '=',\n                regData: '='\n            },\n            template: '<div class=\"register-name\">%{{regName}}</div>' +\n                      '<div class=\"register-data\">0x{{regData}}</div>',\n            link: function($scope, elem) {\n                $scope.$watch('regData', function () {\n                    move(elem[0])\n                        .set('color', '#0B0B0B')\n                        .set('background-color', '#37F3FF')\n                        .duration('0s')\n                        .delay('0s')\n                        .then()\n                        .set('color', '#37F3FF')\n                        .set('background-color', '#0B0B0B')\n                        .duration('.2s')\n                        .delay('.1s')\n                        .pop()\n                        .end();\n                });\n            }\n        }\n    });\n"
  },
  {
    "path": "src/script/directives/stack.js",
    "content": "/**\n * Created by shuding on 6/4/15.\n * <ds303077135@gmail.com>\n */\nangular\n    .module('y86')\n    .directive('stackContainer', function () {\n        return {\n            restrict:   'E',\n            transclude: true,\n            template:   '<h3>MEMORY</h3>' +\n                        '<div ng-transclude=\"true\"></div>'\n        }\n    })\n    .directive('stack', function () {\n        return {\n            restrict: 'E',\n            transclude: true,\n            template: '<div ng-transclude=\"true\"></div>'\n        }\n    });\n"
  },
  {
    "path": "src/script/kernels/alu.js",
    "content": "/**\n * Created by shuding on 6/9/15.\n * <ds303077135@gmail.com>\n */\n\nvar Constant = require('script/kernels/constant');\n\nmodule.exports = ALU;\n\nfunction ALU() {\n    function init(alu) {\n        alu.data = {\n            ZF:     1,\n            SF:     0,\n            OF:     0,\n            inA:    0,\n            inB:    0,\n            tVal:   0,\n            fCode:  0,\n            update: 0\n        };\n\n        calc(alu);\n        cond(alu);\n\n        config(alu);\n        update(alu);\n    }\n\n    function calc(alu) {\n        alu.calc                 = {};\n        alu.calc[Constant.A_ADD] = function () {\n            alu.data.tVal = (alu.data.inA + alu.data.inB) | 0;\n            alu.updateAll();\n        };\n        alu.calc[Constant.A_AND] = function () {\n            alu.data.tVal = alu.data.inA & alu.data.inB;\n            alu.updateAll();\n        };\n        alu.calc[Constant.A_SUB] = function () {\n            alu.data.tVal = (alu.data.inA - alu.data.inB) | 0;\n            alu.updateAll();\n        };\n        alu.calc[Constant.A_XOR] = function () {\n            alu.data.tVal = alu.data.inA ^ alu.data.inB;\n            alu.updateAll();\n        };\n    }\n\n    function cond(alu) {\n        alu.cond                  = {};\n        alu.cond[Constant.C_TRUE] = function () {\n            return true;\n        };\n        alu.cond[Constant.C_L]    = function () {\n            return alu.SF() ^ alu.OF();\n        };\n        alu.cond[Constant.C_E]    = function () {\n            return alu.ZF();\n        };\n        alu.cond[Constant.C_NE]   = function () {\n            return !alu.cond[Constant.C_E]();\n        };\n        alu.cond[Constant.C_LE]   = function () {\n            return (alu.cond[Constant.C_L]) | alu.cond[Constant.C_E];\n        };\n        alu.cond[Constant.C_GE]   = function () {\n            return !alu.cond[Constant.C_L];\n        };\n        alu.cond[Constant.C_G]    = function () {\n            return !alu.cond[Constant.C_LE];\n        };\n    }\n\n    function config(alu) {\n        alu.config           = {};\n        alu.config.setInA    = function (data) {\n            alu.data.inA = data;\n        };\n        alu.config.setInB    = function (data) {\n            alu.data.inB = data;\n        };\n        alu.config.setFCode  = function (data) {\n            alu.data.fCode = data;\n        };\n        alu.config.setUpdate = function (data) {\n            alu.data.update = data;\n        };\n    }\n\n    function update(alu) {\n        alu.updateOF                 = {};\n        alu.updateOF[Constant.A_ADD] = function () {\n            alu.OF((alu.data.inA < 0) == (alu.data.inB < 0) && (alu.data.tVal < 0) != (alu.data.inA < 0));\n        };\n        alu.updateOF[Constant.A_SUB] = function () {\n            alu.OF((alu.data.inA < 0) == (alu.data.inB > 0) && (alu.data.tVal < 0) != (alu.data.inB < 0));\n        };\n        alu.updateOF[Constant.A_AND] = function () {\n            alu.OF(0);\n        };\n        alu.updateOF[Constant.A_XOR] = function () {\n            alu.OF(0);\n        };\n    }\n\n    init(this);\n}\n\nALU.prototype.ZF = function (flag) {\n    if (typeof flag !== 'undefined') {\n        this.data.ZF = (+flag);\n    }\n    return this.data.ZF;\n};\n\nALU.prototype.SF = function (flag) {\n    if (typeof flag !== 'undefined') {\n        this.data.SF = (+flag);\n    }\n    return this.data.SF;\n};\n\nALU.prototype.OF = function (flag) {\n    if (typeof flag !== 'undefined') {\n        this.data.OF = (+flag);\n    }\n    return this.data.OF;\n};\n\nALU.prototype.updateAll = function () {\n    if (!this.data.update) {\n        return;\n    }\n    this.SF(!!(this.data.tVal >>> 31));\n    this.ZF(!this.data.tVal);\n    this.updateOF[this.data.fCode]();\n};\n\nALU.prototype.execute = function () {\n    this.calc[this.data.fCode]();\n    return this.data.tVal;\n};\n\nALU.prototype.condition = function (cond) {\n    if (!(0 <= cond && cond < 8))\n        return true;\n    return this.cond[cond]();\n};\n"
  },
  {
    "path": "src/script/kernels/constant.js",
    "content": "/**\n * Created by shuding on 6/9/15.\n * <ds303077135@gmail.com>\n */\n\nmodule.exports = {\n\n    REGISTERS: [\n        'R_EAX',\n        'R_ECX',\n        'R_EDX',\n        'R_EBX',\n        'R_ESP',\n        'R_EBP',\n        'R_ESI',\n        'R_EDI'\n    ],\n\n    P_LOAD:   0,\n    P_STALL:  1,\n    P_BUBBLE: 2,\n    P_ERROR:  3,\n\n    I_NOP:    0,\n    I_HALT:   1,\n    I_RRMOVL: 2,\n    I_IRMOVL: 3,\n    I_RMMOVL: 4,\n    I_MRMOVL: 5,\n    I_OPL:    6,\n    I_JXX:    7,\n    I_CALL:   8,\n    I_RET:    9,\n    I_PUSHL:  0xa,\n    I_POPL:   0xb,\n    I_IADDL:  0xc,\n    I_LEAVE:  0xd,\n\n    A_ADD:  0,\n    A_SUB:  1,\n    A_AND:  2,\n    A_XOR:  3,\n    A_NONE: 4,\n\n    F_OF: 1, // OF at bit 0\n    F_SF: 2, // SF at bit 1\n    F_ZF: 4, // ZF at bit 2\n\n    C_TRUE: 0,\n    C_LE:   1,\n    C_L:    2,\n    C_E:    3,\n    C_NE:   4,\n    C_GE:   5,\n    C_G:    6,\n\n    STAT_BUB: 0,\n    STAT_AOK: 1,\n    STAT_HLT: 2,\n    STAT_ADR: 3,\n    STAT_INS: 4,\n    STAT_PIP: 5,\n\n    R_EAX:  0,\n    R_ECX:  1,\n    R_EDX:  2,\n    R_EBX:  3,\n    R_ESP:  4,\n    R_EBP:  5,\n    R_ESI:  6,\n    R_EDI:  7,\n    R_NONE: 0xf,\n\n    DEF_CC: 4\n};\n"
  },
  {
    "path": "src/script/kernels/cpu.js",
    "content": "/**\n * Created by shuding on 6/9/15.\n * <ds303077135@gmail.com>\n */\n\nvar Constant     = require('script/kernels/constant');\nvar Memory       = require('script/kernels/memory');\nvar Register     = require('script/kernels/register').Register;\nvar PIPERegister = require('script/kernels/register').PIPERegister;\nvar ALU          = require('script/kernels/alu');\n\nmodule.exports = CPU;\n\nfunction clone(obj) {\n    if (null == obj || \"object\" != typeof obj) {\n        return obj;\n    }\n    var constructor = obj.constructor || obj.__proto__.constructor;\n    var copy        = new constructor();\n    for (var attr in obj) {\n        if (obj.hasOwnProperty(attr)) {\n            copy[attr] = obj[attr];\n        }\n    }\n    return copy;\n}\n\nfunction saveHistory(cpu, cycle) {\n    cpu.history[cycle] = {\n        Memory:      clone(cpu.Memory),\n        Register:    clone(cpu.Register),\n        Input:       clone(cpu.Input),\n        Output:      clone(cpu.Output),\n        ALU:         clone(cpu.ALU),\n        cycle:       cpu.cycle,\n        instruction: cpu.instruction,\n        state:       cpu.state,\n        halt:        cpu.halt,\n        mrmovl:      cpu.mrmovl,\n        popl:        cpu.popl,\n        cond:        cpu.cond,\n        ret:         cpu.ret,\n        use:         cpu.use,\n        mispredict:  cpu.mispredict\n    };\n}\n\nfunction timeMachine(cpu, cycle) {\n    cpu.Memory      = cpu.history[cycle].Memory;\n    cpu.Register    = cpu.history[cycle].Register;\n    cpu.Input       = cpu.history[cycle].Input;\n    cpu.Output      = cpu.history[cycle].Output;\n    cpu.ALU         = cpu.history[cycle].ALU;\n    cpu.instruction = cpu.history[cycle].instruction;\n    cpu.cycle       = cpu.history[cycle].cycle;\n    cpu.state       = cpu.history[cycle].state;\n    cpu.halt        = cpu.history[cycle].halt;\n    cpu.mrmovl      = cpu.history[cycle].mrmovl;\n    cpu.popl        = cpu.history[cycle].popl;\n    cpu.cond        = cpu.history[cycle].cond;\n    cpu.ret         = cpu.history[cycle].ret;\n    cpu.use         = cpu.history[cycle].use;\n    cpu.mispredict  = cpu.history[cycle].mispredict;\n}\n\nfunction saveCPI (cpu, cycle, cpi) {\n    cpu.cpi[cycle] = cpi;\n}\n\nfunction CPU() {\n    this.Memory   = new Memory();\n    this.Register = new Register();\n    this.Input    = new PIPERegister();\n    this.Output   = new PIPERegister();\n    this.ALU      = new ALU();\n\n    this.history = [];\n    this.cpi     = [0];\n\n    /**\n     * Initialization\n     */\n    function init(cpu) {\n        cpu.cycle       = 0;\n        cpu.instruction = 0;\n        cpu.state       = Constant.STAT_AOK;\n        cpu.halt        = false;\n\n        cpu.mrmovl = 0;\n        cpu.popl   = 0;\n        cpu.cond   = 0;\n        cpu.ret    = 0;\n\n        cpu.use        = 0;\n        cpu.mispredict = 0;\n\n        saveHistory(cpu, 0);\n    }\n\n    init(this);\n}\n\nCPU.prototype.goto = function (cycle) {\n    if (cycle < this.history.length) {\n        timeMachine(this, cycle);\n    }\n};\n\nCPU.prototype.backword = function () {\n    if (this.history[this.cycle - 1]) {\n        timeMachine(this, this.cycle - 1);\n    }\n};\n\nCPU.prototype.forward = function () {\n    if (this.cycle + 1 < this.history.length) {\n        timeMachine(this, this.cycle + 1);\n        return;\n    }\n\n    var input  = this.Input;\n    var output = this.Output;\n\n    if (input.W_icode == Constant.I_HALT) {\n        this.state = Constant.STAT_HLT;\n    }\n\n    if (this.state != Constant.STAT_AOK && this.state != Constant.STAT_BUB) {\n        throw new Error('State error: ' + this.state);\n    }\n\n    this.writeBack();\n    this.memory();\n    this.execute();\n    this.decode();\n    this.fetch();\n\n    this.cycle++;\n\n    if (this.state != Constant.STAT_BUB) {\n        this.instruction++;\n    }\n\n    this.nextPIPERegister();\n\n    saveCPI(this, this.cycle, this.updateCPI());\n    saveHistory(this, this.cycle);\n};\n\nCPU.prototype.updateCPI = function () {\n    var lp = (this.mrmovl + this.popl) * this.use;\n    var mp = this.cond * this.mispredict;\n    var rp = this.ret;\n\n    if (!this.instruction)\n        lp = mp = rp = 0;\n    if (!this.mrmovl && !this.popl)\n        lp = 0;\n    if (!this.cond)\n        mp = 0;\n\n    if (lp)\n        lp /= this.instruction * (this.mrmovl + this.popl);\n    if (mp)\n        mp /= this.instruction * this.cond;\n    if (rp)\n        rp /= this.instruction;\n\n    return lp + mp * 2 + rp * 3 + 1;\n};\n\nCPU.prototype.fetch = function () {\n    if (this.halt) {\n        return;\n    }\n\n    var input  = this.Input;\n    var output = this.Output;\n\n    var next;\n\n    if (input.M_icode == Constant.I_JXX && !input.M_Cnd) {\n        next = input.M_valA;\n    } else if (input.W_icode == Constant.I_RET) {\n        next = input.W_valM;\n    } else {\n        next = input.F_predPC;\n    }\n\n    var insruction = this.Memory.readByte(next++);\n    output.D_icode = insruction >> 4;\n    output.D_ifun  = insruction & 15;\n\n    if ([Constant.I_NOP, Constant.I_HALT, Constant.I_RRMOVL, Constant.I_IRMOVL, Constant.I_RMMOVL, Constant.I_MRMOVL, Constant.I_OPL, Constant.I_JXX, Constant.I_CALL, Constant.I_RET, Constant.I_PUSHL, Constant.I_POPL, Constant.I_LEAVE, Constant.I_IADDL].indexOf(output.D_icode) == -1) {\n        output.F_stat = output.D_stat = Constant.STAT_INS;\n        return;\n    } else if (output.D_icode == Constant.I_HALT) {\n        output.F_stat = output.D_stat = Constant.STAT_HLT;\n        return;\n    } else {\n        output.F_stat = output.D_stat = Constant.STAT_AOK;\n    }\n\n    if ([Constant.I_RRMOVL, Constant.I_OPL, Constant.I_IRMOVL, Constant.I_MRMOVL, Constant.I_RMMOVL, Constant.I_PUSHL, Constant.I_POPL, Constant.I_IADDL].indexOf(output.D_icode) != -1) {\n        var regByte = this.Memory.readByte(next++);\n        output.D_rA = regByte >> 4;\n        output.D_rB = regByte & 15;\n    } else {\n        output.D_rA = output.D_rB = Constant.R_NONE;\n    }\n\n    if ([Constant.I_IRMOVL, Constant.I_RMMOVL, Constant.I_MRMOVL, Constant.I_JXX, Constant.I_CALL, Constant.I_IADDL].indexOf(output.D_icode) != -1) {\n        output.D_valC = this.Memory.readInt(next);\n        next += 4;\n    }\n\n    output.F_predPC = next;\n    if ([Constant.I_JXX, Constant.I_CALL].indexOf(output.D_icode) != -1) {\n        output.F_predPC = output.D_valC;\n    }\n    output.D_valP = next;\n};\n\nCPU.prototype.decode = function () {\n\n    var input  = this.Input;\n    var output = this.Output;\n\n    output.E_icode = input.D_icode;\n    output.E_ifun  = input.D_ifun;\n    output.E_valC  = input.D_valC;\n    output.E_stat  = input.D_stat;\n\n    if ([Constant.I_RRMOVL, Constant.I_RMMOVL, Constant.I_OPL, Constant.I_PUSHL].indexOf(input.D_icode) != -1) {\n        output.E_srcA = input.D_rA;\n    } else if ([Constant.I_POPL, Constant.I_RET].indexOf(input.D_icode) != -1) {\n        output.E_srcA = Constant.R_ESP;\n    } else if (input.D_icode == Constant.I_LEAVE) {\n        output.E_srcA = Constant.R_EBP;\n    } else {\n        output.E_srcA = Constant.R_NONE;\n    }\n\n    if ([Constant.I_OPL, Constant.I_RMMOVL, Constant.I_MRMOVL, Constant.I_IADDL].indexOf(input.D_icode) != -1) {\n        output.E_srcB = input.D_rB;\n    } else if ([Constant.I_PUSHL, Constant.I_POPL, Constant.I_CALL, Constant.I_RET].indexOf(input.D_icode) != -1) {\n        output.E_srcB = Constant.R_ESP;\n    } else if (input.D_icode == Constant.I_LEAVE) {\n        output.E_srcB = Constant.R_EBP;\n    } else {\n        output.E_srcB = Constant.R_NONE;\n    }\n\n    if ([Constant.I_RRMOVL, Constant.I_IRMOVL, Constant.I_OPL, Constant.I_IADDL].indexOf(input.D_icode) != -1) {\n        output.E_dstE = input.D_rB;\n    } else if ([Constant.I_PUSHL, Constant.I_POPL, Constant.I_CALL, Constant.I_RET, Constant.I_LEAVE].indexOf(input.D_icode) != -1) {\n        output.E_dstE = Constant.R_ESP;\n    } else {\n        output.E_dstE = Constant.R_NONE;\n    }\n\n    if ([Constant.I_MRMOVL, Constant.I_POPL].indexOf(input.D_icode) != -1) {\n        output.E_dstM = input.D_rA;\n    } else if (input.D_icode == Constant.I_LEAVE) {\n        output.E_dstM = Constant.R_EBP;\n    } else {\n        output.E_dstM = Constant.R_NONE;\n    }\n\n    if ([Constant.I_CALL, Constant.I_JXX].indexOf(input.D_icode) != -1) {\n        output.E_valA = input.D_valP;\n    } else if (output.E_srcA == output.M_dstE) {\n        output.E_valA = output.M_valE;\n    } else if (output.E_srcA == input.M_dstM) {\n        output.E_valA = output.W_valM;\n    } else if (output.E_srcA == input.M_dstE) {\n        output.E_valA = input.M_valE;\n    } else if (output.E_srcA == input.W_dstM) {\n        output.E_valA = input.W_valM;\n    } else if (output.E_srcA == input.W_dstE) {\n        output.E_valA = input.W_valE;\n    } else {\n        output.E_valA = this.Register.get(output.E_srcA);\n    }\n\n    if (output.E_srcB == output.M_dstE) {\n        output.E_valB = output.M_valE;\n    } else if (output.E_srcB == input.M_dstM) {\n        output.E_valB = output.W_valM;\n    } else if (output.E_srcB == input.M_dstE) {\n        output.E_valB = input.M_valE;\n    } else if (output.E_srcB == input.W_dstM) {\n        output.E_valB = input.W_valM;\n    } else if (output.E_srcB == input.W_dstE) {\n        output.E_valB = input.W_valE;\n    } else {\n        output.E_valB = this.Register.get(output.E_srcB);\n    }\n\n};\n\nCPU.prototype.execute = function () {\n\n    var input  = this.Input;\n    var output = this.Output;\n    var alu    = this.ALU;\n\n    output.M_icode = input.E_icode;\n    output.M_valA  = input.E_valA;\n    output.M_dstM  = input.E_dstM;\n    output.M_stat  = input.E_stat;\n\n    if (input.E_icode == Constant.I_MRMOVL) {\n        this.mrmovl++;\n    }\n    if (input.E_icode == Constant.I_POPL) {\n        this.popl++;\n    }\n    if (input.E_icode == Constant.I_JXX) {\n        this.cond++;\n    }\n    if (input.E_icode == Constant.I_RET) {\n        this.ret++;\n    }\n\n    if (input.E_icode == Constant.I_HALT && input.E_stat != Constant.STAT_BUB) {\n        this.halt     = true;\n        output.M_stat = Constant.STAT_HLT;\n    }\n\n    // ALU-A\n    if ([Constant.I_RRMOVL, Constant.I_OPL].indexOf(input.E_icode) != -1) {\n        alu.config.setInA(input.E_valA);\n    } else if ([Constant.I_IRMOVL, Constant.I_RMMOVL, Constant.I_MRMOVL, Constant.I_IADDL].indexOf(input.E_icode) != -1) {\n        alu.config.setInA(input.E_valC);\n    } else if ([Constant.I_CALL, Constant.I_PUSHL].indexOf(input.E_icode) != -1) {\n        alu.config.setInA(-4);\n    } else if ([Constant.I_RET, Constant.I_POPL, Constant.I_LEAVE].indexOf(input.E_icode) != -1) {\n        alu.config.setInA(4);\n    } else {\n        alu.config.setInA(0);\n    }\n\n    // ALU-B\n    if ([Constant.I_RMMOVL, Constant.I_MRMOVL, Constant.I_OPL, Constant.I_CALL, Constant.I_PUSHL, Constant.I_RET, Constant.I_POPL, Constant.I_IADDL, Constant.I_LEAVE].indexOf(input.E_icode) != -1) {\n        alu.config.setInB(input.E_valB);\n    } else {\n        alu.config.setInB(0);\n    }\n\n    // ALU-fCode\n    if (input.E_icode == Constant.I_OPL) {\n        alu.config.setFCode(input.E_ifun);\n    } else {\n        alu.config.setFCode(0);\n    }\n\n    // ALU-Update\n    if ([Constant.I_OPL, Constant.I_IADDL].indexOf(input.E_icode) != -1 && [Constant.STAT_ADR, Constant.STAT_INS, Constant.STAT_HLT].indexOf(output.W_stat) == -1 && [Constant.STAT_ADR, Constant.STAT_INS, Constant.STAT_HLT].indexOf(input.W_stat) == -1) {\n        alu.config.setUpdate(1);\n    } else {\n        alu.config.setUpdate(0);\n    }\n\n    output.M_valE = alu.execute();\n    output.M_Cnd  = alu.condition(input.E_ifun);\n    output.M_valA = input.E_valA;\n\n    if (input.E_icode == Constant.I_RRMOVL && !output.M_Cnd) {\n        output.M_dstE = Constant.R_NONE;\n    } else {\n        output.M_dstE = input.E_dstE;\n    }\n};\n\nCPU.prototype.memory = function () {\n\n    var input  = this.Input;\n    var output = this.Output;\n\n    var rMem = false, wMem = false, mAddr = 0;\n\n    output.W_stat  = input.M_stat;\n    output.W_icode = input.M_icode;\n    output.W_valE  = input.M_valE;\n    output.W_dstE  = input.M_dstE;\n    output.W_dstM  = input.M_dstM;\n\n    if ([Constant.I_RMMOVL, Constant.I_PUSHL, Constant.I_CALL, Constant.I_MRMOVL].indexOf(input.M_icode) != -1) {\n        mAddr = input.M_valE;\n    } else if ([Constant.I_POPL, Constant.I_RET, Constant.I_LEAVE].indexOf(input.M_icode) != -1) {\n        mAddr = input.M_valA;\n    }\n\n    rMem = [Constant.I_MRMOVL, Constant.I_POPL, Constant.I_RET, Constant.I_LEAVE].indexOf(input.M_icode) != -1;\n\n    wMem = [Constant.I_RMMOVL, Constant.I_PUSHL, Constant.I_CALL].indexOf(input.M_icode) != -1;\n\n    if (rMem) {\n        output.W_valM = this.Memory.readInt(mAddr);\n    }\n    if (wMem) {\n        this.Memory.writeInt(mAddr, input.M_valA);\n    }\n};\n\nCPU.prototype.writeBack = function () {\n\n    var input = this.Input;\n\n    this.state = input.W_stat;\n    if (input.W_icode == Constant.I_RMMOVL) {\n        return;\n    }\n\n    this.Register.set(input.W_dstE, input.W_valE);\n    this.Register.set(input.W_dstM, input.W_valM);\n};\n\nCPU.prototype.nextPIPERegister = function () {\n\n    var input  = this.Input;\n    var output = this.Output;\n\n    var F_stall = (([Constant.I_MRMOVL, Constant.I_POPL, Constant.I_LEAVE].indexOf(input.E_icode) != -1) && ([output.E_srcA, output.E_srcB].indexOf(input.E_dstM) != -1)) || ([input.D_icode, input.E_icode, input.M_icode].indexOf(Constant.I_RET) != -1);\n\n    var D_stall = ([Constant.I_MRMOVL, Constant.I_POPL, Constant.I_LEAVE].indexOf(input.E_icode) != -1) && ([output.E_srcA, output.E_srcB].indexOf(input.E_dstM) != -1);\n\n    var D_bubble = (input.E_icode == Constant.I_JXX && !output.M_Cnd) || ((!D_stall) && ([input.D_icode, input.E_icode, input.M_icode].indexOf(Constant.I_RET) != -1));\n\n    var E_bubble = (input.E_icode == Constant.I_JXX && !output.M_Cnd) || (([Constant.I_MRMOVL, Constant.I_POPL, Constant.I_LEAVE].indexOf(input.E_icode) != -1 && [output.E_srcA, output.E_srcB].indexOf(input.E_dstM) != -1));\n\n    var M_bubble = [Constant.STAT_ADR, Constant.STAT_INS, Constant.STAT_HLT].indexOf(output.W_stat) != -1 || [Constant.STAT_ADR, Constant.STAT_INS, Constant.STAT_HLT].indexOf(input.W_stat) != -1;\n\n    if (([Constant.I_MRMOVL, Constant.I_POPL].indexOf(input.E_icode) != -1) && (input.E_dstM == input.E_srcA || input.E_dstM == input.E_srcB)) {\n        this.use++;\n    }\n\n    if (input.E_icode == Constant.I_JXX && !input.M_Cnd) {\n        this.mispredict++;\n    }\n\n    // Copy from output\n    var reg = new PIPERegister();\n    for (var name in output) {\n        if (output.hasOwnProperty(name)) {\n            reg.set(name, output[name]);\n        }\n    }\n\n    if (M_bubble) {\n        reg.set({\n            M_icode: Constant.I_NOP,\n            M_stat:  Constant.STAT_BUB,\n            M_dstE:  Constant.R_NONE,\n            M_dstM:  Constant.R_NONE,\n            M_Cnd:   false\n        });\n    }\n\n    if (E_bubble) {\n        reg.set({\n            E_icode: Constant.I_NOP,\n            E_ifun:  0,\n            E_stat:  Constant.STAT_BUB,\n            E_dstE:  Constant.R_NONE,\n            E_dstM:  Constant.R_NONE,\n            E_srcA:  Constant.R_NONE,\n            E_srcB:  Constant.R_NONE\n        });\n    }\n\n    if (D_stall) {\n        reg.set({\n            D_icode: input.D_icode,\n            D_ifun:  input.D_ifun,\n            D_rA:    input.D_rA,\n            D_rB:    input.D_rB,\n            D_valC:  input.D_valC,\n            D_valP:  input.D_valP\n        });\n    }\n\n    if (D_bubble) {\n        reg.set({\n            D_icode: Constant.I_NOP,\n            D_ifun:  0,\n            D_stat:  Constant.STAT_BUB\n        });\n    }\n\n    if (F_stall) {\n        reg.set('F_predPC', input.F_predPC);\n    }\n\n    this.Input = reg;\n};\n"
  },
  {
    "path": "src/script/kernels/main.js",
    "content": "/**\n * Created by shuding on 6/9/15.\n * <ds303077135@gmail.com>\n */\n\n(function (window, undefined) {\n    var Y86 = {\n        modules: []\n    };\n\n    window.xhrGETSync = function (url) {\n        var xhr = new XMLHttpRequest();\n        xhr.open('GET', url + '?' + (new Date()).getTime(), false);\n        xhr.send();\n        if (xhr.readyState == 4) {\n            return xhr.responseText;\n        }\n        return undefined;\n    };\n\n    /**\n     * The require (CommonJS) function.\n     * @param path\n     */\n    window.require = function (path) {\n        // Module cache\n        if (typeof Y86.modules[path] !== 'undefined') {\n            return Y86.modules[path];\n        }\n\n        var data = xhrGETSync(path + '.js');\n        if (typeof data !== 'undefined') {\n            Y86.modules[path] = eval('(function (window, undefined) { var module = {}; ' + data + '; return module.exports; })(window)');\n        }\n\n        return Y86.modules[path];\n    };\n})(window);\n"
  },
  {
    "path": "src/script/kernels/memory.js",
    "content": "/**\n * Created by shuding on 6/9/15.\n * <ds303077135@gmail.com>\n */\n\nvar Utils = require('script/kernels/utils');\n\nmodule.exports = Memory;\n\nfunction Memory() {\n    this.data = [];\n\n    this.fillTo = function (address) {\n        for (var i = this.data.length; i <= address; ++i) {\n            this.data[i] = [0, 0, 0, 0];\n        }\n    };\n    this.get    = function (address) {\n        var index  = Math.floor(address / 4);\n        var offset = address % 4;\n        if (typeof this.data[index] == 'undefined') {\n            this.fillTo(index);\n        }\n        return this.data[index][offset];\n    };\n    this.set    = function (address, byte) {\n        var index  = Math.floor(address / 4);\n        var offset = address % 4;\n        if (typeof this.data[index] == 'undefined') {\n            this.fillTo(index);\n        }\n        this.data[index][offset] = byte;\n    };\n}\n\nMemory.prototype.writeByte = function (address, byte) {\n    if (!Utils.checkByte(byte)) {\n        throw new Error('Byte error in `Memory writeByte`');\n    }\n    this.set(address, byte);\n};\n\nMemory.prototype.readByte = function (address) {\n    return this.get(address);\n};\n\nMemory.prototype.writeInt = function (address, int) {\n    if (!Utils.checkNumber(int)) {\n        throw new Error('Int error in `Memory writeInt`');\n    }\n    for (var i = 0; i < 4; ++i) {\n        this.set(address + i, int & 255);\n        int >>= 8;\n    }\n};\n\nMemory.prototype.readInt = function (address) {\n    return this.get(address + 0) +\n           this.get(address + 1) * 256 +\n           this.get(address + 2) * 65536 +\n           this.get(address + 3) * 16777216;\n};\n"
  },
  {
    "path": "src/script/kernels/parser.js",
    "content": "/**\n * Created by shuding on 6/8/15.\n * <ds303077135@gmail.com>\n */\n\nvar Constant = require('script/kernels/constant');\nvar CPU      = require('script/kernels/cpu');\n\nmodule.exports = Parser;\n\nfunction Parser(text) {\n    if (typeof text !== 'string' && !(text instanceof String)) {\n        throw new Error('Type error at `new Parser`');\n    }\n\n    /**\n     * Initialization & parse .yo into lines of instructions\n     * @param parser\n     */\n    function init(parser) {\n        parser.raw     = text;\n        parser.syntaxs = [];\n        parser.map     = {};\n        parser.lines   = [];\n        parser.regLine = /^\\s*0[xX]([0-9a-fA-F]+)\\s*:\\s*([0-9a-fA-F]*)\\s*\\|.*$/;\n\n        parser.Constant = Constant;\n        parser.CPU      = new CPU();\n\n        text.split('\\n').forEach(function (rawLine, index) {\n            parser.syntaxs.push(rawLine);\n\n            var parts = rawLine.match(parser.regLine);\n            if (parts != null) {\n                if (parts[2].length % 2) {\n                    throw new Error('Address error at `Parse init`: ' + (index + 1));\n                }\n\n                try {\n                    var address     = parseInt(parts[1], 16);\n                    var instruction = parts[2];\n\n                    parser.map[address] = index;\n                    storeInstruction(parser, address, instruction);\n                } catch (err) {\n                    throw new Error('Format error at `Parse init`: ' + (index + 1));\n                }\n            }\n        });\n    }\n\n    function storeInstruction(parser, address, instruction) {\n        parser.lines.push([address, instruction]);\n\n        for (var offset = 0; offset < instruction.length; offset += 2, address += 1) {\n            parser.CPU.Memory.writeByte(address, parseInt(instruction.substr(offset, 2), 16));\n        }\n    }\n\n    init(this);\n}\n"
  },
  {
    "path": "src/script/kernels/register.js",
    "content": "/**\n * Created by shuding on 6/9/15.\n * <ds303077135@gmail.com>\n */\n\nvar Constant = require('script/kernels/constant');\nvar Utils    = require('script/kernels/utils');\n\nmodule.exports = {\n    Register:     Register,\n    PIPERegister: PIPERegister\n};\n\nfunction Register() {\n    /**\n     * Initialization: set all registers to 0\n     */\n    function init(register) {\n        Constant.REGISTERS.forEach(function (name) {\n            register[Constant[name]] = 0;\n        });\n    }\n\n    init(this);\n}\n\nRegister.prototype.get = function (name) {\n    if (!Utils.checkNumber(name)) {\n        if (typeof this[Constant[name]] === 'undefined') {\n            throw new Error('Register error undefined name: ' + name);\n        }\n        return this[Constant[name]];\n    }\n    return this[name];\n};\n\nRegister.prototype.set = function (name, value) {\n    if (!Utils.checkNumber(name)) {\n        if (typeof Constant[name] !== 'undefined' && name !== 'R_NONE') {\n            this[Constant[name]] = value;\n        } else {\n            return false;\n        }\n    }\n    if (!(0 <= name && name < 8))\n        return false;\n    this[name] = value;\n    return true;\n};\n\nfunction PIPERegister() {\n    var defaults = {\n        // Fetch\n        F_predPC:  0,\n        F_carryPC: -1,\n        F_stat:    Constant.STAT_AOK,\n\n        // Decode\n        D_icode:   Constant.I_NOP,\n        D_ifun:    0,\n        D_rA:      Constant.R_NONE,\n        D_rB:      Constant.R_NONE,\n        D_valC:    0,\n        D_valP:    0,\n        D_carryPC: -1,\n        D_stat:    Constant.STAT_BUB,\n\n        // Execute\n        E_icode:   Constant.I_NOP,\n        E_ifun:    0,\n        E_valC:    0,\n        E_valA:    0,\n        E_valB:    0,\n        E_dstE:    Constant.R_NONE,\n        E_dstM:    Constant.R_NONE,\n        E_srcA:    Constant.R_NONE,\n        E_srcB:    Constant.R_NONE,\n        E_carryPC: -1,\n        E_stat:    Constant.STAT_BUB,\n\n        // Memory\n        M_icode:   Constant.I_NOP,\n        M_valE:    0,\n        M_valA:    0,\n        M_dstE:    Constant.R_NONE,\n        M_dstM:    Constant.R_NONE,\n        M_stat:    Constant.STAT_BUB,\n        M_carryPC: -1,\n        M_Cnd:     false,\n\n        // Write Back\n        W_icode: Constant.I_NOP,\n        W_valE:  0,\n        W_valM:  0,\n        W_dstE:  Constant.R_NONE,\n        W_dstM:  Constant.R_NONE,\n        W_stat:  Constant.STAT_BUB\n    };\n\n    function init(register) {\n        for (var name in defaults) {\n            if (defaults.hasOwnProperty(name)) {\n                register[name] = defaults[name];\n            }\n        }\n    }\n\n    init(this);\n}\n\nPIPERegister.prototype.get = function (name) {\n    if (typeof this[name] === 'undefined') {\n        throw new Error('Register error undefined name: ' + name);\n    }\n    return this[name];\n};\n\nPIPERegister.prototype.set = function (name, value) {\n    if (typeof name == 'object') {\n        for (var key in name) {\n            if (name.hasOwnProperty(key)) {\n                if (Utils.checkNumber(name[key])) {\n                    this[key] = name[key];\n                }\n            }\n        }\n    } else {\n        if (!Utils.checkNumber(value)) {\n            return false;\n        }\n        this[name] = value;\n    }\n    return true;\n};\n"
  },
  {
    "path": "src/script/kernels/utils.js",
    "content": "/**\n * Created by shuding on 6/9/15.\n * <ds303077135@gmail.com>\n */\n\nmodule.exports = Util = {};\n\nUtil.checkNumber = function (data) {\n    data = +data;\n    return !isNaN(data) && data === parseInt(data);\n};\n\nUtil.checkByte = function (data) {\n    data = +data;\n    if (!Util.checkNumber(data))\n        return 0;\n    return 0 <= data && data < 256;\n};\n"
  },
  {
    "path": "src/style/board.css",
    "content": "\nboard, board.top-line {\n  position: absolute;\n  display: block;\n  left: 15px;\n  right: 15px;\n  top: 15px;\n  bottom: 15px;\n  padding: 10px;\n}\n\nboard small {\n  float: right;\n  font-size: 13px;\n}\n\n/* flexbox container */\nboard > div {\n  display: flex;\n  display: -webkit-flex;\n  flex-direction: column;\n  -webkit-flex-direction: column;\n  height: 100%;\n}"
  },
  {
    "path": "src/style/clock.css",
    "content": "\nclock {\n  display: inline-block;\n  padding: 2px 3px;\n}\n"
  },
  {
    "path": "src/style/code.css",
    "content": "\ncode-container {\n  flex-grow: 1;\n  -webikt-flex-grow: 1;\n  height: 100%;\n}\n\ncode-container > pre {\n  margin: 0;\n  padding: 2px;\n  max-height: calc(100% - 30px);\n  border: 1px solid #37F3FF;\n  white-space: inherit;\n  overflow: scroll;\n}\n\ncode-container > pre > code {\n  position: relative;\n  display: block;\n  min-width: 100%;\n  padding-bottom: 2px;\n  border-bottom: 1px solid;\n  font-size: 14px;\n}\n\ncode-container > h2 {\n  position: relative;\n  display: inline-block;\n  margin: 0 2px -3px 0;\n  padding: 0 10px;\n  cursor: pointer;\n  font-size: 1.2em;\n  max-width: 150px;\n  overflow: hidden;\n  white-space: nowrap;\n  text-overflow: ellipsis;\n}\n\ncode-container > h2:first-of-type {\n  margin-left: 10px;\n}\n\ncode-container > h2:not(.active):hover {\n  background-color: #005256;\n}\n\ncode-container .tab {\n  display: inline-block;\n  position: absolute;\n  width: 100%;\n  height: 100%;\n  left: 0;\n  z-index: -1;\n  border: 1px solid #2F6669;\n  border-bottom: none;\n  cursor: pointer;\n}\n\ncode-container input[type=file] {\n  position: absolute;\n  width: 100%;\n  height: 100%;\n  left: 0;\n  opacity: 0;\n  cursor: pointer;\n}\n\ncode-container h2.active {\n  color: #000;\n}\n\ncode-container h2.active .tab {\n  background-color: #37F3FF;\n  border: 1px solid #37F3FF;\n}\n\ncode-container .info {\n  font-size: 9px;\n  margin: 2px 0;\n  float: right;\n  color: rgba(55, 243, 255, 0.7);\n}\n\ncode-line-indicator {\n  position: absolute;\n  width: 100%;\n  height: 1.2em;\n  background-color: #016A6F;\n  mix-blend-mode: lighten;\n  transition: top 80ms ease-out;\n}\n\ncode-line {\n  display: block;\n  height: 1.2em;\n  white-space: pre;\n}\n\ncode-line:hover {\n  font-weight: 900;\n  color: #00F2FF;\n  background-color: #002B2D;\n}\n\ncode-line > span.line-number {\n  display: inline-block;\n  width: 30px;\n  padding-right: 4px;\n  text-align: right;\n  color: #00C2CE;\n  background-color: #002B2D;\n}\n\ncode-container:before {\n  content: '';\n  width: 3px;\n  height: 42px;\n  background: rgba(55, 243, 255, 0.8);\n  display: block;\n  position: absolute;\n  top: 48px;\n  margin-left: -3px;\n}\n\ncode-container:after {\n  content: '';\n  width: 1px;\n  height: 100px;\n  background: rgba(55, 243, 255, 0.5);\n  display: block;\n  position: absolute;\n  bottom: 25px;\n  margin-left: -3px;\n}\n"
  },
  {
    "path": "src/style/condition.css",
    "content": "\ncondition {\n  display: inline-block;\n  padding: 2px 3px;\n}\n"
  },
  {
    "path": "src/style/control.css",
    "content": "\ncontrol-container > div {\n  display: flex;\n  display: -webkit-flex;\n  width: 300px;\n  font-size: 0;\n  flex-direction: column;\n  -webkit-flex-direction: column;\n  -ms-flex-direction: column;\n  align-items: center;\n  -webkit-align-items: center;\n}\n\n/* Overwrites */\n\ncontrol-container input,\ncontrol-container input:focus,\ncontrol-container input:active,\ncontrol-container button {\n  border: none;\n  outline: none;\n  color: #37F3FF;\n  background: none;\n  -webkit-appearance: none;\n}\n\ncontrol-container input[type=text] {\n  width: 2em;\n  text-align: center;\n  border-bottom: 1px solid #186065;\n}\n\n/**/\n\nfrequency {\n  height: 30px;\n  line-height: 20px;\n  font-size: 12px;\n}\n\n#frequency-input {\n  width: 200px;\n  height: 1px;\n  vertical-align: middle;\n  -webkit-appearance: none;\n  background: #23868E;\n  cursor: pointer;\n  transition: all .3s ease;\n}\n\n#frequency-input::-webkit-slider-thumb {\n  width: 2px;\n  height: 15px;\n  -webkit-appearance: none;\n  background: #23868E;\n  cursor: pointer;\n  transition: all .3s ease;\n}\n\n#frequency-input::-moz-range-thumb {\n  width: 2px;\n  height: 15px;\n  background: #23868E;\n  border: none;\n  cursor: pointer;\n  transition: all .3s ease;\n}\n\n#frequency-input::-moz-range-track {\n  background: #23868E;\n}\n\n#frequency-input:hover, #frequency-input:active {\n  background: #21A0A7;\n}\n\n#frequency-input:hover::-webkit-slider-thumb {\n  height: 20px;\n  background: #37F3FF;\n}\n\n#frequency-input:active::-webkit-slider-thumb {\n  height: 20px;\n  background: #37F3FF;\n}\n\n#frequency-input:hover::-moz-range-thumb {\n  height: 20px;\n  background: #37F3FF;\n}\n\n#frequency-input:active::-moz-range-thumb {\n  height: 20px;\n  background: #37F3FF;\n}\n\nfrequency-label {\n  position: absolute;\n  bottom: 4px;\n  display: inline-block;\n  padding-left: 28px;\n  width: 50px;\n  font-size: 10px;\n  font-weight: 900;\n  text-align: left;\n  z-index: 1;\n}\n\n/* Buttons */\n\ncontrol-container button {\n  min-width: 35px;\n  padding: 6px 9px;\n  text-align: center;\n  font-size: 18px;\n  font-weight: bolder;\n  font-family: inherit;\n  border: 1px solid rgba(0, 0, 0, 0);\n  -webkit-font-smoothing: subpixel-antialiased;\n  cursor: pointer;\n  transition: all .2s ease;\n}\n\ncontrol-container button:hover {\n  color: #37F3FF;\n  border-top: 1px solid #07939C;\n  background-color: rgba(55, 243, 255, 0.08);\n}\n\ncontrol-container {\n  position: relative;\n  display: block;\n}\n\n"
  },
  {
    "path": "src/style/cpi.css",
    "content": "cpi-container {\n  display: block;\n}\n\ncpi-container > div {\n  display: flex;\n  display: -webkit-flex;\n  position: relative;\n  margin-right: 20px;\n  box-shadow: 0 0 0 1px #23868E;\n}\n\ncpi-container > h6 {\n  position: absolute;\n  margin: 0;\n  padding: 3px;\n  z-index: 1;\n}\n\ncpi-container > div > canvas {\n  width: 100%;\n  height: 50px;\n}\n\n#cpi-input {\n  position: absolute;\n  width: 100%;\n  height: 50px;\n  margin: 0;\n  vertical-align: middle;\n  -webkit-appearance: none;\n  background: transparent;\n  cursor: pointer;\n  outline: none;\n  transition: all .3s ease;\n}\n\n#cpi-input::-webkit-slider-thumb {\n  width: 1px;\n  height: 50px;\n  -webkit-appearance: none;\n  background: #23868E;\n  cursor: pointer;\n  transition: all .3s ease;\n}\n\n#cpi-input::-moz-range-thumb {\n  width: 1px;\n  height: 50px;\n  background: #23868E;\n  border: none;\n  cursor: pointer;\n  transition: all .3s ease;\n}\n\n#cpi-input::-moz-range-track {\n  background: #23868E;\n}\n\n#cpi-input:hover::-webkit-slider-thumb {\n  background: #37F3FF;\n}\n\n#cpi-input:active::-webkit-slider-thumb {\n  background: #37F3FF;\n}\n\n#cpi-input:hover::-moz-range-thumb {\n  background: #37F3FF;\n}\n\n#cpi-input:active::-moz-range-thumb {\n  background: #37F3FF;\n}\n"
  },
  {
    "path": "src/style/main.css",
    "content": "@font-face {\n  font-family: 'Jura';\n  font-weight: 100;\n  src: url(../font/Jura/Jura-Light.ttf);\n}\n\n@font-face {\n  font-family: 'Jura';\n  font-weight: 300;\n  src: url(../font/Jura/Jura-Regular.ttf);\n}\n\n@font-face {\n  font-family: 'Jura';\n  font-weight: 600;\n  src: url(../font/Jura/Jura-Medium.ttf);\n}\n\n@font-face {\n  font-family: 'Jura';\n  font-weight: 900;\n  src: url(../font/Jura/Jura-DemiBold.ttf);\n}\n\n/* Overwrites */\n\n* {\n  box-sizing: border-box;\n  -webkit-box-sizing: border-box;\n}\n\n::selection {\n  background: none;\n}\n\n::-webkit-scrollbar {\n  display: none;\n}\n\nbody {\n  position: absolute;\n  top: 0;\n  left: 0;\n  width: 100%;\n  height: 100%;\n  min-width: 960px;\n  min-height: 580px;\n  margin: 0;\n  font-family: 'Jura', sans-serif;\n  color: #37F3FF;\n  overflow: hidden;\n  font-kerning: auto;\n  -moz-osx-font-smoothing: grayscale;\n  -webkit-font-smoothing: antialiased;\n  font-feature-settings: \"liga\" 0;\n  background: #0B0B0B;\n  background-image: url(/src/style/bg.png);\n  background-size: 20px 20px;\n  box-shadow: 0 0 20px 30px rgba(0, 0, 0, 0.5) inset;\n}\n\nbody:before, body:after {\n  content: '';\n  display: block;\n  position: fixed;\n  width: 120vmin;\n  height: 120vmin;\n  pointer-events: none;\n  margin: auto;\n  left: 50%;\n  top: 50%;\n  border-radius: 100%;\n  border: 1px solid rgba(104, 246, 255, 0.22);\n  border-right-style: dashed;\n  border-left-style: dashed;\n  box-shadow: 0 0 0 10px rgba(55, 243, 255, 0.05);\n  -webkit-transform: translate(-50%, -50%);\n  -moz-transform: translate(-50%, -50%);\n  -ms-transform: translate(-50%, -50%);\n  transform: translate(-50%, -50%);\n  z-index: -1;\n}\n\nbody:before {\n  width: calc(100vmax - 10px);\n  height: calc(100vmax - 10px);\n  border-color: #008288;\n  border-style: dotted;\n  box-shadow: 0 0 100px rgba(55, 243, 255, 0.2), 0 0 100px rgb(0, 0, 0) inset;\n}\n\nh1, h2, h3, p, span, small, div {\n  cursor: default;\n}\n\ncode, code span {\n  cursor: text;\n}\n\nh1, h2 {\n  margin: 0;\n  font-weight: 600;\n  text-shadow: 0 0 10px rgba(55, 243, 255, 0.6);\n}\n\nh1 {\n  float: right;\n  text-align: center;\n}\n\nh3 {\n  display: inline-block;\n  margin-bottom: 0;\n  padding-bottom: 2px;\n  border-bottom: 3px double #0E7379;\n}\n\na {\n  display: inline-block;\n  color: #1CF2FF;\n  text-decoration: none;\n}\n\n.shadow-bg {\n  background: rgba(0, 0, 0, 0.4);\n}\n\n.top-line {\n  position: relative;\n  border-top: 1px solid #0E7379;\n}\n\n.top-line:before {\n  content: \"\";\n  position: absolute;\n  display: block;\n  left: 2px;\n  top: -3px;\n  width: 1px;\n  height: 5px;\n  background-color: #17C3CD;\n}\n\n.top-line:after {\n  content: \"\";\n  position: absolute;\n  display: block;\n  right: 2px;\n  top: -3px;\n  width: 1px;\n  height: 5px;\n  background-color: #17C3CD;\n}\n\n.top-dotted {\n  margin: 5px 2px 0 2px;\n  border-top: 3px double #18474A;\n}\n\n.container {\n  padding: 10px;\n}\n\n.container-line > div {\n  padding: 5px;\n}\n\n.container-left {\n  text-align: left;\n}\n\n.container-left > h3 {\n  padding-right: 4px;\n}\n\n.container-right > h3 {\n  padding-left: 4px;\n}\n\n.container-right {\n  text-align: right;\n}\n\n.container-left > div {\n  border-left: 1px solid #0E7379;\n  padding-bottom: 15px;\n}\n\n.container-right > div {\n  border-right: 1px solid #0E7379;\n  padding-bottom: 15px;\n}\n\nflex-container {\n  display: flex;\n  display: -webkit-flex;\n  align-items: flex-start;\n  -webkit-align-items: flex-start;\n  -ms-align-items: flex-start;\n}\n\n.tool-sidebar {\n  height: 100%;\n  display: flex;\n  display: -webkit-flex;\n  flex-direction: column;\n  -webkit-flex-direction: column;\n}\n\n.flex-grow {\n  flex: 1;\n  -webkit-flex: 1;\n  padding: 10px 0;\n  overflow: hidden;\n}\n\n/**/\n\nboard {\n  perspective: 900px;\n}\n\nregister-container {\n  display: block;\n}\n\nstack-container {\n  display: block;\n}\n\ncode-container {\n}\n\nclock-container {\n  display: block;\n}\n\ncondition-container {\n  display: block;\n}\n\n/* 3D */\n\n.rot-top {\n  transform: rotateX(-15deg) scaleY(0.95);\n}\n\n.rot-left {\n  transform: rotateY(10deg) scaleX(0.9);\n}\n\n.rot-right {\n  transform: rotateY(-10deg) scaleX(0.9);\n}\n"
  },
  {
    "path": "src/style/pipe.css",
    "content": "/**\n* Created by shuding on 6/10/15.\n* <ds303077135@gmail.com>\n*/\nfetch, decode, execute, memory, write-back {\n  display: flex;\n  display: -webkit-flex;\n  width: 100%;\n}\n\nfetch > h3, decode > h3, execute > h3, memory > h3, write-back > h3 {\n  width: 120px;\n  flex: 0 0 120px;\n  text-align: center;\n  border: none;\n}\n\nfetch > div, decode > div, execute > div, memory > div, write-back > div {\n  display: flex;\n  display: -webkit-flex;\n  flex: 1;\n  -webkit-flex: 1;\n  align-items: center;\n  -webkit-align-items: center;\n}\n\npipe-attr {\n  display: block;\n  width: 10%;\n  max-width: 150px;\n  padding: 2px 5px;\n}\n\npipe-attr h6, pipe-attr p {\n  margin: 0;\n}\n\npipe-attr h6 {\n  color: #00b6c1;\n}\n\npipe-attr:hover {\n  box-shadow: 0 0 0 1px rgb(54, 243, 255) inset;\n}\n"
  },
  {
    "path": "src/style/register.css",
    "content": "\nregister-container {\n  padding: 10px;\n}\n\nregister-container > div {\n  max-height: calc(100% - 40px);\n  overflow: scroll;\n}\n\nregister {\n  display: block;\n}\n\n.register-name {\n  color: #188188;\n  font-size: 13px;\n  font-weight: 900;\n}\n\n.register-data {\n  font-family: 'Jura', 'Courier New', monospace;\n}\n"
  },
  {
    "path": "src/style/stack.css",
    "content": "\nstack-container > div {\n  max-height: calc(100% - 40px);\n  font-family: 'Jura', 'Courier New', monospace;\n  overflow: scroll;\n}\n\nstack > div > span:last-of-type {\n  font-weight: 900;\n  color: #0ADCE6;\n  border-left: 1px solid;\n  padding-left: 3px;\n  margin-left: 3px;\n}\n"
  },
  {
    "path": "src/test/Forward.yo",
    "content": "  0x0000: 30820a000000 | irmovl $10,%edx\n  0x0006: 308203000000 | irmovl $3,%edx\n  0x000c: 2020         | rrmovl %edx,%eax\n  0x000e: 10           | halt\n                       | "
  },
  {
    "path": "src/test/Halt.yo",
    "content": "  0x0000: 308001000000 | irmovl $1,%eax\n  0x0006: 10           | halt\n  0x0007: 308301000000 | irmovl $1,%ebx\n                       | "
  },
  {
    "path": "src/test/List_Sum.yo",
    "content": "  0x0000: 308400020000 | irmovl Stack, %esp\n  0x0006: 308500020000 | irmovl Stack, %ebp\n  0x000c: 702c000000   | jmp main\n  0x0011:              | .align 4\n                       | \n  0x0014:              | ele1:\n  0x0014: 0a000000     | .long 0x00a\n  0x0018: 1c000000     | .long ele2\n  0x001c:              | ele2:\n  0x001c: b0000000     | .long 0x0b0\n  0x0020: 24000000     | .long ele3\n  0x0024:              | ele3:\n  0x0024: 000c0000     | .long 0xc00\n  0x0028: 00000000     | .long 0\n                       | \n  0x002c:              | main:\n  0x002c: 308214000000 | irmovl ele1,%edx\n  0x0032: a028         | pushl %edx\n  0x0034: 803a000000   | call sum_list\n  0x0039: 10           | halt\n                       | \n  0x003a:              | sum_list:\n  0x003a: a058         | pushl %ebp\n  0x003c: 2045         | rrmovl %esp,%ebp\n  0x003e: 6300         | xorl %eax,%eax\n  0x0040: 502508000000 | mrmovl 8(%ebp),%edx\n  0x0046: 6222         | andl %edx,%edx\n  0x0048: 7362000000   | je L3\n  0x004d:              | L6:\n  0x004d: 501200000000 | mrmovl (%edx),%ecx\n  0x0053: 6010         | addl %ecx,%eax\n  0x0055: 502204000000 | mrmovl 4(%edx),%edx\n  0x005b: 6222         | andl %edx,%edx\n  0x005d: 744d000000   | jne L6\n  0x0062:              | L3:\n  0x0062: 2054         | rrmovl %ebp,%esp\n  0x0064: b058         | popl %ebp\n  0x0066: 90           | ret\n  0x0067:              | .pos 0x200\n  0x0200:              | Stack:\n                       | "
  },
  {
    "path": "src/test/asum.yo",
    "content": "                      | /* $begin code-yso */\n                      | /* $begin code-ysa */\n                      | # Execution begins at address 0\n  0x000:              | \t.pos 0\n  0x000: 308400010000 | init:\tirmovl Stack, %esp  \t# Set up Stack pointer\n  0x006: 308500010000 | \tirmovl Stack, %ebp  \t# Set up base pointer\n  0x00c: 7024000000   | \tjmp Main\t\t# Execute main program\n                      |\n                      | # Array of 4 elements\n  0x014:              | \t.align 4\n  0x014: 0d000000     | array:\t.long 0xd\n  0x018: c0000000     | \t.long 0xc0\n  0x01c: 000b0000     | \t.long 0xb00\n  0x020: 00a00000     | \t.long 0xa000\n                      |\n  0x024: 308004000000 | Main:\tirmovl $4,%eax\n  0x02a: a008         | \tpushl %eax\t# Push 4\n  0x02c: 308214000000 | \tirmovl array,%edx\n  0x032: a028         | \tpushl %edx      # Push array\n  0x034: 803a000000   | \tcall Sum\t# Sum(array, 4)\n  0x039: 10           | \thalt\n                      |\n                      | /* $begin sum-ys 0 */\n                      | \t# int Sum(int *Start, int Count)\n  0x03a: a058         | Sum:\tpushl %ebp\n  0x03c: 2045         | \trrmovl %esp,%ebp\n  0x03e: 501508000000 | \tmrmovl 8(%ebp),%ecx \t# ecx = Start\n  0x044: 50250c000000 | \tmrmovl 12(%ebp),%edx\t# edx = Count\n  0x04a: 308000000000 | \tirmovl $0, %eax\t\t# sum = 0\n  0x050: 6222         | \tandl   %edx,%edx\n  0x052: 7374000000   | \tje     End\n  0x057: 506100000000 | Loop:\tmrmovl (%ecx),%esi      # get *Start\n  0x05d: 6060         | \taddl %esi,%eax          # add to sum\n  0x05f: 308304000000 | \tirmovl $4,%ebx          #\n  0x065: 6031         | \taddl %ebx,%ecx          # Start++\n  0x067: 3083ffffffff | \tirmovl $-1,%ebx\t        #\n  0x06d: 6032         | \taddl %ebx,%edx          # Count--\n  0x06f: 7457000000   | \tjne    Loop             # Stop when 0\n  0x074:              | End:\n  0x074: b058         | \tpopl %ebp\n  0x076: 90           | \tret\n                      | /* $end sum-ys 0 */\n  0x100:              | \t.pos 0x100\n  0x100:              | Stack:\t# The stack goes here\n                      | /* $end code-ysa */\n                      | /* $end code-yso */\n"
  }
]