[A83] Re: tst + tstio instructions


[Prev][Next][Index][Thread]

[A83] Re: tst + tstio instructions




The m and p flags are minus and positive, which merely reflect the sign of the result.  Note that this is distinctly different from the carry, as adding 2 to -3 still results in the m flag being set even though the carry is not.  And p is true when m isn't true.

As for pe and po, those stand for parity even and parity odd, which are alternate states of the parity/overflow flag.  Parity is defined as the number of bits set in a piece of data, so %10101010 has 4 bits set and therefore parity even, while %00000111 has 3 bits set and therefore parity odd.  The parity flag is also useful when using ldi, cpi, and all the other opcodes that automatically decrement bc (not dec bc itself though!), because they will set pe when bc is 0 and po when bc is not 0.  So you can do a loop such as this:

invert_and_copy:
 ld a,(hl)
 cpl
 ld (hl),a
 ldi
 jp po,invert_and_copy

This inverts bc bytes at hl and also copies them to de.

Also keep in mind that the sign flag (m/p) and parity flag (pe/po) are not supported by the jr instruction, only by jp, call, and ret.


In a message dated Tue, 3 Jul 2001  8:38:46 AM Eastern Daylight Time, "Ronald Teune" <rtwolf@gmx.net> writes:

<< 
And how about jp m,xxxx ? And what's the use of ld a,a ?
RET  C       D8   1 NOP 1    ;ret if carry (whatever it is)
RET  M       F8   1 NOP 1    ;?
RET  NC      D0   1 NOP 1 ;ret if not carry
RET  NZ      C0   1 NOP 1  ;ret if not zero
RET  P       F0   1 NOP 1    ;?
RET  PE      E8   1 NOP 1  ;?
RET  PO      E0   1 NOP 1  ;?
RET  Z       C8   1 NOP 1   ;ret if zero

>You probably mean that if it contains a 2 at the end, it's junk to us...
>
>Includes OUT0, OTIM* OTDM*, (SLP), [
>
>but
>IND, INDR, INI and INIR don;t have that (yeah, I found more insturctions
:-)
>
>What do they do?




 >>