Hi all.
I have a known working c project.
It was requested of me to make an assembly module for the ADC we are using partially for our own learning, and partially because we use some micros programmed entirely in assembly.
I have created ADS1271asm.asm. Currently I am just trying to test basic functionality and so i've created a function to return the absolute value of the passed variable.
in my main.c I have created the prototype:
extern Uint16 _abs_value_asmfunc(Uint16 value);
And have called the function:
ABS_VALUE = _abs_value_asmfunc(GARBAGE_DATA);
When I build main.c, and ADS1271asm.asm as individual files, both build properly. When I build the project, I get the familiar error #10234-D: unresolved symbols remain, citing that:
undefined first referenced
symbol in file
--------- ----------------
__abs_value_asmfunc ./main.obj
Which usually means it's a linker error or definition error. I'm pretty certain it's a linker error, as I have my function defined as above in main.c, and I'm stumped what I'm missing.
lastly, here is my assembly code in it's entirety, with commented out sections (tab formatting got a little wonky here):
;-----------------------------------------------------------------------;
; ;
; DATA AREA ;
; ;
;-----------------------------------------------------------------------;
;section .data ;Section for declaring initialized data or constants
;
;SETC OBJMODE ; Set to C28x enhanced mode
;.retain
;.retainrefs
;-----------------------------------------------------------------------;
; ;
; BSS AREA ;
; ;
;-----------------------------------------------------------------------;
;section .bss ;Section for declaring variables
.def _abs_value_asmfunc
; .sect "ramfuncs"
.global _abs_value
.global __abs_value_asmfunc
;
;
;-----------------------------------------------------------------------;
; ;
; CODE AREA ;
; ;
;-----------------------------------------------------------------------;
;section .text ;Section used for keeping functional code
_abs_value_asmfunc:
CLRC TC ;Clear TC flag, use as sign flag
MOV ACC, @_abs_value << 16 ;Shift variable up to AH
ABSTC ACC ;Take absolute value
NEGTC ACC ;Negate ACC if TC=1
LRET ;Return from address on stack
Couple final questions:
when I take out the comments for section .bss (but not .data) I get the error:
"../ADS1271asm.asm", ERROR! at line 42: [E0005] Operand missing
If I take out the comments for section .text, I get the error:
"../ADS1271asm.asm", ERROR! at line 54: [E0300] Symbol section has already been defined
commenting out both .bss and .data will allow the file to compile.
Lastly, I have read through the following TI documents:
CPU Instruction set
Optimizing C Compiler
C28x Assembly Language
Easy Way of Creating a C-callable Assembly Function
Any help you can offer would be appreciated.
-Cam Buskell