Hi Kusti, I fear that you are right: there seems to be a banksel missing for g_stepperstate before 01020 - and if that's added, the one removed in 01021 needs to stay. I also agree that the movff statements should not be in there. I'll try to look into this tonight and tomorrow evening, but it has been quite a while for me to actually develop sdcc... Let's see. Currently, I have no workaround. One could try removing volatile and see if that's related to the issues. I understand that you probably need the structures to be volatile, so this would only help analyse the issue, not fix it.
Best regards, Raphael On Aug 29, 2016 9:22 AM, "Kustaa Nyholm" <kustaa.nyh...@planmeca.com> wrote: > Hi, > > spent a better part of the evening trying to figure out why my code does > not work. > > In the early hours of the morning I came up with this test code (in > "main.c"): > > void testxxx() { > hid_tx_buffer.uint8[33] = g_stepper_state[1].position.uint8[1]; > hid_tx_buffer.uint8[34] = g_stepper_state[1].position.uint8[2]; > > } > > The first assignment works but the second one fails (based on observing > the results in actual hardware, PIC18F45K50). > > Looking at the compiled code it looks to me that there is a missing BANKSEL > at line 01021? > > Also I don't see the point of the MOVFF instructions at 01013 and 01019, > what is the purpose? > > 000000 01008 _testxxx: > 01009 ; .line 59; main.c > hid_tx_buffer.uint8[34] = g_stepper_state[1].position.uint8[2]; > 000000 CFD9 FFE5 01010 MOVFF FSR2L, POSTDEC1 > 000004 CFE1 FFD9 01011 MOVFF FSR1L, FSR2L > 01012 ; .line 60; main.c } > 000008 C??? F??? 01013 MOVFF (_g_stepper_state + 5), > (_g_stepper_state + 5) > 00000C ???? 01014 BANKSEL (_g_stepper_state + 5) > 00000E 51?? 01015 MOVF (_g_stepper_state + 5), W, B > 000010 ???? 01016 BANKSEL (_hid_tx_buffer + 33) > 000012 6F?? 01017 MOVWF (_hid_tx_buffer + 33), B > 01018 ; .line 61; main.c > 000014 C??? F??? 01019 MOVFF (_g_stepper_state + 6), > (_g_stepper_state + 6) > 000018 51?? 01020 MOVF (_g_stepper_state + 6), W, B > 01021 ; removed redundant BANKSEL > 00001A 6F?? 01022 MOVWF (_hid_tx_buffer + 34), B > 00001C CFE4 FFD9 01023 MOVFF PREINC1, FSR2L > 000020 0012 01024 RETURN > > The declarations for the data structures are as follows. > > In a header file included in "main.c" > > //------------------------------------ > typedef union { > uint8_t uint8[4]; > uint16_t uint16[2]; > uint32_t uint32; > } uint32_t_multi_view; > > typedef struct { > uint32_t_multi_view position; > } stepper_status_t; > > extern volatile __at(0x300) stepper_status_t g_stepper_state[]; > //------------------------------------ > > > > and in an other header file, also included in "main.c" > > > //------------------------------------ > typedef struct { > union { > uint8_t uint8[64]; > uint16_t uint16[32]; > uint32_t uint32[16]; > int8_t int8[64]; > int16_t int16[32]; > int32_t int32[16]; > }; > } hid_buffer_t; > > extern volatile hid_buffer_t hid_tx_buffer; > //------------------------------------ > > and oh yeah, this is my SDCC on Mac OS X Yosemite: > > > //------------------------------------ > /Users/nyholku/sdcc-3.4.0/bin/sdcc -v > SDCC : > mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 > 3.4.0 #8981 (Apr 5 2014) (Mac OS X i386) > published under GNU General Public License (GPL) > //------------------------------------ > > > > wbr Kusti > > > This e-mail may contain confidential or privileged information. If you are > not the intended recipient (or have received this e-mail in error) please > notify the sender immediately and destroy this e-mail. Any unauthorized > copying, disclosure or distribution of the material in this e-mail is > strictly forbidden. We will not be liable for direct, indirect, special or > consequential damages arising from alteration of the contents of this > message by a third party or as a result of any virus being passed on or as > of transmission of this e-mail in general. > ------------------------------------------------------------ > ------------------ > _______________________________________________ > Sdcc-user mailing list > Sdcc-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sdcc-user >
------------------------------------------------------------------------------
_______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user