How is Hex Value controlled bitwise?

I have a very basic understanding of bitwise operators. I find it difficult to understand how value is assigned. If someone can point me in the right direction, I would be very grateful.

My Hex Address: 0xE0074000

Decimal value: 3758571520

Binary value: 11100000000001110100000000000000

I am trying to program a simple microcontroller and use the register access class in the Microsoft.Net Micro Framework to force the controller to do what I want.

Register T2IR = new Register(0xE0074000); T2IR.Write(1 << 22); 

In my example above, how are bits moving in binary representation? I do not understand how bit control is assigned to an address in binary form.

If someone can point me in the right direction, I would be very believable.

+7
source share
2 answers

Forget about decimal places to get started. You will come back to this later.

First you need to see the logic between HEX and BINARY.

Ok, for a byte you have 8 bits (# 7-0)

 #7 = 0x80 = %1000 0000 #6 = 0x40 = %0100 0000 #5 = 0x20 = %0010 0000 #4 = 0x10 = %0001 0000 #3 = 0x08 = %0000 1000 #2 = 0x04 = %0000 0100 #1 = 0x02 = %0000 0010 #0 = 0x01 = %0000 0001 

When you read this in binary, in a byte like this,% 00001000

Then the bit is set, is the fourth from right to right aka bit # 3, which has a value of 08 hex (actually also a decimal, but still forgets about the decimal value when you define hex / binary)

Now, if we have the binary number% 10000000 This is bit # 7, which is included. It has a hex value of 0x80

So all you have to do is sum them in "nibbles" (each part of the hex byte is called a piece of some geeks)

the maximum you can get in nibble is (decimal) 15 or F as 0x10 + 0x20 + 0x40 + 0x80 = 0xF0 = binary% 11110000

so all lights on (4 bits) in nibble = F in hexadecimal (15 decimal)

the same applies to lower nibble.

Do you see the template?

+9
source

See @BerggreenDK answer for what a change is. Here is some information about what she likes in hex (the same thing, just a different view):

Shift is a very simple concept to understand. The register has a fixed size, and any bits that do not fit will fall from the end. So take this example:

int num = 0xffff << 16;

Now your variable in hexadecimal format will be 0xffff0000 . Notice how the right end is filled with zeros. Now move it again.

 num = num << 8; num = num >> 8; 

num now 0x00ff0000 . You are not returning your old bits. The same applies to right shifts.

Trick: shifting left by 1 is like multiplying a number by 2, and shifting right by 1 is equal to an integer dividing everything by 2.

+3
source

All Articles