Mail Archives: djgpp/1995/02/23/21:52:52
>> long x;
>>
>> asm(
>> "movl $0, _x\n"
>> ::);
>>
>> (provided x is global/static), but how can I do the equivalent of C
>>
>> typedef struct
>> {
>> long first;
>> long second;
>> } vector;
>>
>> vector data[10];
>>
>> for (x=0; x < 10; x++)
>> {
>> data[x].first = 0;
>> }
>
>I'm not sure if this works, but give it a try:
Why do you want to do this in the first place? GCC generally produces
rather efficient code; if part of your program is too slow, it's more
likely due to a bad algorithm than to a suboptimal implementation of a
good one. Look at the assembly generated by GCC (with the `-S' flag)
before trying to optimize it.
NB: These opinions are regurgitated but seem reasonable to me.
>
> asm ("\n\
> push %eax \n\
> push %ebx \n\
> push %ecx \n\
> movl _data, %ebx \n\
> xorl %eax, %eax \n\
> xorl %ecx, %ecx \n\
>L_jump_label: \n\
> movl $0x0, (%ebx, %eax,)\n\
> addl $0x8, %eax \n\
> addl $0x1, %ecx \n\
> cmp $0xa, %ecx \n\
> jnz L_jump_label \n\
> pop %ecx \n\
> pop %ebx \n\
> pop %eax \n\
> ");
>
>Hope that helps,
>Long.
>
>
>+--------------------------------------------------------+
>| Long Doan ldoan1 AT osf1 DOT gmu DOT edu |
>| ld AT netrix DOT com |
>+--------------------------------------------------------+
>
--- Aaron Ucko (ucko AT vax1 DOT rockhurst DOT edu; finger for PGP public key) -=- httyp!
-=*=-Just because you're paranoid doesn't mean they aren't out to get you.-=*=-
Geek code 2.1 [finger hayden AT vax1 DOT mankato DOT msus DOT edu for explanation]:
GCS/M/S d(-) H s g+ p? !au a-- w+ v+ C++(+++)>++++ UL++(-)(S+)>++++ P++
L+(++) 3(-) E-(----) !N>++ K- W-(---) M-(--) V(--) po-(--) Y+(++) t(+) !5 j R
G tv--(-) b+++ !D(--) B--(---) e>++++(*) u++(@) h!() f(+) r-(--)>+++ n+(-) y?
- Raw text -