On Tue, 17 May 2005, Leon Heller wrote: > All, > > Is it possible to impliment a jump table based on the value read from an IO > port? > What I want is to have a 8 routines, and when the value from a port is read > (3 bit value) it jumps to the appropriate routine, I want to avoid CMP and > BREQ if possible as I need a constant length for this, using multiple > CMP/BREQs would result in a variable excution time. > > Oh, I'm doing this in assembler.... > > Any thoughts? > > > > > I've not actually done it but it should be quite easy: something like > using the ICALL instruction after setting the Z registers to the start > of the jump table and adding the input value to ZL. It's actually more > complicated than that, but you should get the idea. > > Leon > -- Yes, I've done it that way (in assembler). I'll have to dig for the sample code if you want it. One thing to do is to make sure you mask off all but the 3 bits you're going to add to the ZL register. Otherwise it's possible to end up some place you have no idea where. Zack
Message
Re: [AVR-Chat] Jumptable
2005-05-17 by Zack Widup
Attachments
- No local attachments were found for this message.