I realized that there is no way to make a subroutine that prints a string.
What would be nice is if you could pass a string to a subroutine that would output the string. However, when you pass a string it is passed as a VAR LONG that contains the hub address of the string. And SEROUT will try to send that as the value.
So I'm looking for suggestions on how to implement this. Here are some ideas:
SEROUTSTR pin,baud,value ' A new command SEROUTSTR
SEROUT pin,baud, STRPTR value ' A prefix word before the value
SEROUT pin,baud,[noparse][[/noparse]value] ' Enclose value in square brackets
I'd like to hear your ideas.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
I like using a prefix. I would prefer using a punctuation character as a prefix rather than something like STRPTR just for ease of use, kind of like the inverse of "@". "[noparse]/noparse" is already used in PBasic with a completely different meaning, so I think it would be better to stay away from that. Having a different statement is also possible, but would preclude possibly extending the SEROUT statement in the future to multiple parameters.
@Christof, I see what you are trying to do. I'll get the "speed" parameter of SHIFTOUT working. Then you can just specify what speed you want SHIFTOUT to operate at.
The next release will support something like:
SHIFTOUT pin1, pin2, LSBFIRST, datavalue, 5
The ",5" means to send the bits 5 times faster than normal.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
@Bean: Are you able to post PropBASIC ver. 90 here? The normal site is down, and I'm having trouble getting strings to work - just wondering if it's because I'm using ver. 89.
I can post all 3 versions on forum if he said it is OK
Regards
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Nothing is impossible, there are only different degrees of difficulty. For every stupid question there is at least one intelligent answer. Don't guess - ask instead. If you don't ask you won't know. If your gonna construct something, make it·as simple as·possible yet as versatile as posible.
Gerry,
Thanks. I'll have to confer with BradC. The program works okay when I use the version I compile. But the version he compiled must not be picking up the fix.
We'll try to get it sorted ASAP.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
Bean said...
@Mike, As a take on the "SHIFTOUT value\bits" format, how about "SEROUT pin,baud,value\STR" ?
My first thought was to prefix the value with a $ (a 'kind of S' for string).
But I also like (and think I prefer) your idea to add the suffix \STR.
It means in the future we could also see \DEC or \HEX without changing the logic. Furthermore, \STR or \HEX seems to follow the concept of BASIC more than $ or ¬ prefixes ! It should almost be obvious what they do instead of requiring a reference guide.
The latest version of PropBasic is available for download (00.00.92).
In case you missed it, SEROUT can now send strings. So you can now do
SEROUT 30, T115200, "Hello There"
Here are the other changes:
Version 00.00.91
Fixed: pin = longvar ' Used "test", should have been "cmp"
Added: SEROUT pin,baud,longvar\STR (longvar is a pointer to HUB string)
Added: SHIFTOUT and SHIFTIN speed multiplier
Version 00.00.92
Fixed: ON...GOSUB for LMM
Changed: GOSUB only works with declared SUBs and FUNCs
Fixed: Problem with value over 31-bits with bst " temp = 4294967295"
Fixed: Divide by zero locks-up. Now returns zero.
Fixed: SEROUT string error if HUB offset is > $1FF
Fixed: SEROUT string can have an index
I'll work on updating all the demos to use the new features.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
Hi Bean,
sorry, that I still have wishes for PropBasic:
1. Would it be possible, to modify the LET statement: Y= 2*X + 4 *a Strictly calculated from left to right. I think, that a stack is still not needed for this and the benefit would be, that you can write more compact code.
2. Again I ask about float support (only together with LMM of course). Is this on your list?
3. What about the docu? Is this still worked on? It would be a great pity to have such a good tool and not to know how to use it....
Christof
I can answer the docs question as it's in my lap: Yes, it's still being worked on. Both Bean and I do this stuff for fun (no profit) so PropBASIC has to take a back seat to our paying jobs. Thanks for being patient.
BTW, I am NOT in favor of your request for more than one operator per line. The goal of PropBASIC, in addition to having a nice BASIC compiler for the Propeller, is to show users how to translate BASIC to PASM. While your program using a complex expression would be more compact, the resulting code wouldn't. Just my $0.02. Multiplication takes a fair bit of code, and in my opintion should be dropped into a function so that it's only compiled once -- like this
FUNC MULT
param3 = param1 * param2
RETURN param3
ENDFUNC
Now your code becomes:
y = MULT 2, x
y2 = MULT 4, a
y = y + y2
Yes, your source listing is longer, but the resulting code is more compact (which is what's important).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
Hi Jon,
thanks for the answer. I am very happy that you still work for PropBasic. I had feared, that this might be a dropped project (Instead now a C-Compiler?). Your doc in this quality is very very much work, I think!
Well, I thought simply from left to right: Y= 2*X + 4 *a would be calculated to the result Y= ((2*X)+4)*A eqivalent to:
Y= 2 * X
Y= Y + 4
Y= Y * A
I think, that this could perhaps be done without great changement of the compiler.
I have now a project using PropBasic. I am still impressed, how much code can reside inside one cog. In 250 lines of basic code -only the program, without variables declarations- there is a complete 3-axis step motor controller in one cog. And the possible speed is much higher, than my motors allow....
Thanks for your input how to gain some bytes,
Christof
Comments
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
What would be nice is if you could pass a string to a subroutine that would output the string. However, when you pass a string it is passed as a VAR LONG that contains the hub address of the string. And SEROUT will try to send that as the value.
So I'm looking for suggestions on how to implement this. Here are some ideas:
SEROUTSTR pin,baud,value ' A new command SEROUTSTR
SEROUT pin,baud, STRPTR value ' A prefix word before the value
SEROUT pin,baud,[noparse][[/noparse]value] ' Enclose value in square brackets
I'd like to hear your ideas.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
could you please have a look at this:
My routine SFast for a faster shiftout (for 74HC595) does not work,
.. can this ever be nz?
················· test········· __param1,#0·················· '····· SerData= __param1
················· muxnz········ outa,SerData
This is compiled from the line 147 of the pbas-file.
Should this be?
test········· __param1,#1 wz·················· '····· SerData= __param1
Christof
Using #1 won't work because the pin should be high with any non-zero value in the variable.
I think the "test" should be "cmp".
Can you change it in the .spin file and let me know if that works ?
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
I like using a prefix. I would prefer using a punctuation character as a prefix rather than something like STRPTR just for ease of use, kind of like the inverse of "@". "[noparse]/noparse" is already used in PBasic with a completely different meaning, so I think it would be better to stay away from that. Having a different statement is also possible, but would preclude possibly extending the SEROUT statement in the future to multiple parameters.
The next release will support something like:
SHIFTOUT pin1, pin2, LSBFIRST, datavalue, 5
The ",5" means to send the bits 5 times faster than normal.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
If the port shall be 1 on everything not zero:
...
do
__param3 = __param1 & 1
\ cmp __param3,#0 wz ' SerData= __param3
\ muxnz outa,SerData
__param1= __param1 >> 1
pauseus 1
SClk = 1
pauseus 1
SClk = 0
loop __param2
This works.
Christof
I hope, it is helpful and OK, if I send you my discoveries what seem to me "beta version features" here.
There is a difference between non-LMM and LMM, when I run my simple sceduler.
I·think for the·ON .... GOSUB construct,·LMM is not adapted yet?
Because of the impressive speed of PropBasic I want to use it for SubTasks within tasks.
Best regards
Christof
If you declare a hub or cog variable as long you can assign it the max. 32 bit value using hex or binary notation but not decimal
ie
myvar = $FF_FF_FF_FF or
myvar = %1111_1111_1111_1111_1111_1111_1111_1111
works but
myvar = 4294967295· does not.
Gerry
@Gerry, Are you using the latest version of PropBASIC ? It seems to work for me. I think that was a problem in a previous version.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.com
Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.
I am using latest version 0.90, error is from propellent with message that
"source register/constant cannot exceed $1FF"
Gerry
Can you post the program that is causing the error ? Or better yet a very small program that exhibits the error.
Thanks,
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.com
Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.
·code produced is mov·········· cogvar,#4294967295
regards
Gerry
If Bean can't post v90
I can post all 3 versions on forum if he said it is OK
Regards
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
For every stupid question there is at least one intelligent answer.
Don't guess - ask instead.
If you don't ask you won't know.
If your gonna construct something, make it·as simple as·possible yet as versatile as posible.
Sapieha
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.com
Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.
Thanks. I'll have to confer with BradC. The program works okay when I use the version I compile. But the version he compiled must not be picking up the fix.
We'll try to get it sorted ASAP.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
My first thought was to prefix the value with a $ (a 'kind of S' for string).
But I also like (and think I prefer) your idea to add the suffix \STR.
It means in the future we could also see \DEC or \HEX without changing the logic. Furthermore, \STR or \HEX seems to follow the concept of BASIC more than $ or ¬ prefixes ! It should almost be obvious what they do instead of requiring a reference guide.
.
In case you missed it, SEROUT can now send strings. So you can now do
SEROUT 30, T115200, "Hello There"
Here are the other changes:
Version 00.00.91
Fixed: pin = longvar ' Used "test", should have been "cmp"
Added: SEROUT pin,baud,longvar\STR (longvar is a pointer to HUB string)
Added: SHIFTOUT and SHIFTIN speed multiplier
Version 00.00.92
Fixed: ON...GOSUB for LMM
Changed: GOSUB only works with declared SUBs and FUNCs
Fixed: Problem with value over 31-bits with bst " temp = 4294967295"
Fixed: Divide by zero locks-up. Now returns zero.
Fixed: SEROUT string error if HUB offset is > $1FF
Fixed: SEROUT string can have an index
I'll work on updating all the demos to use the new features.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
Post Edited (Bean) : 4/16/2010 4:33:12 PM GMT
Christof
Thanks for all the hard work.
SEROUT with strings is a Godsend!
Jim
While we fixed the problem with assigning decimal values, now hex values ($ prefix) don't work.
In Delphi "VAL(string, longint, error)" works for hex values, but "VAL(string, double, error)" doesn't work for hex values. I didn't realize that.
Sorry about the problem. I'll get it fixed and post a new version ASAP.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
Sorry for not catching that before I release it
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
Post Edited (Bean) : 4/19/2010 1:33:00 AM GMT
sorry, that I still have wishes for PropBasic:
1. Would it be possible, to modify the LET statement: Y= 2*X + 4 *a Strictly calculated from left to right. I think, that a stack is still not needed for this and the benefit would be, that you can write more compact code.
2. Again I ask about float support (only together with LMM of course). Is this on your list?
3. What about the docu? Is this still worked on? It would be a great pity to have such a good tool and not to know how to use it....
Christof
BTW, I am NOT in favor of your request for more than one operator per line. The goal of PropBASIC, in addition to having a nice BASIC compiler for the Propeller, is to show users how to translate BASIC to PASM. While your program using a complex expression would be more compact, the resulting code wouldn't. Just my $0.02. Multiplication takes a fair bit of code, and in my opintion should be dropped into a function so that it's only compiled once -- like this
Now your code becomes:
Yes, your source listing is longer, but the resulting code is more compact (which is what's important).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
thanks for the answer. I am very happy that you still work for PropBasic. I had feared, that this might be a dropped project (Instead now a C-Compiler?). Your doc in this quality is very very much work, I think!
Well, I thought simply from left to right: Y= 2*X + 4 *a would be calculated to the result Y= ((2*X)+4)*A eqivalent to:
Y= 2 * X
Y= Y + 4
Y= Y * A
I think, that this could perhaps be done without great changement of the compiler.
I have now a project using PropBasic. I am still impressed, how much code can reside inside one cog. In 250 lines of basic code -only the program, without variables declarations- there is a complete 3-axis step motor controller in one cog. And the possible speed is much higher, than my motors allow....
Thanks for your input how to gain some bytes,
Christof