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.
Is there any way to treat .c files as assembly language files?
I have a code generator that creates .c files, so it would be very useful if I could put a directive such as "#asm" at the beginning of the files that contain assembly language only, to force the assembler to be used instead of the C compiler.
For example, a .asm file such as the following would be transformed into a C file:
(.asm file)
;-------------------------------------------------------------------------------
; sys_svc.asm
;
; The interrupt handler for svc (supervisor mode)
.text
.arm
;-------------------------------------------------------------------------------
; SVC Interrupt Handler
.global _svc
.asmfunc
_svc:
stmfd sp!, {r0-r12,lr}
ldmfd sp!, {r0-r12,pc}^
.endasmfunc
;-------------------------------------------------------------------------------
(.c file)
void svc(void)
{
#asm
; The interrupt handler for svc (supervisor mode)
.text
.arm
;-------------------------------------------------------------------------------
; SVC Interrupt Handler
.global _svc
.asmfunc
_svc:
stmfd sp!, {r0-r12,lr}
ldmfd sp!, {r0-r12,pc}^
.endasmfunc
#endasm
}
Regards,
Dave
Dave,
There is a compiler option to tell the compiler how to interpret file name extensions. The option for interpreting it as a assembly source file is --asm_file=filename. Please take a look at Section 2.3.6 of the TMS470 Compiler Users Guide for details.
However, assembly directives and instructions embedded in a C source file need to be enclosed within asm statements. Please see section 6.5.4 of the same Users Guide.
Either way, it appears that some further processing needs to be done to the file before it can be compiled as a C or asm source file without errors.