I have 1 byte at the address FFF0 and i have to read the byte bits-wise i.e i have to store the first 4 bits in a variable and the other 4 bits in another variable from that fff0 address byte .eg :fff0 : int v1=first 4 bits ,v2 = other 4 bits ;fff0 =00100011 ;v1 =0011(lower bits),v2=0010(upper bits).

I think you may mean FFF0 is hex. If so that is 2 bytes (32-bit). Other than that I can't really make sense of your question. The definition of first and last depends on endianness.

public static class BITS
    {
      public const byte BIT0 = 0x01;
      public const byte BIT1 = 0x02;
      public const byte BIT2 = 0x04;
      public const byte BIT3 = 0x08;
      public const byte BIT4 = 0x10;
      public const byte BIT5 = 0x20;
      public const byte BIT6 = 0x40;
      public const byte BIT7 = 0x80;
    }
    void button7_Click(object sender, EventArgs e)
    {
      byte b1 = GetFirstFourBytes(0xFF);
      byte b2 = GetLastFourBytes(0xFF);
      Debug.WriteLine("First Four: " + Convert.ToString(b1, 2).PadLeft(sizeof(byte) * 8, '0'));
      Debug.WriteLine("Last Four: " + Convert.ToString(b2, 2).PadLeft(sizeof(byte) * 8, '0'));
    }
    byte GetFirstFourBytes(byte b)
    {
      return Convert.ToByte((b & (BITS.BIT0 | BITS.BIT1 | BITS.BIT2 | BITS.BIT3)));
    }
    byte GetLastFourBytes(byte b)
    {
      return Convert.ToByte((b & (BITS.BIT4 | BITS.BIT5 | BITS.BIT6 | BITS.BIT7)));
    }
First Four: 00001111
Last Four: 11110000

sir I will make you clear what am doing .I have intel hex format file i.e
:01F7F0001107 here
01 represents the data length
f7f0 represents the address
00 represents the type format
11represents the data
07 is the checksum
here i have took the data at the address f7fo and stored in the string variable.Till now i have have stored 11 in a string variable.But now what i want i have to store 1 in one variable and other 1 in another variable .i.e total=11 now i want v1 =1 &v2 =1
how to do it sir??if it is total=23 i want v1=2,v2=3.

I'm not sure I understand you -- can you post your code?

Sir sorry i have not code yet ...i have a byte 23 ,here i have to seperate and store it in a variable. i .e v1 =1 ,v2 =3.This is wat i have to do sir .

byte a = 23;
byte v1 = (byte)(a / 10);
byte v2 = (byte)(a % 10);

If you mean 0x23 (which is different than just plain old 23) then change the number 10 to the number 16 or you can do this:

byte a = 0x23;
byte v1 = (byte)(a >> 4);
byte v2 = (byte)(a & 0xF);

sir can you tell me difference between 0*23 and normal 23 ???

0x23 is hexadecimal notation, 23 is decimal notation.
In binary notation this gives:
00010111 = 0x17 in hex = 23 in decimal
00100011 = 0x23 in hex = 35 in decimal
Perhaps a site like http://www.computerhope.com/binhex.htm can help you to understand.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.