Re: Assy question

From: Spiro Trikaliotis (Trik-news_at_gmx.de)
Date: 2001-03-15 07:57:15

Hi,

> In the book '6502 Assembly Language Programming' by
> Lance Leventhal, it is stated that
> SED ; 2 cycles
> CLC ; 2 cycles
> LDA $40 ; 3 cycles
> ADC #$90 ; 2 cycles
> ADC #$40 ; 2 cycles
> STA $41 ; 3 cycles
> CLD ; 2 cycles
> ; 16 cycles total
>
> is 'quicker' than
>
> LDA $40 ; 3 cycles
> CMP #10 ; 2 cycles
> BCC ASCZ ; 2/3/4 cycles
> ; 2=no branch / 3=branch / 4=cross-page branch
> ADC #'A'-'9'-'2' ; 2 cycles
> ASCZ ADC #'0' ; 2 cycles
> STA $41 ; 3 cycles
> ; 13/14 cycles total

> Have I miscounted my cycles? Is there ANY circumstance
> under which the first routine is 'quicker' than the
> second???  :-/

I don't think you have miscounted your cycles. But, IMHO, is not fair to
count SED and CLD in the first case! Why? There are two reasons:

1. These routines are here w/o context; we do not know if outside of the
hex-to-ascii-conversion, the decimal flag has to be set or not. If it has to
be set all the times, then you can add these two instructions to the 2nd
case, resulting in 12 cycles for the first / 17/18 cycles for the second
case.

2. When converting like here, it is unlikely that you will have to convert
just one digit. So, when you have to convert, for example, 4 digits, then
you have to SED and CLD only once (if you arrange your conversion in a good
maner).

Spiro.

-
This message was sent through the cbm-hackers mailing list.
To unsubscribe: echo unsubscribe | mail cbm-hackers-request@dot.tml.hut.fi.

Archive generated by hypermail 2.1.1.