hippy
Posts: 10253
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Annoying feature of 'pioasm'

Wed Jun 16, 2021 11:15 am

I am not able to raise an issue on github myself so am reporting it here -

prog-one.pio

Code: Select all

.program one
  nop

Code: Select all

pi@Pi3B:/~ $ pioasm prog-one.pio 
prog-one.pio:1.10-12: syntax error, unexpected integer, expecting identifier
    1 | .program one
      |          ^~~
Guess it's doing some sort of aliasing or substitution, turning "one" into an integer.

Not sure how I can determine the 'pioasm' version as --help and --version don't report it, or I would have included that.

trejan
Posts: 3310
Joined: Tue Jul 02, 2019 2:28 pm

Re: Annoying feature of 'pioasm'

Wed Jun 16, 2021 7:49 pm

hippy wrote:
Wed Jun 16, 2021 11:15 am
Guess it's doing some sort of aliasing or substitution, turning "one" into an integer.
Yep. The tokeniser is doing it for ZERO and ONE.

lurk101
Posts: 681
Joined: Mon Jan 27, 2020 2:35 pm
Location: Cumming, GA (US)

Re: Annoying feature of 'pioasm'

Wed Jun 16, 2021 10:31 pm

Seems there are predefined values for symbols ZERO and ONE.

Code: Select all

.define public CLKS_PER_BIT 25
.define T0H 8
.define T1H 16
.define T0L (CLKS_PER_BIT - T0H)
.define T1L (CLKS_PER_BIT - T1H)

L0: out x, ONE side ZERO                   ; stall low
    jmp !x L1  side ONE  [T0H - ONE]       ; Branch on the bit we shifted out. Positive pulse
    nop        side ONE  [T1H - T0H - ONE] ; high for long pulse
L1: jmp x-- L0 side ZERO [T1L - 2]         ; start low
    jmp L0     side ZERO [T0L - T1L - ONE] ; low for a long tail
Assembles just fine. Not sure I'd want to bang the extra keystrokes for values 0 & 1!
How to make your arguments stronger? Longer is not the answer.

kilograham
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 736
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: Annoying feature of 'pioasm'

Thu Jun 17, 2021 1:37 am

Ha, i have no idea why we added that... the oldest un-squashed version of pioasm i can find has those. (perhaps the original PIO examples had them)... are they really causing that much wailing and gnashing of teeth?

lurk101
Posts: 681
Joined: Mon Jan 27, 2020 2:35 pm
Location: Cumming, GA (US)

Re: Annoying feature of 'pioasm'

Thu Jun 17, 2021 2:54 am

kilograham wrote:
Thu Jun 17, 2021 1:37 am
Ha, i have no idea why we added that... the oldest un-squashed version of pioasm i can find has those. (perhaps the original PIO examples had them)... are they really causing that much wailing and gnashing of teeth?
I don't think so. I ran it to it early trying to create the label ZERO: but where else would you type ZERO instead of 0?
How to make your arguments stronger? Longer is not the answer.

hippy
Posts: 10253
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Annoying feature of 'pioasm'

Thu Jun 17, 2021 10:47 am

kilograham wrote:
Thu Jun 17, 2021 1:37 am
are they really causing that much wailing and gnashing of teeth?
It wasted my time due to having to workaround the issue; which is time I would rather have not wasted, would have preferred to put to more constructive use working on something else.

It is impossible to say how much collective time has been or will be wasted by people encountering this issue and those caused by the 'global replacement' approach. It could be a lot or maybe very little. It probably depends on how quickly a user can figure out what is going on, why what would be expected to work doesn't.

In comparison to time wasted resolving issues with the PIO Assembler included within MicroPython this was 'nothing'; the issue and the solution obvious to me. Hence I classed it as "annoying" rather than anything worse. I wouldn't categorise it as a priority issue but believed it was worth reporting.

lurk101
Posts: 681
Joined: Mon Jan 27, 2020 2:35 pm
Location: Cumming, GA (US)

Re: Annoying feature of 'pioasm'

Thu Jun 17, 2021 2:21 pm

Tried deleting them from lexer.ll. Got unrelated Bison error on the pioasm rebuild! Oh well...
How to make your arguments stronger? Longer is not the answer.

kilograham
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 736
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: Annoying feature of 'pioasm'

Thu Jun 17, 2021 3:09 pm

probably a version error....

i have

flex 2.6.4
bison (GNU Bison) 3.7.2

hippy
Posts: 10253
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Annoying feature of 'pioasm'

Thu Jun 17, 2021 4:10 pm

lurk101 wrote:
Thu Jun 17, 2021 2:21 pm
Tried deleting them from lexer.ll. Got unrelated Bison error on the pioasm rebuild! Oh well...
But still sort of better than me. I deleted 'lexer.ll' completely and 'pioasm' still builds. What steps am I missing ... ?

Code: Select all

cd ~/pico/pico-sdk/tools/pioasm
cmake .
make

trejan
Posts: 3310
Joined: Tue Jul 02, 2019 2:28 pm

Re: Annoying feature of 'pioasm'

Thu Jun 17, 2021 4:46 pm

hippy wrote:
Thu Jun 17, 2021 4:10 pm
But still sort of better than me. I deleted 'lexer.ll' completely and 'pioasm' still builds. What steps am I missing ... ?
It doesn't regenerate the lexer unless you tell it to.

Do "cmake -DPIOASM_GENERATE_PARSER=1 ."

Stock RPi OS will cause it to complain about bison not being the correct version and then fails to parse lexer.ll properly as mentioned previously.

Edit: Bison needs to be upgraded or you can try editing it to use the older version. YMMV.
Last edited by trejan on Thu Jun 17, 2021 7:13 pm, edited 2 times in total.

lurk101
Posts: 681
Joined: Mon Jan 27, 2020 2:35 pm
Location: Cumming, GA (US)

Re: Annoying feature of 'pioasm'

Thu Jun 17, 2021 5:36 pm

trejan wrote:
Thu Jun 17, 2021 4:46 pm
Stock RPi OS will cause it to complain about bison not being the correct version and then fails to parse lexer.ll properly as mentioned previously.
Actually lex is fine. Update bison.

Code: Select all

wget https://ftp.gnu.org/gnu/bison/bison-3.7.6.tar.gz
tar xf bison-3.7.6.tar.gz 
cd bison-3.7.6
./configure --prefix=/usr
make
sudo make install
bison --version
How to make your arguments stronger? Longer is not the answer.

lurk101
Posts: 681
Joined: Mon Jan 27, 2020 2:35 pm
Location: Cumming, GA (US)

Re: Annoying feature of 'pioasm'

Thu Jun 17, 2021 5:45 pm

Woo hoo!

Code: Select all

/home/pi/pico-user/sparkle/ws2812.pio:11.12-14: undefined symbol 'ONE'
   11 | L0: out x, ONE   side 0                 ; stall low
      |            ^~~
Now I'm wondering, what was the point of all that? :P
How to make your arguments stronger? Longer is not the answer.

trejan
Posts: 3310
Joined: Tue Jul 02, 2019 2:28 pm

Re: Annoying feature of 'pioasm'

Thu Jun 17, 2021 5:56 pm

lurk101 wrote:
Thu Jun 17, 2021 5:36 pm
Actually lex is fine. Update bison.
Hmm. The errors were because of commenting out the ONE/ZERO. If I just remove them completely then it does compile with stock RPi OS. cmake still complains about bison being old but it does work.

lurk101
Posts: 681
Joined: Mon Jan 27, 2020 2:35 pm
Location: Cumming, GA (US)

Re: Annoying feature of 'pioasm'

Thu Jun 17, 2021 6:26 pm

trejan wrote:
Thu Jun 17, 2021 5:56 pm
lurk101 wrote:
Thu Jun 17, 2021 5:36 pm
Actually lex is fine. Update bison.
Hmm. The errors were because of commenting out the ONE/ZERO. If I just remove them completely then it does compile with stock RPi OS. cmake still complains about bison being old but it does work.
Don't know! With RPiOS 64 bit stock bison

Code: Select all

pi@raspberrypi:~/pico-sdk/tools/pioasm/b $ bison --version
bison (GNU Bison) 3.3.2
I get

Code: Select all

[  8%] [FLEX][pioasm_lexer] Building scanner with flex 2.6.4
cd /home/pi/pico-sdk/tools/pioasm && /usr/bin/flex -o/home/pi/pico-sdk/tools/pioasm/gen/lexer.cpp lexer.ll
[ 16%] [BISON][pioasm_parser] Building parser with bison 3.3.2
cd /home/pi/pico-sdk/tools/pioasm && /usr/bin/bison -Wcounterexamples -d -o /home/pi/pico-sdk/tools/pioasm/gen/parser.cpp parser.yy
/usr/bin/bison: invalid argument ‘counterexamples’ for ‘--warning’
All is well with bison 3.7.6

Code: Select all

[  8%] [FLEX][pioasm_lexer] Building scanner with flex 2.6.4
[ 16%] [BISON][pioasm_parser] Building parser with bison 3.7.6
Scanning dependencies of target pioasm
How to make your arguments stronger? Longer is not the answer.

trejan
Posts: 3310
Joined: Tue Jul 02, 2019 2:28 pm

Re: Annoying feature of 'pioasm'

Thu Jun 17, 2021 7:12 pm

lurk101 wrote:
Thu Jun 17, 2021 6:26 pm
Don't know!
Yeah. You're right. I've been distracted today with other things so not had the opportunity to look at it properly. cmake is complaining about the bison version and doesn't even run bison in the Makefile which is why I thought it worked.

I can get it to compile with the stock 3.3.2 bison if I edit CMakeLists.txt and change the bison version to 3.3.2 and remove COMPILE_FLAGS "-Wcounterexamples". Next step is to edit parser.yy and change %require "3.4.2" to %require "3.3.2" and comment out %define parse.lac full. This disables LAC which relates to syntax error handling.

kilograham
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 736
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: Annoying feature of 'pioasm'

Thu Jun 17, 2021 8:41 pm

you're better off just upgrading bison.

trejan
Posts: 3310
Joined: Tue Jul 02, 2019 2:28 pm

Re: Annoying feature of 'pioasm'

Thu Jun 17, 2021 8:46 pm

kilograham wrote:
Thu Jun 17, 2021 8:41 pm
you're better off just upgrading bison.
Yep

lurk101
Posts: 681
Joined: Mon Jan 27, 2020 2:35 pm
Location: Cumming, GA (US)

Re: Annoying feature of 'pioasm'

Thu Jun 17, 2021 9:35 pm

kilograham wrote:
Thu Jun 17, 2021 1:37 am
Ha, i have no idea why we added that...
Likely part of early experimentation with flex and bison.
How to make your arguments stronger? Longer is not the answer.

kilograham
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 736
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: Annoying feature of 'pioasm'

Fri Jun 18, 2021 2:01 am

more likely because the one someone had previously hacked together in python had it (i'm guessing though as I can't find that)

hippy
Posts: 10253
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Annoying feature of 'pioasm'

Fri Jun 18, 2021 10:57 am

trejan wrote:
Thu Jun 17, 2021 4:46 pm
Do "cmake -DPIOASM_GENERATE_PARSER=1 ."
Thanks. I was expecting 'cmake' to create a Makefile which automatically rebuild everything which had changed or depended on something which had changed; like a well written hand-crafted 'Makefile' normally would.

I also had to use "hash -r" to clear my executable cache before I could get things to take effect, but that may just be my set-up.

kilograham
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 736
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: Annoying feature of 'pioasm'

Fri Jun 18, 2021 12:28 pm

has nothing to do with make vs cmake. we chose not to introduce dependencies on flex and bison.

hippy
Posts: 10253
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Annoying feature of 'pioasm'

Fri Jun 18, 2021 1:10 pm

kilograham wrote:
Fri Jun 18, 2021 12:28 pm
has nothing to do with make vs cmake. we chose not to introduce dependencies on flex and bison.
I can't say I really understand that. If lexer.ll hasn't changed then whatever is created from that doesn't need to be rebuilt so there would be no dependency on flex or bison, doesn't matter if they exist or not.

Rather than "if (PIOASM_GENERATE_PARSER)" would it not be possible to use an "if (touched lexer.ll)" or something like it ?

I wasn't saying it was an issue of "make vs cmake" more an issue of cmake generated 'Makefile' versus a hand-crafted 'Makefile' intended to do the same job.

kilograham
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 736
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: Annoying feature of 'pioasm'

Fri Jun 18, 2021 1:24 pm

what about "make clean" etc.. there are trade offs;. yes, we could have spent time on this - for exceedingly little benefit - but decided not to as we had many more important things to do.

hippy
Posts: 10253
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Annoying feature of 'pioasm'

Fri Jun 18, 2021 1:33 pm

kilograham wrote:
Fri Jun 18, 2021 1:24 pm
what about "make clean" etc.. there are trade offs;. yes, we could have spent time on this - for exceedingly little benefit - but decided not to as we had many more important things to do.
Fair enough. But all it seems to have done is cause time to be expended on explaining how to make it work when its behaviour was different to how I expected it to be.

I have added a "README.md" to my 'pioasm' directory to describe how to build things so I hopefully won't run into the issue in future.

Return to “SDK”