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.

Compiler/LAUNCHXL-F28069M: Accessing C variable from Assembly function

Part Number: LAUNCHXL-F28069M

Tool/software: TI C/C++ Compiler

Hello Community,

I am working with the F28069M EVM and I'm trying to implement a assembly function, inside a C project, which has to use variable declare, externally, in .C file
The variable inside the .c file is: RunPt

and this is de code I had in the .asm file:

	;.cdecls C,NOLIST	%{ #include "x00_RTOS.h" %}

	.def _OS_Start
    .global _OS_Start
    .ref RunPt
***********************************************************************
* Function: codestart section
*
* Description: Branch to code starting point
***********************************************************************
    .sect "OS_Start"
_OS_Start:
	EALLOW
	MOVZ 	AR2,@RunPt
	MOV		@SP,AR2
EDIS
	LRETR

The output error is that the compiler:

 undefined first referenced
  symbol       in file     
 --------- ----------------
 RunPt     ./x00_OSasm.obj 
 
error: unresolved symbols remain

Does anyone know how to resolve this problem?

  • To reference a variable declared in a C file in an assembly module, you'll need to prefix the variable name with an underscore.  Change the variable name in the assembly file to _RunPt, leaving the C name unchanged.  This was done in the thread you referenced with the variable "MyVar".

    Regards,

    Richard

  • Hello Richard,

    Thank you for your answer. The underscore prefix needs to be added to the variable name at every reference/usage of it inside the .asm code.

    ;	Created on: Mar 21, 2020
    ;	 Author: JuanFco
    
         .def _OS_Start
        .global _OS_Start
        .ref _RunPt
    ***********************************************************************
    * Function: codestart section
    *
    * Description: Branch to code starting point
    ***********************************************************************
    	.text
        .sect "OS_Start"
    _OS_Start:	.asmfunc
    	EALLOW
    	MOVZ 	AR2,@_RunPt
    	MOV		@SP,AR2
    	EDIS
    	LRETR
    	.endasmfunc

    I would like to add that, the correct implementation is mentioned in the following document form TI: SPRU513C.pdf, Page 57, Section 3.14 Debugging Assembly Source, Example 3-4. Viewing Assembly Variable as C Types

    Regards.