Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.apple2.programmer > #1368

Re: Can anyone see a way to improve this ?

From "Anton Treuenfels" <teamtempest@yahoo.com>
Newsgroups comp.sys.apple2.programmer
References <34030b70-c7cb-4b31-a99a-6b44c3877066@googlegroups.com>
Subject Re: Can anyone see a way to improve this ?
Date 2014-10-27 08:38 -0500
Message-ID <tJKdnSuS86Vx19PJnZ2dnUU7-b-dnZ2d@earthlink.com> (permalink)

Show all headers | View raw


"mdj" <mdj.mdj@gmail.com> wrote in message 
news:34030b70-c7cb-4b31-a99a-6b44c3877066@googlegroups.com...

         LDX   #$00
NEXTBYTE LDY   #$08
         LDA   #$01
NEXTBIT  EOR   #$FF       ; Set and check complement first
         STA   $2000,X
         CMP   $2000,X
         BNE   ERROR
         EOR   #$FF
         STA   $2000,X
         CMP   $2000,X
         BEQ   CONT
ERROR    JSR   FLAGERR
CONT     ASL
         DEY
         BNE   NEXTBIT
         INX
         BNE   NEXTBYTE
         RTS
FLAGERR  RTS              ; Record this meaningfully in the future

=======================

Well you might consider that "ASL" is moving a single set bit "across" the 
A-register from least to most significant bit. Every shift sends a zero bit 
into the carry register - except when the set bit is the MSB, in which case 
the shift will set the carry flag. So you could use that as a signal to 
branch to "NEXTBIT" and not use the Y-register as a counter at all.

Similarly the Z-flag will not be set as long as there is a set bit in the 
A-register, but a shift from the MSB to the carry flag will leave the 
A-register all zero bits, so the Z-flag will be set. You could use that if 
you like, and similary eliminate the Y-register as a counter.

Of course neither will work reliably if "FLAGERR" disturbs the A-register. 
But if so you can put the Y-register to good use like this:

   TAY
   JSR FLAGERR
   TYA

...and as long as FLAGERR doesn't disturb the Y-register you should be okay. 
Otherwise perhaps a judiciously placed PHA/PLA combination would protect the 
value in the A-register.

These changes only save 18 cycles per byte, though, or 4608 cycles per page. 
So while shorter and faster, it's not likely going to make a noticeable 
difference. On a 1-MHz machine you'd have to check around 2000 pages to save 
a single second.

- Anton Treuenfels

Back to comp.sys.apple2.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Can anyone see a way to improve this ? mdj <mdj.mdj@gmail.com> - 2014-10-27 05:04 -0700
  Re: Can anyone see a way to improve this ? "Anton Treuenfels" <teamtempest@yahoo.com> - 2014-10-27 08:38 -0500
  Re: Can anyone see a way to improve this ? Vladimir Ivanov <none@none.tld> - 2014-10-27 15:56 +0200
    Re: Can anyone see a way to improve this ? Michael J. Mahon <mjmahon@aol.com> - 2014-10-27 13:21 -0500
      Re: Can anyone see a way to improve this ? mdj <mdj.mdj@gmail.com> - 2014-10-27 17:48 -0700
        Re: Can anyone see a way to improve this ? Snertking <SNERTKING@GMAIL.COM> - 2014-10-27 21:28 -0400
          Re: Can anyone see a way to improve this ? mdj <mdj.mdj@gmail.com> - 2014-10-27 22:45 -0700
            Re: Can anyone see a way to improve this ? Michael J. Mahon <mjmahon@aol.com> - 2014-10-29 10:33 -0500
              Re: Can anyone see a way to improve this ? mdj <mdj.mdj@gmail.com> - 2014-10-29 22:54 -0700
                Re: Can anyone see a way to improve this ? qkumba <peter.ferrie@gmail.com> - 2014-10-31 14:46 -0700
      Re: Can anyone see a way to improve this ? Snertking <SNERTKING@GMAIL.COM> - 2014-10-27 21:25 -0400
      Re: Can anyone see a way to improve this ? michael.pohoreski@gmail.com - 2014-12-30 10:12 -0800
  Re: Can anyone see a way to improve this ? awanderin <awanderin@gmail.com> - 2014-10-27 21:35 -0600

csiph-web