Skip to content

Commit d3f2eec

Browse files
committed
added clobbered registers for customasm-toolbox extension
1 parent b03c8a3 commit d3f2eec

File tree

6 files changed

+223
-170
lines changed

6 files changed

+223
-170
lines changed

.customasm.json

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
11
{
2-
"ruleDefinitions": ["./asm/rules.asm"]
2+
"ruleDefinitions": ["./asm/rules.asm"],
3+
"showClobberedRegisters": true,
4+
"clobberedRegisterInstructions": [
5+
{
6+
"mnemonic": "call",
7+
"clobberedRegisters": ["TMP"]
8+
},
9+
{
10+
"mnemonic": "ret",
11+
"clobberedRegisters": ["A", "TMP"]
12+
},
13+
{
14+
"mnemonic": "decm",
15+
"clobberedRegisters": ["A", "TMP"]
16+
},
17+
{
18+
"mnemonic": "incm",
19+
"clobberedRegisters": ["A", "TMP"]
20+
},
21+
{
22+
"mnemonic": "jmpind",
23+
"clobberedRegisters": ["A", "TMP"]
24+
},
25+
{
26+
"mnemonic": "ldo",
27+
"clobberedRegisters": ["A", "TMP"]
28+
},
29+
{
30+
"mnemonic": "ldsprel",
31+
"clobberedRegisters": ["A", "TMP"]
32+
},
33+
{
34+
"mnemonic": "sto",
35+
"clobberedRegisters": ["A", "TMP"]
36+
},
37+
{
38+
"mnemonic": "stsprel",
39+
"clobberedRegisters": ["A", "TMP"]
40+
}
41+
]
342
}

docs/src/Instruction/Instruction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default abstract class Instruction {
6666

6767
abstract getExecutedInstructions(): REALInstruction[];
6868

69-
abstract getModifiedRegisters(): Set<string>; //TODO X-Register not showing up? (see e.g. clobbered registers for incm)
69+
abstract getModifiedRegisters(): Set<string>;
7070

7171
getClobberedRegisters() {
7272
const nonClobberedRegisters = ["PC_L", "PC_H", "MAR_L", "MAR_H", "IR", "SP_L", "SP_H", "F", "7SD", "<reg>", "<regd>", "BUF"];

docs/src/Instruction/PSEUDOInstruction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default class PSEUDOInstruction extends Instruction {
2525
for (const mappedInstruction of this.getMappedInstructions()) {
2626
let match;
2727
let mappedInstructionString = mappedInstruction.instanceString();
28+
mappedInstructionString = mappedInstructionString.replaceAll("nextInstructionAddress", ""); //prevents "call" from including "A" as modified
2829
while ((match = REGISTER_REGEX.exec(mappedInstructionString))) {
2930
const register = match[1];
3031
modifiedRegisters.add(register);

docs/src/Instruction/REALInstruction.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ export default class REALInstruction extends Instruction {
4545
if ((match = /IE_(.*)|li (\w+),/.exec(controlString))) {
4646
modifiedRegisters.add(match[1]);
4747
}
48+
49+
if (controlString.includes("RST_TMP")) {
50+
modifiedRegisters.add("TMP");
51+
}
4852
}
4953
}
5054
}

docs/src/PageLoader/loadInstructionDetails.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ async function createAndFillTables() {
1212
const descriptionElements = await getDescriptions(sortedInstructions.map((instruction) => instruction.getMnemonic()));
1313

1414
for (const instruction of sortedInstructions) {
15+
// print clobbered registers for the entry in .customasm.json
16+
/* if (instruction.getClobberedRegisters().size > 0) {
17+
console.log(
18+
`{ "mnemonic": "${instruction.getMnemonic()}", "clobberedRegisters": [${Array.from(instruction.getClobberedRegisters())
19+
.map((reg) => `"${reg}"`)
20+
.join(", ")}] },`,
21+
);
22+
} */
23+
1524
const instructionDetailSection = createHTMLInstructionDetailSection(
1625
instruction,
1726
descriptionElements.get(instruction.getMnemonic()) as HTMLElement,

0 commit comments

Comments
 (0)