Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 May 2002 12:30:37 -0400 (EDT)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Jonathan Mini <mini@FreeBSD.org>
Cc:        Peter Jeremy <peter.jeremy@alcatel.com.au>, cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org
Subject:   Re: cvs commit: src/sys/kern kern_mutex.c
Message-ID:  <XFMail.20020523123037.jhb@FreeBSD.org>
In-Reply-To: <20020523085032.R25907@stylus.haikugeek.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On 23-May-2002 Jonathan Mini wrote:
> John Baldwin [jhb@FreeBSD.org] wrote :
> 
>> 
>> On 23-May-2002 Jonathan Mini wrote:
>> > John Baldwin [jhb@FreeBSD.org] wrote :
>> > 
>> >> In Intel's documentation they said that all current look-alikes worked as
>> >> well.  It's the opcode for 'rep mov'.  I am curious if some implementations
>> >> trash %ecx, and if we are paranoid we could always clobber %ecx in the
>> >> constraints.  [ ... ]
>> > 
>> > The rep prefix doesn't modify any registers.  You do need to make
>> > sure that %ecx was zero when you dispatch a rep mov (unles you're
>> > dispatching a rep mov $0, %ecx), or you'll get an infinite loop.
>> 
>> Bah, it's rep nop, not rep mov. 
> 
> Ahh. rep nop makes a lot more sense.
> 
>> rep does modify %ecx when used with, say
>> string instructions.  It decrements %[e]cx once for each interation.
> 
> Um.. no. It's the string instruction that decrements cx. rep just, well,
> repeats. =)

Umm no.  String instructions modify %esi and %edi.

See http://people.freebsd.org/~jhb/386htm/LODS.htm for example.

If the string instructions modified %ecx, then code like this wouldn't work:

#
# Send up to CX bytes of a null-terminated string at DS:[SI] out to port DX.
#
spew:           lodsb
                or %al,%al
                jz exit
                outsb
                loop spew
exit:           ret

However, the text at http://people.freebsd.org/~jhb/386htm/REP.htm is a bit
ambiguous.  It seems to indicate that REP is only defined when used with
string instructions.  From this reading I think 'rep nop' probably is supposed
to be an undefined operation and I'm actually kind of surprised it doesn't
trigger an illegal instruction fault to be honest.

-- 

John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20020523123037.jhb>