Xref: news2.mv.net comp.os.msdos.djgpp:6533 From: Pål-Kristian Engstad Newsgroups: comp.os.msdos.djgpp Subject: Re: Inline assembly and DMA transfers. Date: Mon, 29 Jul 1996 13:23:55 +0200 Organization: Funcom Oslo AS Lines: 40 Message-ID: <31FC9F4B.35F5@funcom.com> References: <199607230018 DOT KAA25409 AT gbrmpa DOT gov DOT au> Reply-To: engstad AT funcom DOT com NNTP-Posting-Host: khazad.funcom.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Leath Muller wrote: > include > > 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 | ----------------------------------------------------------------------