Am Fri, 30 Jun 2006 11:13:32 +0200 schrieb Robert Dominicus-Schleutermann: > Bodo Rzany schrieb: >> Am Wed, 28 Jun 2006 19:59:27 +0000 (UTC) schrieb Grant Edwards: >> >>> Why isn't this correct? >>> >>> mov.b &0x0034, r15 >>> mov.b &0x0034, r14 >>> add r15, r14 >>> mov r14, &two >>> ret >> >> This *is* correct. But if you really want to deal with assembler >> (which I do prefer on the msp430), you could code as follows: >> >> mov.b &0x0034, r15 >> add r15, r15 >> mov r15, &two >> ret > > Hmmm... I thought about that version too but it is wrong > according to the original C code. > > P6IN is defined "volatile". That means an extra reading of the > input port (debouncing purpose for example). For that part the generated > code and Grants version is correct in reading the port twice. > > Your code should be generated, if the original C code is something > like the following examples: > > two = 2 * P6IN; > > two = P6IN << 1;
You are right. The possible optimizing really depends on what you want to do. Regards, Bodo Rzany