STM8 - Micro SD Card
You will need:

to connect these two.
point an SD card driver (that you write or get somewhere) at the interface (typically SPI) that connects your microcontroller to your SD card
write or get a file system driver for the file system you want to use (e.g. exFAT, littlefs?) that can work with said SD card driver.
open the file
write data to it
close the file
sync the file system (&quot;unmount the sd card&quot;)

Note that accessing file systems inherently will need a bit of RAM. Chances are that you're making your life pretty miserable by sticking to a microcontroller with only 1 kB of RAM in total. Considering the low cost of 32 bit development platforms these days (see, for example, &quot;stm32 blue pill&quot;), I don't think sticking to STM8 is a wise choice here.