From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED, URIBL_DBL_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1693579307; bh=sq64ylhYJhB0oPolcBbALSl3i0XxeEcOBjof0caz+7k=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=m0An2Q67aNbxrTBFvv3Or9QfxtN+fX6U9l2Jpx7fqekriqZX8p6T5/0w0wDupZOvn ++hP9XBIUdUEelTOxD6P6V0iRDSDQXbUDMJU2DxrrDsRu/GusEqbb+ri3KnsOs6yjL 3mayMJFKa4YSfoAORZKovczhdCQbWkJGS0RT2BBp9VgY0D9/1dodpubjufARV61aGa F+imDY3BNhDQnfnt8rPc1wsOvS4/BnkeJJzAcjFLzBWCYeP+ejeoCgHdb6Pya0ycy2 WIsVLDT/z0t2cKpStHD9WDalxoEhixQPCspcCGcydIcc5wvIvEsrqDjBbGmcqocdpE VevmdDA/ieUEA== Received: from biznet-home.integral.gnuweeb.org (unknown [182.253.126.208]) by gnuweeb.org (Postfix) with ESMTPSA id 3748024B385; Fri, 1 Sep 2023 21:41:43 +0700 (WIB) Date: Fri, 1 Sep 2023 21:41:39 +0700 From: Ammar Faizi To: David Laight Cc: Willy Tarreau , Thomas =?iso-8859-1?Q?Wei=DFschuh?= , Nicholas Rosenberg , Alviro Iskandar Setiawan , Michael William Jonathan , GNU/Weeb Mailing List , Linux Kernel Mailing List Subject: Re: [RFC PATCH v1 0/5] nolibc x86-64 string functions Message-ID: References: <20230830135726.1939997-1-ammarfaizi2@gnuweeb.org> <5a821292d96a4dbc84c96ccdc6b5b666@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Bpl: hUx9VaHkTWcLO7S8CQCslj6OzqBx2hfLChRz45nPESx5VSB/xuJQVOKOB1zSXE3yc9ntP27bV1M1 List-Id: On Fri, Sep 01, 2023 at 02:23:28PM +0000, David Laight wrote: > From: Ammar Faizi > > Sent: 01 September 2023 14:06 ... > > __asm__ ( > > ".section .text.nolibc_memmove\n" > > ".weak memmove\n" > > "memmove:\n" > > " movq %rdx, %rcx\n" > > " movq %rdi, %rdx\n" > > " movq %rdi, %rax\n" > > You seem to have confused yourself about whether you are using %eax or %edx. What do you mean? They're all 64-bit pointers. What I know is that the %rdx will be clobbered by "subq %rsi, %rdx" below and the %rax should be return value. That's why I copy the %rdi twice. memmove() returns the dst pointer. Did I miss something? > > " subq %rsi, %rdx\n" > > " cmpq %rcx, %rdx\n" > > " jnb .Lforward_copy\n" > > I think I'd fall through to the forwards copy > and not worry about replicating the 'reps movsb' and 'ret'. > IIRC 'cld' can be slow as well. Alright, I will avoid cld for the forward copy. > > " leaq -1(%rdi, %rcx, 1), %rdi\n" > > " leaq -1(%rsi, %rcx, 1), %rsi\n" > > " std\n" > > ".Lforward_copy:\n" > > " rep movsb\n" > > " cld\n" > > " ret\n" > > ); -- Ammar Faizi