Re: LZ: Help with a routine


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

Re: LZ: Help with a routine



On 20 Sep 96 at 22:07, Jimmy Mardell wrote:


> Mattias Lindqvist wrote:
> > 
> > On 19 Sep 96 at 22:42, Ed Plese, Jr. wrote:
> > 
> > > Actually, I think that if the bit is set, it will set the ZERO
> > > flag, but if it is cleared, then it will clear the Z flag (indicating
> > > nz).
> > 
> > No, the zero flag indicates that something is zero. Therefore if the
> > bit's cleared (meaning it's zero) the Zero flag will be set!
> > 
> 
> Nonono... bit COPIES the bit into the zero flag, and if the bit is set,
> the zero flag will also be set (1=flag set, 0=flag reset in the flag
> register). It's backwards and may be a reason for bugs in programs.


Man! What are you guys talking about???? Consider the following program! 
How do you think it will execute?


#include ti-85.h


.db "bit-test",0


 ld  	a,0
 BIT	1,A
 JR	NZ,IckeZ


 LD	L,A
 LD	H,0
 ROM_CALL(D_HL_DECI)
Wait:	CALL	GET_KEY
 CP	$37
 JR	NZ,Wait


IckeZ:
 RET


.end


Bit 1 of A is of course 0. Now if this would have caused the ZERO flag to
be zero as well, the program would have jumped to RET and ended. But it
doesn't! Therefore: a 0 bit _SETS_ ZERO flag. EOD.


<pre>
--
 Mattias Lindqvist
 d96mli@efd.lth.se
 www.efd.lth.se/~d96mli 
</pre>


References: