Hi Peter,

Peter Kuhar schrieb:
> hi,
> 
> Has anyone allready implemented the bankswitching technichue described in
> http://sourceforge.net/forum/message.php?msg_id=3360254
> 
> I'm currently adding a feature to the aslink to support that.
> Basicaly,
> The codesegments are configured at compile time with:
>     --codeseg BANK2
> linked with:
>     -Wl-bBANK2=0x028000
> 
> 
> 
> The linker finds(now it's a 3 pass linker) lcalls from one bank to another
> and generates proxy function in the common area bank. The crossbank lcalls
> are then painted to the proxy.
> Proxy then switheches the bank, calls the original function and restores the
> bank.
> 
> So there is no need to declare a banked call in source/header files.
> 
> an example proxy from CC2430 MCU looks like this( but could be modified for
> other hardware )
> 
> If we have void led() in BANK2;
> the proxy looks like:
> 
> .globl _FMAL
> .globl _led
> 
> _bc_led::
>     push _FMAP ;save current bank
>     mov _FMAP, #0x02 ; select bank 2
>     lcall _led ;call _led in bank 2
>     pop _FMAP   ;restore bank
>     ret
> 
> 
> FMAP is the bank selecting SFR on CC2430
> 
> the modifications are made in lkmain.c(making a 3 pass link) and
> lkrloc.c(generating
> proxys and relocation lcall calls)
> 
> Any comments/suggestions.

Nice!) I'm not aware that anyone has done that.
One could do with one byte less stack space if the
information from which bank the call originates would be
used as well. A proxy could then look like this:

 _bc_led_called_from_bank1::
     mov   _FMAP, #0x02  ; select bank 2
     lcall _led          ; call _led in bank 2
     ajmp  _bc_return_to_bank_1  ; ajmp/ljmp

 ;...

 _bc_return_to_bank_0:
     mov   _FMAP, #0x00
     ret
 _bc_return_to_bank_1:
     mov   _FMAP, #0x01
     ret
 _bc_return_to_bank_2:
     mov   _FMAP, #0x02
     ret
 _bc_return_to_bank_3:
     mov   _FMAP, #0x03
     ret


The number of instruction cycles would be the same, one byte
less stack would be used. Depending on how the banked calls
are intermixed it might need less or more code memory (as
when called from bank3 a proxy _bc_led_called_from_bank3
would be needed).

(If you want to go fancy one could try "inc _FMAP" here
shaving off one byte and one cycle:^)

Greetings,

Frieder

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to