This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Faking indirect SFR access

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