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
Hello all, thanks for answers. Now, without "using 1", it works fine. I caused the mistake.
Christian Tauschek
However, using significantly reduces the overhead in your ISR - so you should really know how to use it properly (even if it isn't needed in this particular case)
See http://www.keil.com/support/man/docs/c51/c51_le_regbankaccess.htm for details.
Also: http://www.keil.com/support/man/docs/c51/c51_le_regbankspec.htm and the linked knowledgebase articles.