Hi, > 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.
Thanks for the advice, and for the comments you wrote in the far pointer feature request (which I do believe is a worthy feature to include where possible). I have formulated the following code: static uint32_t flash_write_block_addr_tmp; static uint8_t *flash_write_block_buf_tmp; void flash_write_block(const uint32_t addr, const void *buf) { /* Unlock flash, etc... */ flash_write_block_addr_tmp = addr; flash_write_block_buf_tmp = (uint8_t *)buf; for(uint8_t i = 0; i < FLASH_BLOCK_SIZE; i++) { __asm push a ld a, [_flash_write_block_buf_tmp] ldf [_flash_write_block_addr_tmp], a pop a __endasm; flash_write_block_addr_tmp++; flash_write_block_buf_tmp++; } /* Wait for write completion, etc... */ } Is my usage of the LDF instruction correct? Especially the addressing mode of the arguments - i.e. is the "[addr]" syntax the right thing to use? The ASxxxx documentation is kind of confusing with its terminology, and I'm not sure what is correct, whether indirect or indexed (it refers to "[addr]" modes with both terms). Also, I assume it is correct for me to use just "[addr]" and not "[addr].e" to have the pointed-to value treated as extended? The assembler docs say "for the callf, jpf, and ldf instructions the [eaddr].e mode is selected". I plan to use similar code to facilitate copying of the block writing function from program flash into RAM, to allow for the case where the function's code segment is located beyond 32K. Regards, Basil _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user