Hello Harold et all, > As I recall, the application is in C, so you could always use a > switch-case statement and let the compiler deal with it! yes, but the Assembly code generated by the C compiler isn't that tight. I managed to make my computed goto code a little more smart. It have a limitation of 63 possible GOTOs, but executes on just 11 instruction cycles: // COMPUTED GOTO #asm rlncf state, W_ // put state*4 addwf WREG, W_ // in WREG addlw 6 // align future PUSH position push // put PCL+2 on the TOS addwf TOSL,F // add WREG to TOSL clrf WREG addwfc TOSH,F // if carry, increments TOSH return // returns directly to the "goto caseXX" goto case00 goto case01 goto case02 goto case03 etc... #endasm Althought this code works perfectly while I'm simulating it in MPLAB, but doesn't work on the device. This is very strange. I've made some tests and it seens to be a bug on the PIC18F452 part(!). It's like the STKPTR isn't incremented when PUSH is executed. Someone want to try it? Best regards, Brusque ----------------------------------------------------------------- Edson Brusque C.I.Tronics Lighting Designers Ltda Research and Development Blumenau - SC - Brazil Say NO to HTML mail www.citronics.com.br ----------------------------------------------------------------- -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu