6dd26a240bdf0b5ec277cbff4fefdf0ad9f3f642
[ScratchNES.git] / src / CPU / branch-maker.js
1 /**
2 * branch-maker.js
3 * look at the name
4 * it makes branches :P
5 */
6
7 var fs = require("fs");
8
9 // flag: [clear, set]
10
11 var branches = {
12 "C": ["BCC", "BCS"],
13 "Z": ["BNE", "BEQ"],
14 "V": ["BVC", "BVS"],
15 "N": ["BPL", "BMI"]
16 };
17
18 function emit(name, flag, value) {
19 var emission = [];
20
21 // header
22 emission.push("BRANCH");
23 emission.push("mapper read PC+1");
24
25 // emission
26 var flagNum = value ? flag : "(1 - " + flag + ")";
27
28 emission.push(
29 "change PC by " +
30 flagNum +
31 " * (M + 256 * (<M < 128> - 1))"
32 );
33
34 console.log(emission.join("\n"));
35 }
36
37 for(var flag in branches) {
38 emit(branches[flag][0], flag, 0);
39 emit(branches[flag][1], flag, 0);
40 }
This page took 0.0643049999999999 seconds and 3 git commands to generate.