[A83] Re: Question(bit checking)


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

[A83] Re: Question(bit checking)




After typing this one out, I found it's mostly identical to the one below...

;Bit a,(hl) routine, destroys a
BitAHL:
  add a,a   ;a*8
  add a,a
  add a,a
  add a,$46 ;(Bit 0,(HL)) + A
  ld (bitmodify+1),a
BitModify:
  bit 0,(hl)
  ret
; 11 bytes, 54 cycles according to Assembly Studio 8x


>From: "Kirk Meyer" <kirk.meyer@colorado.edu>
>Reply-To: assembly-83@lists.ticalc.org
>To: <assembly-83@lists.ticalc.org>
>Subject: [A83] Re: Question(bit checking)
>Date: Sat, 7 Jul 2001 08:33:17 -0600
>
>
>If it isn't required have the value be dynamic in A (doesn't seem like it
>would be for most applications), then of course you could just check it 
>with
>bit x,[hl].
>
>-----Original Message-----
>From: assembly-83-bounce@lists.ticalc.org
>[mailto:assembly-83-bounce@lists.ticalc.org]On Behalf Of
>ComAsYuAre@aol.com
>Sent: Saturday, July 07, 2001 8:19 AM
>To: assembly-83@lists.ticalc.org
>Subject: [A83] Re: Question(bit checking)
>
>
>The only thing about that is it uses non-standard numbering for the bits,
>going from 1 (the right-most bit) to 8 (the left-most) rather than 0 to 7.
>However, as long as you document this, that should work well enough.  It
>should be noted, however, that speed fluctuates rather significantly
>(proportional to the total execution time) based on which bit you're using.
>Consider the following constant-speed alternative:
>
>  ;hl -> byte
>  ;a = bit # to check, 0-7
>  ;z flag indicates whether bit is 0 or 1
>
>BitCheck:
>  rlca      ;4
>  rlca      ;4
>  rlca      ;4
>  or %01000110   ;7
>  ld ($+3),a    ;13
>  bit 0,(hl)       ;12
>  ret              ;10
>
>Total: 54 t-states.
>
>
>In a message dated 7/7/2001 8:32:53 AM Eastern Daylight Time,
>tijlc@hotmail.com writes:
>
>
> > Another option might be this:
> >
> > ; input: hl->number to check; b=bit to check
> > ; output: nz if flag is set
> >
> > BitFinder:
> >      ld   a,%10000000
> > BitFinderLoop:
> >      rlca
> >      djnz BitFinderLoop
> >      and  (hl)
> >      ret
> >
>
>
>
>----
>Jonah Cohen
><ComAsYuAre@aol.com>
>http://jonah.ticalc.org
>
>
>
>

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com