www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/11/08:31:35

From: Endlisnis <s257m AT unb DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Assembler translation question
Date: Wed, 07 Oct 1998 18:26:04 -0300
Organization: BrunNet
Lines: 58
Message-ID: <361BDC6B.6A9F8785@unb.ca>
References: <361A317E DOT 4A5D5233 AT yahoo DOT com>
NNTP-Posting-Host: usr3fton45.brunnet.net
Mime-Version: 1.0
X-Mailer: Mozilla 4.04 [en] (Win95; U)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

][v][]2. ][) wrote:

>     Maybe you people get questions like these lots of times, I don't
> know 'cause I'm new to this group, but let's have a go at it anyway. =)
> Maybe someone can
> translate this piece of code for me? Pretty please? =)
>     Here goes:
> push ds
> mov cx, double_buffer_size
> les di, video_buffer
> mov ax, 320
> mul y
> add di, ax
> lds si, buffer
> rep movsw
> pop ds

asm ("mull %3;"     "addl %%eax, %%edi;"
     "rep;"
     "movsw;"
: : "c" (double_buffer_size), "D" (video_buffer), "a" (320), "m" (y), "S"
(buffer)
: "%edi");
    I think that will do what you asked, but it would be better to use a
"movsl" to do 32-bit moves.  There may be problems with that code, I did not
test it.
    It is not hard to convert.  First, swap the order of the parameters to
your opcodes.  Then prefix all register names with "%%", then postfix all
opcodes with the size of the operands (b=byte, w=word, l=long).  You can't
access non-global variables directly from asm.  You can ask to have them
loaded into special locations.  I've had double_buffer_size loaded into ECX,
video_buffer loaded into EDI, y loaded into memory.  I can address those
parameters as %0,%1,%2,%3,...  Segments are now called selectors and they work
differently.  My code assumed that you had turned off memory protection
(discussed in the FAQ).  If you haven't, then you will have to make your own
selector (also discussed in the FAQ) and move it into DS.

>
>
>     Okay, maybe you need these: buffer and video_buffer are char *'s,
> double_buffer_size is an integer, and so is y.
>     Is there, by the way, some sort of document that contains most
> (all?) of the old asm commands, and states the DJGPP equivalents next to
> it? Perhaps it's a nice idea for someone to make it? (I would like to do
> it, sure, but I don't get it yet =)
>     Thanks for any help,
>
>     Jan-Jaap



--
     (\/) Endlisnis (\/)
          s257m AT unb DOT ca
          Endlisnis AT GeoCities DOT com
          Endlisnis AT BrunNet DOT Net


- Raw text -


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