asm question

WBahn

Joined Mar 31, 2012
33,109
It really depend on what that comment means.

It could also mean:

if(datahi >= 0x0F || datahi <= 0xff)

Or datahi is greater or equal to 0x0f or datahi is less than or equal to 0xff.
Huh?

If we are working with unsigned integers, then this is always TRUE. If we are working with signed integers, then we REALLY need to know what size the datatype is.
 

spinnaker

Joined Oct 29, 2009
7,830
Huh?

If we are working with unsigned integers, then this is always TRUE. If we are working with signed integers, then we REALLY need to know what size the datatype is.


Your right should be && . Coding all day, it is late, I am old do the math. :)
 

ErnieM

Joined Apr 24, 2011
8,415
Or the statement and the comment are 100% spot on as we have no idea what "datahi" really is.

If it is the high nibble (4 bits) of some other variable, extracted and shifted, then both the statement and comment are correct:

Rich (BB code):
unsigned char MyData;
unsigned char datahi;

MyData = GetSomeDataByte();
datahi = MyData >> 4;
if(datahi == 0x0F)        // if data == 0xF0..0xFF
    { // checks the case as indicated }
Context is everything.
 

WBahn

Joined Mar 31, 2012
33,109
It's out of context, sort of... In this case "datahi" is the high nibble of a two nibble value called "data"...
This is an ambiguous statement. Some could interpret the high nibble of 0x42 to be 0x40 while others could interpret it to be 0x04. Within an appropriate context, either interpretation might be reasonable. But without context, you need to be pretty explicit.

It sounds like it is the upper nibble right masked and shifted to place it in the lower nibble, as ErnieM suggested.
 
Top