Message-ID: <35DF84AC.B28C9CBA@unb.ca> Date: Sat, 22 Aug 1998 23:55:41 -0300 From: Endlisnis MIME-Version: 1.0 To: george DOT foot AT merton DOT oxford DOT ac DOT uk CC: djgpp AT delorie DOT com Subject: Re: VESA: hints, clue but no examples References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk George Foot wrote: > On 22 Aug 98 at 15:35, Endlisnis wrote: > > > Yes. I've made my own 'setdata' function to use a bunch of _farnspokel calls to quickly write a single > > value to a bunch of contiguous locations. > > For a reasonable number of locations, this would probably be faster > if you used an inline assembler routine; push ES, load it with the > selector, load EDI with the offset, EAX with the value and ECX with > the number of longs, then "rep ; stosl" and finally pop ES back > again. Perhaps this: > > inline void flmemset (int selector, int offset, int value, int num_longs) This version of your 'flmemset' function allows any arbitrary # of bytes to be written, (not necessarily multiple of 4). inline void setdata (int selector, int offset, int value, int num_bytes) { asm ( "pushl %%es;" "movw %%dx, %%es;" "cld;" "movb %%al, %%ah;" "rorl $8, %%eax;" "movb %%al, %%ah;" "rorl $8, %%eax;" "movb %%al, %%ah;" "shrl $1, %%ecx;" "jnc NoByte;" "stosb;" "NoByte: ;" "shrl $1, %%ecx;" "jnc NoWord;" "stosw;" "NoWord: ;" "rep; stosl;" "popl %%es " : : "c" (num_bytes), "a" (value), "d" (selector), "D" (offset) : "%ecx", "%edi" ); } BTW, are any of those registers listed in the 'clobbered' list really necessary (in this case)? Since they are listed as input registers, then aren't they automatically listed as 'clobbered'? -- (\/) Endlisnis (\/) s257m AT unb DOT ca Endlisnis AT GeoCities DOT com Endlis AT nbnet DOT nb DOT ca