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.
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user