Rsadeika said...
Are you typing in the full path, and the file name? For instance: PropBASIC F:\PropBASIC\test1.bas /p. I made an
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
Version 0.00.03 has a small bug with values less than 512; it uses the immediate value but leaves out the required #. For values 512 and higher the compiler creates a symbol with the correct value.
Jon,
Okay I fixed the problem with 9-bit constants as parameters, and the DUPLICATE VARIABLE NAME. Version 0.0.04 is in the first post.
humanoido,
I'm not sure, you need to have all the files in one directory. And the path/filename must be complete and be in quotes. I'd make it something simple like C:\PropBasic, then you would use:
PropBASIC "C:\PropBASIC\test.bas"
from the C:\PropBASIC directory.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
Bean said... · 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.
That makes sense to keep overhead low. Can I assume the __TEMPx variables are reused whenever possible?
Is there still a need for __PARAMCNT since all arguments to·a sub are 32bit values anyway?
regards peter
Peter, · Yes, the __TEMPx variables will be used for certain commands that need temporary variables.
__PARAMCNT is still needed because subroutines can still have a variable number of parameters.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
I noticed that you have to have the DEVICE, and FREQ call out in the program. What if I
want to run the program using the prop internal clock, will their be a provision for that?
You probably need to set FREQ to the frequency of the internal clock.
I would prefer passing the FREQ value via the commandline and
that the generated spinfile would get a constant FREQ = <value_from_commandline>
That way you don't have to edit the propbasic source just to run on another frequency.
(I don't see the necessity for DEVICE at all for compiling code that runs entirely in 1 cog)
Rsadeika said...
I noticed that you have to have the DEVICE, and FREQ call out in the program. What if I
want to run the program using the prop internal clock, will their be a provision for that?
Ray
Remember, we're on the very front end of things so there are a lot of rough edges. You can use RC mode like this:
DEVICE P8X32A, RCFAST
FREQ12_000_000
After opening the Spin file in the IDE you need to comment-out the _XINFREQ line. A compiler update will take care of this later.
Start:
temp = PAR
temp = Rd_Byte PAR,3
temp = Rd_Word PAR,3'inline
asm
mov __temp1,#3shl __temp1,#1add __temp1,PARrdword temp,__temp1
endasm
temp = Rd_Long PAR,3
Wr_Byte PAR,3,temp
Wr_Word PAR,3,temp
Wr_Long PAR,3,temp
LOW LED
FOR temp = 1TO20
LED = ~LED
Delay 500
NEXT
'temp2(2) = temp
asm
movd __load,#temp2+2
__load mov00_00,temp
endasm
FOR temp = 0TO2'temp2(temp) = temp<<3
__PARAM1 = temp << 3
asm
mov __temp1,#temp2
add __temp1,temp
movd __load2,__temp1
__load2 mov00_00,__PARAM1
endasm
NEXT
Delay 5000
GOTO Start
END
SUB Delay
PAUSE __PARAM1ENDSUB
FUNC Rd_Byte '__PARAM1 is base, __PARAM2 is byteindex
__PARAM2 = __PARAM2 + __PARAM1asmRDBYTE __PARAM1,__PARAM2endasmRETURNENDFUNC
FUNC Rd_Word '__PARAM1 is base, __PARAM2 is wordindex
__PARAM2 = __PARAM2 << 1__PARAM2 = __PARAM2 + __PARAM1asmRDWORD __PARAM1,__PARAM2endasmRETURNENDFUNC
FUNC Rd_Long '__PARAM1 is base, __PARAM2 is longindex
__PARAM2 = __PARAM2 << 2__PARAM2 = __PARAM2 + __PARAM1asmRDLONG __PARAM1,__PARAM2endasmRETURNENDFUNC
SUB Wr_Byte '__PARAM1 is base, __PARAM2 is byteindex, __PARAM3 is value
__PARAM2 = __PARAM2 + __PARAM1asmWRBYTE __PARAM2,__PARAM3endasmENDSUB
SUB Wr_Word '__PARAM1 is base, __PARAM2 is wordindex, __PARAM3 is value
__PARAM2 = __PARAM2 << 1__PARAM2 = __PARAM2 + __PARAM1asmWRWORD __PARAM2,__PARAM3endasmENDSUB
SUB Wr_Long '__PARAM1 is base, __PARAM2 is longindex, __PARAM3 is value
__PARAM2 = __PARAM2 << 2__PARAM2 = __PARAM2 + __PARAM1asmWRLONG __PARAM2,__PARAM3endasmENDSUB
Compiles into
''*** COMPILED WITH PropBasic VERSION 0.00.0409/01/2009***
CON 'DEVICE P8X32A, XTAL1, PLL16X
_ClkMode = XTAL1 + PLL16X
Ps. it is posible You write litle manual ... On words that can be used and syntax to them
Regards ChJ
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 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.
You can look at the SXB help file for syntax (attached).
That should give you enough info, particular on the loop contructs.
Many commands are not implemented yet and some never will
because the Propellor is very different from SX.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 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, sometimes the regional settings have to be US.
I had that problem some years ago. I now run WinXP SP3 and
have no issues using Dutch regional settings.
> I get a "Navigation to web page was cancelled." error message. OS is Vista Home Preminum 64 bit.
I don't have Vista, but here's the MS KB on that issue...
While it would save one long in cog ram you take a bit hit on speed; 4 cycles for MOV versus 7 to 22 with RDLONG. PropBASIC will ultimately use LMM so this becomes moot.
For small drivers LMM may not be necessary. But I thought of an alternative.
If DATA is implemented (it doesn't work currently) I could use
myConst: DATA LONG 2999
All DATA must appear before PROGRAM Start (or after the basic program) and
is placed in a seperate DAT.
Then I can use
temp = Rd_long @myConst
where Rd_long (or LREAD) is a native·basic statement·to·read·a long from hubram.
BTW. this DATA could also be used to have external variables.
I could do Wr_long @myConst,temp
regards peter
Post Edited (Peter Verkaik) : 9/3/2009 6:24:31 AM GMT
Comments
Yes. I was able to setup EditPlus so that I can edit the PropBASIC source files and compile them with a button press.
Version 0.00.03 has a small bug with values less than 512; it uses the immediate value but leaves out the required #. For values 512 and higher the compiler creates a symbol with the correct value.
With 0.00.03 if you have two or more PAUSE statements in the program you get a nasty error:
Compile
<snip>
71 PAUSE 1024
ERROR 2 DUPLICATE VARIABLE NAME "_1mSec" ; PAUSE 1024
Exception EAccessViolation in module PropBasic.exe at 0001197C.
Access violation at address 0041197C in module 'PropBasic.exe'. Read of address 0000008C.
Output completed (3 sec consumed) - Normal Termination
Okay I fixed the problem with 9-bit constants as parameters, and the DUPLICATE VARIABLE NAME. Version 0.0.04 is in the first post.
humanoido,
I'm not sure, you need to have all the files in one directory. And the path/filename must be complete and be in quotes. I'd make it something simple like C:\PropBasic, then you would use:
PropBASIC "C:\PropBASIC\test.bas"
from the C:\PropBASIC directory.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
·
· Yes, the __TEMPx variables will be used for certain commands that need temporary variables.
__PARAMCNT is still needed because subroutines can still have a variable number of parameters.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
·
I have put the compile command in a .bat file
so you can compile by doubleclicking test.bat using windows explorer.
You may need to edit the path.
regards peter
want to run the program using the prop internal clock, will their be a provision for that?
Ray
I would prefer passing the FREQ value via the commandline and
that the generated spinfile would get a constant FREQ = <value_from_commandline>
That way you don't have to edit the propbasic source just to run on another frequency.
(I don't see the necessity for DEVICE at all for compiling code that runs entirely in 1 cog)
regards peter
Remember, we're on the very front end of things so there are a lot of rough edges. You can use RC mode like this:
DEVICE P8X32A, RCFAST FREQ 12_000_000
After opening the Spin file in the IDE you need to comment-out the _XINFREQ line. A compiler update will take care of this later.
Post Edited (JonnyMac) : 9/1/2009 8:10:18 PM GMT
I tried to implement indexed variables and came up with this
DEVICE P8X32A, XTAL1, PLL16X FREQ 80_000_000 LED PIN 16 temp2 VAR LONG(3) temp var long Delay SUB 1 PROGRAM Start Start: LOW LED FOR temp = 1 TO 20 LED = ~LED Delay 500 NEXT 'temp2(2) = temp asm movd __load,#temp2+2 __load mov 00_00,temp endasm FOR temp = 0 TO 2 'temp2(temp) = temp<<3 __PARAM1 = temp << 3 asm mov __temp1,#temp2 add __temp1,temp movd __load2,__temp1 __load2 mov 00_00,__PARAM1 endasm NEXT Delay 5000 GOTO Start END SUB Delay PAUSE __PARAM1 ENDSUB
It compiles, only temp2 compiles into
temp2 res 1
where it should be
temp2 res 3
And I wonder, is there a way to use less than 4 instructions to have temp2(index) = value
regards peter
What purpose could a NOP have? Delay?
regards peter
DEVICE P8X32A, XTAL1, PLL16X FREQ 80_000_000
LED PIN 16
temp2 VAR LONG(3) temp var long
Delay SUB 1 Rd_Byte FUNC 1,2 Rd_Word FUNC 1,2 Rd_Long FUNC 1,2 Wr_Byte SUB 3 Wr_Word SUB 3 Wr_Long SUB 3
PROGRAM Start
Start: temp = PAR temp = Rd_Byte PAR,3 temp = Rd_Word PAR,3 'inline asm mov __temp1,#3 shl __temp1,#1 add __temp1,PAR rdword temp,__temp1 endasm temp = Rd_Long PAR,3 Wr_Byte PAR,3,temp Wr_Word PAR,3,temp Wr_Long PAR,3,temp LOW LED FOR temp = 1 TO 20 LED = ~LED Delay 500 NEXT 'temp2(2) = temp asm movd __load,#temp2+2 __load mov 00_00,temp endasm FOR temp = 0 TO 2 'temp2(temp) = temp<<3 __PARAM1 = temp << 3 asm mov __temp1,#temp2 add __temp1,temp movd __load2,__temp1 __load2 mov 00_00,__PARAM1 endasm NEXT Delay 5000 GOTO Start END
SUB Delay PAUSE __PARAM1 ENDSUB
FUNC Rd_Byte '__PARAM1 is base, __PARAM2 is byteindex __PARAM2 = __PARAM2 + __PARAM1 asm RDBYTE __PARAM1,__PARAM2 endasm RETURN ENDFUNC
FUNC Rd_Word '__PARAM1 is base, __PARAM2 is wordindex __PARAM2 = __PARAM2 << 1 __PARAM2 = __PARAM2 + __PARAM1 asm RDWORD __PARAM1,__PARAM2 endasm RETURN ENDFUNC
FUNC Rd_Long '__PARAM1 is base, __PARAM2 is longindex __PARAM2 = __PARAM2 << 2 __PARAM2 = __PARAM2 + __PARAM1 asm RDLONG __PARAM1,__PARAM2 endasm RETURN ENDFUNC
SUB Wr_Byte '__PARAM1 is base, __PARAM2 is byteindex, __PARAM3 is value __PARAM2 = __PARAM2 + __PARAM1 asm WRBYTE __PARAM2,__PARAM3 endasm ENDSUB
SUB Wr_Word '__PARAM1 is base, __PARAM2 is wordindex, __PARAM3 is value __PARAM2 = __PARAM2 << 1 __PARAM2 = __PARAM2 + __PARAM1 asm WRWORD __PARAM2,__PARAM3 endasm ENDSUB
SUB Wr_Long '__PARAM1 is base, __PARAM2 is longindex, __PARAM3 is value __PARAM2 = __PARAM2 << 2 __PARAM2 = __PARAM2 + __PARAM1 asm WRLONG __PARAM2,__PARAM3 endasm ENDSUB
Compiles into
'' *** COMPILED WITH PropBasic VERSION 0.00.04 09/01/2009 ***
CON 'DEVICE P8X32A, XTAL1, PLL16X _ClkMode = XTAL1 + PLL16X
_XInFreq = 5000000 'FREQ 80_000_000
' LED PIN 16 'LED PIN 16
' temp2 VAR LONG(3) 'temp2 VAR LONG(3)
' temp var long 'temp var long
' Delay SUB 1 'Delay SUB 1
' Rd_Byte FUNC 1,2 'Rd_Byte FUNC 1,2
' Rd_Word FUNC 1,2 'Rd_Word FUNC 1,2
' Rd_Long FUNC 1,2 'Rd_Long FUNC 1,2
' Wr_Byte SUB 3 'Wr_Byte SUB 3
' Wr_Word SUB 3 'Wr_Word SUB 3
' Wr_Long SUB 3 'Wr_Long SUB 3
PUB __Program 'PROGRAM Start CogNew(@Start, 0) DAT
Start 'Start:
MOV temp,PAR ' temp = PAR
MOV __PARAM1,PAR ' temp = Rd_Byte PAR,3 MOV __PARAM2,#3 CALL #Rd_Byte MOV temp,__PARAM1
MOV __PARAM1,PAR ' temp = Rd_Word PAR,3 MOV __PARAM2,#3 CALL #Rd_Word MOV temp,__PARAM1
[color=red] ' 'inline ' ASM 'asm[/color]
[color=red] mov __temp1,#3 shl __temp1,#1 add __temp1,PAR rdword temp,__temp1 ' ENDASM 'endasm[/color]
MOV __PARAM1,PAR ' temp = Rd_Long PAR,3 MOV __PARAM2,#3 CALL #Rd_Long MOV temp,__PARAM1
MOV __PARAM1,PAR ' Wr_Byte PAR,3,temp MOV __PARAM2,#3 MOV __PARAM3,temp CALL #Wr_Byte
MOV __PARAM1,PAR ' Wr_Word PAR,3,temp MOV __PARAM2,#3 MOV __PARAM3,temp CALL #Wr_Word
MOV __PARAM1,PAR ' Wr_Long PAR,3,temp MOV __PARAM2,#3 MOV __PARAM3,temp CALL #Wr_Long
OR DIRA,LED ' LOW LED ANDN OUTA,LED
MOV temp,#1 ' FOR temp = 1 TO 20 __FOR_temp_1
AND LED,INA WZ, NR ' LED = ~LED IF_NZ ANDN OUTA,LED IF_Z OR OUTA,LED
MOV __PARAM1,#500 ' Delay 500 CALL #Delay
ADD temp,#1 ' NEXT CMPS temp,#20 WZ, WC IF_BE JMP #__FOR_temp_1
' 'temp2(2) = temp ' ASM 'asm
movd __load,#temp2+2 __load mov 00_00,temp ' ENDASM 'endasm
MOV temp,#0 ' FOR temp = 0 TO 2 __FOR_temp_2
' 'temp2(temp) = temp<<3 MOV __PARAM1,temp ' __PARAM1 = temp << 3 SHL __PARAM1,#3
' ASM 'asm
mov __temp1,#temp2 add __temp1,temp movd __load2,__temp1 __load2 mov 00_00,__PARAM1 ' ENDASM 'endasm
ADD temp,#1 ' NEXT CMPS temp,#2 WZ, WC IF_BE JMP #__FOR_temp_2
MOV __PARAM1,_5000 ' Delay 5000 CALL #Delay
JMP #Start ' GOTO Start
JMP #$ 'END
Delay 'SUB Delay
MOV __TEMP1,CNT ' PAUSE __PARAM1 ADD __TEMP1,_1mSec MOV __TEMP2,__PARAM1 __L0001 WAITCNT __TEMP1,_1mSec DJNZ __TEMP2,#__L0001
Delay_ret 'ENDSUB RET
Rd_Byte 'FUNC Rd_Byte '__PARAM1 is base, __PARAM2 is byteindex
ADDS __PARAM2,__PARAM1 ' __PARAM2 = __PARAM2 + __PARAM1
' ASM 'asm
RDBYTE __PARAM1,__PARAM2 ' ENDASM 'endasm
Rd_Byte_ret ' RETURN RET
'ENDFUNC
Rd_Word 'FUNC Rd_Word '__PARAM1 is base, __PARAM2 is wordindex
SHL __PARAM2,#1 ' __PARAM2 = __PARAM2 << 1
ADDS __PARAM2,__PARAM1 ' __PARAM2 = __PARAM2 + __PARAM1
' ASM 'asm
RDWORD __PARAM1,__PARAM2 ' ENDASM 'endasm
Rd_Word_ret ' RETURN RET
'ENDFUNC
Rd_Long 'FUNC Rd_Long '__PARAM1 is base, __PARAM2 is longindex
SHL __PARAM2,#2 ' __PARAM2 = __PARAM2 << 2
ADDS __PARAM2,__PARAM1 ' __PARAM2 = __PARAM2 + __PARAM1
' ASM 'asm
RDLONG __PARAM1,__PARAM2 ' ENDASM 'endasm
Rd_Long_ret ' RETURN RET
'ENDFUNC
Wr_Byte 'SUB Wr_Byte '__PARAM1 is base, __PARAM2 is byteindex, __PARAM3 is value
ADDS __PARAM2,__PARAM1 ' __PARAM2 = __PARAM2 + __PARAM1
' ASM 'asm
WRBYTE __PARAM2,__PARAM3 ' ENDASM 'endasm
Wr_Byte_ret 'ENDSUB RET
Wr_Word 'SUB Wr_Word '__PARAM1 is base, __PARAM2 is wordindex, __PARAM3 is value
SHL __PARAM2,#1 ' __PARAM2 = __PARAM2 << 1
ADDS __PARAM2,__PARAM1 ' __PARAM2 = __PARAM2 + __PARAM1
' ASM 'asm
WRWORD __PARAM2,__PARAM3 ' ENDASM 'endasm
Wr_Word_ret 'ENDSUB RET
Wr_Long 'SUB Wr_Long '__PARAM1 is base, __PARAM2 is longindex, __PARAM3 is value
SHL __PARAM2,#2 ' __PARAM2 = __PARAM2 << 2
ADDS __PARAM2,__PARAM1 ' __PARAM2 = __PARAM2 + __PARAM1
' ASM 'asm
WRLONG __PARAM2,__PARAM3 ' ENDASM 'endasm
Wr_Long_ret 'ENDSUB RET
'********************************************************************** _5000 LONG 5000 LED LONG 65536 _1mSec LONG 80000
__TEMP1 RES 1 __TEMP2 RES 1 __PARAM1 RES 1 __PARAM2 RES 1 __PARAM3 RES 1 __PARAM4 RES 1 __PARAMCNT RES 1 temp2 RES 1 temp RES 1
CON
From the inline code (red) it is clear that there better be native basic statements to access hubram.
Proposal:
· value = Rd_Byte address[noparse][[/noparse],byteindex]
· value = Rd_Word address[noparse][[/noparse],wordindex]
· value = Rd_Long address[noparse][[/noparse],longindex]
··Wr_Byte address[noparse][[/noparse],byteindex],value
··Wr_Word address[noparse][[/noparse],wordindex],value
··Wr_Long address[noparse][[/noparse],longindex],value
When this is available together with the indexed variables, then we have a minimal basic that can do
some real tasks.
regards peter
Jon is right. It's a Propeller instruction pipe issue; without "some instruction" between the modifier and it's target, the sequence will fail.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Propeller Tools
Bean (Hitt Consulting)
Very nice work...
Ps. it is posible You write litle manual ... On words that can be used and syntax to them
Regards ChJ
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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
You can look at the SXB help file for syntax (attached).
That should give you enough info, particular on the loop contructs.
Many commands are not implemented yet and some never will
because the Propellor is very different from SX.
regards peter
Thanks .... But.
Look on atached picture.
Regards.
ChJ
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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
Maybe you need to install the sxkey IDE software.
http://www.parallax.com/tabid/460/Default.aspx
regards peter
Ray
John Abshier
Sapieha, sometimes the regional settings have to be US.
I had that problem some years ago. I now run WinXP SP3 and
have no issues using Dutch regional settings.
regards peter
http://forums.parallax.com/showthread.php?p=597707
regards peter
I don't have Vista, but here's the MS KB on that issue...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ray
John Abshier
temp = 2999
compiles into
mov temp,_2999
but shouldn't that be
mov temp,#2999
which fails (constant too large)
So it seems every constant > 511 needs to be preloaded in a variable
myConst long 2999
then use
temp = myConst
Edit:
Just noticed, _2999 is a preloaded variable with value 2999
regards peter
Post Edited (Peter Verkaik) : 9/2/2009 9:53:02 PM GMT
the mov temp,_2999 must be replaced by
rdlong temp,@_2999
DAT _2999 LONG 2999 PUB __Program 'PROGRAM Start CogNew(@Start, 0) DAT Start 'Start: RDLONG temp,@_2999 ' temp = 2999
Saves 1 long in cog ram for every constant > 511 (but speed becomes slightly less)
Proposal: put all CON values > 511 that are defined before PROGRAM Start
into a seperate DAT section and use RDLONG to load these constants.
regards peter
For small drivers LMM may not be necessary. But I thought of an alternative.
If DATA is implemented (it doesn't work currently) I could use
myConst: DATA LONG 2999
All DATA must appear before PROGRAM Start (or after the basic program) and
is placed in a seperate DAT.
Then I can use
temp = Rd_long @myConst
where Rd_long (or LREAD) is a native·basic statement·to·read·a long from hubram.
BTW. this DATA could also be used to have external variables.
I could do Wr_long @myConst,temp
regards peter
Post Edited (Peter Verkaik) : 9/3/2009 6:24:31 AM GMT