Binary
Another important counting system is "binary". Binary has only two possible digits for each place value: 0 and 1. A binary digit is also called a "bit". In assembly syntax, bits are prefixed by "%".
A byte is made of eight "bits". Because a binary digit has two possible values, and a byte has 8 bits, this means there are 2⁸ possible values in a byte.
For example, a byte can consist of the following bits: 1001 0110
or 1001 0101
. The first bit from the left is called "bit 7" and the final bit is called "bit 0". They are NOT called bits 07, nor bits 81. Here's an overview:
The table below shows a relatively easy way to memorize binary, as it displays a pattern.
Binary  Hexadecimal 
















Note that there is a space inbetween 4 bits for easier readability, although assemblers generally don't accept this syntax. Groups of 4 bits are called "nibbles" and for the purposes of this chapter, they are there to make binary easier to read, because one nibble corresponds to one digit in hexadecimal.
The SNES is capable of working with both 8bit and 16bit numbers. While 8bit numbers are called a byte, 16bit numbers are called a "word". They would look like they have 16 bits in binary (e.g. 10000101 11010101
, which is $85D5
in hexadecimal). In the case of 16bit numbers, the leftmost bit is called "bit 15" while the rightmost bit is called "bit 0":
Flags
Binary is immensely useful when you're giving a hex value multiple purposes, kind of like an on/off toggle for certain features. These bits are called "flags" and are generally used to save space in the working memory of games.
For example, you can divide a byte into 8 bits with each bit having a different meaning. Bit 7 could indicate that a level has rain or not. Bit 6 could indicate that a level layout is horizontal or vertical. Bit 5 could indicate that the level setting is during day or night, etc. This way you can compress information into a single byte. It would look like this in binary:
Finally, here's an overview of how to count up in decimal, hexadecimal and binary:
Decimal  Hexadecimal  Binary 






















































...  ...  ... 






Notation
Sometimes, bits could be written inconsistently, like 11
or 110 0000
. This makes the binary number harder to read, because the general convention is to write bits in groups of eight. In order to read them, you will need to add leading 0s to the digits until there are either 8 bits or 16 bits in total.
In 8bit:
11
becomes00000011
1100000
becomes01100000
In 16bit:
11
becomes00000000 00000011
1100000
becomes00000000 01100000
You can convert between decimal, hexadecimal and binary, by using Windows calculator's "programming" mode. There are also many calculators online which can do this. Assembly syntax accepts decimal and binary also, so you usually don't need to convert between decimal and hexadecimal.
Last updated