There are a number of ways to output the contents of the P register. One way is:
NV.BDIZC 00110100
It's on a single line, and it shows the flag names as well (so you don't have to remember which flag is where). Another way is:
NV.BDIZC
00110100
This time it's easier to see the value (0 or 1) of a particular flag, but it's often more helpful for debugging information to be on a single line when possible.
Another possibility is given in the code below. A bit that is zero is represented by a lower case letter, and a bit that is one is represented by an upper case letter (except for bit 5, which is unused and represented by 0 or 1). That is, the lower value (zero) is lower case, and the upper value (one) is upper case. Like so:
nv1BdIzc
OUTP
PHP
PLA
P1 CLD
LDX #7
.1 ASL
PHA
LDA .3,X
BCS .2
EOR #32 ;toggle letter case
CPX #5
BNE .2
EOR #33 ;undo letter case toggle, and toggle digit instead
.2 JSR OUTPUT
PLA
DEX
BPL .1
RTS
.3 DB "CZIDB1VN"
For debugging you'll probably want to preserve the register (and flag) contents. The following wrapper can be used on the 65C02 (or 65816 emulation mode):
OUTP_65C02
PHP
PHA
PHX
JSR OUTP
PLX
PLA
PLP
RTS
The NMOS 6502 has no PHX and PLX instructions so the wrapper is a slightly more complicated. Note this copies the value of the P register from the value stacked by the wrapper, so JSR P1 (rather than JSR OUTP) is used, since TXA among other instructions will have already overwritten some of the flags before the JSR is reached (and hence the PHP at OUTP would have used the overwritten flag values).
OUTP_6502
PHP
PHA
TXA
TSX
PHA
INX
INX
LDA $100,X ;get P value from stack
JSR P1
PLA
TAX
PLA
PLP
RTS