Hi all, I've been experimenting with printf_tiny and _fast(_f)) from revision 7100. Discussing here about tiny.
Things work fine wIth --model-small and -large (with --stack-auto as well as without) but when I tried --model-huge, I stumbled. At first glance the problem appears to be that _tiny uses lcall _putchar and ret. First, I added __nonbanked to _tiny's prototype and also changed my putchar to be __nonbanked. This worked I then reverted to a bankable putchar and changed _tiny to use _sdcc_banked_call and banked_ret when compiled with --model-huge (see patch below). This did not work: when we call _tiny the h/w (a cc2530 Eval. Module) crashes all over the place. I compared a working with a non-working _tiny.asm. Other than the _banked_call / _ret differences (see full diff at the bottom), there is also this: diff -u device/lib/large-stack-auto/printf_tiny.asm device/lib/huge-stack-auto/printf_tiny.asm @@ -91,7 +91,7 @@ ;------------------------------------------------------------ ;Allocation info for local variables in function 'printf_tiny' ;------------------------------------------------------------ -;fmt Allocated to stack - _bp -4 +;fmt Allocated to stack - _bp -5 ;------------------------------------------------------------ ; printf_tiny.c:85: void printf_tiny(__code const char *fmt, ...) __reentrant ; ----------------------------------------- Suspicious? I should probably also mention that during those tests, even though I'm building with huge, I'm not doing any real bank switching. Everything resides in the common segment. Kinda stuck now. In an ideal world, we would have bank-aware printf_foo() flavours but I've run out of ideas of what else I need to change. Any pointers? As ever, thanks very much for your time George (this is what I tried vs rev. 7100, naturally it'd have to use __SDCC_MODEL_HUGE if applied now) Index: device/lib/printf_tiny.c =================================================================== --- device/lib/printf_tiny.c (revision 7100) +++ device/lib/printf_tiny.c (working copy) @@ -286,7 +286,14 @@ mov dpl, a mov a, r0 push acc +#ifdef SDCC_MODEL_HUGE + mov r0,#_putchar + mov r1,#(_putchar >> 8) + mov r2,#(_putchar >> 16) + lcall __sdcc_banked_call +#else lcall _putchar +#endif pop acc mov r0, a pop b @@ -294,7 +301,11 @@ pop dph #endif printf_ret: +#ifdef SDCC_MODEL_HUGE + ljmp __sdcc_banked_ret +#else ret +#endif printf_end: =================================== And the asm diff between large / huge & patched _tiny diff -u device/lib/large-stack-auto/printf_tiny.asm device/lib/huge-stack-auto/printf_tiny.asm --- device/lib/large-stack-auto/printf_tiny.asm 2012-03-30 14:43:21.369747061 +0100 +++ device/lib/huge-stack-auto/printf_tiny.asm 2012-03-30 14:43:21.009747061 +0100 @@ -4,7 +4,7 @@ ; This file was generated Fri Mar 30 14:43:21 2012 ;-------------------------------------------------------- .module printf_tiny - .optsdcc -mmcs51 --model-large + .optsdcc -mmcs51 --model-huge ;-------------------------------------------------------- ; Public variables in this module @@ -91,7 +91,7 @@ ;------------------------------------------------------------ ;Allocation info for local variables in function 'printf_tiny' ;------------------------------------------------------------ -;fmt Allocated to stack - _bp -4 +;fmt Allocated to stack - _bp -5 ;------------------------------------------------------------ ; printf_tiny.c:85: void printf_tiny(__code const char *fmt, ...) __reentrant ; ----------------------------------------- @@ -310,13 +310,13 @@ mov a, r0 push acc + mov r0,#_putchar + mov r1,#(_putchar >> 8) + mov r2,#(_putchar >> 16) + lcall __sdcc_banked_call - - - lcall _putchar - pop acc mov r0, a pop b @@ -325,15 +325,15 @@ printf_ret: + ljmp __sdcc_banked_ret - ret printf_end: pop _bp - ret + ljmp __sdcc_banked_ret .area CSEG (CODE) .area CONST (CODE) .area XINIT (CODE) ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user