Re: Remind me - mem_set()?
- Posted by Spock 3 weeks ago
- 290 views
If I allocate(2000) and want to initialise that to 500 identical (non-null) dwords, in this specific case an #AARRGGBB colour, what's the best way?
I'm thinking mem_set() is missing a size=1 parameter, which (with atom v instead of integer byte_value) can also be 2/4/8, and maybe -4/-8 to poke float32/64...
I realise that mem_copy() would work, but would perform 499 unnecessary reads, or would modern cpus make that completely irrelevant?
I also realise that poke4(addr,repeat(v,500)) would also work, but clearly suboptimal, maybe it is poke4() that is missing a times=1 parameter?
It seems to be one of those rare things I find easier in assembly than Eu/Phix...
I believe a series of 10 mem_copy() calls, with each subsequent call being twice the size of the previous one, could be quite a fast way to do it. You would have to trim the last one.
Spock