From: Panayotis K. <pan...@pa...> - 2011-04-05 13:16:54
|
Hello I had a look at the Byte implementation of the ObjC backend and I saw that you have defined it as "unsigned char" instead of "signed char". Here http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html says that byte is signed in Java. Am I missing something or is this a bug? (and if it is a bug, probably we should also check other locations where byte as an unsigned char was used?) |
From: Troy G. <tro...@gm...> - 2011-04-05 14:08:26
|
Panayotis, >From what I see, what you're saying is correct. http://en.wikipedia.org/wiki/C_variable_types_and_declarations It seems reasonable to typedef "byte" to make this more clear. On Tue, Apr 5, 2011 at 8:16 AM, Panayotis Katsaloulis < pan...@pa...> wrote: > Hello > > I had a look at the Byte implementation of the ObjC backend and I saw that > you have defined it as "unsigned char" instead of "signed char". > > Here > http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html > says that byte is signed in Java. > Am I missing something or is this a bug? > > (and if it is a bug, probably we should also check other locations where > byte as an unsigned char was used?) > > ------------------------------------------------------------------------------ > Xperia(TM) PLAY > It's a major breakthrough. An authentic gaming > smartphone on the nation's most reliable network. > And it wants your games. > http://p.sf.net/sfu/verizon-sfdev > _______________________________________________ > Xmlvm-developers mailing list > Xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlvm-developers > |
From: Arno P. <ar...@pu...> - 2011-04-05 17:49:43
|
things are a little trickier. According to section 2.4.1 of the Java Specs: "The integral types are byte, short, int, and long, whose values are 8-bit, 16-bit, 32-bit, and 64-bit signed two's-complement integers, respectively, and char, whose values are 16-bit unsigned integers representing Unicode characters" Then in Section 3.11.1 of the Java spec it says: "Note that most instructions in Table 3.2 do not have forms for the integral types byte, char, and short. None have forms for the boolean type. Compilers encode loads of literal values of types byte and short using Java virtual machine instructions that sign-extend those values to values of type int at compile time or run time. Loads of literal values of types boolean and char are encoded using instructions that zero-extend the literal to a value of type int at compile time or run time." So, you are correct that a byte is a signed 8-bit value, however it needs to be properly sign extended. In the C backend I already use typedef's consistently, so it should be easy to fix. The Objective-C backend is not as cleanly implemented. Arno On 4/5/11 7:07 AM, Troy Gaines wrote: > Panayotis, > > From what I see, what you're saying is correct. > > http://en.wikipedia.org/wiki/C_variable_types_and_declarations > > It seems reasonable to typedef "byte" to make this more clear. > > > On Tue, Apr 5, 2011 at 8:16 AM, Panayotis Katsaloulis > <pan...@pa... <mailto:pan...@pa...>> wrote: > > Hello > > I had a look at the Byte implementation of the ObjC backend and I > saw that you have defined it as "unsigned char" instead of "signed > char". > > Here > http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html > says that byte is signed in Java. > Am I missing something or is this a bug? > > (and if it is a bug, probably we should also check other locations > where byte as an unsigned char was used?) > ------------------------------------------------------------------------------ > Xperia(TM) PLAY > It's a major breakthrough. An authentic gaming > smartphone on the nation's most reliable network. > And it wants your games. > http://p.sf.net/sfu/verizon-sfdev > _______________________________________________ > Xmlvm-developers mailing list > Xml...@li... > <mailto:Xml...@li...> > https://lists.sourceforge.net/lists/listinfo/xmlvm-developers > > > > > ------------------------------------------------------------------------------ > Xperia(TM) PLAY > It's a major breakthrough. An authentic gaming > smartphone on the nation's most reliable network. > And it wants your games. > http://p.sf.net/sfu/verizon-sfdev > > > > _______________________________________________ > Xmlvm-developers mailing list > Xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlvm-developers |
From: Panayotis K. <pan...@pa...> - 2011-04-05 22:30:38
|
On Apr 5, 2011, at 8:49 PM, Arno Puder wrote: > > things are a little trickier. According to section 2.4.1 of the Java > Specs: "The integral types are byte, short, int, and long, whose values > are 8-bit, 16-bit, 32-bit, and 64-bit signed two's-complement integers, > respectively, and char, whose values are 16-bit unsigned integers > representing Unicode characters" > > Then in Section 3.11.1 of the Java spec it says: "Note that most > instructions in Table 3.2 do not have forms for the integral types byte, > char, and short. None have forms for the boolean type. Compilers encode > loads of literal values of types byte and short using Java virtual > machine instructions that sign-extend those values to values of type int > at compile time or run time. Loads of literal values of types boolean > and char are encoded using instructions that zero-extend the literal to > a value of type int at compile time or run time." > > So, you are correct that a byte is a signed 8-bit value, however it > needs to be properly sign extended. In the C backend I already use > typedef's consistently, so it should be easy to fix. The Objective-C > backend is not as cleanly implemented. > > Arno > So, the problem remains, should "byte" be a signed or unsigned char under ObjC backend, and especially in the Byte methods? My understanding is that it is sometimes a signed integer, but in any case, it is *not* an unsigned char. |
From: Arno P. <ar...@pu...> - 2011-04-05 23:15:11
|
A byte is a signed 8 bit value that needs to be sign-extended to 32 bits when loaded into a register. Arno On Apr 5, 2011, at 3:30 PM, Panayotis Katsaloulis <pan...@pa...> wrote: > > On Apr 5, 2011, at 8:49 PM, Arno Puder wrote: > >> >> things are a little trickier. According to section 2.4.1 of the Java >> Specs: "The integral types are byte, short, int, and long, whose values >> are 8-bit, 16-bit, 32-bit, and 64-bit signed two's-complement integers, >> respectively, and char, whose values are 16-bit unsigned integers >> representing Unicode characters" >> >> Then in Section 3.11.1 of the Java spec it says: "Note that most >> instructions in Table 3.2 do not have forms for the integral types byte, >> char, and short. None have forms for the boolean type. Compilers encode >> loads of literal values of types byte and short using Java virtual >> machine instructions that sign-extend those values to values of type int >> at compile time or run time. Loads of literal values of types boolean >> and char are encoded using instructions that zero-extend the literal to >> a value of type int at compile time or run time." >> >> So, you are correct that a byte is a signed 8-bit value, however it >> needs to be properly sign extended. In the C backend I already use >> typedef's consistently, so it should be easy to fix. The Objective-C >> backend is not as cleanly implemented. >> >> Arno >> > > > So, the problem remains, should "byte" be a signed or unsigned char under ObjC backend, and especially in the Byte methods? > My understanding is that it is sometimes a signed integer, but in any case, it is *not* an unsigned char. > ------------------------------------------------------------------------------ > Xperia(TM) PLAY > It's a major breakthrough. An authentic gaming > smartphone on the nation's most reliable network. > And it wants your games. > http://p.sf.net/sfu/verizon-sfdev > _______________________________________________ > Xmlvm-developers mailing list > Xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlvm-developers |