Skip to content
Browse files

Updated the tabulate.

  • Loading branch information...
1 parent 173f5c0 commit 886b7eb0ffa61a9130359cfeb3d1a42f9fa20cb8 @RuneTekk committed
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/org/sini/Dasm.java
View
10 src/org/sini/Dasm.java
@@ -15,14 +15,16 @@
public String disassemble(int[] memory) {
String code = "";
int position = 0;
- boolean tabulate = false;
+ int tabulate = 0;
while(position < memory.length) {
int opcodeValue = memory[position++];
int insnOpcode = (opcodeValue & 0xF) != 0 ? opcodeValue & 0xF : opcodeValue & 0x3F0;
int arguments = (insnOpcode & 0xF) == 0 ? 1 : 2;
boolean doTabulate = insnOpcode >= Ops.OP_IFE && insnOpcode <= Ops.OP_IFB ? true : false;
- code += (tabulate ? " " : "") + Ops.OP_NAMES[insnOpcode] + " ";
- tabulate = false;
+ for(int tab = 0; tab < tabulate; tab++)
+ code += " ";
+ code += Ops.OP_NAMES[insnOpcode] + " ";
+ tabulate = tabulate < 1 ? 0 : --tabulate;
for(int argument = 0; argument < arguments; argument++) {
code += argument > 0 ? " " : "";
int valueOpcode = (opcodeValue & 0xF) == 0 ? opcodeValue >> 10 : argument == 0 ? opcodeValue >> 4 & 0x3F : opcodeValue >> 10;
@@ -32,7 +34,7 @@ public String disassemble(int[] memory) {
}
code += valueName;
}
- tabulate = doTabulate;
+ tabulate = doTabulate ? tabulate + 1 : tabulate;
code += position < memory.length ? "\n" : "";
}
return code;

0 comments on commit 886b7eb

Please sign in to comment.
Something went wrong with that request. Please try again.