#1595 PIC14: operation at Cast is amusing from the array to point

open
nobody
PIC14
5
2013-07-16
2009-12-23
kazu1108
No

17 a = 0x1234;
18
19 /* This is fail case */
20 *(unsigned short *)(&m_work[OFFSET_A]) = 0;
21 *(unsigned short *)(&m_work[OFFSET_B]) = a;
22 b = *(unsigned short *)(&m_work[OFFSET_A]);
23 hoge(b);

I expect the thing that two bytes change. However, it changes only by one byte.
A part of generated asm is shown below.

24_main ;Function start
125; 2 exit points
126;gen.c:5891: size=0/1, offset=0, AOP_TYPE(res)=8
127; .line 20; "test.c" *(unsigned short *)(&m_work[OFFSET_A]) = 0;
128 BANKSEL _m_work
129 CLRF (_m_work + 0)
130;gen.c:5891: size=0/1, offset=0, AOP_TYPE(res)=8
131; .line 21; "test.c" *(unsigned short *)(&m_work[OFFSET_B]) = a;
132 MOVLW 0x34
133 MOVWF (_m_work + 2)
134; .line 22; "test.c" b = *(unsigned short *)(&m_work[OFFSET_A]);
135 MOVF (_m_work + 0),W
136; .line 23; "test.c" hoge(b);
137 BANKSEL r0x100A
138 MOVWF r0x100A
139 MOVWF STK00
140 MOVF r0x100B,W
141 PAGESEL _hoge
142 CALL _hoge
143 PAGESEL $

version:SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.9.4 #5573 (Dec 1 2009) (CYGWIN)

Discussion

  • kazu1108
    kazu1108
    2009-12-23

    test code and generated asm

     
    Attachments
  • Maarten Brock
    Maarten Brock
    2011-09-18

    • summary: The operation at Cast is amusing from the array to the point --> PIC14: operation at Cast is amusing from the array to point
     
    • Category: --> PIC14