rep movs instruction

  • Follow


how do i override the default ds:esi source when
doing a rep movsd/movsw/movsb etc

I want the source to be gs:esi rather than the
default ds:esi.... I guess the real question is, whats
the syntax of the command (the rep movsd)
when I want to override the source?

ps. I am operating 32 bit pmode using nasm.

alex


0
Reply alex 9/14/2004 7:08:49 AM

On Tue, 14 Sep 2004 07:08:49 +0000 (UTC), "alex" <me@me.com> wrote:

>how do i override the default ds:esi source when
>doing a rep movsd/movsw/movsb etc
>
>I want the source to be gs:esi rather than the
>default ds:esi.... I guess the real question is, whats
>the syntax of the command (the rep movsd)
>when I want to override the source?
Probably: rep movs? gs:esi, es:edi
Or at least, that would be the MASM syntax.
>
>ps. I am operating 32 bit pmode using nasm.
>
>alex
>

-- 
Arargh409 at [drop the 'http://www.' from ->] http://www.arargh.com
BCET Basic Compiler Page: http://www.arargh.com/basic/index.html

To reply by email, remove the garbage from the reply address.

0
Reply spamtrap 9/14/2004 8:57:00 AM


On Tue, 14 Sep 2004 07:08:49 +0000 (UTC), alex wrote:

> how do i override the default ds:esi source when
> doing a rep movsd/movsw/movsb etc
> 
You cannot do that. Source/dest for string operations is hardcoded in the
CPU logic.

-- 
Vulnerant omnes, ultima necat.
http://ry.pl/~omega/
Looking for a job.

0
Reply Omega 9/14/2004 9:04:06 AM

On Tue, 14 Sep 2004 09:04:06 +0000 (UTC), Omega Red
<spamtrap@crayne.org> wrote:

>On Tue, 14 Sep 2004 07:08:49 +0000 (UTC), alex wrote:
>
>> how do i override the default ds:esi source when
>> doing a rep movsd/movsw/movsb etc
>> 
>You cannot do that. Source/dest for string operations is hardcoded in the
>CPU logic.
Go read the book.  You may not be able to change esi, but you can
certainly change ds:

>From ALANG.HLP:
 ===
If the MOVS form of the instruction is used, operands must be
provided to indicate the size of the data elements to be
processed. A segment override can be given for the source operand
(but not for the destination). If MOVSB (bytes), MOVSW (words), or
MOVSD (doublewords) is used, the instruction determines the size
of the data elements to be processed.
 ===

-- 
Arargh409 at [drop the 'http://www.' from ->] http://www.arargh.com
BCET Basic Compiler Page: http://www.arargh.com/basic/index.html

To reply by email, remove the garbage from the reply address.

0
Reply spamtrap 9/14/2004 11:09:57 AM

alex wrote:
> how do i override the default ds:esi source when
> doing a rep movsd/movsw/movsb etc
> 
> I want the source to be gs:esi rather than the
> default ds:esi.... I guess the real question is, whats
> the syntax of the command (the rep movsd)
> when I want to override the source?
> 
> ps. I am operating 32 bit pmode using nasm.

gs rep movsd   ; move dword from [gs:esi] to [es:edi]

You probably already know, but you can only override the source segment. 
  ES is always used as the destination segment for these instructions.

Ed

0
Reply Ed 9/14/2004 1:04:31 PM

The IA32 manual contradicts that. It states
the "destination" cannot be changed using a segment
override, but source can.

> You cannot do that. Source/dest for string operations is hardcoded in the
> CPU logic.


0
Reply alex 9/14/2004 6:27:13 PM

Omega Red wrote:
> On Tue, 14 Sep 2004 07:08:49 +0000 (UTC), alex wrote:
>
>> how do i override the default ds:esi source when
>> doing a rep movsd/movsw/movsb etc
>
> You cannot do that. Source/dest for string operations is hardcoded in
> the CPU logic.

Actually, you can do a segment override on the source (but not the
destination). NASM doesn't support any oprands to movs* so you have to force
a segment override like:
  gs rep movsd

--
Michael Brown
www.emboss.co.nz : OOS/RSI software and more :)
Add michael@ to emboss.co.nz - My inbox is always open

0
Reply Michael 9/14/2004 6:27:16 PM

On Tue, 14 Sep 2004 11:09:57 +0000 (UTC), spamtrap@crayne.org wrote:

> On Tue, 14 Sep 2004 09:04:06 +0000 (UTC), Omega Red
> <spamtrap@crayne.org> wrote:
> 
>>On Tue, 14 Sep 2004 07:08:49 +0000 (UTC), alex wrote:
>>
>>> how do i override the default ds:esi source when
>>> doing a rep movsd/movsw/movsb etc
>>> 
>>You cannot do that. Source/dest for string operations is hardcoded in the
>>CPU logic.
> Go read the book.  You may not be able to change esi, but you can
> certainly change ds:
> 
>>From ALANG.HLP:
>  ===
> If the MOVS form of the instruction is used, operands must be
> provided to indicate the size of the data elements to be
> processed. A segment override can be given for the source operand
> (but not for the destination). If MOVSB (bytes), MOVSW (words), or
> MOVSD (doublewords) is used, the instruction determines the size
> of the data elements to be processed.
>  ===

Yep, my mistake. So says Intel manual.

-- 
Vulnerant omnes, ultima necat.
http://ry.pl/~omega/
Looking for a job.

0
Reply Omega 9/14/2004 6:27:23 PM

This didnt answer the question unfortunately.

<spamtrap@crayne.org> wrote in message
news:jijdk0hvg8na4n7l50pm6or2fk30e66b8k@4ax.com...
> On Tue, 14 Sep 2004 09:04:06 +0000 (UTC), Omega Red
> <spamtrap@crayne.org> wrote:
>
> >On Tue, 14 Sep 2004 07:08:49 +0000 (UTC), alex wrote:
> >
> >> how do i override the default ds:esi source when
> >> doing a rep movsd/movsw/movsb etc
> >>
> >You cannot do that. Source/dest for string operations is hardcoded in the
> >CPU logic.
> Go read the book.  You may not be able to change esi, but you can
> certainly change ds:
>
> >From ALANG.HLP:
>  ===
> If the MOVS form of the instruction is used, operands must be
> provided to indicate the size of the data elements to be
> processed. A segment override can be given for the source operand
> (but not for the destination). If MOVSB (bytes), MOVSW (words), or
> MOVSD (doublewords) is used, the instruction determines the size
> of the data elements to be processed.
>  ===
>
> -- 
> Arargh409 at [drop the 'http://www.' from ->] http://www.arargh.com
> BCET Basic Compiler Page: http://www.arargh.com/basic/index.html
>
> To reply by email, remove the garbage from the reply address.
>


0
Reply alex 9/14/2004 6:27:26 PM

alex wrote:

> how do i override the default ds:esi source when
> doing a rep movsd/movsw/movsb etc
> 
> I want the source to be gs:esi rather than the
> default ds:esi.... I guess the real question is, whats
> the syntax of the command (the rep movsd)
> when I want to override the source?
> 
> ps. I am operating 32 bit pmode using nasm.

The syntax would be
gs rep movsd
or maybe
rep gs movsd
(I didn't try this.)

If neither works you can still use
db 65h
rep movsd

You are lucky that this means
[es:edi]<-[gs:esi]
rather than
[gs:edi]<-[ds:esi]
(You can't change the destination segment register on x86.)

Andr�

0
Reply ISO 9/14/2004 6:27:30 PM

I need to know the syntax of using a segment override with rep movsd.
I cant find where this is documented in the IA32 because i is huge..

If i try

rep movsd gs:

it wont assemble.. I get errors about invalid combination of codes etc..

<spamtrap@crayne.org> wrote in message
news:jijdk0hvg8na4n7l50pm6or2fk30e66b8k@4ax.com...
> On Tue, 14 Sep 2004 09:04:06 +0000 (UTC), Omega Red
> <spamtrap@crayne.org> wrote:
>
> >On Tue, 14 Sep 2004 07:08:49 +0000 (UTC), alex wrote:
> >
> >> how do i override the default ds:esi source when
> >> doing a rep movsd/movsw/movsb etc
> >>
> >You cannot do that. Source/dest for string operations is hardcoded in the
> >CPU logic.
> Go read the book.  You may not be able to change esi, but you can
> certainly change ds:
>
> >From ALANG.HLP:
>  ===
> If the MOVS form of the instruction is used, operands must be
> provided to indicate the size of the data elements to be
> processed. A segment override can be given for the source operand
> (but not for the destination). If MOVSB (bytes), MOVSW (words), or
> MOVSD (doublewords) is used, the instruction determines the size
> of the data elements to be processed.
>  ===
>
> -- 
> Arargh409 at [drop the 'http://www.' from ->] http://www.arargh.com
> BCET Basic Compiler Page: http://www.arargh.com/basic/index.html
>
> To reply by email, remove the garbage from the reply address.
>


0
Reply alex 9/14/2004 6:28:48 PM

this has worked! thanks ed!
no further replies needed to this post

thanks again

"Ed Beroset" <spamtrap@crayne.org> wrote in message 
news:BUB1d.1044$mb6.758@newsread3.news.atl.earthlink.net...
> alex wrote:
>> how do i override the default ds:esi source when
>> doing a rep movsd/movsw/movsb etc
>>
>> I want the source to be gs:esi rather than the
>> default ds:esi.... I guess the real question is, whats
>> the syntax of the command (the rep movsd)
>> when I want to override the source?
>>
>> ps. I am operating 32 bit pmode using nasm.
>
> gs rep movsd   ; move dword from [gs:esi] to [es:edi]
>
> You probably already know, but you can only override the source segment. 
> ES is always used as the destination segment for these instructions.
>
> Ed
> 


0
Reply alex 9/14/2004 6:28:52 PM

Ed Beroset  <spamtrap@crayne.org> wrote in message news:<BUB1d.1044$mb6.758@newsread3.news.atl.earthlink.net>...
> gs rep movsd   ; move dword from [gs:esi] to [es:edi]
> 
> You probably already know, but you can only override the source segment. 
>   ES is always used as the destination segment for these instructions.

When was this introduced?  I can't do this in 16-bit x86 as far as I know...

Also, is gs the only other option or can you override with fs as well?

0
Reply spamtrap 9/14/2004 7:16:05 PM

Jim Leonard wrote:
> Ed Beroset  <spamtrap@crayne.org> wrote in message news:<BUB1d.1044$mb6.758@newsread3.news.atl.earthlink.net>...
> 
>>gs rep movsd   ; move dword from [gs:esi] to [es:edi]
>>
>>You probably already know, but you can only override the source segment. 
>>  ES is always used as the destination segment for these instructions.
> 
> 
> When was this introduced?  I can't do this in 16-bit x86 as far as I know...

I'm not sure if you're asking about when this capability was added to 
NASM or to the x86 line of CPUs.  I don't know the definitive answer to 
either question, but if you're really interested, you could peruse the 
CVS logs for NASM on Sourceforge for the former.  If you mean the CPU, I 
happened to look it up in the databook nearest me, which happens to be a 
paper original Pentium databook with a 1993 copyright date.  So the 
answers are probably NASM: at least a year ago and likely longer; x86: 
at least eleven years ago and likely longer.  My recollection is that it 
worked on the original 8088s, but you'd want to look that up before 
relying on it.

> Also, is gs the only other option or can you override with fs as well?

You can override it with any segment register: cs, ds, es, fs, gs or ss.

Ed

0
Reply Ed 9/14/2004 8:44:09 PM

Ed Beroset  <spamtrap@crayne.org> writes:

> Jim Leonard wrote:
> > Ed Beroset  <spamtrap@crayne.org> wrote in message news:<BUB1d.1044$mb6.758@newsread3.news.atl.earthlink.net>...
> >
> >>gs rep movsd   ; move dword from [gs:esi] to [es:edi]
> >>
> >> You probably already know, but you can only override the source
> >> segment.  ES is always used as the destination segment for these
> >> instructions.
> > When was this introduced?  I can't do this in 16-bit x86 as far as I
> > know...
> 
> I'm not sure if you're asking about when this capability was added to
> NASM or to the x86 line of CPUs.  I don't know the definitive answer
> to either question, but if you're really interested, you could peruse
> the CVS logs for NASM on Sourceforge for the former.  If you mean the
> CPU, I happened to look it up in the databook nearest me, which
> happens to be a paper original Pentium databook with a 1993 copyright
> date.  So the answers are probably NASM: at least a year ago and
> likely longer; x86: at least eleven years ago and likely longer.  My
> recollection is that it worked on the original 8088s, but you'd want
> to look that up before relying on it.

It's by the by, but the 8086 was the original in that branch of the 
family tree, not the 8088.

However, it's there in black and white in my "preliminary" MCS-86 USER'S 
MANUAL, (c) Intel Corporation 1978, page 4-3.

Never bin old manuals!

Phil
-- 
They no longer do my traditional winks tournament lunch - liver and bacon. 
It's just what you need during a winks tournament lunchtime to replace lost 
.... liver.   -- Anthony Horton, 2004/08/27 at the Cambridge 'Long Vac.' 

0
Reply Phil 9/14/2004 9:22:10 PM

spamtrap@crayne.org (Jim Leonard) wrote:

>Ed Beroset  <spamtrap@crayne.org> wrote:
>> gs rep movsd   ; move dword from [gs:esi] to [es:edi]
>> 
>> You probably already know, but you can only override the source segment. 
>>   ES is always used as the destination segment for these instructions.
>
>When was this introduced?  I can't do this in 16-bit x86 as far as I know...

Oh, yes: this has been possible on every x86 processor, clear back to the
8086.

>Also, is gs the only other option or can you override with fs as well?

ANY segment register:
    rep movs byte ptr es:[di], byte ptr cs:[si]
-- 
- Tim Roberts, timr@probo.com
  Providenza & Boekelheide, Inc.

0
Reply Tim 9/15/2004 5:53:31 AM

>>Also, is gs the only other option or can you override with fs as well?
>
>ANY segment register:
>    rep movs byte ptr es:[di], byte ptr cs:[si]

Just note that FS and GS are 386+ specific (but will also work in real
mode there)

0
Reply spamtrap 9/15/2004 8:38:19 PM

16 Replies
484 Views

(page loaded in 0.129 seconds)

Similiar Articles:


















7/21/2012 11:37:06 PM


Reply: