Hi, all
My preference is to program in mixed assembly and C environments, and share C headers containing declarations
between the C and assembly code. but, how to refer to C bit-field lable of structure members in assembly code?
I 'm puzzled by this question for a long time.
//for example
//in C Header file ctest.h
typedef struct CRITICAL_FAULT_FLAGS { // bits description
int Err0:1; // BIT0
int Err1:1; // BIT1
int Err2:1; // BIT2
int Err3:1; // BIT3
int Err4:1; // BIT4
int Err5:1; // BIT5
int Err6:1; // BIT6
int Err7:1; // BIT7
int Err8:1; // BIT8
int Err9:1; // BIT9
int Err10:1; // BIT10
int Err11:1; // BIT11
int Err12:1; // BIT12
int Err13:1; // BIT13
int Err14:1; // BIT14
int Err15:1; // BIT15
} CRITICAL_FAULTS;
//in C code sorce file ctest.c:
#include "ctest.h"
CRITICAL_FAULTS strCriticalFaults;
strCriticalFaults.Err0 = 1;
strCriticalFaults.Err5 = 1;
//Then I reference the C constructs in assembly code as below in asmTest.asm file
.cdecls C,LIST,WARN,"ctest.h"
.ref _strCriticalFaults
MOVW DP, #_strCriticalFaults
MOV AL, @_strCriticalFaults.Err5 ;here , I need mask off garbage bits
;//but how to mask off garbage bits, and access the BIT5 using the C Bit-field lable Err5
;// by the way,when use #_Err5 or #_Err0 in asmTest.asm, Compilation failure and occur
;// "The following symbols are undefined", beacuse A label for a structure member cannot be declared global
thanks for any help