Mail Archives: djgpp/1996/07/29/09:47:42
Leath Muller wrote:
> include <stdio.h>
>
> volatile char *mem_block = NULL;
> volatile int value = 0;
>
> void fill_block()
> {
[--snip--]
> }
>
Try this:
static __inline__ void fill_block(char *mem_block, int value)
{
asm volatile ( "1: movl %1, (%0)\n"
" addl $4, %0\n"
" decl %2\n"
" cmpl $0, %2\n"
" jnz 1b\n"
: /* Outputs. */
: /* Inputs. */
"r" (mem_block), "r" (value), "r" (50)
: /* Modifies. */
"cc", /* Condition flags. */
"memory" /* Memory. */
);
}
Note that with this scheme, you'll get:
1. The function inlined, avoiding a precious call.
2. Register allocation automatic by the compiler.
PKE.
--
----------------------------------------------------------------------
| Pål-Kristian Engstad | engstad AT funcom DOT com | Games programmer, PSX |
| Funcom Oslo AS | Ph +47 22 42 01 02 | developer & Linux Fan |
----------------------------------------------------------------------
- Raw text -