PMESS LD A,(HL) ; get character from message
INC HL ; move message pointer to next character
CP 10 ; newline?
RET Z ; return if so
OR A ; zero?
RET Z ; done if so
CALL PCHAR ; print character
JP PMESS ; keep looping
If instead of "RET Z" we had to do a conditional jump to a return it would be 10 cycles for each test instead of 5. CP 10
JP Z,DONE ; 10 cycles, jump taken or not
...
JP PMESS
DONE: RET ; 10 cycles, BTW
The conditional return just happens to be cheaper if not taken because it skips the work of popping the return address off the stack. Though purely an outcome of the implementation you can treat it as sort of a branch prediction.Incidentally, the Z-80 also has relative branches (JR) that differ in execution time whether they are taken or not. The branch offset is a single byte so JR is only 2 bytes compared to JP's 3. A JR is 7 cycles if not taken, 12 otherwise. Again, we can treat it as a hard-coded branch prediction that predicts the branch is not taken. If space or distance to target is not a problem, a JR is faster if taken less than 60% of the time.
Absolute jumps ("JP") were 3 bytes, relative jumps ("JR") were two, whether conditional or not -- but, that's still longer than the 1-byte return instruction...; Though, absolute jumps were the fastest - they did not need to access the stack and adjust SP like "ret", and did not need to do addition like "jr".
I used to know the opcodes by heart, but I last wrote Z80 code in 1987, and last wrote x86 machine code in 1997, and nowadays I don't remember all of the binary representations, and sometimes I get the binary representations of the two mixed. I'm getting old ...
The 6502 has only an 8 bit stack pointer which points into page 1 only (addresses 0x100 .. 0x1FF).