Skip to content

Does not support binary or hex values #30

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

Closed
dannystaple opened this issue Dec 27, 2021 · 2 comments · Fixed by #42
Closed

Does not support binary or hex values #30

dannystaple opened this issue Dec 27, 2021 · 2 comments · Fixed by #42

Comments

@dannystaple
Copy link
Contributor

In principle, the RP2040 datasheet section 3.3.2 suggests that a value can be expressed as a binary value, eg:
0b10101.

In practice this causes an exception:

lib/adafruit_pioasm.py", line 182, in assemble
    value = int(instruction[-1])
ValueError: invalid literal for int() with base 10: '0b10101'

this also applies to hex values.
ValueError: invalid literal for int() with base 10: '0x1a'

This may be simply a note to put under https://learn.adafruit.com/intro-to-rp2040-pio-with-circuitpython (which thinking about it, I should link to from the docs for this module).

@tannewt
Copy link
Member

tannewt commented Dec 28, 2021

I think int(instruction[-1], 0) will fix this by having python interpret it as an int literal and therefore auto-detect the base.

@dannystaple
Copy link
Contributor Author

dannystaple commented Jan 1, 2022

As a workaround, you can use a f-string. Ie:

program = f"""
.program set_binary_y    
    set y, {0b11}    ; set a value in y
"""

This will work for hex and binary values.

jepler added a commit to jepler/Adafruit_CircuitPython_PIOASM that referenced this issue Apr 23, 2022
Closes: adafruit#30 (though I don't know what octal syntax is accepted by
official pioasm, we will accept python-style 0o567 not C-style 0567)
jepler added a commit to jepler/Adafruit_CircuitPython_PIOASM that referenced this issue Apr 25, 2022
Closes: adafruit#30 (though I don't know what octal syntax is accepted by
official pioasm, we will accept python-style 0o567 not C-style 0567)
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 a pull request may close this issue.

2 participants