diff --git a/README.md b/README.md index abf7cb5..130b659 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Simple 8-bit Assembler Simulator A simulator which provides a simplified assembler syntax (based on NASM) and is simulating a x86 like cpu. Press Help inside the simulator to see an overview about the supported instructions. -####TRY IT ONLINE +####TRY IT ONLINE ### Features - 8-bit CPU @@ -13,13 +13,11 @@ A simulator which provides a simplified assembler syntax (based on NASM) and is Make sure you have Grunt installed to compile the `asmsimulator.js` script. Run `grunt` to build the project. -### Background -A technical introduction is available on my blog: [www.mschweighauser.com](https://www.mschweighauser.com/make-your-own-assembler-simulator-in-javascript-part1/). ### License **The MIT License** -Copyright (c) 2015 Marco Schweighauser +Copyright (c) 2015 Marco Veera Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/assets/asmsimulator.js b/assets/asmsimulator.js index 4d04f8c..1c811e4 100644 --- a/assets/asmsimulator.js +++ b/assets/asmsimulator.js @@ -692,19 +692,19 @@ var app = angular.module('ASMSimulator', []); var indirectRegisterAddress = function(value) { var reg = value % 8; - + var base; if (reg < self.gpr.length) { base = self.gpr[reg]; } else { base = self.sp; } - + var offset = Math.floor(value / 8); if ( offset > 15 ) { offset = offset - 32; } - + return base+offset; }; @@ -760,7 +760,7 @@ var app = angular.module('ASMSimulator', []); if (self.ip < 0 || self.ip >= memory.data.length) { throw "Instruction pointer is outside of memory"; } - + var regTo, regFrom, memFrom, memTo, number; var instr = memory.load(self.ip); switch(instr) { @@ -1440,6 +1440,7 @@ var app = angular.module('ASMSimulator', []); try { $scope.reset(); + $scope.code=angular.element($('#sourceCode')).val(); var assembly = assembler.go($scope.code); $scope.mapping = assembly.mapping; var binary = assembly.code; diff --git a/favico.ico b/favico.ico new file mode 100644 index 0000000..a85c0f8 Binary files /dev/null and b/favico.ico differ diff --git a/fontHack.js b/fontHack.js new file mode 100644 index 0000000..4d2b1dd --- /dev/null +++ b/fontHack.js @@ -0,0 +1,38 @@ +/* +* The Typekit service used to deliver this font or fonts for use on websites +* is provided by Adobe and is subject to these Terms of Use +* http://www.adobe.com/products/eulas/tou_typekit. For font license +* information, see the list below. +* +* source-code-pro: +* - http://typekit.com/eulas/0000000000000000000179cf +* +* © 2009-2017 Adobe Systems Incorporated. All Rights Reserved. +*/ +if(!window.Typekit)window.Typekit={};window.Typekit.config={"a":"9089820","c":[".tk-source-code-pro","\"source-code-pro\",sans-serif"],"dl":"AAAAOgAAAApV7OIGA94rKA","fi":[17454],"fc":[{"id":17454,"family":"source-code-pro","src":"https://use.typekit.net/af/32c94c/0000000000000000000179cf/27/{format}{?primer,subset_id,fvd,v}","descriptors":{"weight":"400","style":"normal","subset_id":1}}],"fn":["source-code-pro",["n4"]],"hn":"use.typekit.net","ht":"tk","js":"1.18.24","kt":"hpv3aoy","l":"typekit","ps":1,"ping":"https://p.typekit.net/p.gif{?s,k,ht,h,f,a,js,app,e,_}","pm":true,"type":"configurable"}; +/*{"k":"1.18.24","auto_updating":true,"last_published":"2017-09-24 05:07:28 UTC"}*/ +;(function(window,document,undefined){if(!document.querySelector){document.documentElement.className+=" wf-inactive";return;}function aa(a,b,c){return a.call.apply(a.bind,arguments)}function ba(a,b,c){if(!a)throw Error();if(2>>16)*b&65535)<<16)};function t(a,b){this.b=b||Array(Math.ceil(a/32));if(!b)for(var c=0;cthis.b.length)throw Error("Index is out of bounds.");var b=Math.floor(a/32);this.b[b]|=1<this.b.length)throw Error("Index is out of bounds.");var b=Math.floor(a/32);return!!(this.b[b]&1<>>17,d=r(d,461845907),d^=ga[c]||0,d=d<<13|d>>>19,d=r(d,5)+3864292196,d^=4,d^=d>>>16,d=r(d,2246822507),d^=d>>>13,d=r(d,3266489909),d^=d>>>16,d=(d>>>0)%this.b;else{d=ga[c]||0;var e,f,g=a.length%4,k=a.length-g;for(f=0;f>>17,e=r(e,461845907),d^=e,d=d<<13|d>>>19,d=r(d,5)+3864292196;e=0;switch(g){case 3:e^=(a.charCodeAt(f+2)&4294967295)<<16;case 2:e^=(a.charCodeAt(f+1)&4294967295)<<8;case 1:e^=(a.charCodeAt(f+0)&4294967295)<<0,e=r(e,3432918353),e=e<<15|e>>>17,e=r(e,461845907),d^=e}d^=a.length;d=r(d^d>>>16,2246822507);d=r(d^d>>>13,3266489909);d=((d^d>>>16)>>>0)%this.b}if(!this.g.has(d))return!1}return!0};function ha(a){a.length%4&&(a+=Array(5-a.length%4).join("="));a=a.replace(/\-/g,"+").replace(/\_/g,"/");if(window.atob)a=window.atob(a);else{a=a.replace(/=+$/,"");if(1==a.length%4)throw Error("'atob' failed: The string to be decoded is not correctly encoded.");for(var b=0,c,d,e=0,f="";d=a.charAt(e++);~d&&(c=b%4?64*c+d:d,b++%4)?f+=String.fromCharCode(255&c>>(-2*b&6)):0)d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(d);a=f}c=[];for(b=0;ba.documentMode:1))b="i";else{a:{if(/AppleWebKit/.test(b)&&/Android/.test(b)&&!/OPR|Chrome|CrMo|CriOS/.test(b)&&(a=/Android ([^;)]+)/.exec(b))&&a[1]){a=parseFloat(a[1]);a=3.1<=a&&4.1>a;break a}a=!1}if(!a)a:{if(/Silk/.test(b)&&/Linux|Ubuntu|Android/.test(b)&&(b=/Silk\/([\d\._]+)/.exec(b))&&b[1]){a=2<=parseFloat(b[1]);break a}a=!1}b=a?"j":"k"}return b};function H(a){this.b=a}function I(a,b){return a.b.replace(/\{([^\{\}]+)\}/g,function(a,d){if("?"==d.charAt(0)){for(var e=d.slice(1).split(","),f=[],g=0;gparseInt(a[1],10)||536===parseInt(a[1],10)&&11>=parseInt(a[2],10))}return Q}ua.prototype.start=function(){this.g.serif=this.m.b.offsetWidth;this.g["sans-serif"]=this.o.b.offsetWidth;this.F=m();wa(this)};function xa(a,b,c){for(var d in P)if(P.hasOwnProperty(d)&&b===a.g[P[d]]&&c===a.g[P[d]])return!0;return!1} +function wa(a){var b=a.i.b.offsetWidth,c=a.j.b.offsetWidth,d;(d=b===a.g.serif&&c===a.g["sans-serif"])||(d=va()&&xa(a,b,c));d?m()-a.F>=a.I?va()&&xa(a,b,c)&&(!a.A||a.A.hasOwnProperty(a.b.b))?R(a,a.D):R(a,a.H):ya(a):R(a,a.D)}function ya(a){setTimeout(h(function(){wa(this)},a),50)}function R(a,b){setTimeout(h(function(){y(this.i.b);y(this.j.b);y(this.m.b);y(this.o.b);b(this.b)},a),0)};function za(a,b,c,d,e,f,g){this.i=a;this.u=b;this.b=d;this.m=c;this.g=e||3E3;this.o=f||void 0;this.j=g}za.prototype.start=function(){var a=this.m.g.document,b=this,c=m(),d=new Promise(function(d,e){function k(){m()-c>=b.g?e():a.fonts.load(b.b.style+" "+b.b.weight+" 300px "+(b.j?F(b.b):b.b.b),b.o).then(function(a){1<=a.length?d():setTimeout(k,25)},function(){e()})}k()}),e=new Promise(function(a,c){setTimeout(c,b.g)});Promise.race([e,d]).then(function(){b.i(b.b)},function(){b.u(b.b)})};function S(a,b,c,d){this.w=a;this.b=b;this.g=0;this.o=this.m=!1;this.A=c;this.u=d}var T=null; +function Aa(a,b,c){var d={},e=b.b.length;if(!e&&c)C(a.b);else{a.g+=e;c&&(a.m=c);var f=[];K(b,function(b){var c=a.b;c.i&&z(c.g,[c.b.b("wf",b.b,E(b),"loading")]);D(c,"fontloading",b);c=null;if(null===T)if(window.FontFace){var e=/Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent),p=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))(?:\.([0-9]+))/.exec(window.navigator.userAgent);T=e?42 + Simple 8-bit Assembler Simulator in Javascript + - - + + + + + + + + + - Fork me on GitHub + Fork me on GitHub