Subject: RE: [stella] Re: Help with efficient cod From: arb@xxxxxxxxxxxxxxxxxx Date: Tue, 30 Sep 1997 10:54:52 +1000 |
> I was curious if there was a more efficient way to do something like this. > -------------------------------------------------------------------------- -- > lda #$00 > sta CHECK > > checkit ldx CHECK > lda VARIABLE > cmp CHECK > beq pointers,x > inc CHECK > lda CHECK > cmp #$05 ;or whatever the highest check number(+1) is > bne checkit > > lda STUFF ;continue with the rest of your programme > " " > " " > " " > rts > > pointers jmp framistat > jmp dohickey > jmp whachamacallit > jmp thingy > jmp dodad > -------------------------------------------------------------------------- -- > Depending on the value in VARIABLE you want to go to different subroutines. > If the variable is zero then you want to run the framistat routine > or if it is one then the dohickey routine, etc. You should make VARIABLE a multiple of three, then use an indirect jmp. Something like this should work: checkit lda VARIABLE tax sbc #$10 ; # of options * 3 + 1 bmi jumptable lda STUFF ;continue with the rest of your programme " " " " " " rts jumptable jmp (pointers, x) pointers framistatLO, framistatHI dohickeyLO, dohickeyHI whachamacallitLO, whachamacallitHI thingyLO, thingyHI dodadLO, dodadHI Or... checkit lda VARIABLE ; load VARIABLE sbc #$05 ; # of options + 1 bmi jumptable lda STUFF ;continue with the rest of your programme " " " " " " jumptable lda VARIABLE asl ; multiply by 2 adc VARIABLE ; add another VARIABLE, to give VARIABLE * 3 txa ; stuff VARIABLE * 3 into X jmp (pointers, x) ; hit the jump table ; jump table goes here, addresses in LO, HI form. > CRACKERS It's been a while since I played with 650x code, but this should work... -- Amos Bannister IT Support Officer La Trobe Shire Traralgon, Victoria AUSTRALIA arb@xxxxxxxxxxxxxxxxxx -- 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 -> |
---|---|---|
[stella] Re: jmp (abs,x) [not a 650, Jim Nitchals | Thread | Re: [stella] stick/paddle combos, Eckhard Stolberg |
Re: [stella] Re: Help with efficien, Jim Nitchals | Date | Re: [stella] Re: Help with efficien, Greg Troutman |
Month |