From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Llv2e-00013V-Gc for qemu-devel@nongnu.org; Mon, 23 Mar 2009 21:02:56 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Llv2e-000133-3t for qemu-devel@nongnu.org; Mon, 23 Mar 2009 21:02:56 -0400 Received: from [199.232.76.173] (port=57505 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Llv2d-000130-Sr for qemu-devel@nongnu.org; Mon, 23 Mar 2009 21:02:55 -0400 Received: from qw-out-1920.google.com ([74.125.92.147]:64850) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Llv2d-0002fJ-Cx for qemu-devel@nongnu.org; Mon, 23 Mar 2009 21:02:55 -0400 Received: by qw-out-1920.google.com with SMTP id 5so1064192qwf.4 for ; Mon, 23 Mar 2009 18:02:53 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <1237850625-15864-1-git-send-email-glommer@redhat.com> Date: Mon, 23 Mar 2009 22:02:53 -0300 Message-ID: <5d6222a80903231802r648aa025ieef9f61008fd1a37@mail.gmail.com> Subject: Re: [Qemu-devel] [PATCH] compute checksum for roms bigger than a segment From: Glauber Costa Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Mon, Mar 23, 2009 at 9:48 PM, malc wrote: > On Mon, 23 Mar 2009, Glauber Costa wrote: > >> =C2=A0 =C2=A0xor =C2=A0ax, ax >> =C2=A0 =C2=A0xor =C2=A0bx, bx >> =C2=A0 =C2=A0xor =C2=A0cx, cx >> + =C2=A0xor =C2=A0dx, dx >> + >> =C2=A0 =C2=A0mov =C2=A0ch, [2] >> =C2=A0 =C2=A0shl =C2=A0cx, #1 >> + >> + =C2=A0jnc checksum_loop >> + =C2=A0mov =C2=A0dx, cx >> + =C2=A0mov =C2=A0cx, #0xffff > > =C2=A0 =C2=A0 xchg dx, cx > =C2=A0 =C2=A0 dec =C2=A0cx > >> + >> =C2=A0checksum_loop: >> =C2=A0 =C2=A0add =C2=A0al, [bx] >> =C2=A0 =C2=A0inc =C2=A0bx >> =C2=A0 =C2=A0loop checksum_loop >> + >> + =C2=A0cmp =C2=A0dx, #0 > > =C2=A0 =C2=A0 test dx, dx ok. > >> + =C2=A0je checksum_out >> + >> + =C2=A0add =C2=A0al, [bx] > > =C2=A0 =C2=A0 DS:[0] is added twice, intended? it's not DS:[0]. It's the last byte from the previous segment that is not caught by the loop Note it happens before cleaning bx and increasing cs. It works with it, does not without it. > >> + =C2=A0mov =C2=A0cx, dx >> + =C2=A0mov =C2=A0dx, ds >> + =C2=A0add =C2=A0dx, #0x1000 > > =C2=A0 =C2=A0 add =C2=A0dh, #0x10 Why is it preferred? --=20 Glauber Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act."