Knowing the use case makes things clear. This brings up a thought though. Given that the NSC800 and Z80 will set P for Parity OR Overflow how would one disambiguate the two?
Given that you have the value of interest in A and flag P is set. Then you do: MOV A,A If P is now NOT set, you know that P was set due to overflow. If P is still set then you know it is set because of Parity but you don’t know it may have also been set due to overflow. If Parity is what is important you can filter out the Overlfow condition with a MOV A,A. (in my mind it works anyhow 😊 ) Jeff Birt From: M100 <[email protected]> On Behalf Of Stephen Adolph Sent: Wednesday, December 18, 2024 6:19 PM To: [email protected] Subject: SPAM-LOW: [M100] Z80 is not quite 8085 compatible. I've been debugging my NSC800 CP/M modified Model 100. I noticed that, in M100 BASIC, issuing this command ? 65535-32767 produced gibberish. I went on a bit of a deep dive on this. Here is what I found. NSC800 and Z80 dual purpose the P flag to be a P/V flag, meaning parity or overflow. This messed up the M100 in one specific place. RST 5 is a subroutine that is used to determine the type of a variable. 1069H (3AH) LDA FB65H ; Type of last variable used 106CH (FEH) CPI 08H 106EH (3DH) DCR A 106FH (3DH) DCR A 1070H (3DH) DCR A 1071H (C9H) RET what is interesting here is that the CPI operation correctly sets the flags, then so do the following DCR. EXCEPT! in the Z80, DCR opcode treats the P flag as OVERFLOW and not PARITY. The calling subroutine ends up getting mostly correct flags, but not the P flag. So any subsequent use of the P flag would be a problem. Turns out this exact thing happens at 352AH (EFH) RST 5 ; Determine type of last var used 352BH (E0H) RPO this RPO redirects the program counter on the status of that flag. Bingo. This appears to be the only such occurrence in the rom. So, I have yet another patch for the NSC800, that manually calculates parity and corrects the flag, so the existing M100 rom code can run cleanly. new ROM binary is here: https://bitchin100.com/wiki/index.php?title=NSC800_Conversion#Modified_M100_Main_ROM
