69796468d1882526111919adb380c52aefe0d512
[ScratchNES.git] / src / CPU / build-lookups.js
1 /*
2 * build-lookups.js
3 * builds lookup tables for bitwise operations
4 */
5
6 var fs = require("fs");
7
8 emit("EOR", function(a,b){return a^b});
9 emit("ORA", function(a,b){return a|b});
10 emit("AND", function(a,b){return a&b});
11 emit("hex", function(a,b){return ((a<<4)|b).toString(16)});
12
13 function emit(name, func) {
14 var emission = [];
15
16 for(var i = 0; i < 256; ++i) {
17 var a = (i & 0xF0) >> 4;
18 var b = (i & 0x0F) >> 0;
19 emission.push(func(a,b));
20 }
21
22 fs.writeFileSync("bin/" + name + ".txt", emission.join("\n"));
23 }
This page took 0.059729 seconds and 3 git commands to generate.