Announcement

Collapse
No announcement yet.

OVF() result with bit shift inconsistant

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • OVF() result with bit shift inconsistant

    If I use the following code I get the correct results for pulling the high and low order bits from a variable:
    Code:
    hex:=0xAB+0x100*0x61;
    hex:=hex<<1;
    k[1]:=OVF();
    hex:=hex<<1;
    k[0]:=OVF();
    hex2:=hex;
    hex2:=hex2>>2;
    hex:=hex<<1;
    h[5]:=OVF();
    hex:=hex<<1;
    h[4]:=OVF();
    hex:=hex<<1;
    h[3]:=OVF();
    hex:=hex<<1;
    h[2]:=OVF();
    hex:=hex<<1;
    h[1]:=OVF();
    hex:=hex<<1;
    h[0]:=OVF();
    hex:=hex<<1;
    l[7]:=OVF();
    hex:=hex<<1;
    l[6]:=OVF();
    hex:=hex<<1;
    l[5]:=OVF();
    hex:=hex<<1;
    l[4]:=OVF();
    hex:=hex<<1;
    l[3]:=OVF();
    hex:=hex<<1;
    l[2]:=OVF();
    hex:=hex<<1;
    l[1]:=OVF();
    hex:=hex<<1;
    l[0]:=OVF();
    But if I use for next loops as below I get all zeros:
    Code:
    hex:=0xAB+0x100*0x61;
    for(x:=1;x>=0;x--)
        hex:=hex<<1;
        k[x]:=OVF();
    next
    for(x:=5;x>=0;x--)
        hex:=hex<<1;
        h[x]:=OVF();
    next
    for(x:=7;x>=0;x--)
        hex:=hex<<1;
        l[x]:=OVF();
    next
    Any idea why?
    I have several instances calculating non standard CRC where loops would shorten the code considerably.

Working...
X