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.

TMS320F28035: atomic read/modify/write of C28X CPU

Part Number: TMS320F28035

Hi, In F2803x multiday workshop, F28x Atomic read/modify/write is introduced. The example is shown below:

So I test it in my code as below, but there will be error shown below:

warning #99922: "../Example_2803xLEDBlink.c", line 35: Assembly statement "AND
*XAR1,#0x1234" creates a label, which may not be what was intended. Use a
colon after a label or a space before a non-label to silence the warning.
warning #99922: "../Example_2803xLEDBlink.c", line 35: Assembly statement "AND
*XAR1,#0x1234" creates a label, which may not be what was intended. Use a
colon after a label or a space before a non-label to silence the warning.
1 Assembly Error, No Assembly Warnings

>> Compilation failure
subdir_rules.mk:65: recipe for target 'Example_2803xLEDBlink.obj' failed
"C:\Users\a0223719\AppData\Local\Temp\{4543FEC9-CF37-4246-8C43-FE6DB9DEDA45}", ERROR! at line 138:
[E0002]
Invalid mnemonic specification
AND *XAR1,#0x1234

1. why there will be error ?

2. I cannot find any atomic instruct in SPRU430F like "AND *XAR2,#1234h", I can only find basic assembly language instruction like

"MOV AL,*XAR2

AND AL,#1234h

MOV *XAR2,AL"

Are there a list of atomic instructions offered?

3. In assembly, can I directly write the atomic instruction instead of the assembly language instruction? If I write the code in C, will the compiler automatic generate atomic instruction when it can?

  • Howard Zou said:
    warning #99922: "../Example_2803xLEDBlink.c", line 35: Assembly statement "AND
    *XAR1,#0x1234" creates a label, which may not be what was intended. Use a
    colon after a label or a space before a non-label to silence the warning.

    In C28x assembly, the first column is reserved for labels.  You will need to enter a space between the " and the AND.  This will move the AND out of the first column.

    asm(" AND.....");

    In general coding I would avoid using asm("...").  I recall it can confuse the C environment if you modify registers within a asm(" ") statement and it interferes with optimization.  The experts in the Compiler forum would be able to better comment on this practice in a real application.

    Howard Zou said:

    2. I cannot find any atomic instruct in SPRU430F like "AND *XAR2,#1234h", I can only find basic assembly language instruction like

    "MOV AL,*XAR2

    AND AL,#1234h

    MOV *XAR2,AL"

    Are there a list of atomic instructions offered?

    There isn't a list.  In general instructions that perform a read-modify-write are atomic -examples: OR, AND, XOR... looking through SPRU430, some of the instructions mention this in the description.  Unfortunately there is not a complete list.

    AND *XAR2,#1234h  is an instruction of the form AND loc16, #16bitSigned and is described on page 154.

    Howard Zou said:
    3. In assembly, can I directly write the atomic instruction instead of the assembly language instruction? If I write the code in C, will the compiler automatic generate atomic instruction when it can?

    An atomic instruction is an assembly language instruction.

    Yes, the compiler will use these instructions when it can.

    -Lori