Kin of the Stars

Please sign in to post.

Join the forum, it's quick and easy

Kin of the Stars

Please sign in to post.

Kin of the Stars

Would you like to react to this message? Create an account in a few clicks or log in to continue.
Kin of the Stars

A community for the fans of Crest of the Stars, Abh culture, anime, technology, science fiction, video games, and friendly conduct.


    Computer Hex code Tutorial

    Almael
    Almael
    Imperial Admiral
    Imperial Admiral


    Number of posts : 2849
    Imperial Credits : 18924
    Registration date : 2009-03-18

    Computer Hex code Tutorial Empty Computer Hex code Tutorial

    Post by Almael 10/8/2009, 12:21 pm

    This is a little tutorial on Hex code for everyone who's interested in what all those freaks are talking about.

    Computer use the binary system consisting of zeros and ones. This
    system is used to code characters or commands. But a binary unit is
    only one bit. With one bit only two things can be represented as either
    zero or one. To code more thing a bigger unit is needed which is a
    byte. A byte has 8 bits and you can code 256 things.
    The next unit is a word (2 bytes), then a long word (4 bytes).

    Since it's inconvenient to write all the bits out, a new counting
    system is used to represent the value. This system is called
    hexadecimal system, hence, hexadecial code.
    The hexadecimal system has sixten basic numbers instead of ten as in the decimal system.
    They are 0,1,2, ... ,9,A,B,C,D,E,F
    The number digits are composed as in the decimal system. A hexadecimal
    number is usually written with two digits and always represents one
    Byte.
    Examples:
    01 = a byte with a value of 1
    0A = a byte with a value of 10
    0F = a byte with a value of 15
    1F = a byte with a value of 16+15=31
    20 = a byte with a value of 2*16=32

    Likewise a word will be represented by two hexadecimal numbers
    Example:
    01 10 = a word with a value of 1*256+1*16= 272

    ---------------------------------------------------------------
    So how do I calculate the value quickly?
    Here you have to understand the binary system. With each increased
    digit you multyply by two to get the maximum value of that digit
    position. Or in simple mathemathics it's 2 to the n-th power, with n
    being the digit position.

    The first digit is then 2^0 (n=0)which is 1, so each number at this position equals a one difference.
    The second digit is then 2^1 which is 2, so each number at this position equals a two difference.

    To calculate hexnumbers you do the same. So for the first digit it's a one difference.
    For the second digit it's a 16 difference etc.
    You can use windows calculator to make the calculation, just mark the
    hex box and type then mark the decimal box and you got the value in
    decimal number.
    ------------------------------------------------------------------------------------------

    In order to navigate in files a position system is needed to find certain bytes.
    The system is simply a counter which just counts or numbers the bytes within a file.
    This counter is colled offset. It's also a hex number. Usually a hexcode or an offset is writtin with leading 0x to indicate that it's a hexadecimal number.

    So the first byte in a file gets the number zero. The second byte the number 1 and so on.
    Example:
    an offset of 0x011 means the 17th byte in a file.
    ------------------------------------------------------------------------------------------

    As humans we read a number from left to right with left being the higher digits.
    A computer reads only forward so there is a problem if where the higer digits should be.
    Historically, we have intel and motorola as the first major processor producers, hence we have two solutions.
    They are called 'Little Endian' (Intel) and 'Big Endian' (Motorola)
    Intel order the last digits first, while Motorola order the higher digits first.
    Intel further orders the words like wise.

    Example:
    0xE1A2B3F2 would look as follows:
    Intel: F2B3 A2E1
    Motorola: E1A2 B3F2

    ------------------------------------------------------------------------------------------

    Japan usually uses the Motorola convention, and it's own coding systems.
    Games usually have custom systems. Newer ones also have been featuring variable macro codes build on micro codes. For each part of the game play the codes have also been shown to be different.

      Current date/time is 3/28/2024, 5:20 pm