Topic: Call,Math Info  (Read 1300 times)

0 Members and 1 Guest are viewing this topic.

Call,Math Info
« on: October 14, 2015, 01:54:02 AM »

Lancelot

  • Moderator, Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 7386
Call,Math

Call,Math syntax is at Call Topic http://TheOven.org/index.php?topic=45.0

Below is some info about Math operations to clear confusions :

Binary:
There is only 8 bits ( 1 Byte ) , starting from 0 (=> 8th bit is Bit7) (LSB 0 bit numbering)
Shortly: counting bits start from 0
ex: Bit40 means 41st bit  :wink:

Ex:
10000100 = Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Bit7=1, Bit3=1, rest of the Bits=0

On 32 bit, 1 Unit is 4 bytes, 4x8 bits (4 hex values)
On 64 bit, 1 Unit is 8 bytes, 8x8 bits (8 hex values)

Important:
**************
Math rules, count binary right to left
Computer world, count binary left to right
Decimal or Hex equivalent is same since this does not change value.
Still
You must be sure which bit system you are dealing with,
ex:
"normal bit 0000 0001"=hex 01
"reversebit 0000 0001"=hex 80
**************

Giving Example:
Math rules (right to left ) :
10011110
Bit7=1 Bit6=0 Bit5=0  Bit4=1 Bit3=1 Bit2=1 Bit1=1 Bit0=0
-->

BitNo:  7 6 5 4 3 2 1 0
Binary: 1 0 0 1 1 1 1 0


Computer world ( left to right ( Reverse Bit) ) :
01111001
Bit0=0 Bit1=1 Bit2=1 Bit3=1 Bit4=1 Bit5=0 Bit6=0 Bit7=1
-->

BitNo:  0 1 2 3 4 5 6 7
Binary: 1 0 0 1 1 1 1 0


as you see bit equivalent is same on both world, so converting to any other base also same:
Math 10011110 == Computer 01111001 == decimal=158 hex=9e

* This sometimes creates confusions on bit no....
counting bits from left to right result no confusion (reminding: starting from 0 ;) )
but
when one reads hex: 9e
naturally interpret hex: 9e to Math World right to left (mistake start here)
1 0 0 1 1 1 1 0
and than count "the bit" no left to right, wrong (mistake continues) (bold becomes Bit7, wrong)
result wrong

one of correct way:
1)
interpret 9e to Math World right to left
1 0 0 1 1 1 1 0
count bits from right,
bit0 correct  :thumbsup:
2)
interpret 9e to Computer World left to right (reverse bit)
0 1 1 1 1 0 0 1
count bits from left :)
bit0 correct  :thumbsup:


In computer world left to right
Bit47 :
47/8=5 + 7 ----> 6th byte, bit7
after first 5 byte

BitNo:  0 1 2 3 4 5 6 7
Binary: x x x x x x x x


ps:
00000001 = hex80
(remember this is reverse bit)

Bit40 :
40/8=5 + 0 ----> 6th byte, bit0
after first 5 byte

BitNo:  0 1 2 3 4 5 6 7
Binary: x x x x x x x x

--> Bit40 = 6th byte , Bit0

ps:
10000000 = hex01
(remember this is reverse bit)



**
Call,RegWriteBinaryBit Example:

Following computer world, Windows registry, Reg_Binary,
 Count bits left to right (reverse bits) :)

Giving example with Reg_Binary UserPrefencesMask

            HexNo: ----1---- ----2---- ----3---- ----4---- ----5---- ----6---- ----7---- ----8----
            BitNo: 0123 4567 89                                     (40)
(rBit) Byte BitNo: 0123 4567 0123 4567 0123 4567 0123 4567 0123 4567 0123 4567 0123 4567 0123 4567

9e3e038012000000 - 0111 1001 0111 1100 1100 0000 0000 0001 0100 1000 0000 0000 0000 0000 0000 0000

Bit40=1
Call,RegWriteBinaryBit,6,0,1 => (HexNo=6, BitNo=0, Value=1)          1
9e3e038012010000 - 0111 1001 0111 1100 1100 0000 0000 0001 0100 1000 1000 0000 0000 0000 0000 0000

Bit18=1
Call,RegWriteBinaryBit,3,2,1 =>          1
9e3e078012000000 - 0111 1001 0111 1100 1110 0000 0000 0001 0100 1000 0000 0000 0000 0000 0000 0000

Bit13=0
Call,RegWriteBinaryBit,2,5,0 =>    0
9e1e038012000000 - 0111 1001 0111 1000 1100 0000 0000 0001 0100 1000 0000 0000 0000 0000 0000 0000


Some Math Conversion Tips:
Bit40 ===> 40/8=5 + 0 ----> 6th byte (HexNo), Bit0
Bit18 ===> 18/8=2 + 2 ----> 3th byte (HexNo), Bit2
Bit13 ===> 13/8=1 + 5 ----> 2th byte (HexNo), Bit5

9e3e038012010000 --> 01 --> 6th byte (HexNo)
hex01--> convert to bit --> 0000 0001 ---ReverseBit--> 1000 0000 --> ex: count left to right (0123 4567) The BitNo you want to change -> BitNo=5*8 + x

9e3e078012000000 --> 07 --> 3th byte (HexNo)
hex07--> convert to bit --> 0000 0111 ---ReverseBit--> 1110 0000 --> ex: count left to right (0123 4567) The BitNo you want to change -> BitNo=5*8 + x

9e1e038012000000 --> 1e --> 2nd byte (HexNo)
hex1e--> convert to bit --> 00011110 ---ReverseBit--> 0111 1000 -->  ex: count left to right (0123 4567) The BitNo you want to change -> BitNo=5*8 + x


Ex:
To get ImeToolBar displayed, Bit40=1
(40/8=5*8+0 -> 6th Byte (hex) Bit0=1)
-->
Code: [Select]
RegHiveLoad,Tmp_Default,%RegDefault%
Call,RegWriteBinaryBit,6,0,1,HKLM,0x3,"Tmp_Default\Control Panel\Desktop",UserPreferencesMask
RegHiveUnLoad,Tmp_Default


Some other examples following other websites:
to avoid confusions websites seem to provide some binary settings following "computer binary" with letters
ex: http://www.tenforums.com/tutorials/6377-visual-effects-settings-change-windows-10-a.html#option4
1001ABC0 00D1EF10 00000G11

-->

01234567 01234567 01234567
1001ABC0 00D1EF10 00000G11


A : 1st byte, bit 4 = Bit4
Call,RegWriteBinaryBit,1,4,.....
G : 3rd byte, bit 5 = Bit21
Call,RegWriteBinaryBit,3,5,.....

ex: http://www.wincert.net/forum/topic/9965-solved-adjust-visual-styles-does-not-apply/#entry87066
1001ABC0 00D1EF10 00000GH1 10000000 000100J0

-->

01234567 01234567 01234567 01234567 01234567
1001ABC0 00D1EF10 00000GH1 10000000 000100J0


J: 5th byte, bit 6 = Bit38
Call,RegWriteBinaryBit,5,6,.....





http://www.silisoftware.com/tools/tweakui.php
Chris: http://www.wincert.net/forum/topic/9965-solved-adjust-visual-styles-does-not-apply/#entry87066
http://www.sevenforums.com/tutorials/1908-visual-effects-settings-change.html
http://www.tenforums.com/tutorials/6377-visual-effects-settings-change-windows-10-a.html#option4

https://technet.microsoft.com/en-us/library/cc957204.aspx
http://theoven.org/index.php?topic=1440.msg17016;topicseen#msg17016
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_20677328.html

https://en.wikipedia.org/wiki/Hexadecimal
https://en.wikipedia.org/wiki/Binary_number
https://en.wikipedia.org/wiki/Bit_numbering
https://en.wikipedia.org/wiki/Byte

« Last Edit: December 06, 2015, 06:50:19 AM by Lancelot »

 

Powered by EzPortal