PDA

View Full Version : Accessing a PBP array from inside an assembly language routine.



cupajoe
- 2nd August 2004, 03:48
Hi all,

Its been a while since I've posted. I am wondering if anyone knows the syntax for accessing a byte array (e.g. mybuffer var byte[16]) from inside of an assembly language routine. I am trying not to force the array to a known memory location using equates. I apologize if this has been covered. I tried searching the archives but I came up empty.

Thanks in advance,

Joe Kupcha.

Ingvar
- 4th August 2004, 10:18
Hi Joe,

ASM
movlw 0x05
movwf _YourArray + 7
ENDASM

This snippet should place 5 in the eighth element of YourArray.

If you need the index to be a variable, you'll need to use the FSR and INDF registers. FSR is your index and INDF will contain the element pointed.

This program should clear your array.

YourArray VAR BYTE[16]
LoopCounter VAR BYTE

ASM
clrf _LoopCounter
movlw _YourArray
movwf FSR
Loop
clrf INDF
incf FSR
incf _LoopCounter
btfss _LoopCounter,4
goto Loop
ENDASM

/Ingvar

cupajoe
- 8th August 2004, 16:00
Ingvar,

Thanks. I was trying to use a variable for the pointer. Your examples should get me going.

I am trying to load a ring buffer from inside an assembly language routine. I came up with a work around. I load the received character into a byte variable and increment the array pointer (with a mask to wrap it back to zero), then exit the ISR. In the main loop I check the value of the byte variable and if its not zero I load it into the next element in the array.

Thanks again,

Joe Kupcha.