Shop OBEX P1 Docs P2 Docs Learn Events
Execf call skip behaviour — Parallax Forums

Execf call skip behaviour

Hello,

I have an issue with a program that uses execf with call instructions.
See this example:

CON
    _clkfreq    = 160_000_000

DAT
                org     $000

                call    #test_execf
                call    #test_execf_nop

                jmp     #$

test_execf
                debug(udec(test_execf))

                push    #$+2
                execf   op1
                debug(udec(t1))

                push    #$+2
                execf   op2
                debug(udec(t1))

                push    #$+2
                execf   op3
                debug(udec(t1))

                ret

test_execf_nop
                debug(udec(test_execf_nop))

                push    #$+2
                execf   op1_nop
                debug(udec(t1))

                push    #$+2
                execf   op2_nop
                debug(udec(t1))

                push    #$+2
                execf   op3_nop
                debug(udec(t1))

                ret

op1             long    op     |    %1_1_0 << 10
op2             long    op     |    %1_0_1 << 10
op3             long    op     |    %0_1_1 << 10

op1_nop         long    op_nop | %01_01_00 << 10
op2_nop         long    op_nop | %01_00_01 << 10
op3_nop         long    op_nop | %00_01_01 << 10

op              call    #sub1
                call    #sub2
                call    #sub3
                ret

op_nop          call    #sub1
                nop
                call    #sub2
                nop
                call    #sub3
                nop
                ret

sub1    _ret_   mov     t1, #1

sub2    _ret_   mov     t1, #2

sub3    _ret_   mov     t1, #3

t1              res     1
t2              res     1

This is an image of the debug output:

You can see that, apparently, contiguous calls can't skipped but if there is another instruction in between (a nop in this case) the skip pattern works.

Is that the correct behaviour or I'm missing something ?

Comments

  • TonyB_TonyB_ Posts: 2,178
    edited 2021-04-26 10:36

    CALL must use absolute addressing with SKIPF/EXECF, e.g CALL #\routine or CALL reg, if the instruction after the call might be skipped. See "Special SKIPF Branching Rules" in the doc.

    It is safest to use absolute addressing for every CALL in a SKIPF sequence. I do that for non-skipping CALLs, too, just in case they become part of a skip sequence later.

  • @TonyB_ said:
    CALLs must use absolute addressing with SKIPF/EXECF, e.g CALL #\routine or CALL reg.

    Isn't that what I'm using ?
    No, just noticed the backslash !!!

    (some rants and really bad words deleted before posting)

    New postit: P2 CALL/JMP ARE RELATIVE !!!

    Thanks for your help!

Sign In or Register to comment.