Mail Archives: djgpp/1995/06/28/14:19:26
>>>>> "George" == George C Moschovitis <gmoscho AT alexander DOT cc DOT ece DOT ntua DOT gr> writes:
George> is there anyway i can rearange the c++ code for the
George> compiler to produce better output ? or any switch i should
George> use ?
Returning structs is often slow in C, depending on the calling
convention used by the compiler. Why not pass in a pointer to the
struct you want to fill in? That's the standard C idiom. For
example:
inline void
__dpmi_allocate_low_memory(int size, __dpmi_memblock *m)
{
m->l.segment = __dpmi_allocate_dos_memory((size>>4)+1,&m->l.selector);
m->l.size = size;
}
By the way, "(size + 15) >> 4" will do the right thing and also waste
less memory.
Who cares how slow your function to allocate DOS memory is anyway?
It's got so much other overhead involved that a few cycles won't
matter. Don't fall into the trap of wasting all your time optimizing
irrelevant code...I've seen too many programmers make that mistake.
George> From the (admitedly) limited asm outputs i
George> have seen gcc doesnt seem to use register passing that
George> much :( On this topic how can i tell the compiler to which
George> registers to pass the parameters ?
On the x86 gcc doesn't pass arguments in registers, it passes them on
the stack. If you inline a function, of course, arguments won't get
passed at all.
-Mat
- Raw text -