Skip to content

Commit

Permalink
Fixed the implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowsAdi committed Mar 10, 2024
1 parent aa41773 commit 7b61bb5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
15 changes: 7 additions & 8 deletions src/main/java/lysis/builder/MethodParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
import lysis.instructions.LZeroGlobal;
import lysis.instructions.LZeroLocal;
import lysis.instructions.SwitchCase;
import lysis.instructions.LAlign;
import lysis.lstructure.Function;
import lysis.lstructure.LBlock;
import lysis.lstructure.LGraph;
Expand Down Expand Up @@ -228,13 +227,6 @@ private LInstruction readInstruction(SPOpcode op) throws Exception {
case idxaddr_b:
return new LIndexAddress(readInt32());

case align_pri:
case align_alt:
{
Register reg = (op == SPOpcode.addr_pri) ? Register.Pri : Register.Alt;
return new LAlign(reg);
}

case move_pri:
case move_alt: {
Register reg = (op == SPOpcode.move_pri) ? Register.Pri : Register.Alt;
Expand Down Expand Up @@ -692,6 +684,13 @@ private LInstruction readInstruction(SPOpcode op) throws Exception {
pc_ += num - 8; // skip dbgname
return new LDebugBreak();
}

case align_pri:
case align_alt:
{
Register reg = (op == SPOpcode.addr_pri) ? Register.Pri : Register.Alt;
return new LAlign(trackGlobal(readInt32()), reg);
}

default:
throw new Exception("Unrecognized opcode: " + op);
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/lysis/instructions/LAlign.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
import lysis.lstructure.Register;

public class LAlign extends LInstructionReg {

private long offset_;

public LAlign(Register reg) {
super(reg);
public long offset() {
return offset_;
}
public LAlign(long offset, Register reg) {
super(reg);
offset_ = offset;
}

@Override
Expand All @@ -19,6 +25,6 @@ public Opcode op() {
@Override
public void print(DataOutputStream tw) throws IOException {
tw.writeBytes("align." + RegisterName(reg()) + ", "
+ (reg() == Register.Pri ? RegisterName(Register.Alt) : RegisterName(Register.Pri)));
+ (reg() == Register.Pri ? RegisterName(Register.Alt) : RegisterName(Register.Pri)) + offset());
}
}

0 comments on commit 7b61bb5

Please sign in to comment.