Forest Darling wrote on 2024-06-25 15:00:
Hello all!
I am new to using SDCC, and I am working with some legacy 8051 codebase
that is written in assembly. I would like to port one function at a
time
from assembly to C, eventually converting the entire codebase while
testing
it as I go. However, I need to be in control of how the C generated
code
uses registers/RAM.
There are two main issues:
1. make the C code implement "callee" saving of registers, so that
the
calling assembly code doesn't have to be rewritten
This is handled by the callee-saves pragma. See the manual. But beware
that
this option is not regression tested. It may even disappear in the
future.
2. make sure that the C functions do not clobber the existing global
internal RAM variables. I either need to reserve the known used
areas of
RAM (blacklist), explicitly define the RAM that is okay to use for
the
"overlay" section (whitelist), in my case using external RAM would
be
acceptable since the assembly doesn't use it except for external bus
peripherals. I could also forbid using global RAM altogether (like
the
reentrant option), but I think that might use too much stack...
Either black listing or white listing will be ok. It is not possible to
let
the compiler use external RAM only. It will always need direct memory.
But
by using --stack-auto you can severely limit it.
I have tried Googling things, but I can't seem to find straightforward
documentation on function attributes that might be useful. Any insight
would be appreciated!
Thanks,
--Forest
Maarten
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user