PDA

View Full Version : ASM question



Charles Linquis
- 8th February 2011, 03:41
I'm using 18F's and I'm trying to build a small array in ASM, and then read it back with an ASM routine.

I figured that if I defined the array in BANKA SYSTEM, I could probably get the first address of that array using the "GetAddress/CHK?RP" macro

After that, I could incf a pointer and add it to the address to move down the array.

Then I could use something like the movff instruction to move the contents of that location to my send buffer.

While I know how to move the contents of one variable into another, I don't know how to move the contents of a memory LOCATION to a variable.

Am I going about this the right way? Or is there a simple solution?

Darrel Taylor
- 8th February 2011, 16:20
It would probably be easier to use an FSR.
And the array doesn't need to be in BANKA so you're not limited in size.

This shows how it could work in PBP.
Hopefully you can see how it works with ASM too.


MyArray VAR BYTE[32]
Abyte VAR BYTE
X VAR BYTE

Init:
ARRAYWRITE MyArray,["Hello World!",13,10]

;------------------------------------------
Main:
@ LFSR 0, _MyArray
FOR X = 0 TO 13
@ MOVE?BB POSTINC0, _Abyte
HSEROUT [Abyte]
NEXT X
PAUSE 1000
GOTO Main

Charles Linquis
- 8th February 2011, 17:37
Thanks Darrel,

That is exactly what I was looking for.

Now I'll have a fully functional I2C slave running in an ASM interrupt. Much less overhead than writing it in PBP.