| ??? 08/21/06 21:46 Read: times |
#122742 - Jump TABLE Responding to: ???'s previous message |
Erik Malund said:
mov a,BSNCcost ;get color
mov dptr,#BSNjcol
jmp @a+dptr
BSNjcol: sjmp BSNr2 ; read 1/2 time
sjmp BSNr4
sjmp BSNr8
; etc That's a computed goto. This:
mov a,BSNCcost;
mov dptr,#TableBase;
movc a,@a+dptr
push a;
mov a,BSNCcost;
inc dptr;
movc a,@a+dptr
push a;
ret; call routine pointed to by table
; return here
TableBase:
dw, addrBSNr2;
dw, addrBSNr4;
dw, addrBSNr8;
; etc
That's the equivalent table driven version. I expect for many case statements the compiler can 'optimise' this further by just looking up the LS byte of the address provided the code sits within a 256 byte page. Ian |



