I too am trying to read inner and outer loop variables in nested for..next but am unable to find rp@ on a PIC18. rp@ does not seem to be a builtin word and I can't locate it in any .fs files. All help gratefully received.
Best wishes,
Tristan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think rp@ has never existed for PIC18 because it is not possible to index into the HW return stack. So it was rather pointless to read the return stack pointer.
BUT, some years ago I changed the return stack handling so that call/return uses the hardware stack and R> >R FOR NEXT uses a software stack where FSR2 is the stack pointer.
Assuming the Q71 family the return stack pointer can be fetched by by reading C4D9.
I need in the second loop the loopcounter of the first loop.
As example I call it counter1.
Is this posible in FF?
Cheers
Jan
On the PIC24 you can do it like this.
Or like this.
For PIC18 and the ATMEGA different offsets must be used.
I too am trying to read inner and outer loop variables in nested for..next but am unable to find rp@ on a PIC18. rp@ does not seem to be a builtin word and I can't locate it in any .fs files. All help gratefully received.
Best wishes,
Tristan
I think rp@ has never existed for PIC18 because it is not possible to index into the HW return stack. So it was rather pointless to read the return stack pointer.
BUT, some years ago I changed the return stack handling so that call/return uses the hardware stack and R> >R FOR NEXT uses a software stack where FSR2 is the stack pointer.
Assuming the Q71 family the return stack pointer can be fetched by by reading C4D9.
The cells on the return stack has the bytes swapped so some extra code is needed to fetch the indexes. Did some trials but messed it up.
Last edit: Mikael Nordman 2023-05-30
Thank you. Just what I needed. Below seems to work with the Q71.
Best wishes,
Tristan
normaly I can copy the top item of the return stack with r@ , how to make a copy of the second item? or in geneneral copy the n-th element?
cheers, Jan
found solutinin, second item on retrnstack is rp@ 2- @