Is there 16-bit memset?

Started by
4 comments, last by DekuTree64 23 years, 1 month ago
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^_^)
Advertisement
What do you mean by it won''t work because it''s 8 bit?
Gee Brain, what we gonna do tonight?
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^_^)
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)
Gee Brain, what we gonna do tonight?
search the forum, there was a decent thread not too long ago with a number of memset algo''s

Magmai Kai Holmlor
- The disgruntled & disillusioned
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
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.
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.

This topic is closed to new replies.

Advertisement