#71 SFR banking for MCS51

open
nobody
5
2010-05-21
2004-04-11
Maarten Brock
No

Hi,

Silicon Labs has some 8051 derivatives which have most
of their sfr's paged(banked). For these it might be
usefull to add "sfr banked" to the mcs51 port of SDCC.
It can have it's syntax similar to that for the Z80:

sfr banked at 0x0199 SBUF1;

Writing 0x20 to SBUF1 would generate:

mov SFRPAGE,#0x01
mov 0x99,#0x20

Other sfr's like SP, ACC, DPL, DPH and SFRPAGE are
mapped to all pages, so they can be declared the usual
way:

sfr at 0xE0 ACC;

One of the advantages of paged sfr's is that there can
be more bit addressable sfr locations, so the following
support would be needed as well:

sbit banked at 0x019B TB81; //ninth transmission bit

Generating for setting the bit:

mov SFRPAGE,#0x01
setb 0x9B

Since the sfr SFRPAGE is not volatile, it's value can be
tracked during compilation. So the following C code:

TB81 = 1;
SBUF1 = 0x20;

Might generate:

mov SFRPAGE,#0x01
setb 0x9B
mov 0x99,#0x20

But I don't know how to tell the compiler a specific sfr is
NOT volatile. Maybe this needs a new keyword as well
(nonvolatile)?

I think this can make programming a lot easier on these
devices.

Greetings,
Maarten Brock

Discussion

    • labels: --> mcs51(8051) target