Showing results for 
Search instead for 
Did you mean: 

How to create Run-in-RAM code using SDCC?

Vyacheslav Azarov
Associate III

Hello everyone,

Is it possible to create Run-in-RAM code using SDCC? If possible then how to do this?

Thanks in advance.

Philipp Krause
Senior II

SDCC deson't have direct support for this yet. However, there are some ways this can be done using code and ram section options, then copying the function to RAM manually (e.g. using memcpy()).

Here's an example of one way to do this (it uses a custom copy function instead of memcpy()):

Vyacheslav Azarov
Associate III

Very thanks. Copying a segment is not a problem. The problem is to create it correctly. I did not find in the SDCC documentation the possibility of creating relocatable code. Is it possible? This would greatly simplify the design processes. In the given in the attachment example the call pointers are absolute. STM8L15x have very attractive characteristics of ULP run. I would like to do something using free tools.

I understand. There is no way to do this using SDCC without external tools. In any case, is possible resort to editing the code in assembler and linking the program code manually, through explicit indication of sections locations. Thanks.

Vyacheslav Azarov
Associate III

In my opinion, the best solution to this problem was proposed by Philipp Krause in Sourceforge. I think the question is settled. Thanks again.