This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Assembler Jmp instruction length

I am using TI v15.9.0.STS and have an assembly file where if the jump instruction destinations are out of range, an inverse jump is place in their location, and a bra instruction is inserted after the jump.

This would be fine, except that it seems that the distance is not accounted for by symbols that are forward linking.

How do I turn this off, and just have the assembler give me an error message?

David

  • I assume you are talking about an MSP430X device. I'm sorry, I'm not familiar with an "inverse jump." Could you show me an example of the generated assembly code?
  • I think I have basically found the problem, but I don't understand how to turn this off, which is what I'm looking for.

    Here is a little sample listing:

    Basically, what I see in this example is that if a JMP instruction is out of range, a BR instruction will be substituted into the code, and the JMP instruction will be modified to the opposite case, to jump over the BR following (28xx is a JNC instruction, and a 2 word offset jumps over the next 2 words, 0080 is a BR instruction, and the word following is the address).  So far, so good, however if you look at line 7, you will see that the label3 location indicated is 0x0408, which would be correct if an instruction hadn't been inserted, but is wrong for this case, since label3 has been moved to 0x040c.

    Turns out, this error only occurs on .equ statements, as far as I've seen.

    MSP430 Assembler PC v4.4.6 Tue Dec 01 13:41:07 2015
    
    Tools Copyright (c) 2003-2015 Texas Instruments Incorporated
    ../testjump.asm                                                      PAGE    1
    
           1            labelmacro      .macro  label
           2                    .word   label
           3                    .endm
           4            
           5 000000               .text
           6 000000               labelmacro      label2
    1        000000 0000!         .word   label2
           7 000002               labelmacro      label3
    1        000002 0408'         .word   label3
           8            
           9 000004       label1: .space  1025
          10 000406 2802  label2: jc      label1
             000408 0080!
             00040a 0000 
          11      040C' label3  .equ    $
    
    No Assembly Errors, No Assembly Warnings
    

  • Oh, I see now, it's inserting a jmp on the inverse condition. This happens as part of variable length instruction optimization, and I'm pretty sure it cannot be turned off. I've submitted SDSCM00052531 to track this issue.
  • Hi David,

    Is there a reason that you need to use the symbol "label3 .equ $"? Would defining the label "label3: " at that location instead be a viable workaround?
  • I've gone through the process of replacing almost all of the '.equ $' with ':''s and those don't cause the problem to occur.  There are a few places, however, where the address is actually being computed as items like '.equ $+2' or equivalent, and I don't see a way to say ':+2' to provide the same effect.

    Whether I get rid of all the offending statements or not, it's still an error.

    David

  • > There are a few places, however, where the address is actually being computed as items like '.equ $+2' or equivalent, and I don't see a way to say ':+2' to provide the same effect.

    $+2 is typically used to mean "the next instruction." (Assuming that the current instruction's size is 2. If it is 4, then $+4 is the next instruction.) You might see this used in a way such as JNE $+4 to skip an instruction in certain cases.

    EDIT: Moving the label to the next instruction may serve as a workaround in these cases.


    > Whether I get rid of all the offending statements or not, it's still an error.

    Absolutely, this is a deficiency in the assembler and it is being tracked as such.