The output even shows different text from what's in the 
code. Either one is not copy/pasted here.

Is there any chance you're stack is overflowing?


> Well then I'm stumped.  For some reason the payload_len has changed from 
> 2d to 9000.  Take a look at the program output.
> 
> 
> 
> Maarten Brock wrote:
> > Anthony,
> >
> >    
> >> I didn't need to adapt the __sdcc_banked_call routine, I was able to use
> >> the provided example unmodified.
> >>      
> >
> > Ok.
> >
> >    
> >> rf_send_b is expecting payload_len  to be at SP -4  and payload to be at
> >> SP -1.  rf_send doesn't put payload on the stack at all so rf_send_b
> >> doesn't find payload_len in the correct position.
> >>      
> >
> > No, rf_send_b wants payload at SP+1 (plus 1) and it puts it there
> > itself at the start of the function when receiving DPL/DPH/B. It
> > treats payload as a local variable.
> >
> >    
> >>    Maarten Brock wrote:
> >>      
> >>> Anthony,
> >>>
> >>> I see no problem with payload being sent through
> >>> DPL/DPH/B. It is properly assigned when sending in
> >>> cc2430_rf_send() and properly read and put on stack when
> >>> receiving in cc2430_rf_send_b(). Are you messing up DPTR
> >>> or B or the stack in your adapted __sdcc_banked_call
> >>> except the one push of the current bank?
> >>>
> >>> Btw. Did you know that sdcc can also printf pointers
> >>> with %p?
> >>>
> >>> Maarten
> >>>
> >>>
> >>>        
> >>>> I'm using:
> >>>>
> >>>> u...@instant-contiki:~/contiki-2.x/examples/udp-ipv6$ sdcc -v
> >>>> SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08
> >>>> 2.9.4 #5556 (Oct 29 2009) (UNIX)
> >>>>
> >>>>
> >>>> compile flags are:
> >>>>
> >>>> sdcc --codeseg BANK1 --std-c99 --model-large --stack-auto  -c
> >>>> ../../cpu/cc2430/dev/cc2430_rf.c -o obj-brione/cc2430_rf.o
> >>>> sdcc --codeseg HOME --std-c99 --model-large --stack-auto  -c
> >>>> ../../cpu/cc2430/dev/cc2430_rf_intr.c -o obj-brione/cc2430_rf_intr.o
> >>>>
> >>>> In the following routines, I see incorrect variable passing on the stack.
> >>>>
> >>>> int cc2430_rf_send(void *data, unsigned short len);
> >>>> int cc2430_rf_send_b (void *data, unsigned short len) __banked;
> >>>>
> >>>> int
> >>>> cc2430_rf_send(void *payload, unsigned short payload_len)
> >>>> {
> >>>>      printf("sending %x bytes.\n",payload_len);
> >>>>      printf("payload addr %08lx.\n", payload);
> >>>>      return cc2430_rf_send_b(payload, payload_len);
> >>>> }
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> int
> >>>> cc2430_rf_send_b(void *payload, unsigned short payload_len) __banked
> >>>> {
> >>>>      uint8_t i, counter;
> >>>>      printf("sending %x bytes.\n",payload_len);
> >>>>      printf("payload addr %08lx.\n", payload);
> >>>>     }
> >>>>
> >>>> In the assembly for cc2430_rf_send  the payload arg is mov'd to dpl,
> >>>> dph, b instead of pushed on the stack;
> >>>>                                996
> >>>> ;------------------------------------------------------------
> >>>>                                997 ;Allocation info for local variables 
> >>>> in
> >>>> function 'cc2430_rf_send'
> >>>>                                998
> >>>> ;------------------------------------------------------------
> >>>>                                999 ;payload_len               Allocated 
> >>>> to
> >>>> stack - offset -4
> >>>>                               1000 ;payload                   Allocated 
> >>>> to
> >>>> registers r2 r3 r4
> >>>>                               1001
> >>>> ;------------------------------------------------------------
> >>>>                               1002 ;
> >>>> ../../cpu/cc2430/dev/cc2430_rf_intr.c:123: cc2430_rf_send(void *payload,
> >>>> unsigned short payload_len)
> >>>>                               1003 ;
> >>>> -----------------------------------------
> >>>>                               1004 ;        function cc2430_rf_send
> >>>>                               1005 ;
> >>>> -----------------------------------------
> >>>>       01E7                    1006 _cc2430_rf_send:
> >>>>
> >>>> <calls to printf deleted>
> >>>>
> >>>>       0240 D0 04              1054         pop     ar4
> >>>>       0242 D0 03              1055         pop     ar3
> >>>>       0244 D0 02              1056         pop     ar2
> >>>>                               1057 ;
> >>>> ../../cpu/cc2430/dev/cc2430_rf_intr.c:127: return
> >>>> cc2430_rf_send_b(payload, payload_len);
> >>>>       0246 E5*00              1058         mov     a,_bp
> >>>>       0248 24 FC              1059         add     a,#0xfc
> >>>>       024A F8                 1060         mov     r0,a
> >>>>       024B E6                 1061         mov     a,@r0
> >>>>       024C C0 E0              1062         push    acc
> >>>>       024E 08                 1063         inc     r0
> >>>>       024F E6                 1064         mov     a,@r0
> >>>>       0250 C0 E0              1065         push    acc
> >>>>       0252 8A 82              1066         mov     dpl,r2
> >>>>       0254 8B 83              1067         mov     dph,r3
> >>>>       0256 8C F0              1068         mov     b,r4
> >>>>       0258 78r00              1069         mov     r0,#_cc2430_rf_send_b
> >>>>       025A 79s00              1070         mov     r1,#(_cc2430_rf_send_b
> >>>>    >>   8)
> >>>>       025C 7As00              1071         mov     r2,#(_cc2430_rf_send_b
> >>>>    >>   16)
> >>>>       025E 12s00r00           1072         lcall   __sdcc_banked_call
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>                               1087
> >>>> ;------------------------------------------------------------
> >>>>                               1088 ;Allocation info for local variables 
> >>>> in
> >>>> function 'cc2430_rf_send_b'
> >>>>                               1089
> >>>> ;------------------------------------------------------------
> >>>>                               1090 ;payload_len               Allocated 
> >>>> to
> >>>> stack - offset -4
> >>>>                               1091 ;payload                   Allocated 
> >>>> to
> >>>> stack - offset 1
> >>>>                               1092 ;i                         Allocated 
> >>>> to
> >>>> registers r5
> >>>>                               1093 ;counter                   Allocated 
> >>>> to
> >>>> registers r2
> >>>>                               1094
> >>>> ;------------------------------------------------------------
> >>>>                               1095 ;
> >>>> ../../cpu/cc2430/dev/cc2430_rf.c:158: cc2430_rf_send_b(void *payload,
> >>>> unsigned short payload_len) __banked
> >>>>                               1096 ;
> >>>> -----------------------------------------
> >>>>                               1097 ;        function cc2430_rf_send_b
> >>>>                               1098 ;
> >>>> -----------------------------------------
> >>>>       0254                    1099 _cc2430_rf_send_b:
> >>>>       0254 C0*00              1100         push    _bp
> >>>>       0256 85 81*00           1101         mov     _bp,sp
> >>>>       0259 C0 82              1102         push    dpl
> >>>>       025B C0 83              1103         push    dph
> >>>>       025D C0 F0              1104         push    b
> >>>>                               1105 ;
> >>>> ../../cpu/cc2430/dev/cc2430_rf.c:161: printf("sending %x
> >>>> bytes.\n",payload_len);
> >>>>       025F E5*00              1106         mov     a,_bp
> >>>>       0261 24 FC              1107         add     a,#0xfc
> >>>>       0263 F8                 1108         mov     r0,a
> >>>>       0264 E6                 1109         mov     a,@r0
> >>>>       0265 C0 E0              1110         push    acc
> >>>>       0267 08                 1111         inc     r0
> >>>>       0268 E6                 1112         mov     a,@r0
> >>>>       0269 C0 E0              1113         push    acc
> >>>>       026B 74r0A              1114         mov     a,#__str_0
> >>>>
> >>>>
> >>>> Program output is
> >>>> sending 2d bytes.
> >>>> payload_len addr 40006b00.
> >>>> sending 9000 bytes.
> >>>> payload addr 00e09100.
> >>>>
> >>>>          
> >
> >
> > ------------------------------------------------------------------------------
> > This SF.Net email is sponsored by the Verizon Developer Community
> > Take advantage of Verizon's best-in-class app development support
> > A streamlined, 14 day to market process makes app distribution fast and easy
> > Join now and get one step closer to millions of Verizon customers
> > http://p.sf.net/sfu/verizon-dev2dev
> > _______________________________________________
> > Sdcc-user mailing list
> > Sdcc-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/sdcc-user
> >    
> 
> 



------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to