Re: Is this the optimal 6502 NEXT?



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)

.



Relevant Pages

  • Re: [RosAsm example]
    ... | call 'User32.DefWindowProcA'| jmp D$Mret ... Ok, my handlers wont use/need/rely-on stack contents anyway, ... It works, but honestly wolfgang, whats wrong with PROC and ENDP ?? ...
    (alt.lang.asm)
  • Re: Add My Idea to the C++ Compiler
    ... If I have to tell that JMP Table should be faster than ... > Speculative execution, and parallel execution. ... > code and starts executing any instructions there that might not depend ... > on arguments passed via the stack. ...
    (comp.lang.cpp)
  • Re: Memoizing recursive words
    ... CALL AA becomes JMP AA ... On the first entry to AA the return stack contains the address just ... 1- false recurse; ...
    (comp.lang.forth)
  • Re: Changes in Aleph1 Smashing the Stack...
    ... Use JMP and CALL with a label instead of the relative address. ... > by Aleph1 Smashing the Stack for Fun and Profit I have got some problems. ... > where I can find information about how changes in new versions of gcc ...
    (Vuln-Dev)
  • how to read (R|E)IP
    ... I.e. to avoid the usage of stack for asmcall (pure register, ... mov edx, eip ... jmp foo ...
    (comp.lang.asm.x86)