Skip to content
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

pioasm: allow optional target for .wrap #2163

Open
magy00 opened this issue Jan 6, 2025 · 2 comments
Open

pioasm: allow optional target for .wrap #2163

magy00 opened this issue Jan 6, 2025 · 2 comments
Labels
enhancement New feature or request pioasm
Milestone

Comments

@magy00
Copy link

magy00 commented Jan 6, 2025

It could sometimes be convenient (and possibly allow more descriptive source code) if .wrap would optionally accept the same target expressions as jmp (with .wrap_target as the default):

.wrap (<target>)

E.g.

loop:
    mov osr, rxfifo[y]
    ...
    jmp y--, loop
    .wrap loop

would be equivalent to

.wrap_target
loop:
    mov osr, rxfifo[y]
    ...
    jmp y--, loop
    .wrap

@lurch lurch added enhancement New feature or request pioasm labels Jan 6, 2025
@kilograham kilograham added this to the 2.2.0 milestone Jan 7, 2025
@magy00
Copy link
Author

magy00 commented Jan 13, 2025

Perhaps even allow .wrap <target> at the end of an instruction (like side).

It would also be convenient to have e.g. . return the current location. Then

delay:
    jmp x--, delay

could be written as

    jmp x--, .

and

    .origin 0
    irq set   0
.wrap
    irq clear 0
.wrap_target
    …
    out pc, 1

as

    .origin 0
    irq set   0   .wrap skip
    irq clear 0
skip:
    …
    out pc, 1

or as an (extreme) example (alternative ringing cadence generator):

.program ring_sequence_irq_0
    .pio_version 1
    .fifo txget
    //mov y, ~null    // start of reversed sequence

    .origin   0
    irq set   0   .wrap .+1
    irq clear 0

    mov osr, rxfifo[y]
    mov x, osr
    jmp x--, .      // delay

    mov osr, y      // used to toggle irq flag
    jmp y--, .+1    // decrement only

    out pc, 1

@magy00
Copy link
Author

magy00 commented Jan 23, 2025

Maybe moving WORD value from directive: to base_instruction: in parser.yy could also be convenient (the .word directive basically is an instruction). Could be useful for things like:

.define public  UI  5  // unit interval (4-32), in integer .clock_div cycles
.define public  PREAMBLE_B_Z    0b00010111  // sub-frame 1 at start of block

    // assemble either mov pins, null or mov pins, ~null
    .define mov_pins_null 0b1010000000000000
    .word (mov_pins_null + (PREAMBLE_B_Z>>4 << 3))    [UI-1]
    .word (mov_pins_null + (PREAMBLE_B_Z>>5 << 3))    [UI-1]
    .word (mov_pins_null + (PREAMBLE_B_Z>>6 << 3))    [UI-1]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pioasm
Projects
None yet
Development

No branches or pull requests

3 participants