463e2d23e652de7a98eed4d4ec195a52aa61effb
[ScratchNES.git] / src / CPU / build-crement.js
1 /* INC style instructions */
2
3 var fs = require("fs");
4
5 var registers = {
6 "M": ["INC", "DEC"],
7 "X": ["INX", "DEX"],
8 "Y": ["INY", "DEY"]
9 };
10
11 for(var reg in registers) {
12 emit(reg, registers[reg][0], 0);
13 emit(reg, registers[reg][1], 1);
14 }
15
16 function emit(register, name, value) {
17 var emission = [];
18
19 if(register == "M") {
20 emission.push("RW, N, Z, OP");
21 emission.push("set OP to (OP " + (value ? "-" : "+") + " 1) mod 256");
22 } else {
23 emission.push("IMPLIED," + register + ",N,Z," + register);
24 emission.push("set " + register + " to (" + register + " " + (value ? "-" : "+") + " 1) mod 256");
25 }
26
27 fs.writeFileSync("instructions/" + name, emission.join("\n"));
28 }
This page took 0.063325 seconds and 3 git commands to generate.