Bitmask table
[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 emit("bitmask", function(a,b){return ("00000000"+((a<<4)|b).toString(2)).substr(-8,8)});
13
14 function emit(name, func) {
15 var emission = [];
16
17 for(var i = 0; i < 256; ++i) {
18 var a = (i & 0xF0) >> 4;
19 var b = (i & 0x0F) >> 0;
20 emission.push(func(a,b));
21 }
22
23 fs.writeFileSync("bin/" + name + ".txt", emission.join("\n"));
24 }
This page took 0.120669 seconds and 4 git commands to generate.