Archived

This topic is now archived and is closed to further replies.

DekuTree64

Is there 16-bit memset?

Recommended Posts

Just writing a simple rectangle filler, and it''d be faster if I could memset each row instead of incrementing, but I''m using 16-bit color so the 8-bit memset won''t work. Not that I''ll be drawing enough rectangles for it to matter, but it''d help my tri-filler too, so I figured I''d ask.
-Deku-chan DK Art (my site, which has little programming-related stuff on it, but you should go anyway^_^)

Share this post


Link to post
Share on other sites
I mean it sets one byte at a time, so I can''t set a 2-byte value with it. Like, if my color value is 0xE00F, then it sets each pixel to 0xE0E0 (or it might be 0x0F0F, not sure which side it cuts off).



-Deku-chan

DK Art (my site, which has little programming-related stuff on it, but you should go anyway^_^)

Share this post


Link to post
Share on other sites
It would probably be faster to set up a 32bit (or 64bit) register with the data, then write directly to memory for the number of words you want to write.

(I got help with this answer from Tybalt who is sitting here hassling me to promote his site)

Share this post


Link to post
Share on other sites
Yep. And if you take a look at the MSVC generated assembler listings, you''ll see that the memset expands into inline assembly that copies data in DWORDS. At least, if the 3rd argument, (i.e. the size of data) is a constant.

Share this post


Link to post
Share on other sites