Does anyone know if there is a way to make a #define in 'C' visible to A51 code (or visa-versa)? I know how to make a header file in Hi-Tech C51 that will let 'C' and 'A51 definitions coexist, but can't figure out how to this with Keil. In Hi-Tech's C51 compiler you can create a common ('C' and 'A51') header file like this: ; #define C_1 1 ; #define C_2 2 ; #define C_3 3 ;#if (0) ASSEM_1 EQU 1 ASSEM_2 EQU 2 ASSEM_3 EQU 3 ;#endif But when I try this in Keil it chokes on the ; before the #define. Any ideas?
A51 Version 6 adds a C preprocessor to the assembler. Therefore it is possible to use #define statements also in the assembler language. If you have an older version of our tools you should consider to upgrade it.
$SET (WATCHDOG = 1) $IF (WATCHDOG = 1) SRVWDT ; SERVICE WATCHDOG $ENDIF
$SET (WATCHDOG = 1)
Assuming you have version 6 or newer of A51/C51, just take the semi-colons out of your code example and it should assemble fine. The C preprocessor in A51 will process those lines.