PropBASIC 00.00.04 Sept 1, 2009 Download it and try it.
Bean
Posts: 8,129
Okay, it is still VERY basic. Only a few commands have been implemented. But members have been bugging me for something ANYTHING to try out.
So here it is. Be sure to read the PropBASIC.txt file. It is just a command line utility for now. You MUST HIT ENTER after it is done compiling for it to end.
If you have any questions please ask.
0.0.04 Sept 1, 2009
· Fixed problem with·9-bit constants used as parameters to subroutines.
· Fixed problem with using PAUSE more than once, cause DUPLICATE VARIABLE error
Bean.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
Post Edited (Bean (Hitt Consulting)) : 9/1/2009 3:21:06 PM GMT
So here it is. Be sure to read the PropBASIC.txt file. It is just a command line utility for now. You MUST HIT ENTER after it is done compiling for it to end.
If you have any questions please ask.
0.0.04 Sept 1, 2009
· Fixed problem with·9-bit constants used as parameters to subroutines.
· Fixed problem with using PAUSE more than once, cause DUPLICATE VARIABLE error
Bean.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
Post Edited (Bean (Hitt Consulting)) : 9/1/2009 3:21:06 PM GMT

Comments
Post Edited (JonnyMac) : 8/31/2009 5:46:14 PM GMT
The compiler seems to be looking for INVALID.TXT
Oops, Sorry about that Jon. I updated the program. Try it now.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
Post Edited (Bean (Hitt Consulting)) : 8/31/2009 6:20:57 PM GMT
Yeah it looks like spin will not allow the word "Main" to be used as a label.
I changed it to "Main1" and it worked.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
·
At the end of the FOR-NEXT loop there is a peculiar line:
Is the "+" supposed to be there? It doesn't seem to hurt, but I've never seen such syntax.
No that "+" is not supposed to be there. I'll remove that. But I'm surprised that it works....
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
·
I missed NOT from the list of operators.
So I inserted temp = NOT temp
Start: LOW LED FOR temp = 1 TO 10 TOGGLE LED PAUSE 500 NEXT temp = not temp ENDIt compiles without error and the line temp = NOT temp
seems to be ignored.
regards peter
Also, the Main issue was caused by the compiler's use of Main; suggest you change that to RunPB or something else that a programmer typically wouldn't use.
Post Edited (JonnyMac) : 8/31/2009 7:48:06 PM GMT
Delay mov __param1, #500 ' PAUSE 500 mov __param2, _1ms add __param2, cnt __L0001 waitcnt __param2, _1ms djnz __param1, #__L0001And, you might consider optimizing for short delays that are powers of two. A pause of 8 milliseconds might expand to this:
Delay8 mov __param1, _1ms ' PAUSE 8 shl __param1, #3 add __param1, cnt waitcnt __param1, #0Post Edited (JonnyMac) : 8/31/2009 9:46:06 PM GMT
With so little room in one cog have you considered callable code blocks instead of straight inline compilation?
' Pulse (make output and toggle) pin for n microseconds ' -- move pin# to _param1 ' -- move microseconds to _param2 _pulsout mov _param3, #1 shl _param3, _param1 wz if_z jmp #_pulsout_ret tjz _param2, #_pulseout_ret xor outa, _param3 or dira, _param3 mov _param1, _param2 call #_pauseus xor outa, _param3 _pulsout_ret ret ' Pause program in milliseconds ' -- move milliseconds to _param1 before calling ' _pause tjz _param1, #_pause_ret mov _param2, _1ms add _param2, cnt :loop waitcnt _param2, _1ms djnz _param1, #:loop _pause_ret ret ' Pause program in microseconds ' -- move microseconds to _param1 before calling ' _pauseus tjz _param1, #_pauseus_ret mov _param2, _1us add _param2, cnt :loop waitcnt _param2, _1us djnz _param1, #:loop _pauseus_ret retPost Edited (JonnyMac) : 8/31/2009 10:17:13 PM GMT
Ken Gracey
Parallax Inc.
For the life of me I could not find a reference to PAUSEUS. I broke out my BS2 books and SX books and did a Parallex site search for the command. I finaley found it in the SX/B help. Boy, you couln't have hidden a command any better.·
I guess it's old hat to you SX guys. This·is to help the BS2 guys that come over to the dark side.
So - you have loops, delays, flashing lights and goto already.
Can't wait for the next installment!
Get it from the top post.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
·
-Andy
Small error with setting up for PAUSE 500. The compiler outputs:
... it's missing the # for the immediate value.
Post Edited (JonnyMac) : 9/1/2009 2:49:52 AM GMT
The compiler output uses Main but doesn't have to. Here's the original output:
PUB Main ' PROGRAM Start CogNew(@__PROGSTART, 0) DAT __PROGSTART JMP #StartI manually edited to this:
PUB RunPB ' PROGRAM Start CogNew(@Start, 0) DAT '' ========================================================================= Start ORG 0 'Start:... which works fine, frees 'Main' for programmer use, and saves the beginning (unnecessary?) jmp. I don't think Spin cares about having a Main; it simply runs the first method. Right?
Enter causes it to end however no compiled spin file appears on the
E drive or anywhere. Where is it?
Post Edited (humanoido) : 9/1/2009 7:11:31 AM GMT
Delay 'SUB Delay MOV __TEMP1,CNT ' PAUSE __PARAM1 ADD __TEMP1,_1mSec MOV __TEMP2,__PARAM1 __L0001 WAITCNT __TEMP1,_1mSec DJNZ __TEMP2,#__L0001 Delay_ret 'ENDSUB RETYou could just as well use __PARAM2 and __PARAM3.
regards peter
instead of PUB Main call it something else.
I'd prefer PUB start and also a PUB stop.
These seem to be the standard names for starting and stopping a cog.
Also, why putting in
· _ClkMode = XTAL1 + PLL16X································
· _XInFreq =·· 5000000······································ 'FREQ 80_000_000
I only have a spinstamp and therefor always need to edit the generated file.
I would like to import the generated file as
OBJ
· pbcog: "test.spin"
in my own program (in which I use main as
the program starting point) and call pbcog.start() from there.
regards peter
This is a cool and ambitious project
I'd love to be able to write a tiny compiler for a controller.
I need a good book about compiler creation.
I would need a "Compiler Construction for Dummies" type of book, not a tome
usable only by CompSci Phd's
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Some mornings I wake up cranky.....but usually I just let him sleep -
plus an edited test.spin to make test.spin a loadable module.
The programs import test.spin
They also declare a long array to be passed to the PropBasic cog.
I think that is the most useful setup. I can write my cogcode in PropBasic
and my mainprogram in spin. Having not to use PASM directly makes
a difference, even if the compiled PASM is not optimized.
The modified test.spin
PUB Stop CogStop(cog_id) DAT __PROGSTART JMP #__StartOR DIRA,LED ' LOW LED ANDN OUTA,LEDOR DIRA,LED ' TOGGLE LED XOR OUTA,LEDMOV __PARAM1,500 ' Delay 500 CALL #DelayADD temp,#1 ' NEXT CMPS temp,#10 WZ, WC IF_BE JMP #__FOR_temp_1MOV __TEMP1,CNT ' PAUSE __PARAM1 ADD __TEMP1,_1mSec MOV __TEMP2,__PARAM1 __L0001 WAITCNT __TEMP1,_1mSec DJNZ __TEMP2,#__L0001Delay_ret 'ENDSUB RETAdd1_ret ' RETURN __PARAM1 RETThe protoboard program
{{ Protoboard PropBasic test program }} CON _ClkMode = XTAL1 + PLL16X _XInFreq = 5000000 OBJ pbcog: "test.spin" VAR long PBparameters[noparse][[/noparse]26] PUB Main pbcog.Start(@PBparameters)regards peter
· I've decided that the __PARAMx variables will be used exclusively for subroutine parameters. So you DON'T need to store them into other variables in the subroutine, because they will never be used by PropBASIC commands.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
·
· For the spin stamp change "DEVICE P8X32A, XTAL1, PLL16X" to "DEVICE P8X32A, XTAL1, PLL8X". The compiler will then generate the correct _XInFreq for "FREQ 80_000_000".
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
·
I understand the necessity for FREQ 80_000_000.
That value is used for PAUSE and PAUSEUS.
But why including PLL multiplier and oscillator frequency?
I don't think a cog needs that info.
And I want to set clkmode and inxfreq in my program file,
not in a object that I import in my program file.
BTW, I tried commenting out DEVICE but then
the compiler crashes.
regards peter
Is there still a need for __PARAMCNT since all arguments to·a sub are 32bit values anyway?
regards peter
assumption that all you need is PropBASIC test1.bas /p, but that did not work.
<edit
The program, I think, is supposed to flash the LED, but with a setting of 'delay 500', I did not see anything happen.
When I increased the value to 'delay 1500', then I saw it flash. So, I am not sure as to how the delay values
are supposed to work.
edit>
Ray
Post Edited (Rsadeika) : 9/1/2009 1:34:35 PM GMT