Thread: *crys* Binary

Results 1 to 7 of 7
  1. #1
    Someguytwo's Avatar
    Join Date
    Nov 2007
    Posts
    141
    Reputation
    -5
    Thanks
    9

    *crys* Binary

    I'm reading a book on asm, and it told me not to continue if I don't understand binary. I don't understand binary.

    Can some complain to me in more depth?

    I understand the 10110 is equal to :

    1 x 2^4 = 16
    0 x 2^3 = 0
    1 x 2^2 = 4
    1 x 2^1 = 2
    0 x 2^0 = 0

    ^ = to the power of.
    What defines those values in the center, if all we input it 10110?

  2. #2
    arunforce's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    A place for amigos
    Posts
    24,704
    Reputation
    4747
    Thanks
    12,562
    My Mood
    Yeehaw
    If you mean what defines 101011 or whatever, that's what the BIOS/CPU does, if I'm not mistaken.

    I'm not 100% if that is what you are asking, please refine. If you are talking about Base-2, it's because it's the easiest representation of On-Off, hence that's why we use Base-2.
    Last edited by arunforce; 02-03-2008 at 02:48 PM.



    BRING BACK BT, BRING BACK SAGA, BRING BACK VF, BRING BACK MPGHCRAFT, BRING BACK HABAMON


  3. #3
    Someguytwo's Avatar
    Join Date
    Nov 2007
    Posts
    141
    Reputation
    -5
    Thanks
    9
    I need to know how time find out what they mean, or equal. For instance, the example in the book says :
    Take the binary number 10110:
    1 x 2^4 = 16
    0 x 2^3 = 0
    1 x 2^2 = 4
    1 x 2^1 = 2
    0 x 2^0 = 0
    Answer: 22
    And I'm supposed to understand binary by looking at that. =/

  4. #4
    arunforce's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    A place for amigos
    Posts
    24,704
    Reputation
    4747
    Thanks
    12,562
    My Mood
    Yeehaw
    Quote Originally Posted by Someguytwo View Post
    I need to know how time find out what they mean, or equal. For instance, the example in the book says :


    And I'm supposed to understand binary by looking at that. =/
    So, what you are saying is you understand how binary works, but you don't fully understand it? That's all there is to it, 8 bits make a byte. That's why there is a 255 character limit in the ASCII code list, hence why the sum of (2^8 to 0) = 256. Then each byte is represented on screen as ASCII characters.

    For example 101 equals:
    1 x 2^2 = 4
    0 x 2^1 = 0
    1 x 2^0 = 1

    The sum of them equals 5, so 101 equals 5.



    BRING BACK BT, BRING BACK SAGA, BRING BACK VF, BRING BACK MPGHCRAFT, BRING BACK HABAMON


  5. #5
    Someguytwo's Avatar
    Join Date
    Nov 2007
    Posts
    141
    Reputation
    -5
    Thanks
    9
    Okay, I understand now. Thanks Arun.

  6. #6
    Mexiforce's Avatar
    Join Date
    Sep 2006
    Location
    Toronto, Ontario
    Posts
    2,155
    Reputation
    -66
    Thanks
    123
    The easiest way to understand binary is like this: the very rightmost number is worth 1, and then to the left of that, you multiply 1 by 2, that place is worth 2, etc

    11 = 3
    10 = 2
    01 = -1 ( I think)

    so think of it like this, take 1, and every number to the left of it, you multiply it by 2 every time, so you go 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, etc. Every number to the right of the one you're looking at is ALWAYS worth 1 value less than what you're looking at. I know I'm bad at explaining this, but it's how I understand it, so if you're looking at 10000, which is equal to 32, then the "0000" is 1+2+4+8+16, even though 0 represents off and 1 represents on.

    I just realized this thread is a month old, but my post is educational, so gtfo and don't call me on a necro.

  7. #7
    Jakor's Avatar
    Join Date
    Feb 2008
    Posts
    48
    Reputation
    10
    Thanks
    0
    The biggest time you will use this is BITMASKS where you set a bit in a number to represent options.

    lets take a byte:
    Code:
    00h 00000000b
    now lets make a bunch of flags that we can use:
    Code:
    FLAG1 equ 1d
    FLAG2 equ 2d
    FLAG3 equ 4d
    FLAG4 equ 8d
    FLAG5 equ 16d
    FLAG6 equ 32d
    FLAG7 equ 64d
    FLAG8 equ 128d
    now in order to apply these flags we use "or"
    Code:
    .data
    Flag db 0
    .code
    mov eax, FLAG    ;eax = 00000000b
    or eax, FLAG1    ;eax = 00000001b
    ;00000000b eax
    ;00000001b FLAG1
    or eax, FLAG3    ;eax = 00000101b
    ;00000001b eax
    ;00000100b FLAG3 cause 100b = 4d aka FLAG3
    or eax, FLAG6    ;eax = 00100101b
    ;00000101b eax
    ;00100000b FLAG6 cause 00100000b = 32d aka FLAG6
    as you see we can change the bit in a byte by changing the byte to binary and changing the number we "or" into binary then "or'ing" them together...


    @Junior731:
    01b = 1d not -1
    negative numbers use the SIGN FLAG to determine if the number should be negative or not. dword -1 in programming= 0FFFFFFFFh and will not necessarily set the sign flag. the sign flag is used in math functions, not set on a per data section. (aka all data is positive unless your math made it negative then it is only negative if you use the sign flag to tell if it is.)

Similar Threads

  1. WTF? i am crying
    By Gourav2122 in forum Flaming & Rage
    Replies: 5
    Last Post: 12-01-2007, 03:56 PM
  2. Replies: 24
    Last Post: 09-27-2007, 05:18 PM
  3. Saddest commercial that will make you cry
    By arunforce in forum General
    Replies: 10
    Last Post: 09-27-2007, 03:17 PM
  4. wrh@x noob crying
    By prox32 in forum General
    Replies: 9
    Last Post: 07-31-2007, 03:06 AM
  5. *curls up and cries*
    By i eat trees in forum General
    Replies: 25
    Last Post: 09-02-2006, 11:21 PM

Tags for this Thread