Oh and, how do you post code like you guys do? I have been using < code>.... whats the tag to put it in a nice little grey box?
Oh and, how do you post code like you guys do? I have been using < code>.... whats the tag to put it in a nice little grey box?
BBCode:
http://www.phpbb.com/phpBB/faq.php?mode=bbcode
Luciano
Thanks, Luciano
My macro now looks like thus:
(Sample_Array is a word array that I'm using to store my data in).Code:TXArray var Sample_Array TXIndex var word SYSTEM TXData var word SYSTEM @TX_Sample macro index @ MOVE?WW index, TXIndex TXData = TXArray[TXIndex] Hserout [TXData / 100, TXData // 100] @ endm
This works great, and I can call it like this:
Thanks for the pointers, fellow PBPers. The only thing I couldn't do was get it to take both the array and the index as arguments.... I have to nut out the whole memory addressing thing in my head before I can get it to work.Code:@ TX_Sample _Sample
Good job guy. i just want to remind you something. Every time a macro is called, that duplicate his whole code. so, by using the following
this will generate less code everytime you call the macro.Code:asm TX_Sample macro index MOVE?WW index, TXIndex L?CALL TXnow endm TXnow ENDASM TXData = TXArray[TXIndex] Hserout [TXData / 100, TXData // 100] RETURN
Here's another method to send a specific index of Word array var.
there's probably tons of way like using AOUT?xxx macro too.. well still unsure of that one AOUT?xxxCode:DEFINE LOADER_USED 1 DEFINE OSC 20 DEFINE HSER_RCSTA 90h DEFINE HSER_TXSTA 24h DEFINE HSER_SPBRG 129 ' 9600 Bauds TXData var WORD SYSTEM aVar var word[4] SYSTEM avar[0]=0 avar[1]=100 avar[2]=1000 avar[3]=10000 goto start asm Usend macro index MOVE?WW aVar + (index*2) , TXData L?CALL TXnow endm TXnow ENDASM Hserout [dec TXData,13,10] RETURN start: @ Usend 0 @ Usend 1 @ Usend 2 @ Usend 3 pause 500 goto start
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Macro's can be usefull. But, they're not always the best choice.<br>Code:TRANSMIT: Temp = Sample_Array(Index) HSEROUT [Temp / 100, Temp // 100] RETURN Index = 2 : GOSUB TRANSMIT
DT
Yes, I was aware of that after reading one of your earlier posts. I am sitting slightly under 50% of my available code space (on an 18f452), and on top of that the data sending routines are used in a part of the code where speed is preferable (but not critical). To use the fastest method I would have to find out what macros HSEROUT calls, and call them directly somehow.... and the smallest code version would be something along the same lines using gosubs. Anyway if the timing becomes more important or code space is an issue then I will rewrite the macro. But for the meantime, I have improved readability by a large degree. Thanks for the ideas/wisdom guys, it's great to know that there's such a concentrated pool of knowledge in this forum to ask when I have a tough PBP question.....
Also.... the macro method makes me feel like my code is more 'modular,' and more like a functional language, which makes me feel warm inside![]()
Bookmarks