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

Re: ASM code as slow as basic one in Double HIRES!!



Cyril Thibout <info@pulsar-informatique.com> wrote:
> Hi
> 
> I just tried to write an ASM piece of code for Apple IIe Double HIRES
> with the french ARLEQUIN (chat mauve) library.
> 
> This code just switch to DHR and write 15 "X" upon a different background each time.
> 
> The big surprise is that the MErlin8 ASM program is as slow as the basic one.
> 
> If you don't have the arlequin soft or book , please tell me.
> 
> But can you tell me why the ASM version is no faster than the basic one?
> 
> thanks
> 
> cyril
> 
> 
> 
> BASIC code:
> 
> 10 & WINDOW(0,19,0,191,1): & BACK(4): & MODE(2)
> 15 & COL(0): & DISPLAY(2)
> 20 FOR B = 1 TO 15: & BACK(B): & WRITE("X"): NEXT
> 30 GET A$: & DISPLAY(0): END
> 
> 
> ASM (MErlin8)version :
> 
> * programme DHR
> ORG $8000
> 
> WINDOW JSR $1FF0
> DFB #$24
> DW PCOORD
> BACK JSR $1FF0
> DFB #$0C
> DW PBACK
> MODE JSR $1FF0
> DFB #$3C
> DW PMODE
> COL JSR $1FF0
> DFB #$08
> DW PCOL
> DISPLAY JSR $1FF0
> DFB #$6C
> DW PDISP
> 
> 
> LDX #$0F
> BOUCLE STX PBACKX
> BACKX JSR $1FF0
> DFB #$0C
> DW PBACKX
> WRITEX JSR $1FF0
> DFB $40
> DW WRITELIST
> 
> DEX
> BNE BOUCLE
> 
> 
> RTS
> 
> PCOORD DW $00
> DW $13
> DW $00
> DW $BF
> DW $01
> PBACK DW $04
> PMODE DW $02
> PCOL DW $00
> PDISP DW $02
> PBACKX DW $0F
> WRITELIST DW ADPATH
> ADPATH DB 1
> ASC "X"

Consider where the program is spending it's time. 

If it is spending 99% of its time in the graphics routines and 1% in your
calling code, then causing your calling code to run infinitely fast will
result in a 1% speedup in the program. 

This is why it works so well to use BASIC to handle user I/O and file
I/O--there is no need for speed when all the time is spent waiting for the
user or the disk!

To optimize a program efficiently, profile it to determine where it is
spending significant time. These are the only routines worth optimizing. 

-michael - NadaNet 3.1 and AppleCrate II: http://home.comcast.net/~mjmahon