From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FEOEV-0007R5-Q4 for qemu-devel@nongnu.org; Wed, 01 Mar 2006 05:07:00 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FEOEP-0007PX-QL for qemu-devel@nongnu.org; Wed, 01 Mar 2006 05:06:55 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FEOEL-0007P9-85 for qemu-devel@nongnu.org; Wed, 01 Mar 2006 05:06:52 -0500 Received: from [195.130.225.22] (helo=mrqout1.tiscali.it) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FEOFZ-0005kc-BM for qemu-devel@nongnu.org; Wed, 01 Mar 2006 05:08:05 -0500 Received: from ps19 (10.39.75.89) by mail-6.mail.tiscali.sys (7.2.066.3) id 43E1CA380005D05D for qemu-devel@nongnu.org; Wed, 1 Mar 2006 11:06:44 +0100 Message-ID: <23402837.1141207604525.JavaMail.root@ps19> Date: Wed, 1 Mar 2006 11:06:44 +0100 (CET) From: "carlo.andreoli@tiscali.it" Subject: Re: [Qemu-devel] Printing bogus values in ne2000_asic_ioport_read()/ ne2000_receive() MIME-Version: 1.0 Content-Type: text/plain;charset="UTF-8" Content-Transfer-Encoding: quoted-printable Reply-To: "carlo.andreoli@tiscali.it" , 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 Regarding the bogus numbers occasionally printed, you can see that the=20 leading ffs are printed when the character has its bit7 set to 1. This occurs=20 because in printf("%02x ", s[i]); the expected argument for %02x is an integer, and since the actual=20 argument is a (signed) character, the compiler promotes it to an integer extending=20 the sign bit. You can simply write instead printf("%02x ", (unsigned char)s[i]); and the problem should disappear, since in this case the promotion to=20 an integer adds non-significative 0s that are ignored when printig Carlo ----Messaggio originale---- Da: kumrao2003@yahoo.com Data: 25/02/2006 19.29 A: Ogg: [Qemu-devel] Printing bogus values in ne2000_asic_ioport_read()/=09 ne2000_receive() Hi, I am using QEMU in one of my research projects. I landed in a problem where I see bogus numbers being printed when I printed the packet/each word that is received from ne2000. In ne2000_receive(), I copied the packet received to a static char [] and printed the packet using static void print_packet(char *s, int len) { int i,j; for (i=3D0;i instead of just the last byte. For eg: 52 54 00 12 34 56 00 ffffffff 4f 0a 46 05 08 00 45 00 00 ffffff80 00 00 40 00 40 01 ffffffbc 2b ffffffc0 ffffffa8 fffffffe fffffffe ffffffc0 ffffffa8 ff =09=09 Tiscali ADSL 4 Mega Flat Naviga senza limiti con l'unica Adsl a 4 Mega di velocit=C3=A0 a soli 19,95= =E2=82=AC al mese! Attivala subito e hai GRATIS 2 MESI e l'ATTIVAZIONE.=20 http://abbonati.tiscali.it/banner/middlepagetracking.html?c=3Dwebmailadsl&r= =3Dhttp://abbonati.tiscali.it/adsl/sa/4flat_tc/&a=3Dwebmail&z=3Dwebmail&t= =3D14