Re: Is this the optimal 6502 NEXT?
- From: BruceMcF <agila61@xxxxxxxxxxxx>
- Date: Sun, 29 Aug 2010 01:24:24 -0700 (PDT)
On Aug 21, 3:45 am, chitselb <chits...@xxxxxxxxx> wrote:
volksForth comes out to 32 clocks for the best case (entry at $0009)
and 42 if page boundaries are crossed. So are there any tricks that I
missed out on here?
As far as why mine is 20/26 cycles rather than 30/45, its because it
is creating the
JMP ((IP))
.... instruction by putting a JMP () opcode in front of the IP
location. That allows the NEXT to avoid one 16-bit fetch, and finding
a way to avoid 16-bit fetches or stores is normally a speed win in
6502 code.
As is often the case when hitting the 16-bit wall, set things up the
right way around for a 65816 and the problems go away. For a 65816,
just put it into 16-bit mode, 0,Y is the return stack, the hardware
stack is the data stack, and NEXT is a five byte macro to add to the
end of primitives, and the model is far more classic:
NEXT:
INX
INX
JMP (0,X)
EXIT:
LDX 0,Y
DEY
DEY
INX
INX
JMP (0,X)
ENTER: ; ( JSR ENTER is DOCOL)
INY
INY
STX 0,Y
PLX
INX
JMP (0,X)
.
- References:
- Is this the optimal 6502 NEXT?
- From: chitselb
- Is this the optimal 6502 NEXT?
- Prev by Date: Re: Is this the optimal 6502 NEXT?
- Next by Date: Re: Is this the optimal 6502 NEXT?
- Previous by thread: Re: Is this the optimal 6502 NEXT?
- Next by thread: Re: Is this the optimal 6502 NEXT?
- Index(es):
Relevant Pages
|