43 lines
1.3 KiB
Java
43 lines
1.3 KiB
Java
package backend.mips.instr;
|
|
|
|
import backend.mips.instr.type.MipsCompareType;
|
|
import backend.mips.instr.type.MipsType;
|
|
import backend.mips.Register;
|
|
|
|
public class MipsComp extends MipsInstr {
|
|
private MipsCompareType compareType;
|
|
private Register rd;
|
|
private Register rs;
|
|
private Register rt;
|
|
private int immediate;
|
|
private boolean isImmediate;
|
|
|
|
public MipsComp(MipsCompareType compareType, Register rd, Register rs, Register rt) {
|
|
super(MipsType.COMPARE);
|
|
this.compareType = compareType;
|
|
this.rd = rd;
|
|
this.rs = rs;
|
|
this.rt = rt;
|
|
this.immediate = 0;
|
|
this.isImmediate = false;
|
|
}
|
|
|
|
public MipsComp(MipsCompareType compareType, Register rd, Register rs, int immediate) {
|
|
super(MipsType.COMPARE);
|
|
this.compareType = compareType;
|
|
this.rd = rd;
|
|
this.rs = rs;
|
|
this.rt = null;
|
|
this.immediate = immediate;
|
|
this.isImmediate = true;
|
|
}
|
|
|
|
public String toString() {
|
|
if (this.isImmediate) {
|
|
return this.compareType.toString() + " " + this.rd + ", " + this.rs + ", " + this.immediate + "\n";
|
|
} else {
|
|
return this.compareType.toString() + " " + this.rd + ", " + this.rs + ", " + this.rt + "\n";
|
|
}
|
|
}
|
|
}
|