|
Subject: [stella] Re: Help with efficient code From: jimn8@xxxxxxxxxx (Jim Nitchals) Date: Mon, 29 Sep 1997 21:20:45 -0700 (PDT) |
I wrote:
> lda variable
> cmp #num_entries
> bcs not_in_table
> asl
> tax
> lda jump_table,x
> sta temp ; temp should be 2 bytes somewhere in RAM
> lda jump_table+1,x
> sta temp+1
> jmp (temp) ; jump indirect through temp
Whoops! Forgot about jmp (abs,x) which I remembered as a 65816 opcode.
Sorry... and thanks to Amos Bannister for the reminder (btw, the
instruction works differently than his example.)
The revised version should read:
lda variable
cmp #num_entries
bcs not_in_table
asl
tax
jmp (jump_table,x)
jmp_table:
dc.w framistat
etc.
The only catch being, due to a bug in the 6502 the jump table itself
cannot cross a page boundary. Align it to an even address if you're
not 100% sure that no entry in the table crosses a 256 byte page
boundary.
Finding bugs in the 6502 and exploiting them was a favorite technique
in disguising copy protection code in Apple II and Atari 400/800 disk
based games.
--
Archives updated once/day at http://www.biglist.com/lists/stella/archives/
Unsubscribing and other info at http://www.biglist.com/lists/stella/stella.html
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [stella] Re: Help with efficien, Jim Nitchals | Thread | Re: [stella] Re: Help with efficien, Greg Miller |
| Re: [stella] Re: Help with efficien, Greg Troutman | Date | Re: [stella] Unexploited Controller, PatMan |
| Month |