Are you aware of https://github.com/oliverschmidt/cc65/blob/master/libsrc/common/copydata.s ?