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.

CCS/TMS570LS1224: Assembler Issue (CCS 7.2)

Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN

Tool/software: Code Composer Studio

I've got a short assembler file for the TMS570 that won't assemble. The assembler throws the following error:

line 1: error #171: expected a declaration

I'm not sure what's happening here. If I use this same file with a Cortex-M processor (adding .thumb) it works just fine. Any ideas?

 .text
 .align 2
 .syntax unified
  
.global Clz

Clz:
	clz		  r0,r0			// determine bit position of highest bit set in the 32-bit word
	bx		  lr

	.end

  • Jerry,

    According to the compiler documentation, __clz(int src) is a supported intrinsic and can be called from C/C++ code.

    From the compiler TRM:

    C/C++ Compiler IntrinsicAssembly
    Instruction
    Description
    int count = _ _clz(int src); CLZ count , src Returns the count of leading zeros

    i.e., there shouldn't be a need for the assembly function since it is already a compiler intrinsic.

  • Yes, I'm aware that CLZ is an intrinsic. I used that one just for example purposes. I deleted several hundred lines of assembly, which are not already intrinsics, so I do still need to know how to make an assembly file assemble without the "line 1: error #171: expected a declaration" error that I've been seeing.
  • You need to add the .arm declaration after the .text section declaration.

    A snippet from an assembly file generated from HalCoGen shows the below:

        .text
        .arm
    
    ;-------------------------------------------------------------------------------
    ; Initialize CPU Registers
    ; SourceId : CORE_SourceId_001
    ; DesignId : CORE_DesignId_001
    ; Requirements: HL_SR477, HL_SR476, HL_SR492
    
        .def     _coreInitRegisters_
        .asmfunc
    
    
    _coreInitRegisters_
    
    
        ; After reset, the CPU is in the Supervisor mode (M = 10011)
            mov r0, lr
            mov r1, #0x0000
            mov r2, #0x0000
            mov r3, #0x0000
            mov r4, #0x0000
            mov r5, #0x0000
            mov r6, #0x0000
            mov r7, #0x0000
            mov r8, #0x0000
            mov r9, #0x0000
            mov r10, #0x0000
            mov r11, #0x0000
            mov r12, #0x0000
            mov r13, #0x0000
            mrs r1, cpsr
            msr spsr_cxsf, r1
            ; Switch to FIQ mode (M = 10001)
            cps #17
            mov lr, r0
            mov r8, #0x0000
            mov r9, #0x0000
            mov r10, #0x0000
            mov r11, #0x0000
            mov r12, #0x0000
            mrs r1, cpsr
            msr spsr_cxsf, r1
            ; Switch to IRQ mode (M = 10010)
            cps #18
            mov lr, r0
            mrs r1,cpsr
            msr spsr_cxsf, r1
            ; Switch to Abort mode (M = 10111)
            cps #23
            mov lr, r0
            mrs r1,cpsr
            msr spsr_cxsf, r1
            ; Switch to Undefined Instruction Mode (M = 11011)
            cps #27
            mov lr, r0
            mrs r1,cpsr
            msr spsr_cxsf, r1
            ; Switch to System Mode ( Shares User Mode registers ) (M = 11111)
            cps #31
            mov lr, r0
            mrs r1,cpsr
            msr spsr_cxsf, r1
    
    
            mrc   p15,     #0x00,      r2,       c1, c0, #0x02
            orr   r2,      r2,         #0xF00000
            mcr   p15,     #0x00,      r2,       c1, c0, #0x02
            mov   r2,      #0x40000000
            fmxr  fpexc,   r2
    
            fmdrr d0,         r1,     r1
            fmdrr d1,         r1,     r1
            fmdrr d2,         r1,     r1
            fmdrr d3,         r1,     r1
            fmdrr d4,         r1,     r1
            fmdrr d5,         r1,     r1
            fmdrr d6,         r1,     r1
            fmdrr d7,         r1,     r1
            fmdrr d8,         r1,     r1
            fmdrr d9,         r1,     r1
            fmdrr d10,        r1,     r1
            fmdrr d11,        r1,     r1
            fmdrr d12,        r1,     r1
            fmdrr d13,        r1,     r1
            fmdrr d14,        r1,     r1
            fmdrr d15,        r1,     r1
            bl    next1
    next1
            bl    next2
    next2
            bl    next3
    next3
            bl    next4
    next4
            bx    r0
    
        .endasmfunc
    
    

  • the ARM assembly instructions can not start in the first column. They must be preceded by white space.
    .text
    .align 2
    .syntax unified ----- it is not correct directive
    .global Clz ------ please add white space before "." (QJ)
  • Hello Jerry,

    Have you tried to add white space to the instructions?