Skip to content

Commit 5601f23

Browse files
committed
sp word alignment on real hardware
1 parent a7b1057 commit 5601f23

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

emulator/src/Chipset/CPU.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ namespace casioemu {
244244
SetupOpcodeDispatch();
245245
SetupRegisterProxies();
246246
impl_csr_mask = emulator.GetModelInfo("csr_mask");
247+
real_hardware = emulator.GetModelInfo("real_hardware");
247248
}
248249

249250
void CPU::SetupOpcodeDispatch() {

emulator/src/Chipset/CPU.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ namespace casioemu {
6565
size_t impl_hint;
6666
uint16_t impl_csr_mask;
6767

68+
bool real_hardware;
69+
6870
void SetupOpcodeDispatch();
6971
void SetupRegisterProxies();
7072

emulator/src/Chipset/CPUControl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace casioemu {
1010
void CPU::OP_ADDSP() {
1111
impl_operands[0].value |= (impl_operands[0].value & 0x80) ? 0xFF00 : 0;
1212
reg_sp += impl_operands[0].value;
13+
if (real_hardware) reg_sp &= ~1;
1314
}
1415

1516
void CPU::OP_CTRL() {
@@ -46,6 +47,7 @@ namespace casioemu {
4647
break;
4748
case 11:
4849
reg_sp = impl_operands[1].value;
50+
if (real_hardware) reg_sp &= ~1;
4951
break;
5052
}
5153
}

0 commit comments

Comments
 (0)