Thanks Maarten, The inline asm did the trick. Final code looks like:
static uint16_t fw_begin(void) __naked { __asm__("ldw x,#s_HOME"); __asm__("ret"); } static uint16_t fw_end(void) __naked { __asm__("ldw x,#s_HOME"); __asm__("addw x,#l_HOME"); __asm__("addw x,#l_GSINIT"); __asm__("addw x,#l_GSFINAL"); __asm__("addw x,#l_CONST"); __asm__("addw x,#l_CODE"); __asm__("addw x,#l_INITIALIZER"); __asm__("ret"); } I was able to validate this agains ihex content. It would be nice to be able to access linker defined symbols from C afterall. On Tue, Jun 14, 2022 at 5:27 PM Maarten Brock <sourceforge.br...@dse.nl> wrote: > > Hello Wlodzimierz, > > I just tried using inline asm, but could not get it working with .equ > either. > It does work however as a return value from a function. > > unsigned int get_l_data(void) __naked > { > __asm > ldw x,#l_DATA > __endasm; > } > > Maarten > > Wlodzimierz Lipert schreef op 2022-06-13 08:54: > > Hello, > > > > I would like to impl. FW checksuming for STM8. I was unable to find > > out how to access l_DATA/s_DATA from C. Looks like all C symbols are > > prefixed with "_" and there is no way to generate "l_DATA"/"s_DATA" > > within C. > > > > extern uint16_t l_DATA; > > extern uint16_t s_DATA; > > > > static > > uint16_t calc_fw_checksum(void) > > { > > uint16_t crc16 = UINT16_C(0xFFFF); > > { // .text & data sections > > uint8_t *begin = (uint8_t*)((uint16_t)&l_DATA); > > const uint8_t *const end = (uint8_t *)((uint16_t)&l_DATA) + > > s_DATA; > > > > while(begin != end) crc16 = crc16_update(crc16, *begin++); > > } > > return crc16; > > } > > > > I have similar code for GCC/AVR. > > https://github.com/wdl83/rgb_strip_lamp/blob/master/rtu_cmd.c > > > > Thanks. -- BR/Pozdrawiam. Wlodzimierz Lipert _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user