delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/02/07/12:13:15

Date: Mon, 7 Feb 2000 18:40:12 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Jan-Jaap Severs <janjaaps AT yahoo DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Inline asm translations?
In-Reply-To: <389ED6AC.76B16F3F@yahoo.com>
Message-ID: <Pine.SUN.3.91.1000207183712.20861E-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: dj-admin AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Mon, 7 Feb 2000, Jan-Jaap Severs wrote:

> void FillDoubleBuffer( int color )
> {
>         asm {
>           mov cx, double_buffer_size
>           mov al, BYTE PTR color
>           mov ah, al
>           les di, double_buffer
>           rep stosw
>         }
> }

Why can't you use memset?  That's exactly what it does, and GCC will 
inline it automatically (if you compile with optimizations).

> And another one:
> 
> asm {
> les di, dest_addr
> mov al, BYTE PTR color
> mov ah, al
> mov cx, xe
> sub cx, xs
> inc cx
> shr cx, 1
> rep stosw
> }

This is also memset, except that it does some simple arithmetics on the 
number of bytes to set.

I suggest to use C library functions wherever you can, instead of getting 
yourself into complications and portability problems with inline assembly.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019