I am using a 89C450 mcu. I need to execute 1 of 100 subroutines depending on the value of the acc Sort of like a lookup table I think. Any ideas?
- posted
16 years ago
I am using a 89C450 mcu. I need to execute 1 of 100 subroutines depending on the value of the acc Sort of like a lookup table I think. Any ideas?
Use JMP @A+ DPTR
Acc = jmp val DPTR = table start
entry:- MOV DPTR,#TABLESTART ADDA,A ADDA,A (A*3) JMP @ A+DPTR
Table start :
ljmp routine 0 (3 BYTES PER JUMP) ljmp routine1 . . . . ljmp routine99
Ooops not quite right......too late to think straight......
16 bit add to TableStart( DPTR), A 16 bit add to TableStart( DPTR), A 16 bit add to TableStart( DPTR), A (DPTR+0,3,6,9,etc)clr Acc jmp @A+DPTR
TableStart : Ljmp Routine0 (3 bytes) Ljmp Routine1 etc
Thanks very much Works like a charm
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.