compiling ebasic3 with p2gcc
David Betz
Posts: 14,516
in Propeller 2
I just tried compiling my ebasic3 interpreter using p2gcc and I realize that I don't know how to invoke it properly. Here is the command I issued and the error message I got. I see it has a -L option to specify the library base address but how do I tell it how to locate prefix.spin2?
p2gcc -o eb3_p2gcc -D PROPELLER -L ../p2gcc/lib ebasic.c db_compiler.c db_edit.c db_expr.c db_generate.c db_image.c db_scan.c db_statement.c db_symbols.c db_system.c db_vmdebug.c db_vmint.c editbuf.c simple_vsnprintf.c osint_prop2.c Could not open /prefix.spin2
Comments
@David, adding strchr, strtoul and memmove should be fairly easy. There is an existing vsprintf, so it shouldn't be to hard to add vsnprintf. I think for setjmp and longjmp I just need to store the values of lr and sp. I need to look into this to make sure that's sufficient. Feel free to implement the functions, and I'll add them to the repository.
p2gcc did have a problem with initialized char and short variables that are declared outside of functions. If the total size of the chars and shorts isn't a multiple of 4 it creates an odd size object. When this is linked with the other objects it causes them to not be long-aligned. I modified p2link to check for this, and it pads out odd size objects when linking. I checked this fix for p2link_src/p2link.c into GitHub.
Thanks but are you saying that the GitHub sources aren't necessarily the most current code? Where do I go to make sure I'm using the latest version?
When I build and run the code you posted in the zip file it just prints ebasic3. I added a print before the "return 0" in main, it just appears to run straight through main, and then returns. Did you have to make any changes to get it to the point where you could edit? Do I need to put something in argc and argv? They are initialized to zero.
https://github.com/dbetz/ebasic3
You can build the p2gcc version with this command:
Edit: And thanks for the setjmp/longjmp implementation. It seems to work fine!
How hard would it be to have an option to use the inbuilt ROM Monitor Serial Routines? They are just hubexec calls and the requirement of COG $1E0-$1EF for variables. They have not changed in the new respin.
That sounds much harder than everyone doing their own variation on bit-bashing serial. It'll never catch on
Mike
There are two reads, one is char only, no buffering, and the other reads a string terminated with <cr>.
Don’t have the link just now. Will post it later.
An extra feature i found handy is to output a formatted memory dump. Set registers with start address, end address, and call it. Can be cog/lut/hub and formats address, 16 hex byte pairs, 16 ascii chars per line, which BTW can be saved and later fed back into the monitor lo load memory.
They were my thoughts. Plus read/write strings, etc. BTW strings must be in hub.