subject

The C library function memset(p, c,n) writes (uint8_t)(c) repeatedly n times begininig at the address held in pointer p. Sometimes it is more efficient or convenient to copy a multibyte quantity instead of a single byte one. Implement the following function. void memset16(void *b, int num_bytes, void *pattern16)
In this function, b has the address of a memory buffer that is num_bytes long. The function should repeatedly copy the 16 byte pattern that pattern16 points at into the memory buffer until num_bytes have been written. If num_bytes is not a multple of 16, the final wriite of the 16 byte pattern should be truncated to finish filling the buffer.
For example if the 16 bytes that pattern16 points at is 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff, then memset(b, 20, pattern16) should write to the buffer pointed at by p the 20 bytes 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff 00 11 22 33.
Use SSE instructions to improve efficiency. Here's pseudocode.
x = SSE unaligned load from pattern16
while (num_bytes >= 16)
SSE unaligned store x to p
advance p by 16 bytes
decrement num_bytes by 16
while (num_bytes > 0)
store 1 byte from pattern16 to p
advance p by 1 byte
advance pattern16 by 1 byte
decrement num_bytes by 1
void memset16(void *p, void *pattern16, int num_bytes)

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:20
Print "usernum1 is negative." if usernum1 is less than 0. end with newline. convert usernum2 to 0 if usernum2 is greater than 10. otherwise, print "usernum2 is less than or equal to 10.". end with newline
Answers: 3
question
Computers and Technology, 22.06.2019 19:00
If your accelerator suddenly gets stuck what should you do
Answers: 2
question
Computers and Technology, 23.06.2019 12:10
2. fabulously fit offers memberships for$35 per month plus a $50 enrollmentfee. the fitness studio offersmemberships for $40 per month plus a$35 enrollment fee. in how many monthswill the fitness clubs cost the same? what will the cost be?
Answers: 1
question
Computers and Technology, 23.06.2019 23:30
What are "open-loop" and "closed-loop" systems
Answers: 1
You know the right answer?
The C library function memset(p, c,n) writes (uint8_t)(c) repeatedly n times begininig at the addres...
Questions
question
Mathematics, 02.02.2020 16:43
question
Mathematics, 02.02.2020 16:43
question
Mathematics, 02.02.2020 16:43
Questions on the website: 13722363