Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix for "; comment only lines" #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 4, 2021
Merged

Fix for "; comment only lines" #5

merged 5 commits into from
Feb 4, 2021

Conversation

dglaude
Copy link
Contributor

@dglaude dglaude commented Jan 31, 2021

This should fix #4 but there might be a better way.

This should fix adafruit#4 but there might be a better way.
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! I think we'll want this check earlier though.

@@ -60,6 +60,8 @@ def assemble(text_program):
assembled = []
for instruction in instructions:
print(instruction)
if len(instruction) == 0:
continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want this on line 41. The comment shouldn't end up in instructions because it will mess up the label location (line 55).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't use JUMP yet in PIO... so I would not notice and I don't have a test case to validate or invalidate the result.
Feel free to fix it another way.

While for most library, it is hard to have regression test because it is hardware, the assembler hardware independent, so it is a perfect target for automated testing with known input and output.

@tannewt
Copy link
Member

tannewt commented Feb 2, 2021

@dglaude Mind testing the version I've added to this PR?

library should not print
@dglaude dglaude changed the title My fix for "; comment only lines" Fix for "; comment only lines" Feb 2, 2021
@dglaude
Copy link
Contributor Author

dglaude commented Feb 2, 2021

My initial version was failing to produce the expected output when comment when jump.
It was also failing with a message about not supporting .wrap_target when the comment is on first line.
Here is my testing code, I recorded the expected output, and then I started to drop comment up, down and center:

import adafruit_pioasm

program1 = """;NeoPixels are 800khz bit streams.
.program ws2812
.side_set 1
.wrap_target
bitloop:
  out x 1        side 0 [1]; Side-set still takes place when instruction stalls
  jmp !x do_zero side 1 [1]; Branch on the bit we shifted out. Positive pulse
            ; Here
do_one:
  jmp  bitloop   side 1 [1]; Continue driving high, for a long pulse
do_zero:     ; <= this is a label
  nop            side 0 [1]; Or drive low, for a short pulse
.wrap
; Zeroes are 1/3 duty cycle (~416ns) and ones are 2/3 duty cycle (~833ns).
"""

expected1 = [24865, 4387, 4352, 41282]
assembled1 = adafruit_pioasm.assemble(program1)

for i in assembled1:
    j = expected1.pop(0)
    print(i, j)
    if i != j:
        print("ERROR ^^^")
        break

@dglaude
Copy link
Contributor Author

dglaude commented Feb 2, 2021

So your version works. (CI fail but that is something else I guess)

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tannewt tannewt merged commit cf81c94 into adafruit:main Feb 4, 2021
@dglaude dglaude deleted the patch-1 branch February 4, 2021 23:05
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Feb 10, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_CharLCD to 3.3.7 from 3.3.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_CharLCD#57 from BiffoBear/fix-home-docstring

Updating https://github.com/adafruit/Adafruit_CircuitPython_DymoScale to 1.1.2 from 1.1.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_DymoScale#10 from adafruit/REUSE
  > Added pre-commit-config file

Updating https://github.com/adafruit/Adafruit_CircuitPython_EMC2101 to 1.1.3 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_EMC2101#4 from MaxBec/hotfix_pwm_freq

Updating https://github.com/adafruit/Adafruit_CircuitPython_FocalTouch to 1.2.4 from 1.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_FocalTouch#19 from kmatch98/add_irq

Updating https://github.com/adafruit/Adafruit_CircuitPython_PyPortal to 5.1.2 from 5.1.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#105 from jfurcean/fix_api_docs
  > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#104 from adafruit/dherrada-patch-1

Updating https://github.com/adafruit/Adafruit_CircuitPython_RFM69 to 2.1.2 from 2.1.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_RFM69#35 from BiffoBear/add-timeout-to-op-mode_setter

Updating https://github.com/adafruit/Adafruit_CircuitPython_PIOASM to 0.1.4 from 0.1.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#5 from dglaude/patch-1

Updating https://github.com/adafruit/Adafruit_CircuitPython_ProgressBar to 1.3.6 from 1.3.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_ProgressBar#24 from adafruit/REUSE
  > Added pre-commit-config file

Updating https://github.com/adafruit/Adafruit_CircuitPython_RTTTL to 2.4.4 from 2.4.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_RTTTL#23 from adafruit/dherrada-patch-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fail on line containing no instruction but only a comment. ( starting with ; )
2 participants