Hi all. I am facing this problem. If I am using following syntax, logically it is ok, but it is generating a wrong asm code via keil C51. Problem 1
ACC = ACC + B;
ADD A, B;
MOV A, B; ADD A, B;
ACC = z; B = 0; if(ACC<100) ...
MOV A, z(0X0A) CLR A; MOV B, A;
Your problem is that you are using a C compiler but you are writing assembly code. This is like using a chainsaw to perform dental surgery. The compiler has to use the accumulator to do its job. When you write code that tries to manipulate the accumulator, you will ultimately fail. The reason is because the compiler uses the accumulator. So, if the compiler uses the accumulator and you also use the accumulator in your C program, you will corrupt the code the compiler is trying to generate. If you want to write assembly code, use the assembler. Jon
OK. This means compiler is unnecessarily increasing the no. of instructions. isn't it? Anyway thanks for that. What about generating DA A instruction via C code.
As Jon says, forget about assembler. You are using a 'C' compiler. This should give you a starting point: int a=5,b=7; char buff[10]; a+=b; sprintf(buff,"%d",a); LCD_print(buff);
What about generating DA A instruction via C code. What about hammering a nail in with a screwdriver? ... same thing Erik
View all questions in Keil forum