If I have a char* for example :
and I want to add 0x00 before each byte .Code:{0x01,0x02,0x03,0x04,0x05}
the result will be :
What is the faster way to do that ?Code:{0x00,0x01,0x00,0x02,0x00,0x03,0x00,0x04,0x00,0x05}
If I have a char* for example :
and I want to add 0x00 before each byte .Code:{0x01,0x02,0x03,0x04,0x05}
the result will be :
What is the faster way to do that ?Code:{0x00,0x01,0x00,0x02,0x00,0x03,0x00,0x04,0x00,0x05}
Probably picking up more than one character at a time, which would be processor dependent. In assembly on X86 with xmm registers, you could load 16 bytes at a time, copy to another xmm register, then use pshufb on both xmm registers to insert the zeroes, then store 16 bytes at a time (twice).
> What is the faster way to do that ?
Faster than what?
You haven't shown us what you're doing at the moment.
Unless you have some woefully underpowered micro-controller, or needing to do 100's of MB/sec, this looks like a premature optimisation.
For those of us not familiar with assembly, couldn't the same be achieved by memcpy'ing into a uint16_t pointer? Would probably need to account for endianness though.
EDIT: offtopic, BTW, do u guys know if the forums were under ddos attack? It was hard to access the site the past 24 hours. I was getting this error:Attachment 15622