No macros in SX/B?
Paul Baker
Posts: 6,351
Im trying to make my first SX/B project more readable through macros, but docs make no mention of macros and using SASM macros doesn't work, are macros availible?
Comments
I don't believe that macros are available in SX/B. I'm curious about how big/complicated your project is that you want to use macros on it. Is it already well decomposed into logical functions? Have you considered breaking parts of the program into separate source files? I think the keyword is "Load" which lets you include other source files into a project. That could help break the bulk of the program's source listing into a collection of smaller, more readable source listings.
Thanks, PeterM
You should be able to use macros with-in ASM..ENDASM blocks.
Also Peter is correct LOAD will load in an external sxb file and INCLUDE will load in an external src file.
Could you give an example of what you want to do ?
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video Display Module" Available Now.
www.sxvm.com
"I thought I was wrong once...But I was mistaken [noparse];)[/noparse]"
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
SPI_CMD(0) = $A4
SPI_CMD(1) = $53
SPI_CMD(2) = $00
SPI_CMD(3) = $00
GOSUB Send_SPI
I was hoping to define a macro something like
macro SPI_String 4
SPI_CMD(0) = \1
SPI_CMD(1) = \2
SPI_CMD(2) = \3
SPI_CMD(3) = \4
GOSUB Send_SPI
endm
then define the following
Program_Enable CON "($A4, $53, $00, $00)"
So I can declare in my code:
SPI_String Program_Enable
which is more readable than the original code, but like I said its no biggie.
One final question, does string constant substitution occur in ASM blocks or does SX/B pass ASM blocks straight to SASM without preprocessing the block?
Post Edited (Paul Baker) : 5/4/2005 3:59:35 PM GMT
Declare the subroutine:
SEND_SPI··· SUB··· 1, 4
Here's the subroutine code:
SEND_SPI:
· spiCmd(0) = __PARAM1
· spiCmd(1) =·__PARAM2
· spiCmd(2) = __PARAM3
· spiCmd(3) = __PARAM4
· DEC __PARAMCNT
· DO WHILE __PARAMCNT > 0
····dataOut = spiCmd(__PARAMCNT)
··· ' send it
··· DEC __PARAMCNT
· LOOP·
· RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Post Edited (Jon Williams) : 5/4/2005 4:22:32 PM GMT
Somthing like:
SEND_SPI:
Count=__PARAMCNT
spiCmd(0) = __PARAM1
spiCmd(1) = __PARAM2
spiCmd(2) = __PARAM3
spiCmd(3) = __PARAM4
DEC Count
DO WHILE Count > 0
dataOut = spiCmd(Count)
' send it
DEC Count
LOOP
RETURN
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video Display Module" Available Now.
www.sxvm.com
"I thought I was wrong once...But I was mistaken [noparse];)[/noparse]"
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
SEND_SPI SUB 1, 4
Im guessing the 4 is the number of parameters passed, what is the 1 for?
http://forums.parallax.com/showthread.php?p=517621
You'll find SUB in Reference\Definitions.· Quickly, the first parameter is the minium number of parameters required (if any), the second parameter is the maximum number of parameters allowed.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA