Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386/stand/mbr Compact crc32 code by 1...



details:   https://anonhg.NetBSD.org/src/rev/cc7884b8e263
branches:  trunk
changeset: 319180:cc7884b8e263
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Sat May 19 18:18:16 2018 +0000

description:
Compact crc32 code by 12 bytes of text.

>From dave0 in #NetBSD on Freenode circa December 2017.

Tested in a 32-bit userland harness to produce identical results as old
code for one set of inputs.

diffstat:

 sys/arch/i386/stand/mbr/gpt.S |  19 +++++--------------
 1 files changed, 5 insertions(+), 14 deletions(-)

diffs (44 lines):

diff -r aa4ae40b3e4f -r cc7884b8e263 sys/arch/i386/stand/mbr/gpt.S
--- a/sys/arch/i386/stand/mbr/gpt.S     Sat May 19 18:14:51 2018 +0000
+++ b/sys/arch/i386/stand/mbr/gpt.S     Sat May 19 18:18:16 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gpt.S,v 1.1 2011/01/06 01:08:49 jakllsch Exp $ */
+/*     $NetBSD: gpt.S,v 1.2 2018/05/19 18:18:16 jakllsch Exp $ */
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -428,21 +428,14 @@
  * %ebx                crc (returned)
  */
 crc32:
-       push    %dx                     /* preserve drive number */
-       push    %ax                     /* preserve original CRC */
-
-       xorl    %ebx, %ebx
-       decl    %ebx                    /* init value */
+       orl      $-1, %ebx              /* init value */
 1:
-       lodsb                           /* load next message byte to %al */
+       xorb    (%si), %bl              /* xoring next message byte with previous result */
+       inc     %si
        movb    $8, %cl                 /* set bit counter */
 2:
-       movb    %al, %dl
-       xorb    %bl, %dl                /* xoring with previous result */
        shrl    $1, %ebx
-       shrb    $1, %al
-       testb   $1, %dl
-       jz      3f
+       jnc     3f
 crc32_poly = . + 3                     /* gross, but saves a few bytes */
        xorl    $0xedb88320, %ebx       /* EFI CRC32 Polynomial */
 3:
@@ -451,8 +444,6 @@
        jne     1b
        notl    %ebx                    /* result correction */
 
-       pop     %ax
-       pop     %dx
        ret
 #endif
 



Home | Main Index | Thread Index | Old Index