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
