Am 03.03.20 um 22:27 schrieb Basil Hussain:
> Hi all,
> 
>> Ideally, there would be some kind of fmemcpy function that dealt with
>> 'far' pointers. This is what the docs for ST's SPL instructs Raisonance
>> users to use, but I don't think any such thing exists in SDCC's standard
>> C library. Would it be possible to write an equivalent in assembly?
> 
> Further to this, having now done some experimentation, it appears to me 
> that with the current state of SDCC it is not actually possible to write 
> plain C code that will read from or write to flash memory past 32KB, due 
> to the limitation of memory pointers being 16-bit even in large memory 
> model mode.
> 
> Using an STM8S208RB, which has 128KB of flash, I attempted writing to 
> the last block of flash, at address 0x27F7F. It didn't work, and just 
> hung the processor. I presume this was because the pointer to this 
> address got truncated to 0x7F7F, which is not within the flash memory 
> range, and is actually a reserved area (with the SWIM and debug 
> registers following).
> 
> Would it be possible for SDCC to add 'far' pointers? Then, when using 
> large memory model, one could choose between conventional 'near' 16-bit 
> pointers and 'far' 24-bit pointers as and when the code dictates.
> 

We have an open feature request:

https://sourceforge.net/p/sdcc/feature-requests/560/


> I will have to see if I can put together some inline assembly code to 
> deal with reading and writing from memory locations that need a 24-bit 
> address, because at present it doesn't seem to be possible with just C 
> code. Does anyone have any suggestions for that?

The easiest is probably to use ldf. It can only read a byte at a time,
so it is somewhat slow, and it needs the pointer at a fixed location in
memory (i.e. like a static or global variable) so it makes your function
non-reentrant.

Philipp

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to