Mini-challenge - fastest 24 bit countdown

Programming the 6502 microprocessor and its relatives in assembly and other languages.
IamRob
Posts: 357
Joined: 26 Apr 2020

Re: Mini-challenge - fastest 24 bit countdown

Post by IamRob »

I guess the routine I posted fails in one respect. If the Accumulator is already at $FF, then gets incremented to $00, then the subtraction at the bottom of the routine will fail as the carry will be cleared in that case.
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Mini-challenge - fastest 24 bit countdown

Post by BigEd »

oh no!
IamRob
Posts: 357
Joined: 26 Apr 2020

Re: Mini-challenge - fastest 24 bit countdown

Post by IamRob »

* I just had to revisit this thread as I couldn’t get this out of my head,

* This should be up there for one of the smallest/fastest
* The smallest

INY
INX
INC $0

LOOP EQU * ; 5 cycles per loop
DEY
BNE LOOP

DEX
BNE LOOP

DEC $0
BNE LOOP

RETURN RTS


* The fastest

INY
INX
INC $0 ; or INC for 65c02

LP EQU *
DEY
BNE LP
BEQ DOX

LOOP EQU *
DEY
DEY
DEY
DEY
DEY
DEY
DEY
DEY
DEY
DEY

DOX EQU *
DEX
BNE LOOP

DEC $0 ; or just DEC for 65c02
BNE LOOP

RETURN RTS
Post Reply