Skip to content

Allow specifying PIO/SM number for "assemble" - #4

Open
kuba2k2 wants to merge 5 commits into
byteit101:mainfrom
kuba2k2:feature/assemble-pio-num
Open

Allow specifying PIO/SM number for "assemble"#4
kuba2k2 wants to merge 5 commits into
byteit101:mainfrom
kuba2k2:feature/assemble-pio-num

Conversation

@kuba2k2

@kuba2k2 kuba2k2 commented Jul 19, 2026

Copy link
Copy Markdown

This PR makes it possible to specify PIO/SM number when using the assemble command for loading PIO programs, without having to manually configure wrap/side-set configuration.

Example of loading two single-instruction programs to SM 0/1/2/3 from a single PIO file:

> assemble -i prog.pio +l -P sample_in -p 0 -s 0
pioasm exited with code 0
parsed program "sample_in" with 1 PIO SM instructions
(pio0:sm*) loaded program sample_in at address 0x00
(pio0:sm0) set wrap=0
(pio0:sm0) set wrap_target=0
(pio0:sm0) set side-set count to 0
(pio0:sm0) set side-set opt=false
(pio0:sm0) set side-set pindirs=false
> assemble -i prog.pio +l -P sample_in -p 0 -s 1
pioasm exited with code 0
parsed program "sample_in" with 1 PIO SM instructions
(pio0:sm*) loaded program sample_in at address 0x01
(pio0:sm1) set wrap=1
(pio0:sm1) set wrap_target=1
(pio0:sm1) set side-set count to 0
(pio0:sm1) set side-set opt=false
(pio0:sm1) set side-set pindirs=false
> assemble -i prog.pio +l -P sample_out -p 0 -s 2
pioasm exited with code 0
parsed program "sample_out" with 1 PIO SM instructions
(pio0:sm*) loaded program sample_out at address 0x02
(pio0:sm2) set wrap=2
(pio0:sm2) set wrap_target=2
(pio0:sm2) set side-set count to 0
(pio0:sm2) set side-set opt=false
(pio0:sm2) set side-set pindirs=false
> assemble -i prog.pio +l -P sample_out -p 0 -s 3
pioasm exited with code 0
parsed program "sample_out" with 1 PIO SM instructions
(pio0:sm*) loaded program sample_out at address 0x03
(pio0:sm3) set wrap=3
(pio0:sm3) set wrap_target=3
(pio0:sm3) set side-set count to 0
(pio0:sm3) set side-set opt=false
(pio0:sm3) set side-set pindirs=false

Notice how the wrap/wrap target addresses are now relative to the just-loaded program's start address.

@kuba2k2

kuba2k2 commented Jul 19, 2026

Copy link
Copy Markdown
Author

Also added automatic relocation of jmp target addresses when the program is loaded at a non-zero address (the pico-sdk does that too).

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.

1 participant