Hehe, i agree.
Just a question. Is there any possible problem by using
againstCode:wData var word SYSTEM
Code:wData var word
Hehe, i agree.
Just a question. Is there any possible problem by using
againstCode:wData var word SYSTEM
Code:wData var word
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Well, can't say for sure, but I've never had any problems with SYSTEM.
PBP tries to protect against duplicate variable names by adding an underscore "_" in front of everything that's specified by the user.
The only thing that "SYSTEM" does, is prevent that underscore from being added.
It could cause a Naming Conflict with other things being used at the ASM level, but when that happens, the compiler will let you know.
It does make things look nicer without all those _'s. But then, those _'s can make it easier to differentiate between what's PBP and what's ASM variables, when it's debugging time.
It's hard to say which way is better.
<br>
Last edited by Darrel Taylor; - 29th August 2005 at 07:01.
DT
Thanks guys, that's exactly what I needed, and it works great. Now to make things more tricky..... the data I'm sending out is in an array, and I normally use this macro inside a for loop that's cycling through the array.
The old code:
<code>
For Sample = 0 to (N_SAMPLES - 1)
Hserout [Sample_Array[Sample] / 100, Sample_Array[Sample] // 100]
Next
</code>
For obvious reasons, I can't just write:
<code>
@ Transmit _Sample_Array[_Sample]
</code>
I will rewrite the macro to so that the argument is the Index of the Sample_Array array, so the macro will be dedicated to using that one array, like such:
<code>
@ Transmit _Sample
</code>
I'll post my macro when I've finished writing it, but just for discussions sake, is there some easy way to call a member of an array using a macro? I could use something like:
<code>
Addr = Sample_Array + (2 * Sample)
@ Transmit _Addr
</code>
To do the same thing, right? This doesn't help much since my aim is to improve readability here.
I guess I could use a macro that takes a word array and an index as arguments:
<code>
@ TX_Array _Sample_Array, _Sample
</code>
Hmmm. I seem to be answering my own questions by writing it down. Macros now seem much more useful. How would I write the above macro, but have it be able to take Word and Byte arrays? In other words, how do you use If statements in macros?
Thanks guys,
forgie
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.
Bookmarks