Cannot compile "put"

mount "/sd", _vfs_open_sdcard()
dim r,test as ulong
chdir("/sd") ' set working directory
open "/sd/testfile" for output as #3
put #3,0,test,1,r
close #3
The result:
/home/pik33/programowanie/P2-retromachine/Propeller/Tracker player/test112.bas:6: error: Unsupported operator 0x0
Comments
Could be that the pos parameter needs to be a '1' or greater...
The flexprop BASIC language description of put includes "starting at position pos in the file (where pos is 1-based)"
put #handle, pos, var [,items [,r]] put is used to write binary data to the open file whose handle is handle, starting at position pos in the file (where pos is 1-based). The position is optional, but if omitted a comma must still be placed to indicate that it is missing. var is the variable containing the first binary data to write, and items is the number of variables to write starting at var. items is often omitted, in which case only 1 item is written. Note that the total number of bytes written is items times the size of each variable.
Try:
put #3,1,test,1,r OR put #3,1,test,r <== if there's only 1 item, no need to state that
Just a guess, really!
I tried
put #3,1,test,1,r
and
put #3,,test,1,r
with the same result
error: Unsupported operator 0x0
Did you try?:
put #3,1,test,r <== check your commas
Now I did.
error: Cannot take address of expression
This compiled for me with flexprop version 5.9.8...
mount "/sd", _vfs_open_sdcard() dim r,test as ulong chdir("/sd") ' set working directory open "/sd/testfile" for output as #3 'put #3,0,test,1,r <== commented out put #3,1,test,r ' added close #3
"/Users/myUser/flexprop/bin/flexspin" -2 -l --tabs=2 -D_BAUD=230400 -O1 --charset=utf8 -I "/Users/myUser/flexprop/include" -I "/Users/myUser/flexprop/include/spin" -I "/Users/myUser/Documents/P2ESCode/p2library" "/Users/myUser/Documents/P2ESCode/putTest.bas" Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2022 Total Spectrum Software Inc. Version 5.9.8 Compiled on: Jan 31 2022 putTest.bas mount.c fmt.c vfs.c errno.c posixio.c fatfs_vfs.c |-ff.cc bufio.c stat.c strncpy.c strncat.c strncmp.c ioctl.c strcpy.c memset.c sdmm.cc stat.c malloc.c strcpy.c memset.c putTest.p2asm Done. Program size is 46760 bytes Finished at Wed Feb 23 06:06:12 2022
What flexprop version are you running?
There's a bug in the setting of the put/get result value. Either leave the result off, or else use the current github source code which has this fixed.
Thanks for the bug report,
I compiled the newest version - Prop2Play stopped to do the directory/file list. I had to return to older Flexprop, which can compile working prop2play. If I manage to catch the error using the simple example, I will put it here.
Edit: the bug can actually be in prop2play, but the older Flexprop can make it work as expected while the new Flexprop cannot - I am now testing simple examples to catch the problem.
I got lost. Simple examples work, the player does not. What is weird, is - in the player:
close #5 ' todo: react to other errors (message box?) open currentdir$+"dirlist.txt" for output as #5 print #5,".."+space$(36) ' this file system has no .. - it needs to be manually added filename$ = dir$("*", fbDirectory) ' find all directories while filename$ <> "" andalso filename$ <> nil if len(filename$)<38 then filename$=filename$+space$(38-len(filename$)) ' the string has to be exactly 38 characters filename2$=right$(filename$,38) ' which enables to use get when reading print #5, filename2$ ' print filename2$ ' write directory name to the file) filename$ = dir$() end while close #5
I commented out opening #0 in the player, so I used standard system print to serial terminal for testing this
If I uncomment the line "print filename2$" the loop works and the directory list is saved to a file and printed on ANSI termina;
If I comment the "print filename2$" line as in this code block, it lists only first directory element to the file.
The next step: compile with old and new flexprop, compare the lst files.
Edit: lists are different:
new:
01ad0 C6 00 00 FF 01ad4 22 6E 06 F6 | mov arg01, ##@LR__1567 01ad8 10 70 06 F6 | mov arg02, #16 01adc 6C DC B0 FD | call #__system___basic_dir 01ae0 14 81 02 F6 | mov local03, result1 01ae4 04 00 00 FF 01ae8 68 FB 05 F1 | add objptr, ##2408 01aec FD 80 62 FC | wrlong local03, objptr 01af0 04 00 00 FF 01af4 68 FB 85 F1 | sub objptr, ##2408 01af8 | ' filename$ = dir$("*", &h10) ' find all directories 01af8 | ' while filename$ <> "" andalso filename$ <> nil 01af8 | LR__0048 01af8 04 00 00 FF
old:
01ad0 C6 00 00 FF 01ad4 80 6E 06 F6 | mov arg01, ##@LR__1565 01ad8 10 70 06 F6 | mov arg02, #16 01adc | ' return _basic_dir(pat, attrib) 01adc D0 5F B0 FD | call #__basic_dir 01ae0 14 81 02 F6 | mov local03, result1 01ae4 04 00 00 FF 01ae8 68 FB 05 F1 | add objptr, ##2408 01aec FD 80 62 FC | wrlong local03, objptr 01af0 04 00 00 FF 01af4 68 FB 85 F1 | sub objptr, ##2408 01af8 | ' filename$ = dir$("*", &h10) ' find all directories 01af8 | ' while filename$ <> "" andalso filename$ <> nil 01af8 | LR__0048
Instead of __basic_dir we have now __system__basic_dir... to be continued...
I gave up.
My "old" flexprop that compiles running version of prop2play is Version 5.9.9-beta-HEAD-v5.9.7-19-g1c955d38 Compiled on: Feb 12 2022
My "new" flexprop that compiles not fully working prop2play is Version 5.9.9-HEAD-v5.9.7-33-g89e95693 Compiled on: Feb 26 2022
I don't know what changed and what can make such difference. The workaround is to continue with the "old" version
Does changing the optimization level change the behavior?
Given you seem to be compiling the compiler yourself, try the git bisect command on the spin2cpp repository. That lets you find the change that causes your issue. Basically, you'd do
git bisect start git bisect bad HEAD git bisect good 1c955d38
and then it checks out some in-between version for you. Compile that with
make clean make
and test with the built compiler. If it works,
git bisect good
, elsegit bisect bad
. It will then check out another version, etc, repeat until it has found the commit of interest. Thengit bisect reset
to return the repository to a clean state.I will try to do this git thing (which I didn't know of yet).
I compile with -O1. O2 gives garbage.:
error: Internal error exceeded local register limit, possibly due to -O2 optimization needing additional registers or code being too complicated
Without optimization the code is way too huge (256 K or something like this). It is already way too huge with -O1 but I will consider a size optimization when all basic things can work. Now it is still at alpha stage.
The result:
pik33@pc:~/Programowanie/src/flexprop/spin2cpp$ git bisect good 495461ad639b5260c503622c66dc3d6b040109b7 is the first bad commit commit 495461ad639b5260c503622c66dc3d6b040109b7 Author: Eric Smith <ersmith@totalspectrum.ca> Date: Sat Feb 12 09:11:29 2022 -0400 move BASIC declare lib functions into the system module Changelog.txt | 3 ++- doc/basic.md | 2 ++ frontends/basic/basic.y | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-)
So, yes, that was the change which made the difference.
What I did, was:
DeclareFunction(systemModule, rettype, 1, funcdef, body, attrib, $1);
back to
DeclareFunction(current, rettype, 1, funcdef, body, attrib, $1);
Then after make install.. it works
The question is: why this change made this difference
I've made some changes just now that might help your situation. The root problem is that some functions are being duplicated in the system and main modules.
It works, but dir$("*", fbNormal) still lists also directories, which I think it shouldn't do as there is no way to get a list of files only. This is now not a problem, I know where to add the patch.
if (oldattrib != 0) { r = stat(ent->d_name, &sbuf); if (r) { // error in stat, break return ""; } mode = sbuf.st_mode & S_IFMT; attrib = 0; if (ent->d_name[0] == '.') { attrib |= fbHidden; } if (0 == (sbuf.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH))) { attrib |= fbReadOnly; } else if (mode != S_IFDIR) { attrib |= fbArchive; } if ( mode == S_IFDIR ) { attrib = fbDirectory; } else if ( mode == S_IFCHR || mode == S_IFBLK || mode == S_IFIFO) { attrib = fbSystem; } if ( 0 == (attrib & oldattrib) ) { continue; }