We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello, why is the simple code below assembled wrong? The disassembly copies the same value from the same memory location 0x06 to tp(n). (MOV @R0,0x06)
Thanks for Help Christian Tauschek
MY WRITTEN CODE: unsigned char tp[20]; for (n = 19; n > 0 ; n--) { tp[n] = tp[n-1]; }
__________________________________________ WRONG DISASSEMBLY:
46: for (n = 19; n > 0 ; n--) { C:0x08CA 7F13 MOV R7,#0x13 47: tp[n] = tp[n-1]; C:0x08CC 7421 MOV A,#0x21 C:0x08CE 2F ADD A,R7 C:0x08CF F8 MOV R0,A C:0x08D0 E6 MOV A,@R0 C:0x08D1 FE MOV R6,A C:0x08D2 7422 MOV A,#tp(0x22) C:0x08D4 2F ADD A,R7 C:0x08D5 F8 MOV R0,A C:0x08D6 A606 MOV @R0,0x06 48: } C:0x08D8 DFF2 DJNZ R7,C:08CC __________________________________________
MY uVISION3: IDE-Version: µVision3 V3.80 Copyright (c) Keil Elektronik GmbH / Keil Software, Inc. 1995 - 2009
License Information: Christian Tauschek Tauschek LIC=----
Tool Version Numbers: Toolchain: PK51 Prof. Develpers Kit Version: 8.18 Toolchain Path: C:\Keil\C51\BIN\ C Compiler: C51.Exe V8.18 Assembler: A51.Exe V8.01 Linker/Locator: BL51.Exe V6.20 Librarian: LIB51.Exe V4.24 Hex Converter: OH51.Exe V2.6 CPU DLL: S8051.DLL V3.65 Dialog DLL: DP51.DLL V2.54
"why is the simple code below assembled wrong?"
What have you done to prove that it is wrong?
"The disassembly copies the same value from the same memory location 0x06 to tp(n). (MOV @R0,0x06)"
0x06 is the direct address of R6. There is no MOV @Ri,Rn instruction, but there is a MOV @Ri,direct instruction.
the reason must be there:
unsigned char n; unsigned char tp[20]; n = 0x09;
there is a difference between (1) "tp[n] = tp[0x08];" and (2) "tp[n] = tp[n - 1];"
normaly it should get the same result in tp[n], but i doesn't why? Only Code (1) works correct thanks Christian Tauschek
Very well then, let us have the smallest complete compilable example that demonstrates your issue -- complete with the version numbers of toolchaain components utilized in your build process, along with the build specifications.
One of your problems with how you have claimed (or questioned whether) this bug exists, is that you have claimed a bug with the IDE (uVision) while providing a (low) level of detail that the IDE is simply not responsible for. In other words, the IDE does not emit code sequences; other parts of the toolchain do that.