Re: A83: Re: Where is everybody?
[Prev][Next][Index][Thread]
Re: A83: Re: Where is everybody?
You obviously misunderstood my comment. I was pointing out the error he was
making with such a general statement. Sure, when testing a SINGLE bit when
the bit position is known beforehand, and it is not in position 0 or 7 in
the accumulator, 'bit' is the fastest way to test it. But if you need to
test an entire sequence if bits, which is going to be better?
; bit value in A
bit 0,a
jr z,bit0
bit 1,a
jr z,bit1
bit 2,a
jr z,bit2
...
rra
jr c,bit0
rra
jr c,bit1
rra
jr c,bit2
...
You save a byte each time there. You also save 4 t-states, but this is
generally irrelevant, and I don't believe that cycle counting in that
instance is valid because there might be more time than 4 t-states to fetch
the constant bit value from memory.
> how do YOU figure that one?
> A bit x,reg takes only 8 clocks.
> A bit x,(HL) takes 12.
>
> just a ld a,(HL) takes 7, and then a shift takes 8. if you want to test
like bit
> 4, you have to shift 4 times.
>
> > How do you figure that one? It is many times more efficient to load the
> > value into the accumulator, shift and test the carry flag, such as when
> > reading keys using the ports.
> >
> > > BTW, The best way to test a bit is to use the bit command.
> > >
> > > syntax:
> > > bit x,Reg (x=bit,Reg=register) [I think!]
Follow-Ups:
References: