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?
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.
Paul,
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.
Again, let me state the Parallax position that SX/B is designed as a learning tool; it will never have all the fancy features of a compiler that you'd actually have to pay for. I know this won't make some happy, but that's the position we've taken with this product. And no, we have not plans to retool it and charge for it. Our goal is educational, and as the SX contest clearly pointed out, clever programmers are doing really neat things with SX/B -- despite any perceived limitations.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Jon Williams Applications Engineer, Parallax
Dallas, TX· USA
Its ok, I didn't need macros, I can get along fine without them. My program is programming another microcontroller via SPI using 4 byte command sequences, my code ends up looking like:
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
Actually you can't use __PARAMCNT like that. It is the most volitile parameter, any array access will destroy it, and it should be considered READ-ONLY. You MUST store it in a regular variable as the first operation in the subroutine.
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.
That's what I get for writing code on the fly! · Hopefully, though, users new to SX/B will get the message that there's more under its hood than what appears at first blush.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Jon Williams Applications Engineer, Parallax
Dallas, TX· USA
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
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