PDA

View Full Version : Using ASM with PBP variables.



BobEdge
- 9th August 2011, 10:12
Hi,

Does anyone out there have any examples of using PBP variables in asm?

In particular I was thinking of reading TMR1H, & TMR1L into a 16 bit PBP variable, or setting up registers, doing A to D conversions, maybee some simple maths.

Anything really, just trying to get my head around a little asm. I am trying to save some code space on a project where I can't change the chip I am using, but have run out of memory. But I want to learn anyway. As much as I love PBP it is always nicer to use asm where it is not to difficult, and use PBP for the more comples parts.

Kind regards
Bob.

mister_e
- 9th August 2011, 10:20
The easiest way is to use PBP macro, so you don't need to bother about BANK switching.

MOVE?WW TMR1L, _YourWordVariable
MOVE?BB TMR1L, YourWordVariable
MOVE?BB TMR1H, (YourWordVariable +1)

you can still use the asm way, but you do not gain any codespace, the MOVE?xx macro are pretty tight.
The whole set of MOVE?xx macro are listed in the .lib fil in the PBP installation folder.

for simple maths... hard to tell, what you consider to be simple... division by 7 seems to be easy, but nightmare to code in asm the first time :s

check out the piclist website. Or come with a specific requirement and some may give this a shot.

BobEdge
- 10th August 2011, 10:41
Thank's for that. I had no idea about the .lib files. Very interesting stuff.

Will also check out the piclist website.

Regards
Bob...

BobEdge
- 10th August 2011, 16:44
Ok, I have been doing a little more delving into asm. So I now have a specific question.
How do I use a macro?
I have tried using it in PBP, and inbetween the ASM, ENDASM commands, but I can't seem to get the syntax right.

mister_e
- 10th August 2011, 17:17
Which macro? the one of PBP or your own?

If PBP one well, no real problem
ByteA VAR BYTE
ByteB VAR BYTE

@ MOVE?CB 123, _ByteA
@ MOVE?BB _ByteA, _ByteB
ByteB is now equal to 123

don't forget, it is CASE SENSITIVE. Try it, and if you still have problem, post your code here, we will have a look to it.

Also, you can refer to various DT include files, or my KeyPad or my Nokia GLCD. Lot's of macro use in those ;)

BobEdge
- 11th August 2011, 11:28
Ahh I see what I was doing wrong. I thought the asm part saw all pbp names as _CAPITALS.

Thanks.