Hi Basil, great that it works!
If you need reentrance it's also possible to turn the far address and a bit of the buffer address on the stack into a piece of code (Addr_MSB = 0xAF, MSB_buf = 0x81) and call it using the Y register. Documenting such a solution would be "interesting" (an example for adding "missing" addressing modes that way is here <https://github.com/TG9541/stm8ef/blob/4a5053236605787c23c322ea39a51a1072f3db35/forth.asm#L892>, and a bit about how SDCC represents parameters on the stack is here <https://github.com/TG9541/stm8ef/wiki/STM8S-Programming#combining-c-and-assembly>). Kind regards, Thomas On 05.03.20 18:51, Basil Hussain wrote:
My code wasn't working, and it took me quite a while to figure out why. I ended up having to install ST's Visual Develop IDE so that I could use the debugger and step through the executing code. The mistake was on this line: ldf ([_flash_write_block_addr_tmp], x), a I forgot to take into account that 'addr_tmp' was a 32-bit variable, so the address the symbol represents would be pointing to the highest byte, which will always be zero for a 24-bit address! If for example the address was 0x00027F80, that code would be trying to write to 0x00027F, which is RAM, not flash! I need to shift the address along one byte, so that line should in fact be: ldf ([_flash_write_block_addr_tmp+1], x), a With that it all works properly. :-) Regards, Basil _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user
_______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user