Hello
i have found something and i am not sure if it is indented behavior. If I have a code like:
con
_clkfreq=100_000_000
dat
org
rep @done,#0
drvnot #0
done
If I compile it with PNUT it knows about the 100MHz set in the con block and the P2 is indeed running with 100MHz after downloading to ram via PNUT
But if I compile and download it with FlexProp the _clkfreq=100MHz gets ignored. In the List file there is no sign of setting the clock. P2 is still in RCFAST mode after downloading
I Know i can set the clock manually. But i wonder if this is indented.
@Surac said:
Hello
i have found something and i am not sure if it is indented behavior. If I have a code like:
con
_clkfreq=100_000_000
dat
org
rep @done,#0
drvnot #0
done
If I compile it with PNUT it knows about the 100MHz set in the con block and the P2 is indeed running with 100MHz after downloading to ram via PNUT
Please check again, I don't think PNut does this. I get the exact same 8 byte binary when I compile your sample program with flexspin and with PNut. If there are no Spin methods, then the Spin setup code (in flexprop) or Spin interpreter (in PNut) is not included, so the clock is not set. In order to set the clock in an assembly only program, use the ASMCLK macro.
this is what pnut outputs as .lst file. as you can see it knows the 100MHz BUT in the .obj or .bin file there is no sign of any clock initialisation. I think PNUT uses features of the bootloader to set the clock frequency. It may be an inconsistent behavior of PNUT because it is useless if it is not in the .bin file.
TYPE: CON VALUE: 05F5E100 NAME: _CLKFREQ
TYPE: CON VALUE: 0100090B NAME: CLKMODE_
TYPE: CON VALUE: 05F5E100 NAME: CLKFREQ_
TYPE: DAT_LONG VALUE: 00200008 NAME: DONE
CLKMODE: $0100090B
CLKFREQ: 100,000,000
XINFREQ: 20,000,000
Hub bytes: 8
00000- 00 02 DC FC 5F 00 64 FD '...._.d.'
neverminded this is a 'feature' one cannot rely on as it only works while downloading via PNUT. In fact, this is quite dangerous as it is unexpected.
Today i tried the integration between Flexprop and VSCODE. It works nice but i have one little concern that isn't related directly with VSCODE, but makes using VSCODE a bit messy.
Downloading the .binary file is done with loadp2. VSCODE opens a shell and starts loadp2.exe with some command line parameters. Easy enough.
loadp2 offers to open a terminal after the download. To exit the terminal, you must press CRTL-]. This may be true on a US layout keyboard. But not on my german layout keyboard.
After searching some time i found i have to press CTRL-+ (plus key) to exit the terminal. On a German Keyboard [ ] are not available without pressing a modifier key. The + Key on a German keyboard is where the ] key is on an US keyboard.
This will all work ok if i use loadp2 directly from the shell (i only have to remember that crtl-] translates to ctrl-+). But in VSCODE the ctrl-+ Key is already catched by VSCODE itself. it is used to scale the VSCODE gui up.
It will be nice to have a command line switch to change the exit shortcut of the terminal somehow. ctrl-] ist only good on US layout keyboards.
a second inconvenience is that if i do not use the terminal loadp2 always asks to press the enter key to exit. Is there a kind of commandline switch to just download the .binary and not wait for enter key afterwards?
Today i tried the integration between Flexprop and VSCODE. It works nice but i have one little concern that isn't related directly with VSCODE, but makes using VSCODE a bit messy.
Downloading the .binary file is done with loadp2. VSCODE opens a shell and starts loadp2.exe with some command line parameters. Easy enough.
loadp2 offers to open a terminal after the download. To exit the terminal, you must press CRTL-]. This may be true on a US layout keyboard. But not on my german layout keyboard.
After searching some time i found i have to press CTRL-+ (plus key) to exit the terminal. On a German Keyboard [ ] are not available without pressing a modifier key. The + Key on a German keyboard is where the ] key is on an US keyboard.
This will all work ok if i use loadp2 directly from the shell (i only have to remember that crtl-] translates to ctrl-+). But in VSCODE the ctrl-+ Key is already catched by VSCODE itself. it is used to scale the VSCODE gui up.
It will be nice to have a command line switch to change the exit shortcut of the terminal somehow. ctrl-] ist only good on US layout keyboards.
a second inconvenience is that if i do not use the terminal loadp2 always asks to press the enter key to exit. Is there a kind of commandline switch to just download the .binary and not wait for enter key afterwards?
As I read, I was horrified when you said Ctrl+ until I read further.
I cannot believe we’re close to 40 years since the PC arrived, and we haven’t solved fundamental problems such as PC/*nix/Mac crlf problems and basic control sequences and keyboard layouts for even the major countries. I guess if we cannot resolve a standard keyboard layout for the English speaking countries (US, UK, AU comes to mind) what hope have we to fix this deeper problem.
@Surac, I feel your pain as I’ve not realised the additional problems non-English-speaking countries have with just these basics.
@Surac: I will add Control-Z as another way to leave the loadp2 program in the next release. Closing the window should also work (does VSCODE give that option?)
VSCode does not open a shell window but uses the shell embedded in the GUI in a Dock. IT is a single window application so there is no easy way to close the terminal, except using what the terminal offers.
i checked Ctrl-Z and it gives a 26 = 0x1A on my German keyboard. Ctrl-A to Ctrl-Z is translated to 1-26
EDIT:
i have digged into the source code of load2p terminal function and found you are reading the keyboard using getch().
getch() returns keyboard scan codes, so they are platform specific (and keyboard specific) and returns a 16 bit value
Scancodes are "near" ascii but only for letters and numbers.
So, the scan code is not depending on the symbol printed on the key but the position of the key on the keyboard. however normal letters and numbers are "changed" to reflect the actual language of the keyboard (very confusing but that's why ctrl-z works and ctrl-] not)
VSCode does not open a shell window but uses the shell embedded in the GUI in a Dock. IT is a single window application so there is no easy way to close the terminal, except using what the terminal offers.
You can kill the terminal session. Just click the trashcan icon.
CON
_clkfreq = 10_000_000
DAT
org $0
asmclk
call #\sub1
call #\sub2 'here it tries to call #$40 = fatal. Also fails if using call #sub2 (relativ call)
ende jmp #ende 'funny: in Flexspin end is a good lable name. in PNUT end is no good lable name. So i use ende here
sub1 dirh #56
ret
org $40 'here is the question relevant part
sub2
dirh #57
ret
This program compiles with no error in FLEXSPIN and PNUT but does not work in both
in Flexspin:
lst. file shows that sub2 is calculated to be $40 but there is no code
sub2 is placed directly behind sub1. it seems the org $40 is obeyed for calculating offsets but not for code generation
using orgf $40 instead of org $40 works as intended in FLEXSPIN and PNUT
shouldn't there be a compiler warning for using org with address or using org twice?
is org even intended to be used with an address != 0?
There are times when you want to generate code that isn't padded out, in case you intend to load things directly to the ORG'd address later, from HUB into COG RAM. So you can certainly use ORG with a COG address and/or multiple times in the DAT section.
In this case the compiler is just doing what you tell it. No warning is needed. You just need to know that ORG will not pad by default and you need to use ORGF instead if you wanted to pad it.
The binary version of Flexprop 5.3.2 is available now from github. This is mainly a bug fix release, although it does have new versions of loadp2 and proploader which accept Control-Z for closing the window alongside Control-].
There seems to be some issues with the serial driver. While typing in on the terminal session sometimes I get a question mark, ?, and sometimes the letter does not take.
I can load a file with no issues it's just when typing.
@iseries said:
There seems to be some issues with the serial driver. While typing in on the terminal session sometimes I get a question mark, ?, and sometimes the letter does not take.
I can load a file with no issues it's just when typing.
Mike
On which platform (P1 or P2)? Which terminal are you using? Which language(s)?
Never mind, I'm on the P2 with a WiFi module in-between. I tried it with just the prop plug and it works just fine. Must be something with the telnet session.
@ersmith said:
@evanh : DEBUG() statements are optional (as they are in PNut). In order to enable debug() flexspin needs the -g flag on the command line. We should probably continue this on the flexspin thread if you have more questions.
Hi Eric, I have noticed that PORT BAUD is doubled automatically after adding '-g' on flexspin 'Commands> Configure Commands> Compile Command".
@ersmith said:
@evanh : DEBUG() statements are optional (as they are in PNut). In order to enable debug() flexspin needs the -g flag on the command line. We should probably continue this on the flexspin thread if you have more questions.
Hi Eric, I have noticed that PORT BAUD is doubled automatically after adding '-g' on flexspin 'Commands> Configure Commands> Compile Command".
I'm not able to reproduce any problem like this. What do you mean exactly by "PORT BAUD" is doubled? Do you mean that the -D_BAUD=xxx parameter appears twice on the command line? Or do you mean that the value for the baud is increased? How did you add the -g, did you use the "Debug Enabled" option in the Option menu, or did you edit the command yourself?
I am using latest version 5.3.2 (on W10). I usually run program code at 115_200 BAUD, and after adding the -g option the BAUD is increased to 230_400.
I directly added '-g' on "Commands> Configure Commands> Compile Command". That was because the debug output was not working (the debug output didn't show any characters). Now, that I have check again I have found that the "Debug Enabled" was already enabled (didn't remember that I have that option enabled).
Don't spend too much time looking at this. The debug is working, and using 230_400 BAUD is also OK.
The code I was testing is this one: (when I use Ports > 115_200 baud output show garbage; characters only works well at 230_400; and what surprised me was that the BAUD speed was automatically adjusted by the GUI)
I had another problem, which I cannot now reproduce, so maybe it was a glitch.
I used TAB instead of spaces while writing the spin2 code. The code didn't run as expected until I noticed this and replaced these tabs with proper amount of spaces.
Using Lazarus IDE for any other programming I simply (uncounsciously) expected the same behaviour (tab key inserts several spaces to the code and not a "tab" ascii code)
Then I tried to repeat the error, but this time the code didn't want to fail. Still... better avoid the TAB key.
Edit: another glitch" comments are not always grayed out. Add a space or something to the line and the comment is gray again. This is the glitch I cannot reproduce at will, too.
@pik33 said:
I had another problem, which I cannot now reproduce, so maybe it was a glitch.
I used TAB instead of spaces while writing the spin2 code. The code didn't run as expected until I noticed this and replaced these tabs with proper amount of spaces.
Using Lazarus IDE for any other programming I simply (uncounsciously) expected the same behaviour (tab key inserts several spaces to the code and not a "tab" ascii code)
Then I tried to repeat the error, but this time the code didn't want to fail. Still... better avoid the TAB key.
Edit: another glitch" comments are not always grayed out. Add a space or something to the line and the comment is gray again. This is the glitch I cannot reproduce at will, too.
sramtest.spin2:757: error: syntax error, unexpected BYTE, expecting number
sramtest.spin2:758: error: syntax error, unexpected WORD, expecting number
sramtest.spin2:759: error: syntax error, unexpected LONG, expecting number
It doesn't like evaluating a byte, word or long expression in a conditional for some reason.
In the meantime to resolve it I have to change all my code to do this the more verbose way:
1: if (source == "F" or source == "R")
val := mem.readByte(addr + i)
else
val := byte[addr][i]
2: if (source == "F" or source == "R")
val := mem.readWord(addr + 2*i)
else
val := word[addr][i]
4: if (source == "F" or source == "R")
val := mem.readLong(addr + 4*i)
else
val := long[addr][i]
@rogloh : The problem isn't BYTE or LONG, it's the multiple possible uses of ":" in Spin2. One of those uses is to indicate the number of return values from a method pointer, e.g.:
x, y := p_method(x):2
This conflicts with its use in lookup/lookdown and also in conditional ? :. I think you could work around the problem by adding parentheses around the mem.ReadByte() method calls in your code above.
Flexspin's parser is only mildly context dependent, whereas PNut's seems to be heavily so. I've tweaked things in github so that the method pointer use will be the one that requires the extra parentheses in the future, rather than the ?: use.
Comments
Hello
i have found something and i am not sure if it is indented behavior. If I have a code like:
If I compile it with PNUT it knows about the 100MHz set in the con block and the P2 is indeed running with 100MHz after downloading to ram via PNUT
But if I compile and download it with FlexProp the _clkfreq=100MHz gets ignored. In the List file there is no sign of setting the clock. P2 is still in RCFAST mode after downloading
I Know i can set the clock manually. But i wonder if this is indented.
Please check again, I don't think PNut does this. I get the exact same 8 byte binary when I compile your sample program with flexspin and with PNut. If there are no Spin methods, then the Spin setup code (in flexprop) or Spin interpreter (in PNut) is not included, so the clock is not set. In order to set the clock in an assembly only program, use the ASMCLK macro.
I can confirm it works like i said.
this is what pnut outputs as .lst file. as you can see it knows the 100MHz BUT in the .obj or .bin file there is no sign of any clock initialisation. I think PNUT uses features of the bootloader to set the clock frequency. It may be an inconsistent behavior of PNUT because it is useless if it is not in the .bin file.
neverminded this is a 'feature' one cannot rely on as it only works while downloading via PNUT. In fact, this is quite dangerous as it is unexpected.
Hello. Me again
Today i tried the integration between Flexprop and VSCODE. It works nice but i have one little concern that isn't related directly with VSCODE, but makes using VSCODE a bit messy.
It will be nice to have a command line switch to change the exit shortcut of the terminal somehow. ctrl-] ist only good on US layout keyboards.
a second inconvenience is that if i do not use the terminal loadp2 always asks to press the enter key to exit. Is there a kind of commandline switch to just download the .binary and not wait for enter key afterwards?
Yes Surac I think it is the -k switch in loadp2 doing it. Disable that command line switch.
You can also issue the byte sequence 255, 0, 0 out the serial port from the P2 to exit from the loadp2 terminal on the PC which can be very handy.
Nice that cured my second inconvenience.
As I read, I was horrified when you said Ctrl+ until I read further.
I cannot believe we’re close to 40 years since the PC arrived, and we haven’t solved fundamental problems such as PC/*nix/Mac crlf problems and basic control sequences and keyboard layouts for even the major countries. I guess if we cannot resolve a standard keyboard layout for the English speaking countries (US, UK, AU comes to mind) what hope have we to fix this deeper problem.
@Surac, I feel your pain as I’ve not realised the additional problems non-English-speaking countries have with just these basics.
@Surac: I will add Control-Z as another way to leave the loadp2 program in the next release. Closing the window should also work (does VSCODE give that option?)
Hello,
VSCode does not open a shell window but uses the shell embedded in the GUI in a Dock. IT is a single window application so there is no easy way to close the terminal, except using what the terminal offers.
i checked Ctrl-Z and it gives a 26 = 0x1A on my German keyboard. Ctrl-A to Ctrl-Z is translated to 1-26
EDIT:
You can kill the terminal session. Just click the trashcan icon.
oh. i was not able to see it Thank you so much. But having ctrl-z will be perfect anyway
The new version of flexprop (5.3.2) is on my Patreon page now. I plan to make a github binary release this weekend.
Giving this Program:
This program compiles with no error in FLEXSPIN and PNUT but does not work in both
in Flexspin:
using orgf $40 instead of org $40 works as intended in FLEXSPIN and PNUT
shouldn't there be a compiler warning for using org with address or using org twice?
There are times when you want to generate code that isn't padded out, in case you intend to load things directly to the ORG'd address later, from HUB into COG RAM. So you can certainly use ORG with a COG address and/or multiple times in the DAT section.
In this case the compiler is just doing what you tell it. No warning is needed. You just need to know that ORG will not pad by default and you need to use ORGF instead if you wanted to pad it.
Jep - makes sense
org only manages lable und jump addresses, not code layout
The binary version of Flexprop 5.3.2 is available now from github. This is mainly a bug fix release, although it does have new versions of loadp2 and proploader which accept Control-Z for closing the window alongside Control-].
There seems to be some issues with the serial driver. While typing in on the terminal session sometimes I get a question mark, ?, and sometimes the letter does not take.
I can load a file with no issues it's just when typing.
Mike
On which platform (P1 or P2)? Which terminal are you using? Which language(s)?
Never mind, I'm on the P2 with a WiFi module in-between. I tried it with just the prop plug and it works just fine. Must be something with the telnet session.
Mike
Hi Eric, I have noticed that PORT BAUD is doubled automatically after adding '-g' on flexspin 'Commands> Configure Commands> Compile Command".
I'm not able to reproduce any problem like this. What do you mean exactly by "PORT BAUD" is doubled? Do you mean that the -D_BAUD=xxx parameter appears twice on the command line? Or do you mean that the value for the baud is increased? How did you add the -g, did you use the "Debug Enabled" option in the Option menu, or did you edit the command yourself?
Regards,
I am using latest version 5.3.2 (on W10). I usually run program code at 115_200 BAUD, and after adding the -g option the BAUD is increased to 230_400.
I directly added '-g' on "Commands> Configure Commands> Compile Command". That was because the debug output was not working (the debug output didn't show any characters). Now, that I have check again I have found that the "Debug Enabled" was already enabled (didn't remember that I have that option enabled).
Don't spend too much time looking at this. The debug is working, and using 230_400 BAUD is also OK.
The code I was testing is this one: (when I use Ports > 115_200 baud output show garbage; characters only works well at 230_400; and what surprised me was that the BAUD speed was automatically adjusted by the GUI)
Compile log (at 115_200):
Compile log (at 230_400)
I seem to remember debug only works at 230400 baud too.
It’s fine, just something to know.
I had another problem, which I cannot now reproduce, so maybe it was a glitch.
I used TAB instead of spaces while writing the spin2 code. The code didn't run as expected until I noticed this and replaced these tabs with proper amount of spaces.
Using Lazarus IDE for any other programming I simply (uncounsciously) expected the same behaviour (tab key inserts several spaces to the code and not a "tab" ascii code)
Then I tried to repeat the error, but this time the code didn't want to fail. Still... better avoid the TAB key.
Edit: another glitch" comments are not always grayed out. Add a space or something to the line and the comment is gray again. This is the glitch I cannot reproduce at will, too.
Or use VSCode with spaces set instead of tabs.
Hi @ersmith
In prior revisions of flexprop this code used to build fine, but now it doesn't since I'm using 5.3.1:
I now get these build errors:
sramtest.spin2:757: error: syntax error, unexpected BYTE, expecting number
sramtest.spin2:758: error: syntax error, unexpected WORD, expecting number
sramtest.spin2:759: error: syntax error, unexpected LONG, expecting number
It doesn't like evaluating a byte, word or long expression in a conditional for some reason.
In the meantime to resolve it I have to change all my code to do this the more verbose way:
@rogloh : The problem isn't BYTE or LONG, it's the multiple possible uses of ":" in Spin2. One of those uses is to indicate the number of return values from a method pointer, e.g.:
This conflicts with its use in lookup/lookdown and also in conditional ? :. I think you could work around the problem by adding parentheses around the mem.ReadByte() method calls in your code above.
Flexspin's parser is only mildly context dependent, whereas PNut's seems to be heavily so. I've tweaked things in github so that the method pointer use will be the one that requires the extra parentheses in the future, rather than the ?: use.
Ok makes sense now. But this seemed to work in prior versions.
There's a new flexprop release 5.4.0, with an updated compiler with a lot of bug fixes (including the ?: one noted above) and some new features: