Hi everyone,
I have an 8051 boot loader for in-system programming. I have a command protocol that allows me to read and write to flash, XRAM, and IRAM over the in-system communications interface (e.g. UART). I would like to add the four pages (0x00, 0x10, 0x0f, and 0x0c) of SFRs, but of course they can only be accessed directly, not indirectly.
Does anyone have a clever way of taking e.g. an SFR address in the range of 0x80 to 0xff as an input and returning the value of the SFR?
The best idea I have at the moment is a jump table, indexed by (addr-0x80), where each entry is a pre-programmed get/set of the corresponding SFR, followed by a jump to the end (effectively a 128-entry switch statement). Assuming I do the SFR paging and any loop management externally, the smallest I can see to shrink this is 3 bytes per entry (MOV A, addr ; RET), for 384 B to cover the full 128 B address space.
Speed is not of particular importance for this particular application, but code space is.
Cheers, -Lance
Whoops, I sometimes forget not everyone is using identical devices. For reference, I am using one of the SiLabs C8051 series devices with flash banking and SFR paging.
If you can configure your hardware to allow XRAM to be mapped to code space and you can write to that XRAM, then maybe worth considering some self modifying code.