Hi all, My code is based on C and I have a lot of cases where I assign a value to a variable. Is it more efficiency to just place the value or first to check if the variable already has this value? I made two identical sample codes where in one code I had only an assignment of a value and in the other one I had verification first. I see that the CODE area in the second sample was bigger then the first one. If CODE area is smaller, it's not mean that all code is more efficiency. Any ideas? Ruven
Hi, ...if the variable already has this value What do you mean? Next construction: if (a != 9) a=9; has no sense with the exception of writting into cycle-limited areas (for example, EEPROM, FLASH etc). Btw, another way to assign a value to a variable is make it via array; something like it: static unsigned char array[256] = {value1, value2, ...}; a = array[x]; such way should work fast if compiler translates it in MOVC A,@A+DPTR - just one assembly command. Good days! Good days!
Oops, has no sense here I mean that insead if (a != 9) a = 9; you may just write a=9; Good days!