Electronic – How to do indirect addressing in PIC ASM

assemblycpic

On my 16F628A's I want to iterate of a predefined sequence of values. How do I do this?

In C, I would do something like this:

char vals = {22, 10, 34, 16};

char id = 0;

port = vals[id];
id++

It's the 'vals[id]' that I haven't figured out.

Best Answer

There are no indirect memory access instructions on midrange pics, instead you put the address of the memory location you want to access into the FSR register. And then the value is accessible at the INDF register.

See section 4.4 of the datasheet for your chip. http://ww1.microchip.com/downloads/en/devicedoc/40044f.pdf