From a035261089403de259e74ce4dd196e2715138ed2 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Sat, 7 Jan 2012 19:56:09 +0100 Subject: Move optimized memcpy and friends and strlen to firmware/asm, using the new automatic-asm-picking infrastructure. --- firmware/target/sh/strlen-sh.S | 96 ------------------------------------------ 1 file changed, 96 deletions(-) delete mode 100644 firmware/target/sh/strlen-sh.S (limited to 'firmware/target/sh/strlen-sh.S') diff --git a/firmware/target/sh/strlen-sh.S b/firmware/target/sh/strlen-sh.S deleted file mode 100644 index e7169e25db..0000000000 --- a/firmware/target/sh/strlen-sh.S +++ /dev/null @@ -1,96 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 by Jens Arnold - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include "config.h" - - .section .icode,"ax",@progbits - - .align 2 - .global _strlen - .type _strlen,@function - -/* Works out the length of a string - * This version is optimized for speed - * - * arguments: - * r4 - start address - * - * return value: - * r0 - string length - * - * register usage: - * r0 - current address - * r1 - current value (byte/long) - * r2 - mask for alignment / zero (for cmp/str) - * r4 - start address - * - */ - -_strlen: - mov r4,r0 /* r0 = start address */ - tst #3,r0 /* long aligned? */ - bt .start_l /* yes, jump directly to the longword loop */ - - /* not long aligned: check the first 3 bytes */ - mov.b @r0+,r1 /* fetch first byte */ - tst r1,r1 /* byte == 0 ? */ - bt .hitzero /* yes, string end found */ - mov.b @r0+,r1 /* fetch second byte */ - mov #3,r2 /* prepare mask: r2 = 0..00000011b */ - tst r1,r1 /* byte == 0 ? */ - bt .hitzero /* yes, string end found */ - mov.b @r0+,r1 /* fetch third byte */ - not r2,r2 /* prepare mask: r2 = 1..11111100b */ - tst r1,r1 /* byte == 0 ? */ - bt .hitzero /* yes, string end found */ - - /* not yet found, fall through into longword loop */ - and r2,r0 /* align down to long bound */ - - /* main loop: check longwords */ -.start_l: - mov #0,r2 /* zero longword for cmp/str */ -.loop_l: - mov.l @r0+,r1 /* fetch long word */ - cmp/str r1,r2 /* any zero byte within? */ - bf .loop_l /* no, loop */ - add #-4,r0 /* set address back to start of this longword */ - - /* the last longword contains the string end: figure out the byte */ - mov.b @r0+,r1 /* fetch first byte */ - tst r1,r1 /* byte == 0 ? */ - bt .hitzero /* yes, string end found */ - mov.b @r0+,r1 /* fetch second byte */ - tst r1,r1 /* byte == 0 ? */ - bt .hitzero /* yes, string end found */ - mov.b @r0+,r1 /* fetch third byte */ - tst r1,r1 /* byte == 0 ? */ - bt .hitzero /* yes, string end found */ - rts /* must be the fourth byte */ - sub r4,r0 /* len = string_end - string_start */ - -.hitzero: - add #-1,r0 /* undo address increment */ - rts - sub r4,r0 /* len = string_end - string_start */ - -.end: - .size _strlen,.end-_strlen - -- cgit v1.2.3