53707ee39a45b24e07d86fcef4125ad2857e30d8
[ScratchNES.git] / src / CPU / build-transfer.js
1 /* builds TAX-family instructions */
2 /* note these get a little funky because of differences in encoding */
3
4 var fs = require("fs");
5
6 var list = ["AX", "AY", "SX", "XA", "XS", "YA"];
7 list.forEach(emit);
8
9 function emit(name) {
10 var emission = [
11 "IMPLIED"
12 ];
13
14 if(name.indexOf("S") > -1) {
15 if(name[0] == "S") {
16 // transfer stack in
17 // encode it to hex
18 emission.push("set " + name[0] + "to item (" + name[1] + "+1) of hex");
19 } else {
20 // transfer stack out
21 // decode hex
22 emission.push("set " + name[0] + "to (join \"0x\" (" + name[1] + "))");
23 }
24 } else {
25 emission.push("set " + name[0] + " to " + name[1]);
26 }
27
28 fs.writeFileSync("instructions/T" + name, emission.join("\n"));
29 }
This page took 0.064095 seconds and 3 git commands to generate.