Fix Flags
This commit is contained in:
@ -295,7 +295,7 @@ public class Commands {
|
||||
|
||||
public static void RRF(int file, int destination) {
|
||||
int fcontent = DataRegister.getRegister(file);
|
||||
int carry = DataRegister.getCarryFlag() << 7;
|
||||
int carry = DataRegister.getCarryFlag();
|
||||
int contentlow = fcontent & 0b1;
|
||||
int result = fcontent >> 1 | carry;
|
||||
DataRegister.setCarryFlag(contentlow);
|
||||
|
||||
@ -89,6 +89,9 @@ public class DataRegister {
|
||||
else {
|
||||
dataRegister[address] = content;
|
||||
dataRegister[0x80 + address] = content;
|
||||
if (address == STATUS){
|
||||
setFlags();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,6 +119,9 @@ public class DataRegister {
|
||||
if (getBit(address, bit) == 1) {
|
||||
dataRegister[address] -= (int) Math.pow(2, bit);
|
||||
dataRegister[0x80 + address] = dataRegister[address];
|
||||
if (address == STATUS){
|
||||
setFlags();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -135,6 +141,9 @@ public class DataRegister {
|
||||
if (getBit(address, bit) == 0) {
|
||||
dataRegister[address] += (int) Math.pow(2, bit);
|
||||
dataRegister[0x80 + address] = dataRegister[address];
|
||||
if (address == STATUS){
|
||||
setFlags();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -173,6 +182,12 @@ public class DataRegister {
|
||||
return programCounter;
|
||||
}
|
||||
|
||||
private static void setFlags() {
|
||||
carryFlag = getDirectBit(STATUS, C);
|
||||
digitCarryFlag = getDirectBit(STATUS, DC);
|
||||
zeroFlag = getDirectBit(STATUS, Z);
|
||||
}
|
||||
|
||||
private static int zeroFlag = 0;
|
||||
|
||||
public static void determineZeroFlag(int result){
|
||||
|
||||
Reference in New Issue
Block a user