Hi
Following code snippet:
------------C PROGRAM---------------------------
const unsigned int code TABLE1[4] = {1,2,3,4}; //constants stored in flash const unsigned int code TABLE2[4] = {5,6,7,8}; const unsigned int code TABLE3[4] = {44,33,44,33};
unsigned int *TableStart;
void main (void) {
TableStart = &TABLE1[0]; //get address of TABLE1[0] int_isr(); TableStart = &TABLE2[0]; int_isr(); TableStart = &TABLE3[0]; int_isr();
}------------ASM PROGRAM---------------------------
EXTRN DATA (TableStart)
int_isr: mov A, #0 ;I want first byte in TABLEx mov DPTR, #TableStart ;get address of TABLEx mov A, @A+DPTR ;put first table value into ACC reti
END
--------------------------------------------------
My aim is to dynamically send a TableStart address from a C program into an ASM interrupt handler (in my example above the ISR is called direct for the purposes of my question - I would normally connect int_isr to a real interrupt, with the C program "stuck" in a while(1) loop).
The result of the code above is that, in int_isr, the DPTR will end up with the address (in RAM) of the TableStart pointer. Instead, I want it to contain the contents of TableStart (which is the start address of the table). How can I achieve this?
Thank you Jack