Binary
Them ones and zeroes...

Now that we're getting into nitty-gritty assembly, we need to delve into a fundamental understanding of binary numbers.
Just like decimal is base 10 and hexadecimal is base 16, binary is base 2. That means we must restrict ourselves to two values: 1 and 0.

Of course, just like it's possible to represent any decimal number in hex, we can also represent any decimal or hex number in binary.

Binary is simply the sum of the powers of 2...
For example:

10111100 (binary) = 1*27 + 0*26 + 1*25 + 1*24 + 1*23 + 1*22 + 0*21 + 0*20 = 188 (decimal)
101 (bin) = 1*22 + 0*21 + 1*20 = 5 (decimal)
1111 (bin) = 1*23 + 1*22 + 1*21 + 1*20 = 15 (decimal)

And here's how you would count in binary, starting from zero...
0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111, 10000, 10001, 10010, 10011, ...

Now, since binary can only have 2 values for a single digit, that means it is useful for certain types of data storage. Like, for example, TSC flags.

<FL+4308

The above TSC code will set the TSC flag 4308.

Binary Terminology
  • set = To turn a binary value into a 1.
  • reset = To clear a binary value, or turn it into a 0.
  • flip = To toggle a binary value. If the value was originally 1, it becomes 0. If it was 0, it now becomes 1.
For example, you might hear some people say that <FL+2100 "sets" flag 2100, while <FL-2100 "resets" flag 2100.

There is no built-in way to toggle a TSC flag except by using <FLJ to jump to an <FL+ if the flag was originally reset, or to <FL- if the flag was originally set.

In reality, all the TSC flags are just a really long list of binary values. Each value is either 1 or 0, depending on whether the flag is set or reset.

Needless to say, unlike TSC, the binary math for assembly will be much more in-depth.

Of course, you don't have to convert binary, decimal, and hex by hand.
To convert, just use the windows calculator once more:

Windows XP Calc - Binary

Windows 7 Calc - Binary

Navigation
Previous Lesson: Framerects
Next Lesson: Logic
Table of Contents