Skip to content

Latest commit

 

History

History
76 lines (55 loc) · 2.91 KB

File metadata and controls

76 lines (55 loc) · 2.91 KB

Data

We gotta talk about data before we continue. So far, we've been sidestepping around it, talking about it as 1s and 0s, or just data. But how data is stored is important for writing assembly.

One unit of data, which is just a single 1 or 0, is called a bit.



The smallest collection of bits is called a byte. Actually, that's not completely true - half of a byte is a nybble, which is adorable, but not commonly used.

Have you heard of kilobytes (KB) or megabytes (MB)? Or the ever popular gigabyte (GB)? Same bytes we're talking about here, just more of them!

A byte is made up of 8 bits. Due to this, 8 is a magic number around here - everything ends up being divisible by 8.

Bytes & ASCII

Why is the magic number 8?

Well, when we're representing a single character (like A), it takes 8 bits to represent that character in data.

This has to do with the fact that each letter is represented by a number. Because each character is represented by a number, we have to have a table mapping which number represents which letter. We can use that mapping to then see which characters correspond with which numbers.

This is done with the ASCII table!




Check out asciitable.com for the full table


In order to represent those ASCII numbers in just 0s and 1s, we have to convert our base 10 number (let's say we're working with A, which maps to 65 on the ASCII table) into a base 2 number (01000001). We have to represent this number in binary because, as we learned earlier, computer data is represented physically by electrical signals being on or off, which maps directly to 1s and 0s.

Our ASCII table goes up to the number 255. In binary, 11111111 is 255. So 8 bits covers all of the ASCII characters!

Note: For more information on number systems and converting to binary, see the number systems section, but for now it's totally fine to hand wave this part!



Let's store this data →



Made with love by Hack Club