1 ; /*-------------------------------------------------------------------------
3 ; crtbank.asm :- C run-time: bank switching
5 ; This library is free software; you can redistribute it and/or modify it
6 ; under the terms of the GNU Library General Public License as published by the
7 ; Free Software Foundation; either version 2, or (at your option) any
10 ; This library is distributed in the hope that it will be useful,
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ; GNU Library General Public License for more details.
15 ; You should have received a copy of the GNU Library General Public License
16 ; along with this program; if not, write to the Free Software
17 ; Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 ; In other words, you are welcome to use, share and improve this program.
20 ; You are forbidden to forbid anyone else to use, share and improve
21 ; what you give them. Help stamp out software-hoarding!
22 ; -------------------------------------------------------------------------*/
35 ; /*-------------------------------------------------------------------------
36 ; Example for SiLabs C8051F12x / C8051F13x with 128kB code memory
37 ; divided into 4 banks of 32kB
38 ; These devices have an sfr called PSBANK containing two parts:
39 ; COBANK (bit 5:4): Constant Operations Bank
40 ; IFBANK (bit 1:0): Instruction Fetch Bank
41 ; From 0x0000 to 0x7FFF bank 0 is always accessed
42 ; From 0x8000 to 0xFFFF bank COBANK is accessed for reading with movc
43 ; From 0x8000 to 0xFFFF bank IFBANK is accessed for executing instructions
45 ; Make your own copy of this file,
46 ; adapt it to your situation,
47 ; and compile/link it in your project
48 ; -------------------------------------------------------------------------*/
55 push _PSBANK ;save return bank
56 xch a,r0 ;save Acc in r0, do not assume any register bank
57 push acc ;push LSB address
59 push acc ;push MSB address
60 mov a,r2 ;get new bank
61 anl a,#0x0F ;remove storage class indicator
63 orl _PSBANK,a ;select bank
68 pop _PSBANK ;restore bank