Lookup table?

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View


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?



Re: Lookup table?



Quoted text here. Click to load it
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



Re: Lookup table?


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



Re: Lookup table?


Thanks very much
Works like a charm


Quoted text here. Click to load it



Site Timeline