@Bean: SXB 2.0 bug when using FUNC with local variables
@Bean,
This program
generates errors "Symbol <__PARAM0> not defined"
(__param0 is not used by SXB)
But note that the lines
lword = wordFunc lbyte,lbyte
do not generate an error but they should as the function expects only 1 byte argument!
Change the line to
lword = wordFunc lbyte
and you get the error "Invalid number of parameters"
I used compiler version r19.
The program is also attached.
Edit: compiler version r14 compiles without error when using lines
lword = wordFunc lbyte
(but then of course the FUNC 1,5,5,byte,byte,word,word no longer works
as that was fixed in a later release).
All later releases generate the errors.
regards peter
Post Edited (Peter Verkaik) : 4/10/2009 3:51:01 PM GMT
This program
' ========================================================================= ' File...... Memory_demo2.SXB ' Compiler.. SXB 2.00.16 ' Purpose... Optimizing memory use ' Author.... Peter Verkaik ' E-mail.... [url=mailto:verkaik6@zonnet.nl]verkaik6@zonnet.nl[/url] ' Started... 10 april, 2009 ' Updated... ' ========================================================================= '****************************************************************************** 'device settings '****************************************************************************** device SX28,OSCHS2 freq 20_000_000 id "Memory" stack 16 '****************************************************************************** 'CON section '****************************************************************************** '****************************************************************************** 'I/O pins '****************************************************************************** '****************************************************************************** 'VAR section '****************************************************************************** bytevar var byte wordvar var word longvar var byte (4) '****************************************************************************** INTERRUPTRATE con 230400 INTERRUPT nocode INTERRUPTRATE returnint '****************************************************************************** 'SUB/FUNC/TASK declarations '****************************************************************************** byteFunc FUNC 1,1 wordFunc FUNC 2,1 longFunc FUNC 4,1 '****************************************************************************** 'Reset entry '****************************************************************************** PROGRAM Start '****************************************************************************** 'Program Code '****************************************************************************** Start: Main: GOTO Main '****************************************************************************** 'Sub/Func/Task code '****************************************************************************** FUNC byteFunc 'returns byte lbyte var byte lword var word lbyte = __param1 lword = wordFunc lbyte ,lbyte return lword_msb ENDFUNC FUNC wordFunc 'returns word lbyte var byte lword var word lbyte = __param1 lword = wordFunc lbyte,lbyte return lword return ENDFUNC FUNC longFunc 'returns long lbyte var byte lword var word lbyte = __param1 lword = wordFunc lbyte,lbyte lword * lbyte 'result in __param1,__param2,__param3,__param4 return ENDFUNC 'end of file Memory_demo2.SXB
generates errors "Symbol <__PARAM0> not defined"
(__param0 is not used by SXB)
But note that the lines
lword = wordFunc lbyte,lbyte
do not generate an error but they should as the function expects only 1 byte argument!
Change the line to
lword = wordFunc lbyte
and you get the error "Invalid number of parameters"
I used compiler version r19.
The program is also attached.
Edit: compiler version r14 compiles without error when using lines
lword = wordFunc lbyte
(but then of course the FUNC 1,5,5,byte,byte,word,word no longer works
as that was fixed in a later release).
All later releases generate the errors.
regards peter
Post Edited (Peter Verkaik) : 4/10/2009 3:51:01 PM GMT
Comments
That is the exact same error as I was getting with my earlier post. __param0 was being generated by compiler when I was attempting to use local variables.
RS_Jim
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There is a fine line between arrogance and confidence. Make sure you don't cross it...
·
Peter, there is a couple problem with the posted program.
1) The wordFunc is defined as having 1 parameter, but you are giving it two (this was not picked up because of the bug).
2) The wordFunc is unconditionally recursive. (Infinate loop)
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There is a fine line between arrogance and confidence. Make sure you don't cross it...
·
The fix appears to work.
To reply at your replies:
1) I added the 2nd argument to show the __param0 bug AND the bug that
2 arguments was not detected.
2) I was busy creatiig FUNC's (using copy and paste) when I encountered
the error. The program as such does not do anything useful.
regards peter