Byte

From C64-Wiki
(Redirected from byte)
Jump to navigationJump to search

A byte contains eight bits and is a unit of information or storage capacity. The eight bits of a byte can represent 256 (2 to the power of 8) values, from 0 to 255. A few computer systems, software or coding languages use a different numbers of bits in a byte. Bytes can be fragmented into nibbles (this are 4 bits) or half-bytes.

The normal character set of a computer system consists of ASCII or ANSI, which has 256 different characters. A byte can be used to contain the value needed to represent an individual character ("A" is the byte "01000001" or the decimal value 65).

Low- / High-Byte[edit | edit source]

8-bit computer systems like the C64/C128 have 16-bit address widths, so they can address 64 kB of memory. So it takes two 8-bit bytes to store a complete, 16-bit memory address. The standard order for memory address bytes is low-order byte first, followed by the high-order byte. For instance, the absolute memory address $C000 (49152 decimal) is stored in two, consecutive RAM bytes as $00, followed by $C0.

As a further example, the assembly instruction LDA $C000, is stored as three bytes. The first is the instruction itself with the absolute addressing mode: $AD, followed by $00 and $C0. The processor fetches the last two bytes as the address $C000.

The system's requirement for byte order is completely arbitrary and was decided on by the CPU's design engineers. In computer science, this choice of byte order is known as "endian-ness" with each individual CPU architecture being either "big endian" (high byte first) or "little endian" (low byte first). The 6502 falls into the latter category.

Bytes units[edit | edit source]

  • 1 Kilobyte (kB / KiB[1]) are 1024 bytes
  • 1 Megabyte (MB / MiB) are 1024 Kilobytes are 1024*1024 bytes
  • 1 Gigabyte (GB / GiB) are 1024 Megabytes
  • 1 Terabyte (TB / TiB) are 1024 Gigabytes
  • 1 Petabyte (PB / PiB) are 1024 Terabytes

When referring to memory or storage capacity of more than 1024 bytes it is better to use the international prefixes. For floppy disks the storage capacity is usually measured in kilobytes, whereas for CDs storage in terms of megabytes is more appropriate, and higher capacity storage media such as DVDs and hard disks are measured in gigabytes.

References[edit | edit source]

Links[edit | edit source]

WP-W11.png Wikipedia: Byte