Tool/software: TI C/C++ Compiler
I have the following code snippit:
void To523(float param_dec, uint16* param_hex) {
long param223;
long param227;
#define one_23 0x800000
#define one_27 0x8000000
param223 = param_dec * (1L << 23); //multiply decimal number by 2^23 (convert float to long)
param223 = param_dec * (one_23); //multiply decimal number by 2^23 (convert float to long)
And here is the resulting assembly code...
32 param223 = param_dec * (1L << 23); //multiply decimal number by 2^23 (convert float to long) 3f1234: 9A00 MOVB AL, #0x0 3f1235: 28A84B00 MOV @AH, #0x4b00 3f1237: 1E42 MOVL *-SP[2], ACC 3f1238: 0644 MOVL ACC, *-SP[4] 3f1239: 767F2A41 LCR FS$$MPY 3f123b: 767F2B78 LCR FS$$TOL 3f123d: 1E48 MOVL *-SP[8], ACC 33 param223 = param_dec * (one_23); //multiply decimal number by 2^23 (convert float to long) 3f123e: 9A00 MOVB AL, #0x0 3f123f: 28A84B00 MOV @AH, #0x4b00 3f1241: 1E42 MOVL *-SP[2], ACC 3f1242: 0644 MOVL ACC, *-SP[4] 3f1243: 767F2A41 LCR FS$$MPY 3f1245: 767F2B78 LCR FS$$TOL 3f1247: 1E48 MOVL *-SP[8], ACC
So you will see the two C instructions compile into identical code, that is good, the compiler noticed that 1L << 23 is a constant.
But, my question is, "Shouldn't the first 2 assembly instructions load the ACC with 0x800000? I see it is being loaded with 0x4b000000. Why?
Thanks, Mark.