14 or 16bit core ??
<br>
Untested, off the top of my head. At least the F84 makes it easy, with only 1 bank of RAM<br>Code:ASM movlw low _array ; load FSR with address of the array movwf FSR rlf _index,W ; mult. index * 2 since array is WORDs addwf FSR, F ; add result to FSR movf INDF, W ; get the LowByte movwf _my_data incf FSR, F ; point to next byte movf INDF, W ; get the HighByte movwf _my_data + 1 ENDASM
DT
i think thats the reverse of what i want, ie: my_data.Byte0=array[index]
but i think im getting the idea... a couple of questions tho..
i take it "low" infront of a veriable gives its memory address?
and how does this FSR thing work? ive never had to use it before.
Thanks
yup, you're right, it's backwards. That's what I get for trying to squeez in a reply when the boss isn't looking.
low is like LowByte or Byte0 in PBP, it just gives the lowest 8-bits of a value.
And, the FSR allows you to Read/Write the value of any RAM location by placing the address of the desired byte in the FSR register, and then reading/writing to/from the INDF register.
It's kind of like using PEEK and POKE in PBP.
It sounds like you might be able to take it from there, but if not let me know, and I'd make it work the other way around when I get off work.
<br>
DT
Im needing to do this becuase im writing a pbp program that has interrupts that are required to be written in ASM.
If I declare a variable in pbp as a word, e.g. my_data VAR WORD, can I then use the variable _my_data in ASM as is?
for example, can i do rrf _my_data,1 and expect the whole word to be rotated?
The only other thing I dont get is how to get the base memory address of the array. Looking at your code here and the comment, i cant see how its doing what the comment said it does:
movlw low _array ; load FSR with address of the array
movwf FSR
Thanks for ur help
>> can i do rrf _my_data,1 and expect the whole word to be rotated?
No, it only works with 1 byte at a time. But, the rrf rotates through the CARRY flag, so a second rrf on the next byte will rotate the CARRY right into the next byte.
>> I dont get is how to get the base memory address of the array
At the ASM level, that's what variables are, pointers(address) to the actual memory location in RAM. So low _array gives you the lowbyte of the address of the variable array.
<br>
DT
Bookmarks