I have a piece of C code, if(u3Varaible0 > u3Variable2) { #ifdef DEF_SOMETHING . . #else . . #endif } else { . . . } The variable length of u3Varaible0 is 3 bytes. I don't want to declare it as "unsigned long"(inorder to save onchip memory and reduce execution cycles), So I have to write this piece C code into asm code look like CLR C MOV Au3Varaible0_L SUBB A,u3Variable2_L MOV Au3Varaible0_M SUBB A,u3Variable2_M MOV Au3Varaible0_H SUBB A,u3Variable2_H JC C0049 . . . . C0049: . . . I want it be a macro(inorder to reduce execution cycles). But now comes the problem: 1. If I write this code as a asm macro in an asm source. I just can't use this macro from a C code. 2. If I try to write is as C macro using #define, It is impossible to use inline assembly in the macro!! 3. #ifdef DEF_SOMETHING will also cause an error in #define macro Does anyone know another good way to solve this fine tune problem?
"The variable length of u3Varaible0 is 3 bytes. I don't want to declare it as "unsigned long" (inorder to save onchip memory and reduce execution cycles)" Are you sure that making it 'unsigned long' will actually hurt that much? If you want to write in 'C', then you will have to use the data types that 'C' provides. 'C' is designed to work with these data types - you will probably find that it actually does it quite efficiently. If you are an accomplished assembler programmer, you may well be able to beat the compiler - but then, if you are an accomplished assembler programmer, you should have no problems implementing a set of 24-bit arithmetic functions...
[Ovid] Yes, I'm sure. If I declare it as unsigned long. ; unsigned long a,b; ; if(a>b) ; SOURCE LINE # 77 MOV R7,b?042+03H MOV R6,b?042+02H MOV R5,b?042+01H MOV R4,b?042 MOV R3,a?041+03H MOV R2,a?041+02H MOV R1,a?041+01H MOV R0,a?041 SETB C LCALL ?C?ULCMP JC ?C0001