Closed xolod79 closed 11 months ago
Fixed: https://github.com/1801BM1/cpu11/commit/abe8b682a7de38f89865fcd4f57d9ba4d6d2256c Thank you for reporting.
Checked it on FPGAs UKNC, it works fine. Thank you!
Checked it on FPGAs UKNC, it works fine.
Awesome, thank you for the verification and confirmation.
The problem is the failure to update the “frozen” copy registers CPC and CPSW after the MTPS command, when the registers should be “unfrozen” and receive the current values of PC and PSW. The USER mode interrupts themselves are pushed onto the stack not by PC and PSW, but by CPC and CPSW. The FIS service is written in such a way that if it was called with interrupts enabled, then it should be executed in HALT mode with interrupts enabled. It starts in HALT mode with interrupts disabled, first saving all registers, CPC and CPSW. And then with the MTPS R0 command, it sets the same priority that was when calling the FIS command. An interrupt may occur immediately after this command. In the original 1801BM2, CPC and CPSW are immediately “unfrozen” and become equal to the current PC and PSW, respectively, they are already put on the stack. And in the FPGA version, after “defrosting” they do not have time to receive the current values of PC and PSW, and “frozen” values are put on the stack, i.e. PC and PSW after the FIS command.
Test code
Fail result on FPGA BM2
000002 in address 000120 says that FIS was successfully interrupted twice after MTPS. On the stack, address 000764 is 001024 and address 000766 is 4. These are the CPC and CPSW after the FADD SP command at address 001024.
It seems that this also happened when switching to a synchronous processor model. And simple workaround for fix CPSW: