MMC and hex

Pat LaVarre LAVARRE at iomega.com
Thu Jan 3 11:29:16 PST 2002


* From the T10 Reflector (t10 at t10.org), posted by:
* "Pat LaVarre" <LAVARRE at iomega.com>
*
> > please copy hlandis at ata-atapi.com on any reply

Ok.

> If the spec says a field is '2F'h then it is saying it is '00101111'b.
> The spec should say the transmission order
> (bit 31 on line 31 or bit 31 first for serial).  

What about when MMC says x80?

In MMC does x80 always mean b1000:0000 or b0000:0000:1000:000 or ... and never b1111:1111:1000:0000?

(If yes, then this is a claim that all hex literals in MMC are unsigned two's complement.  Perhaps we can trust then that the width of every hex literal is obvious from context to the most casual observer.)

> <JPScheible at aol.com> 01/03/02 11:03AM
>
> If you can represent a value in binary,
> then you can represent it in hex
> without knowing anything about its format
> (int, signed int, char, pig latin).
>
> Am I missing something?

Well, I don't like the way you said this.

I'm never comfortable talking just about values.  Down at the level of a digital schematic, at the level of a bus trace, a number never just has a value: always it has a value _and_ a width.

Q1) In converting between hex and binary, how do we cope if the width of the binary value is not a multiple of four bits?

We have to agree how many bits we'll all agree to discard/fabricate implicitly.

Q2) How do we cope if, to print the value as hex, someone stripped the sign bits from a two's complement value?

We have to agree how to restore the sign bits.  We supply missing msb's by copying the hi bit if the field is a signed two's complement value.  We supply missing msb's by filling with zeroes if the field is an unsigned two's complement value.  And so on.

For example, in C, what do the octal/decimal conversions:

        unsigned char ch1 = '\377'; int i1 = ch1; printf("%d ", i1);
        signed char ch2 = '\377'; int i2 = ch2; printf("%d ", i2);
        char ch3 = '\377'; int i3 = ch3; printf("%d\n", i3);

mean?

Platform by platform, I hear the answer varies.  I hear you'll see either of:

        255 -1 -1 // Microsoft C++

        255 -1 255 // C elsewhere, Java if you say 16 bit Java char = C char

You also get 255 -1 -1 if you use the implicitly signed implicitly 8-bit byte of Java in place of the C char type here.  You also get 255 -1 255 if you use the implicitly unsigned 16-bit char of Java in place of the C char type here.

Pat LaVarre


*
* For T10 Reflector information, send a message with
* 'info t10' (no quotes) in the message body to majordomo at t10.org




More information about the T10 mailing list