Skip to content

Commit

Permalink
Fixed absolute branches again but this time with branch prediction su…
Browse files Browse the repository at this point in the history
…pport
  • Loading branch information
TheGag96 committed Jan 30, 2017
1 parent 2e20af3 commit 7404980
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class Application : TkdApplication {
}

////
//Fix output
//Fix and prettify output
////
auto fixed = appender!(string[]);
bool[uint] labelTable = [0 : true];
Expand All @@ -350,14 +350,20 @@ class Application : TkdApplication {
bool madeFix = false;

try {
//branch instructions get a label made for their jump location
if (line.startsWith('b')) {
string opcode = line[0..line.countUntil(' ')];

uint jumpLocation = line[opcode.length+3 .. $].to!int(16);

if (jumpLocation > codeSize) {
if (opcode.endsWith('a')) fixed.put(format(" %s 0x%X\n", opcode, jumpLocation));
else fixed.put(format(" %s 0x%X\n", opcode, jumpLocation-pos));
//check for absolute branches
if (opcode.endsWith('a') || opcode.endsWith("a+") || opcode.endsWith("a-")) {
fixed.put(format(" %s 0x%X\n", opcode, jumpLocation));
}
else {
fixed.put(format(" %s 0x%X\n", opcode, jumpLocation-pos));
}
}
else {
labelTable[jumpLocation] = true;
Expand All @@ -367,6 +373,8 @@ class Application : TkdApplication {
madeFix = true;
}
else if (IMMEDIATES.canFind(line[0..line.countUntil(' ')])) {
//convert most immediate values to hex

string unedited = line[0..line.lastIndexOf(',')+1];
int value = line[unedited.length..$].to!int & 0xFFFF;

Expand Down

0 comments on commit 7404980

Please sign in to comment.